Skip to content

Commit c24b442

Browse files
authored
fix(runtime/genvimvim): omit s[ubstitute] from vimCommand neovim#18480
It's special cased by the vimSubst syntax group, and isn't present in Vim's vimCommand group. For example, this fixes `call s:Foo()` highlighting `:` as Error in Nvim, as the `s` is parsed as vimCommand rather than as vimUserFunc since `contains=vimCommand` was added to vimUserFunc (and vimFunc) in a rt update. Interestingly, `g:`, `l:`, etc. have the same issues due to :global, :list, etc. Vim also has that problem, so it should ideally be fixed upstream. We could also omit g[lobal] from vimCommand and rely on vimGlobal instead, but it doesn't work in some cases, like when there's a `:` before the command. Also, Vim matches only `g` in vimCommand for some reason, which doesn't produce any highlight for `:global/foo/bar` (with Nvim you at least get some highlights on the `global` bit despite the leading `:`). Also, remove special handling of :py3 in syntax/vim.vim, as the generator seems to have no problems finding it.
1 parent 60b1e31 commit c24b442

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

runtime/syntax/vim.vim

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ else
120120
com! -nargs=* VimFoldt <args>
121121
endif
122122

123-
" commands not picked up by the generator (due to non-standard format) {{{2
124-
syn keyword vimCommand contained py3
125-
126123
" Deprecated variable options {{{2
127124
if exists("g:vim_minlines")
128125
let g:vimsyn_minlines= g:vim_minlines

scripts/genvimvim.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ local function cmd_kw(prev_cmd, cmd)
4444
end
4545

4646
-- Exclude these from the vimCommand keyword list, they are handled specially
47-
-- in syntax/vim.vim (vimAugroupKey, vimAutoCmd). #9327
48-
local function is_autocmd_cmd(cmd)
47+
-- in syntax/vim.vim (vimAugroupKey, vimAutoCmd, vimSubst). #9327
48+
local function is_special_cased_cmd(cmd)
4949
return (cmd == 'augroup'
5050
or cmd == 'autocmd'
5151
or cmd == 'doautocmd'
52-
or cmd == 'doautoall')
52+
or cmd == 'doautoall'
53+
or cmd == 'substitute')
5354
end
5455

5556
local vimcmd_start = 'syn keyword vimCommand contained '
@@ -60,7 +61,7 @@ for _, cmd_desc in ipairs(ex_cmds.cmds) do
6061
w('\n' .. vimcmd_start)
6162
end
6263
local cmd = cmd_desc.command
63-
if cmd:match('%w') and cmd ~= 'z' and not is_autocmd_cmd(cmd) then
64+
if cmd:match('%w') and cmd ~= 'z' and not is_special_cased_cmd(cmd) then
6465
w(' ' .. cmd_kw(prev_cmd, cmd))
6566
end
6667
prev_cmd = cmd

0 commit comments

Comments
 (0)