Skip to content

Commit 30ff1e3

Browse files
habamaxchrisbra
authored andcommitted
runtime(vimcomplete): do not complete 'shellcmd' on WSL and Windows
- shellcmd completion is VERY slow on both WSL and Windows, e.g. `term something` or `!something` might take ~10 seconds to show first results. Do not complete it there. - revert previous change to not complete on whitespace, do not complete on *empty* lines instead. closes: #18568 Signed-off-by: Maxim Kim <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent f22cedd commit 30ff1e3

3 files changed

Lines changed: 46 additions & 8 deletions

File tree

runtime/autoload/vimcomplete.vim

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ vim9script
33
# Vim completion script
44
# Language: Vim script
55
# Maintainer: Maxim Kim <[email protected]>
6-
# Last Change: 2025-10-13
6+
# Last Change: 2025-10-15
77
#
88
# Usage:
99
# setlocal omnifunc=vimcomplete#Complete
@@ -22,23 +22,24 @@ def GetTrigger(line: string): list<any>
2222
result = 'function'
2323
elseif line =~ '\v%(^|\s+)\&\k*$'
2424
result = 'option'
25+
elseif line =~ '\vse%[t]\s+(\k+\s+)*no\k*$'
26+
result = 'nooption'
27+
result_len = -2
2528
elseif line =~ '[\[(]\s*$'
2629
result = 'expression'
2730
elseif line =~ '[lvgsb]:\k*$'
2831
result = 'var'
2932
result_len = 2
30-
else
33+
elseif line !~ '^\s*$'
3134
result = getcompletiontype(line) ?? 'cmdline'
3235
endif
3336
return [result, result_len]
3437
enddef
3538

3639
export def Complete(findstart: number, base: string): any
3740
if findstart > 0
41+
prefix = ""
3842
var line = getline('.')->strpart(0, col('.') - 1)
39-
if line =~ '\s\+$'
40-
return -2
41-
endif
4243
var keyword = line->matchstr('\k\+$')
4344
var stx = synstack(line('.'), col('.') - 1)->map('synIDattr(v:val, "name")')->join()
4445
if stx =~? 'Comment' || (stx =~ 'String' && stx !~ 'vimStringInterpolationExpr')
@@ -60,6 +61,9 @@ export def Complete(findstart: number, base: string): any
6061
elseif trigger == 'option'
6162
items = getcompletion(base, 'option')
6263
->mapnew((_, v) => ({word: v, kind: 'v', menu: 'Option', dup: 0}))
64+
elseif trigger == 'nooption'
65+
items = getcompletion(base[2 : ], 'option')
66+
->mapnew((_, v) => ({word: v, kind: 'v', menu: 'Option', dup: 0}))
6367
elseif trigger == 'var'
6468
items = getcompletion(base, 'var')
6569
->mapnew((_, v) => ({word: v, kind: 'v', menu: 'Variable', dup: 0}))
@@ -74,8 +78,11 @@ export def Complete(findstart: number, base: string): any
7478
items = commands + functions
7579
else
7680
try
77-
items = getcompletion(prefix, 'cmdline')
78-
->mapnew((_, v) => ({word: v->matchstr('\k\+'), kind: 'v', dup: 0}))
81+
# :! and :term completion is very slow on Windows and WSL, disable it there.
82+
if !((has("win32") || has("win32unix") || exists("$WSLENV")) && getcompletiontype(prefix) == 'shellcmd')
83+
items = getcompletion(prefix, 'cmdline')
84+
->mapnew((_, v) => ({word: v->matchstr('\k\+'), kind: 'v', dup: 0}))
85+
endif
7986
catch /E220/
8087
endtry
8188

runtime/doc/insert.txt

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*insert.txt* For Vim version 9.1. Last change: 2025 Oct 14
1+
*insert.txt* For Vim version 9.1. Last change: 2025 Oct 16
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1704,6 +1704,36 @@ Notes:
17041704
< to your vimrc
17051705

17061706

1707+
VIM *ft-vim-omni*
1708+
1709+
Simple completion of Vimscript and Vim9script languages.
1710+
1711+
Complete:
1712+
1713+
- set and & options
1714+
- commands and command arguments
1715+
- function names after ->
1716+
- expressions
1717+
- l:, v:, g:, s: and b: variables
1718+
- fallback to command line completion to get candidates
1719+
1720+
Notes
1721+
1722+
- It doesn't complete command arguments that rely on 'shellcmd' completion
1723+
type in Windows and WSL due to general slowness of canditate gathering,
1724+
e.g.
1725+
>
1726+
terminal dir
1727+
!dir
1728+
<
1729+
These completions might take several seconds to gather candidates.
1730+
1731+
- 'autocomplete' can't complete "no" options:
1732+
>
1733+
set noautoindent
1734+
set nobuflisted
1735+
<
1736+
17071737
SYNTAX *ft-syntax-omni*
17081738

17091739
Vim has the ability to color syntax highlight nearly 500 languages. Part of

runtime/doc/tags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7678,6 +7678,7 @@ ft-vb-syntax syntax.txt /*ft-vb-syntax*
76787678
ft-verilog-indent indent.txt /*ft-verilog-indent*
76797679
ft-vhdl-indent indent.txt /*ft-vhdl-indent*
76807680
ft-vim-indent indent.txt /*ft-vim-indent*
7681+
ft-vim-omni insert.txt /*ft-vim-omni*
76817682
ft-vim-plugin filetype.txt /*ft-vim-plugin*
76827683
ft-vim-syntax syntax.txt /*ft-vim-syntax*
76837684
ft-xf86conf-syntax syntax.txt /*ft-xf86conf-syntax*

0 commit comments

Comments
 (0)