diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2025-02-05 23:09:29 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2025-02-05 23:09:29 +0000 |
commit | d5f194ce780c95821a855aca3c19426576d28ae0 (patch) | |
tree | d45f461b19f9118ad2bb1f440a7a08973ad18832 /scripts/gen_vimdoc.lua | |
parent | c5d770d311841ea5230426cc4c868e8db27300a8 (diff) | |
parent | 44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff) | |
download | rneovim-rahm.tar.gz rneovim-rahm.tar.bz2 rneovim-rahm.zip |
Diffstat (limited to 'scripts/gen_vimdoc.lua')
-rwxr-xr-x | scripts/gen_vimdoc.lua | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/scripts/gen_vimdoc.lua b/scripts/gen_vimdoc.lua index 9cd5b598da..d200050fe1 100755 --- a/scripts/gen_vimdoc.lua +++ b/scripts/gen_vimdoc.lua @@ -274,6 +274,7 @@ local config = { 'diagnostic.lua', 'codelens.lua', 'completion.lua', + 'folding_range.lua', 'inlay_hint.lua', 'tagfunc.lua', 'semantic_tokens.lua', @@ -349,12 +350,14 @@ local config = { helptag_fmt = function(name) if name:lower() == 'treesitter' then return 'lua-treesitter-core' + elseif name:lower() == 'query' then + return 'lua-treesitter-query' elseif name:lower() == 'tstree' then return { 'treesitter-tree', 'TSTree' } elseif name:lower() == 'tsnode' then return { 'treesitter-node', 'TSNode' } end - return 'lua-treesitter-' .. name:lower() + return 'treesitter-' .. name:lower() end, }, editorconfig = { @@ -514,6 +517,8 @@ local function inline_type(obj, classes) elseif desc == '' then if ty_islist then desc = desc .. 'A list of objects with the following fields:' + elseif cls.parent then + desc = desc .. fmt('Extends |%s| with the additional fields:', cls.parent) else desc = desc .. 'A table with the following fields:' end @@ -538,7 +543,8 @@ end --- @param generics? table<string,string> --- @param classes? table<string,nvim.luacats.parser.class> --- @param exclude_types? true -local function render_fields_or_params(xs, generics, classes, exclude_types) +--- @param cfg nvim.gen_vimdoc.Config +local function render_fields_or_params(xs, generics, classes, exclude_types, cfg) local ret = {} --- @type string[] xs = vim.tbl_filter(should_render_field_or_param, xs) @@ -558,7 +564,9 @@ local function render_fields_or_params(xs, generics, classes, exclude_types) p.desc = pdesc inline_type(p, classes) - local nm, ty, desc = p.name, p.type, p.desc + local nm, ty = p.name, p.type + + local desc = p.classvar and string.format('See |%s|.', cfg.fn_helptag_fmt(p)) or p.desc local fnm = p.kind == 'operator' and fmt('op(%s)', nm) or fmt_field_name(nm) local pnm = fmt(' • %-' .. indent .. 's', fnm) @@ -591,7 +599,8 @@ end --- @param class nvim.luacats.parser.class --- @param classes table<string,nvim.luacats.parser.class> -local function render_class(class, classes) +--- @param cfg nvim.gen_vimdoc.Config +local function render_class(class, classes, cfg) if class.access or class.nodoc or class.inlinedoc then return end @@ -610,7 +619,7 @@ local function render_class(class, classes) table.insert(ret, md_to_vimdoc(class.desc, INDENTATION, INDENTATION, TEXT_WIDTH)) end - local fields_txt = render_fields_or_params(class.fields, nil, classes) + local fields_txt = render_fields_or_params(class.fields, nil, classes, nil, cfg) if not fields_txt:match('^%s*$') then table.insert(ret, '\n Fields: ~\n') table.insert(ret, fields_txt) @@ -621,11 +630,12 @@ local function render_class(class, classes) end --- @param classes table<string,nvim.luacats.parser.class> -local function render_classes(classes) +--- @param cfg nvim.gen_vimdoc.Config +local function render_classes(classes, cfg) local ret = {} --- @type string[] for _, class in vim.spairs(classes) do - ret[#ret + 1] = render_class(class, classes) + ret[#ret + 1] = render_class(class, classes, cfg) end return table.concat(ret) @@ -656,10 +666,6 @@ local function render_fun_header(fun, cfg) local proto = fun.table and nm or nm .. '(' .. table.concat(args, ', ') .. ')' - if not cfg.fn_helptag_fmt then - cfg.fn_helptag_fmt = fn_helptag_fmt_common - end - local tag = '*' .. cfg.fn_helptag_fmt(fun) .. '*' if #proto + #tag > TEXT_WIDTH - 8 then @@ -774,7 +780,8 @@ local function render_fun(fun, classes, cfg) end if fun.params and #fun.params > 0 then - local param_txt = render_fields_or_params(fun.params, fun.generics, classes, cfg.exclude_types) + local param_txt = + render_fields_or_params(fun.params, fun.generics, classes, cfg.exclude_types, cfg) if not param_txt:match('^%s*$') then table.insert(ret, '\n Parameters: ~\n') ret[#ret + 1] = param_txt @@ -957,6 +964,7 @@ end --- @param cfg nvim.gen_vimdoc.Config local function gen_target(cfg) + cfg.fn_helptag_fmt = cfg.fn_helptag_fmt or fn_helptag_fmt_common print('Target:', cfg.filename) local sections = {} --- @type table<string,nvim.gen_vimdoc.Section> @@ -987,7 +995,7 @@ local function gen_target(cfg) print(' Processing file:', f) local funs_txt = render_funs(funs, all_classes, cfg) if next(classes) then - local classes_txt = render_classes(classes) + local classes_txt = render_classes(classes, cfg) if vim.trim(classes_txt) ~= '' then funs_txt = classes_txt .. '\n' .. funs_txt end |