From 8fb7273ac0b981eeb9afdc82675b908c1600d34f Mon Sep 17 00:00:00 2001 From: ZyX Date: Fri, 1 Jan 2016 12:17:22 +0300 Subject: eval: Move VimL functions list to a lua file Removes all kinds of problems with sorting, provides a ready-to-use function list representation for genvimvim.lua, does not require specifying function name twice (VimL function name (string) + f_ function name). --- scripts/genvimvim.lua | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'scripts/genvimvim.lua') diff --git a/scripts/genvimvim.lua b/scripts/genvimvim.lua index 667af7be6c..729749a52f 100644 --- a/scripts/genvimvim.lua +++ b/scripts/genvimvim.lua @@ -23,6 +23,7 @@ end local options = require('options') local auevents = require('auevents') local ex_cmds = require('ex_cmds') +local eval = require('eval') local cmd_kw = function(prev_cmd, cmd) if not prev_cmd then @@ -113,23 +114,12 @@ local vimfun_start = 'syn keyword vimFuncName contained ' w('\n\n' .. vimfun_start) eval_fd = io.open(nvimsrcdir .. '/eval.c', 'r') 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(eval.funcs) do + if name then + if lld.line_length > 850 then + w('\n' .. vimfun_start) end + w(' ' .. name) end end eval_fd:close() -- cgit From 7e2348f2b1b487c875bbcf6c6711a276f9063040 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sun, 19 Jun 2016 16:41:08 +0200 Subject: eval: use gperf to generate the hash of builtin functions make api functions highlighted as builtins in vim.vim --- scripts/genvimvim.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'scripts/genvimvim.lua') diff --git a/scripts/genvimvim.lua b/scripts/genvimvim.lua index 729749a52f..24c147b811 100644 --- a/scripts/genvimvim.lua +++ b/scripts/genvimvim.lua @@ -1,3 +1,5 @@ +mpack = require('mpack') + if arg[1] == '--help' then print('Usage: lua genvimvim.lua src/nvim runtime/syntax/vim/generated.vim') os.exit(0) @@ -5,6 +7,7 @@ end local nvimsrcdir = arg[1] local syntax_file = arg[2] +local funcs_file = arg[3] package.path = nvimsrcdir .. '/?.lua;' .. package.path @@ -23,7 +26,6 @@ end local options = require('options') local auevents = require('auevents') local ex_cmds = require('ex_cmds') -local eval = require('eval') local cmd_kw = function(prev_cmd, cmd) if not prev_cmd then @@ -112,9 +114,9 @@ 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 name, def in pairs(eval.funcs) do +for name, def in pairs(funcs) do if name then if lld.line_length > 850 then w('\n' .. vimfun_start) @@ -122,7 +124,6 @@ for name, def in pairs(eval.funcs) do w(' ' .. name) end end -eval_fd:close() w('\n') syn_fd:close() -- cgit