diff options
Diffstat (limited to 'scripts/genvimvim.lua')
-rw-r--r-- | scripts/genvimvim.lua | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/scripts/genvimvim.lua b/scripts/genvimvim.lua index 9135c8e3ab..806533f2ff 100644 --- a/scripts/genvimvim.lua +++ b/scripts/genvimvim.lua @@ -1,17 +1,20 @@ +mpack = require('mpack') + if arg[1] == '--help' then - print('Usage: genoptions.lua src/nvim runtime/syntax/vim/generated.vim') + print('Usage: lua genvimvim.lua src/nvim runtime/syntax/vim/generated.vim') os.exit(0) end local nvimsrcdir = arg[1] local syntax_file = arg[2] +local funcs_file = arg[3] package.path = nvimsrcdir .. '/?.lua;' .. package.path local lld = {} local syn_fd = io.open(syntax_file, 'w') lld.line_length = 0 -local w = function(s) +local function w(s) syn_fd:write(s) if s:find('\n') then lld.line_length = #(s:gsub('.*\n', '')) @@ -24,7 +27,7 @@ local options = require('options') local auevents = require('auevents') local ex_cmds = require('ex_cmds') -local cmd_kw = function(prev_cmd, cmd) +local function cmd_kw(prev_cmd, cmd) if not prev_cmd then return cmd:sub(1, 1) .. '[' .. cmd:sub(2) .. ']' else @@ -40,6 +43,15 @@ local cmd_kw = function(prev_cmd, cmd) end end +-- Exclude these from the vimCommand keyword list, they are handled specially +-- in syntax/vim.vim (vimAugroupKey, vimAutoCmd). #9327 +local function is_autocmd_cmd(cmd) + return (cmd == 'augroup' + or cmd == 'autocmd' + or cmd == 'doautocmd' + or cmd == 'doautoall') +end + vimcmd_start = 'syn keyword vimCommand contained ' w(vimcmd_start) local prev_cmd = nil @@ -48,7 +60,7 @@ for _, cmd_desc in ipairs(ex_cmds) do w('\n' .. vimcmd_start) end local cmd = cmd_desc.command - if cmd:match('%w') and cmd ~= 'z' then + if cmd:match('%w') and cmd ~= 'z' and not is_autocmd_cmd(cmd) then w(' ' .. cmd_kw(prev_cmd, cmd)) end prev_cmd = cmd @@ -82,7 +94,7 @@ local vimau_start = 'syn keyword vimAutoEvent contained ' w('\n\n' .. vimau_start) for _, au in ipairs(auevents.events) do - if not auevents.neovim_specific[au] then + if not auevents.nvim_specific[au] then if lld.line_length > 850 then w('\n' .. vimau_start) end @@ -90,7 +102,7 @@ for _, au in ipairs(auevents.events) do end end for au, _ in pairs(auevents.aliases) do - if not auevents.neovim_specific[au] then + if not auevents.nvim_specific[au] then if lld.line_length > 850 then w('\n' .. vimau_start) end @@ -101,7 +113,7 @@ end local nvimau_start = 'syn keyword nvimAutoEvent contained ' w('\n\n' .. nvimau_start) -for au, _ in pairs(auevents.neovim_specific) do +for au, _ in pairs(auevents.nvim_specific) do if lld.line_length > 850 then w('\n' .. nvimau_start) end @@ -111,28 +123,16 @@ end w('\n\nsyn case match') local vimfun_start = 'syn keyword vimFuncName contained ' w('\n\n' .. vimfun_start) -eval_fd = io.open(nvimsrcdir .. '/eval.c', 'r') +funcs = mpack.unpack(io.open(funcs_file):read("*all")) local started = 0 -for line in eval_fd:lines() do - if line == '} functions[] =' then - started = 1 - elseif started == 1 then - assert (line == '{') - started = 2 - elseif started == 2 then - if line == '};' then - break - end - local func_name = line:match('^ {"(%w+)",') - if func_name then - if lld.line_length > 850 then - w('\n' .. vimfun_start) - end - w(' ' .. func_name) +for name, def in pairs(funcs) do + if name then + if lld.line_length > 850 then + w('\n' .. vimfun_start) end + w(' ' .. name) end end -eval_fd:close() w('\n') syn_fd:close() |