diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2025-04-26 10:24:39 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-26 10:24:39 -0700 |
| commit | 50a537d614aacf7e5ecd84fc0b6807d8e8967706 (patch) | |
| tree | 65d01df70b9a20173344c908ae73f74c24301ee3 /scripts/docgen.lua | |
| parent | docs: update configs.md (diff) | |
| download | nvim-lspconfig-50a537d614aacf7e5ecd84fc0b6807d8e8967706.tar nvim-lspconfig-50a537d614aacf7e5ecd84fc0b6807d8e8967706.tar.gz nvim-lspconfig-50a537d614aacf7e5ecd84fc0b6807d8e8967706.tar.bz2 nvim-lspconfig-50a537d614aacf7e5ecd84fc0b6807d8e8967706.tar.lz nvim-lspconfig-50a537d614aacf7e5ecd84fc0b6807d8e8967706.tar.xz nvim-lspconfig-50a537d614aacf7e5ecd84fc0b6807d8e8967706.tar.zst nvim-lspconfig-50a537d614aacf7e5ecd84fc0b6807d8e8967706.zip | |
feat(docgen.lua): improve vimdoc generator #3783
Diffstat (limited to 'scripts/docgen.lua')
| -rwxr-xr-x | scripts/docgen.lua | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/scripts/docgen.lua b/scripts/docgen.lua index be88436c..af308363 100755 --- a/scripts/docgen.lua +++ b/scripts/docgen.lua @@ -69,7 +69,6 @@ Snippet to enable the language server: >lua {{commands}} Default config: {{default_values}} - ]] local section_template_md = [[ @@ -137,7 +136,11 @@ local function make_lsp_section(config_sections, config_name, config_file, is_ma if type(v) == 'boolean' then return ('- `%s` : `%s`'):format(k, v) elseif type(v) ~= 'function' and k ~= 'root_dir' then - return ('- `%s` :\n ```lua\n%s\n ```'):format(k, indent(2, vim.inspect(v))) + if is_markdown then + return ('- `%s` :\n ```lua\n%s\n ```'):format(k, indent(2, vim.inspect(v))) + else + return ('- %s: >lua\n%s'):format(k, indent(2, vim.inspect(v))) + end end local file = assert(io.open(config_file, 'r')) @@ -153,20 +156,18 @@ local function make_lsp_section(config_sections, config_name, config_file, is_ma local config_relpath = vim.fs.relpath(root, config_file) -- XXX: "../" because the path is outside of the doc/ dir. - return ('- `%s` source (use "gF" to open): [../%s:%d](../%s#L%d)'):format( - k, - config_relpath, - linenr, - config_relpath, - linenr - ) + if is_markdown then + return ('- `%s`: [../%s:%d](../%s#L%d)'):format(k, config_relpath, linenr, config_relpath, linenr) + else + return ('- %s (use "gF" to view): ../%s:%d'):format(k, config_relpath, linenr) + end end), }) end, - }) + }) .. (is_markdown and '' or '\n<') -- Workaround tree-sitter-vimdoc bug. - local template_used = is_markdown and section_template_md or section_template_txt - table.insert(config_sections, template(template_used, params)) + local t = is_markdown and section_template_md or section_template_txt + table.insert(config_sections, template(t, params)) end local function make_lsp_sections(is_markdown) |
