aboutsummaryrefslogtreecommitdiff
path: root/src/gen/gen_vimdoc.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2026-10-16 05:49:31 -0400
committerGitHub <noreply@github.com>2026-10-16 05:49:31 -0400
commit45f83c70ee030f9f398b3db9c2e1dbaaf2880c72 (patch)
treef3a23d7ea6c7f01ca636beefcda173e7569cbb61 /src/gen/gen_vimdoc.lua
parentdaa8d2188c4476d2c267e48fbae49c7fffe8d9e3 (diff)
downloadrneovim-45f83c70ee030f9f398b3db9c2e1dbaaf2880c72.tar.gz
rneovim-45f83c70ee030f9f398b3db9c2e1dbaaf2880c72.tar.bz2
rneovim-45f83c70ee030f9f398b3db9c2e1dbaaf2880c72.zip
docs: cleanup tables, highlights.scm #42381
highlights.scm: `#match` is slow, prefer `#lua-match`.
Diffstat (limited to 'src/gen/gen_vimdoc.lua')
-rwxr-xr-xsrc/gen/gen_vimdoc.lua29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/gen/gen_vimdoc.lua b/src/gen/gen_vimdoc.lua
index b17c70c470..4bd560f2a6 100755
--- a/src/gen/gen_vimdoc.lua
+++ b/src/gen/gen_vimdoc.lua
@@ -540,6 +540,7 @@ local config = {
local table_rows = { { 'Field', 'Type' } }
local col1_max_width = 0
+ local col2_max_width = 0
--- @param defs string[]
--- @param type string
--- @param omit_padding_row nil | boolean
@@ -551,6 +552,7 @@ local config = {
for _, def in ipairs(defs) do
table.insert(table_rows, { def, type })
col1_max_width = math.max(col1_max_width, #def)
+ col2_max_width = math.max(col2_max_width, #type)
end
if not omit_padding_row then
table.insert(table_rows, { '', '' })
@@ -565,25 +567,18 @@ local config = {
add_defs(shifted_keys, 'string[]')
add_defs(f_keys, 'string', true, true)
- -- Convert all the table rows into strings by calculating the padding
- -- needed between them
- local table_str_rows = {}
- local min_padding = 3 -- padding between table columns
- local max_width = 0 -- max width of col1 + padding + col2
+ -- Tab-delimited table (see "Tables" in the tree-sitter-vimdoc README), with a separator line
+ -- between groups. Column 2 starts at the first tabstop after the widest column 1.
local indent = ' '
- for _, row in ipairs(table_rows) do
- if #row[1] == 0 then
- table.insert(table_str_rows, '')
- else
- local padding = string.rep(' ', col1_max_width + min_padding - #row[1])
- local val = table.concat(row, padding)
- max_width = math.max(max_width, #val)
- table.insert(table_str_rows, indent .. val)
- end
+ local col2 = (math.floor((#indent + col1_max_width) / 8) + 1) * 8
+ local sep = indent .. string.rep('-', col2 - #indent + col2_max_width)
+ local table_str_rows = {}
+ for i, row in ipairs(table_rows) do
+ local ntabs = col2 / 8 - math.floor((#indent + #row[1]) / 8)
+ local hdr = i == 1 and ' ~' or ''
+ local val = ('%s%s%s%s%s'):format(indent, row[1], ('\t'):rep(ntabs), row[2], hdr)
+ table.insert(table_str_rows, #row[1] == 0 and sep or val)
end
-
- -- Add table header
- table.insert(table_str_rows, 2, indent .. string.rep('-', max_width))
return (brief:gsub('NVIM_TERMDEFS_TABLE', table.concat(table_str_rows, '\n')))
end,
},