vim-patch:9.1.1933: completion: complete_match() is not useful (#36726)

Problem:  completion: complete_match() Vim script function and
          'isexpand' option are not that useful and confusing
          (after v9.1.1341)
Solution: Remove function and option and clean up code and documentation
          (Girish Palya).

complete_match() and 'isexpand' add no real functionality to Vim. They
duplicate what `strridx()` already does, yet pretend to be part of the
completion system. They have nothing to do with the completion mechanism.

* `f_complete_match()` in `insexpand.c` does not call any completion code.
   It’s just a `STRNCMP()` wrapper with fluff logic.
* `'isexpand'` exists only as a proxy argument to that function.
   It does nothing on its own and amounts to misuse of a new option.

The following Vim script function can be used to implement the same
functionality:

```vim
  func CompleteMatch(triggers, sep=',')
    let line = getline('.')->strpart(0, col('.') - 1)
    let result = []
    for trig in split(a:triggers, a:sep)
      let idx = strridx(line, trig)
      if l:idx >= 0
        call add(result, [idx + 1, trig])
      endif
    endfor
    return result
  endfunc
```

related: vim/vim#16716
fixes: vim/vim#18563
closes: vim/vim#18790

cbcbff8712

Co-authored-by: Girish Palya <girishji@gmail.com>
This commit is contained in:
zeertzjq
2025-11-28 10:10:31 +08:00
committed by GitHub
parent 19d5b28977
commit 2c6469aca4
18 changed files with 5 additions and 451 deletions

View File

@@ -3656,31 +3656,6 @@ vim.o.inf = vim.o.infercase
vim.bo.infercase = vim.o.infercase
vim.bo.inf = vim.bo.infercase
--- Defines characters and patterns for completion in insert mode. Used
--- by the `complete_match()` function to determine the starting position
--- for completion. This is a comma-separated list of triggers. Each
--- trigger can be:
--- - A single character like "." or "/"
--- - A sequence of characters like "->", "/*", or "/**"
---
--- Note: Use "\\," to add a literal comma as trigger character, see
--- `option-backslash`.
---
--- Examples:
---
--- ```vim
--- set isexpand=.,->,/*,\\,
--- ```
---
---
--- @type string
vim.o.isexpand = ""
vim.o.ise = vim.o.isexpand
vim.bo.isexpand = vim.o.isexpand
vim.bo.ise = vim.bo.isexpand
vim.go.isexpand = vim.o.isexpand
vim.go.ise = vim.go.isexpand
--- The characters specified by this option are included in file names and
--- path names. Filenames are used for commands like "gf", "[i" and in
--- the tags file. It is also used for "\f" in a `pattern`.