patch 9.1.1341: cannot define completion triggers

Problem:  Cannot define completion triggers and act upon it
Solution: add the new option 'isexpand' and add the complete_match()
          function to return the completion matches according to the
          'isexpand' setting (glepnir)

Currently, completion trigger position is determined solely by the
'iskeyword' pattern (\k\+$), which causes issues when users need
different completion behaviors - such as triggering after '/' for
comments or '.' for methods. Modifying 'iskeyword' to include these
characters has undesirable side effects on other Vim functionality that
relies on keyword definitions.

Introduce a new buffer-local option 'isexpand' that allows specifying
different completion triggers and add the complete_match() function that
finds the appropriate start column for completion based on these
triggers, scanning backwards from cursor position.

This separation of concerns allows customized completion behavior
without affecting iskeyword-dependent features. The option's
buffer-local nature enables per-filetype completion triggers.

closes: #16716

Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
glepnir
2025-04-24 21:48:35 +02:00
committed by Christian Brabandt
parent 32f49738d1
commit bcd5995b40
20 changed files with 363 additions and 17 deletions

View File

@ -90,6 +90,7 @@
# define PV_INEX OPT_BUF(BV_INEX)
#endif
#define PV_INF OPT_BUF(BV_INF)
#define PV_ISE OPT_BOTH(OPT_BUF(BV_ISE))
#define PV_ISK OPT_BUF(BV_ISK)
#ifdef FEAT_CRYPT
# define PV_KEY OPT_BUF(BV_KEY)
@ -1458,6 +1459,10 @@ static struct vimoption options[] =
{"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
(char_u *)&p_im, PV_NONE, did_set_insertmode, NULL,
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"isexpand", "ise", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
(char_u *)&p_ise, PV_ISE, did_set_isexpand, NULL,
{(char_u *)"", (char_u *)0L}
SCTX_INIT},
{"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
(char_u *)&p_isf, PV_NONE, did_set_isopt, NULL,
{