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 <habamax@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
f22cedd75f
commit
30ff1e3b02
@ -3,7 +3,7 @@ vim9script
|
|||||||
# Vim completion script
|
# Vim completion script
|
||||||
# Language: Vim script
|
# Language: Vim script
|
||||||
# Maintainer: Maxim Kim <habamax@gmail.com>
|
# Maintainer: Maxim Kim <habamax@gmail.com>
|
||||||
# Last Change: 2025-10-13
|
# Last Change: 2025-10-15
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# setlocal omnifunc=vimcomplete#Complete
|
# setlocal omnifunc=vimcomplete#Complete
|
||||||
@ -22,12 +22,15 @@ def GetTrigger(line: string): list<any>
|
|||||||
result = 'function'
|
result = 'function'
|
||||||
elseif line =~ '\v%(^|\s+)\&\k*$'
|
elseif line =~ '\v%(^|\s+)\&\k*$'
|
||||||
result = 'option'
|
result = 'option'
|
||||||
|
elseif line =~ '\vse%[t]\s+(\k+\s+)*no\k*$'
|
||||||
|
result = 'nooption'
|
||||||
|
result_len = -2
|
||||||
elseif line =~ '[\[(]\s*$'
|
elseif line =~ '[\[(]\s*$'
|
||||||
result = 'expression'
|
result = 'expression'
|
||||||
elseif line =~ '[lvgsb]:\k*$'
|
elseif line =~ '[lvgsb]:\k*$'
|
||||||
result = 'var'
|
result = 'var'
|
||||||
result_len = 2
|
result_len = 2
|
||||||
else
|
elseif line !~ '^\s*$'
|
||||||
result = getcompletiontype(line) ?? 'cmdline'
|
result = getcompletiontype(line) ?? 'cmdline'
|
||||||
endif
|
endif
|
||||||
return [result, result_len]
|
return [result, result_len]
|
||||||
@ -35,10 +38,8 @@ enddef
|
|||||||
|
|
||||||
export def Complete(findstart: number, base: string): any
|
export def Complete(findstart: number, base: string): any
|
||||||
if findstart > 0
|
if findstart > 0
|
||||||
|
prefix = ""
|
||||||
var line = getline('.')->strpart(0, col('.') - 1)
|
var line = getline('.')->strpart(0, col('.') - 1)
|
||||||
if line =~ '\s\+$'
|
|
||||||
return -2
|
|
||||||
endif
|
|
||||||
var keyword = line->matchstr('\k\+$')
|
var keyword = line->matchstr('\k\+$')
|
||||||
var stx = synstack(line('.'), col('.') - 1)->map('synIDattr(v:val, "name")')->join()
|
var stx = synstack(line('.'), col('.') - 1)->map('synIDattr(v:val, "name")')->join()
|
||||||
if stx =~? 'Comment' || (stx =~ 'String' && stx !~ 'vimStringInterpolationExpr')
|
if stx =~? 'Comment' || (stx =~ 'String' && stx !~ 'vimStringInterpolationExpr')
|
||||||
@ -60,6 +61,9 @@ export def Complete(findstart: number, base: string): any
|
|||||||
elseif trigger == 'option'
|
elseif trigger == 'option'
|
||||||
items = getcompletion(base, 'option')
|
items = getcompletion(base, 'option')
|
||||||
->mapnew((_, v) => ({word: v, kind: 'v', menu: 'Option', dup: 0}))
|
->mapnew((_, v) => ({word: v, kind: 'v', menu: 'Option', dup: 0}))
|
||||||
|
elseif trigger == 'nooption'
|
||||||
|
items = getcompletion(base[2 : ], 'option')
|
||||||
|
->mapnew((_, v) => ({word: v, kind: 'v', menu: 'Option', dup: 0}))
|
||||||
elseif trigger == 'var'
|
elseif trigger == 'var'
|
||||||
items = getcompletion(base, 'var')
|
items = getcompletion(base, 'var')
|
||||||
->mapnew((_, v) => ({word: v, kind: 'v', menu: 'Variable', dup: 0}))
|
->mapnew((_, v) => ({word: v, kind: 'v', menu: 'Variable', dup: 0}))
|
||||||
@ -74,8 +78,11 @@ export def Complete(findstart: number, base: string): any
|
|||||||
items = commands + functions
|
items = commands + functions
|
||||||
else
|
else
|
||||||
try
|
try
|
||||||
items = getcompletion(prefix, 'cmdline')
|
# :! and :term completion is very slow on Windows and WSL, disable it there.
|
||||||
->mapnew((_, v) => ({word: v->matchstr('\k\+'), kind: 'v', dup: 0}))
|
if !((has("win32") || has("win32unix") || exists("$WSLENV")) && getcompletiontype(prefix) == 'shellcmd')
|
||||||
|
items = getcompletion(prefix, 'cmdline')
|
||||||
|
->mapnew((_, v) => ({word: v->matchstr('\k\+'), kind: 'v', dup: 0}))
|
||||||
|
endif
|
||||||
catch /E220/
|
catch /E220/
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
*insert.txt* For Vim version 9.1. Last change: 2025 Oct 14
|
*insert.txt* For Vim version 9.1. Last change: 2025 Oct 16
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@ -1704,6 +1704,36 @@ Notes:
|
|||||||
< to your vimrc
|
< to your vimrc
|
||||||
|
|
||||||
|
|
||||||
|
VIM *ft-vim-omni*
|
||||||
|
|
||||||
|
Simple completion of Vimscript and Vim9script languages.
|
||||||
|
|
||||||
|
Complete:
|
||||||
|
|
||||||
|
- set and & options
|
||||||
|
- commands and command arguments
|
||||||
|
- function names after ->
|
||||||
|
- expressions
|
||||||
|
- l:, v:, g:, s: and b: variables
|
||||||
|
- fallback to command line completion to get candidates
|
||||||
|
|
||||||
|
Notes
|
||||||
|
|
||||||
|
- It doesn't complete command arguments that rely on 'shellcmd' completion
|
||||||
|
type in Windows and WSL due to general slowness of canditate gathering,
|
||||||
|
e.g.
|
||||||
|
>
|
||||||
|
terminal dir
|
||||||
|
!dir
|
||||||
|
<
|
||||||
|
These completions might take several seconds to gather candidates.
|
||||||
|
|
||||||
|
- 'autocomplete' can't complete "no" options:
|
||||||
|
>
|
||||||
|
set noautoindent
|
||||||
|
set nobuflisted
|
||||||
|
<
|
||||||
|
|
||||||
SYNTAX *ft-syntax-omni*
|
SYNTAX *ft-syntax-omni*
|
||||||
|
|
||||||
Vim has the ability to color syntax highlight nearly 500 languages. Part of
|
Vim has the ability to color syntax highlight nearly 500 languages. Part of
|
||||||
|
@ -7678,6 +7678,7 @@ ft-vb-syntax syntax.txt /*ft-vb-syntax*
|
|||||||
ft-verilog-indent indent.txt /*ft-verilog-indent*
|
ft-verilog-indent indent.txt /*ft-verilog-indent*
|
||||||
ft-vhdl-indent indent.txt /*ft-vhdl-indent*
|
ft-vhdl-indent indent.txt /*ft-vhdl-indent*
|
||||||
ft-vim-indent indent.txt /*ft-vim-indent*
|
ft-vim-indent indent.txt /*ft-vim-indent*
|
||||||
|
ft-vim-omni insert.txt /*ft-vim-omni*
|
||||||
ft-vim-plugin filetype.txt /*ft-vim-plugin*
|
ft-vim-plugin filetype.txt /*ft-vim-plugin*
|
||||||
ft-vim-syntax syntax.txt /*ft-vim-syntax*
|
ft-vim-syntax syntax.txt /*ft-vim-syntax*
|
||||||
ft-xf86conf-syntax syntax.txt /*ft-xf86conf-syntax*
|
ft-xf86conf-syntax syntax.txt /*ft-xf86conf-syntax*
|
||||||
|
Reference in New Issue
Block a user