# Vim completion script
# Language: Vim script
# Maintainer: Maxim Kim <habamax@gmail.com>
-# Last Change: 2025-10-13
+# Last Change: 2025-10-15
#
# Usage:
# setlocal omnifunc=vimcomplete#Complete
result = 'function'
elseif line =~ '\v%(^|\s+)\&\k*$'
result = 'option'
+ elseif line =~ '\vse%[t]\s+(\k+\s+)*no\k*$'
+ result = 'nooption'
+ result_len = -2
elseif line =~ '[\[(]\s*$'
result = 'expression'
elseif line =~ '[lvgsb]:\k*$'
result = 'var'
result_len = 2
- else
+ elseif line !~ '^\s*$'
result = getcompletiontype(line) ?? 'cmdline'
endif
return [result, result_len]
export def Complete(findstart: number, base: string): any
if findstart > 0
+ prefix = ""
var line = getline('.')->strpart(0, col('.') - 1)
- if line =~ '\s\+$'
- return -2
- endif
var keyword = line->matchstr('\k\+$')
var stx = synstack(line('.'), col('.') - 1)->map('synIDattr(v:val, "name")')->join()
if stx =~? 'Comment' || (stx =~ 'String' && stx !~ 'vimStringInterpolationExpr')
elseif trigger == 'option'
items = getcompletion(base, 'option')
->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'
items = getcompletion(base, 'var')
->mapnew((_, v) => ({word: v, kind: 'v', menu: 'Variable', dup: 0}))
items = commands + functions
else
try
- items = getcompletion(prefix, 'cmdline')
- ->mapnew((_, v) => ({word: v->matchstr('\k\+'), kind: 'v', dup: 0}))
+ # :! and :term completion is very slow on Windows and WSL, disable it there.
+ 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/
endtry
-*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
< 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*
Vim has the ability to color syntax highlight nearly 500 languages. Part of