Trigger path completion only after typing path separator
Is your feature request related to a problem? Please describe.
Let's say I have a directory with a single foo.vim file inside it and I start editing it.
Having included 'path' in my default complete_items, if I type f I get foo.vim Path (file) as an autocompletion suggestion. I'd like to change this behaviour so that the autocompletion triggers only after typing /, so in this case if I wanted to autocomplete foo.vim I'd have to type ./.
Describe the solution you'd like
Completions from Path sources are only triggered after typing the os's path separator.
Similarly, if a path separator is found completion should only offer path completion items (e.g. if I have /usr/local/ then I most likely don't want auto completion to suggest LSP symbols).
@noib3 I am not sure if you are already aware of this, but you can set trigger character for each source like this
let g:completion_chain_complete_list = {
\ 'default' : {
\ 'default': [
\ {'complete_items': ['lsp']},
\ {'complete_items': ['path'], 'triggered_only': ['/']},
\ }
\}
I didn't know that, I just tried it and it works. However having two separate completion sources is not very ergonomic since it requires extra key presses to select the right source. I wish I could specify path sources to only be triggered after a / while still having a single completion menu with all the possible items.
You could play around with let g:completion_auto_change_source = 1 and changing the priorities of sources as necessary
I tried that with the following setup (lua syntax):
local g = vim.g
g.completion_chain_complete_list = {
default = {
{complete_items = {'path'}, triggered_only = {'/'}},
{complete_items = {'lsp'}},
},
}
g.completion_auto_change_source = 1
I'd expect lsp completions to show up when I'm not typing a path, but I get the same exact behaviour that I get leaving g:completion_auto_change_source to zero.
the per source triggered_only is a new and not yet documented feature.
Perhaps @haorenW1025 the author could help you further