diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2025-06-02 14:16:17 +0800 |
|---|---|---|
| committer | zeertzjq <zeertzjq@outlook.com> | 2025-06-03 06:30:47 +0800 |
| commit | 9bfd0162dc11478febbdfd0fd9c9c880a0f454ae (patch) | |
| tree | ea5929b45e1f245e94451437317461ffa3b9a0de /runtime/lua | |
| parent | bec1449cc51081e064d254f88601358094f3abe8 (diff) | |
| download | rneovim-9bfd0162dc11478febbdfd0fd9c9c880a0f454ae.tar.gz rneovim-9bfd0162dc11478febbdfd0fd9c9c880a0f454ae.tar.bz2 rneovim-9bfd0162dc11478febbdfd0fd9c9c880a0f454ae.zip | |
vim-patch:9.1.1422: scheduling of complete function can be improved
Problem: scheduling of complete function can be improved
Solution: call user completion functions earlier when just determining
the insertion column (Girish Palya)
This change improves the scheduling behavior of async user-defined
completion functions (such as `F{func}`, `F`, or `'o'` values in the
`'complete'` option), particularly benefiting LSP clients.
Currently, these user functions are invoked twice:
1. First with `findstart = 1` to determine the completion start
position.
2. Then with `findstart = 0` to retrieve the actual matches.
Previously, both calls were executed back-to-back. With this change, the
first call (`findstart = 1`) is performed earlier—before any matches are
gathered from other sources.
This adjustment gives event-driven completion sources (e.g., LSP
clients) more time to send their requests while Vim concurrently
collects matches from other sources like the current buffer.
Not sure about the real-world performance gains, but this approach
should, in theory, improve responsiveness and reduce latency for
asynchronous completions.
To test, try using yegappan LSP client:
```vim
set cpt+=o^10
autocmd VimEnter * g:LspOptionsSet({ autoComplete: false, omniComplete: true })
```
If you prefer to use 'native' auto-completion (without plugins), try the
following configuration:
```vim
set cot=menuone,popup,noselect,nearest
autocmd TextChangedI * InsComplete()
def InsComplete()
if getcharstr(1) == '' && getline('.')->strpart(0, col('.') - 1) =~ '\k$'
SkipTextChangedI()
feedkeys("\<c-n>", "n")
endif
enddef
inoremap <silent> <c-e> <c-r>=<SID>SkipTextChangedI()<cr><c-e>
inoremap <silent> <c-y> <c-r>=<SID>SkipTextChangedI()<cr><c-y>
def SkipTextChangedI(): string
set eventignore+=TextChangedI
timer_start(1, (_) => {
set eventignore-=TextChangedI
})
return ''
enddef
inoremap <silent><expr> <tab> pumvisible() ? "\<c-n>" : "\<tab>"
inoremap <silent><expr> <s-tab> pumvisible() ? "\<c-p>" : "\<s-tab>"
```
closes: vim/vim#17396
https://github.com/vim/vim/commit/98c29dbfd1c0765cbe5a2fce71072a33ad629f34
Co-authored-by: Girish Palya <girishji@gmail.com>
Diffstat (limited to 'runtime/lua')
0 files changed, 0 insertions, 0 deletions