girishji / autosuggest.vim

Autocompletion for Vim's command-line.
MIT License
59 stars 4 forks source link

How to disable completion for external commands? #8

Closed jiangyinzuo closed 6 months ago

jiangyinzuo commented 6 months ago

I have two use cases for external commands which are:

1) :!ls 2) :r!ls

I have tried using the following commands for disabling both cases:

autocmd VimEnter * ++once if exists('g:AutoSuggestSetup') | call g:AutoSuggestSetup({ 'cmd': { 'exclude': ['!', 'r'] }}) | endif

and

autocmd VimEnter * ++once if exists('g:AutoSuggestSetup') | call g:AutoSuggestSetup({ 'cmd': { 'exclude': ['!', 'r!'] }}) | endif

However, they work for !ls but don't work for :r!ls. Can you suggest a way to disable both use cases?

jiangyinzuo commented 6 months ago

I use WSL2 and external command completion is extremely slow for me. So I want to disable them in all situations

girishji commented 6 months ago

Both r and r! work correctly for me. Can you check if :echo 'r!ls' =~ 'r!' is 1? It does pattern match, see line 164 in cmd.vim:if context =~ pat.

I suspect g: AutoSuggestSetup is not having effect.

Can you do :echo g:AutoSuggestGetOptions() and check?

jiangyinzuo commented 6 months ago

Thank you for your hint!

Finally I update my vim config as

autocmd VimEnter * ++once if exists('*g:AutoSuggestSetup') | call g:AutoSuggestSetup({ 'cmd': { 'exclude': ['!'] }}) | endif

and it works correctly for me.

exists('*g:AutoSuggestSetup') returns 1 but exists('g:AutoSuggestSetup') returns 0. g:AutoSuggestSetup is a function so I should add * to examine its existence.