docs: misc

fix https://github.com/neovim/neovim.github.io/issues/419

Co-authored-by: Rob Pilling <robpilling@gmail.com>
This commit is contained in:
Justin M. Keyes
2025-11-26 01:17:06 -05:00
parent 45ca080bd1
commit ebb7c38ca2
35 changed files with 336 additions and 253 deletions

View File

@@ -54,6 +54,12 @@ local spell_ignore_files = {
['news.txt'] = { 'tree-sitter' }, -- in news, may refer to the upstream "tree-sitter" library
['news-0.10.txt'] = { 'tree-sitter' },
}
--- Punctuation that indicates a word is part of a path, module name, etc.
--- Example: ".lua" is likely part of a filename, thus we don't want to enforce its spelling.
local spell_punc = {
['.'] = true,
['/'] = true,
}
local language = nil
local M = {}
@@ -118,15 +124,14 @@ local exclude_invalid_urls = {
['http://.'] = 'usr_23.txt',
['http://aspell.net/man-html/Affix-Compression.html'] = 'spell.txt',
['http://aspell.net/man-html/Phonetic-Code.html'] = 'spell.txt',
['http://canna.sourceforge.jp/'] = 'mbyte.txt',
['http://gnuada.sourceforge.net'] = 'ft_ada.txt',
['http://lua-users.org/wiki/StringLibraryTutorial'] = 'lua.txt',
['http://michael.toren.net/code/'] = 'pi_tar.txt',
['http://oldblog.antirez.com/post/redis-and-scripting.html'] = 'faq.txt',
['http://papp.plan9.de'] = 'syntax.txt',
['http://vimcasts.org'] = 'intro.txt',
['http://wiki.services.openoffice.org/wiki/Dictionaries'] = 'spell.txt',
['http://www.adapower.com'] = 'ft_ada.txt',
['http://www.jclark.com/'] = 'quickfix.txt',
['http://oldblog.antirez.com/post/redis-and-scripting.html'] = 'faq.txt',
}
-- Deprecated, brain-damaged files that I don't care about.
@@ -189,7 +194,8 @@ end
--- Removes common punctuation from URLs.
---
--- TODO: fix this in the parser instead... https://github.com/neovim/tree-sitter-vimdoc
--- NOTE: this is currently a no-op, since known issues were fixed in the parser:
--- https://github.com/neovim/tree-sitter-vimdoc/pull/157
---
--- @param url string
--- @return string, string (fixed_url, removed_chars) where `removed_chars` is in the order found in the input.
@@ -197,12 +203,12 @@ local function fix_url(url)
local removed_chars = ''
local fixed_url = url
-- Remove up to one of each char from end of the URL, in this order.
for _, c in ipairs({ '.', ')' }) do
if fixed_url:sub(-1) == c then
removed_chars = c .. removed_chars
fixed_url = fixed_url:sub(1, -2)
end
end
-- for _, c in ipairs({ '.', ')', ',' }) do
-- if fixed_url:sub(-1) == c then
-- removed_chars = c .. removed_chars
-- fixed_url = fixed_url:sub(1, -2)
-- end
-- end
return fixed_url, removed_chars
end
@@ -374,6 +380,22 @@ local function first(node, name)
return nil
end
--- Gets the kind and node text of the previous and next siblings of node `n`.
--- @param n any node
local function get_prev_next(n)
-- Previous sibling kind (string).
local prev = n:prev_sibling()
and (n:prev_sibling().named and n:prev_sibling():named())
and n:prev_sibling():type()
or nil
-- Next sibling kind (string).
local next_ = n:next_sibling()
and (n:next_sibling().named and n:next_sibling():named())
and n:next_sibling():type()
or nil
return prev, next_
end
local function validate_link(node, bufnr, fname)
local helppage, tagname = get_tagname(node:child(1), bufnr)
local ignored = false
@@ -416,14 +438,19 @@ end
---@param stats table
local function visit_validate(root, level, lang_tree, opt, stats)
level = level or 0
local function node_text(node)
return vim.treesitter.get_node_text(node or root, opt.buf)
end
local text = trim(node_text())
local node_name = (root.named and root:named()) and root:type() or nil
-- Parent kind (string).
local parent = root:parent() and root:parent():type() or nil
local toplevel = level < 1
local function node_text(node)
return vim.treesitter.get_node_text(node or root, opt.buf)
end
local text = trim(node_text())
-- local prev, next_ = get_prev_next(root)
local prev_text = root:prev_sibling() and node_text(root:prev_sibling()) or nil
local next_text = root:next_sibling() and node_text(root:next_sibling()) or nil
if root:child_count() > 0 then
for node, _ in root:iter_children() do
@@ -455,6 +482,7 @@ local function visit_validate(root, level, lang_tree, opt, stats)
(spell_ignore_files[fname_basename] or {}) --[[ @as string[] ]],
text_nopunct
)
or (spell_punc[next_text] or spell_punc[prev_text])
)
if not should_ignore then
invalid_spelling[text_nopunct] = invalid_spelling[text_nopunct] or {}
@@ -498,19 +526,12 @@ end
local function visit_node(root, level, lang_tree, headings, opt, stats)
level = level or 0
local node_name = (root.named and root:named()) and root:type() or nil
-- Previous sibling kind (string).
local prev = root:prev_sibling()
and (root:prev_sibling().named and root:prev_sibling():named())
and root:prev_sibling():type()
or nil
-- Next sibling kind (string).
local next_ = root:next_sibling()
and (root:next_sibling().named and root:next_sibling():named())
and root:next_sibling():type()
or nil
-- Parent kind (string).
local parent = root:parent() and root:parent():type() or nil
local function node_text(node, ws_)
node = node or root
ws_ = (ws_ == nil or ws_ == true) and getws(node, opt.buf) or ''
return string.format('%s%s', ws_, vim.treesitter.get_node_text(node, opt.buf))
end
-- Gets leading whitespace of `node`.
local function ws(node)
node = node or root
@@ -522,11 +543,11 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
end
return ws_
end
local function node_text(node, ws_)
node = node or root
ws_ = (ws_ == nil or ws_ == true) and getws(node, opt.buf) or ''
return string.format('%s%s', ws_, vim.treesitter.get_node_text(node, opt.buf))
end
local node_name = (root.named and root:named()) and root:type() or nil
local prev, next_ = get_prev_next(root)
-- Parent kind (string).
local parent = root:parent() and root:parent():type() or nil
local text = ''
local trimmed ---@type string
@@ -1397,7 +1418,7 @@ function M.gen(help_dir, to_dir, include, commit, parser_path)
vim.validate('commit', commit, 'string', true)
vim.validate('parser_path', parser_path, function(f)
return vim.fn.filereadable(vim.fs.normalize(f)) == 1
end, true, 'valid vimdoc.{so,dll} filepath')
end, true, 'valid vimdoc.{so,dll,dylib} filepath')
local err_count = 0
local redirects_count = 0
@@ -1510,7 +1531,7 @@ function M.validate(help_dir, include, parser_path, request_urls)
vim.validate('include', include, 'table', true)
vim.validate('parser_path', parser_path, function(f)
return vim.fn.filereadable(vim.fs.normalize(f)) == 1
end, true, 'valid vimdoc.{so,dll} filepath')
end, true, 'valid vimdoc.{so,dll,dylib} filepath')
local err_count = 0 ---@type integer
local files_to_errors = {} ---@type table<string, string[]>
ensure_runtimepath()

View File

@@ -382,7 +382,7 @@ typedef kvec_withinit_t(ExprASTConvStackItem, 16) ExprASTConvStack;
/// - "error": Dict with error, present only if parser saw some
/// error. Contains the following keys:
/// - "message": String, error message in printf format, translated.
/// Must contain exactly one "%.*s".
/// Must contain exactly one `%.*s`.
/// - "arg": String, error message argument.
/// - "len": Amount of bytes successfully parsed. With flags equal to ""
/// that should be equal to the length of expr string.

View File

@@ -57,8 +57,7 @@
/// If -1 is provided, a top-level split will be created. `vertical` and `split` are
/// only valid for normal windows, and are used to control split direction. For `vertical`,
/// the exact direction is determined by 'splitright' and 'splitbelow'.
/// Split windows cannot have `bufpos`/`row`/`col`/`border`/`title`/`footer`
/// properties.
/// Split windows cannot have `bufpos`, `row`, `col`, `border`, `title`, `footer` properties.
///
/// With relative=editor (row=0,col=0) refers to the top-left corner of the
/// screen-grid and (row=Lines-1,col=Columns-1) refers to the bottom-right
@@ -71,23 +70,19 @@
/// could let floats hover outside of the main window like a tooltip, but
/// this should not be used to specify arbitrary WM screen positions.
///
/// Example: window-relative float
/// Examples:
///
/// ```lua
/// -- Window-relative float with 'statusline' enabled:
/// local w1 = vim.api.nvim_open_win(0, false,
/// {relative='win', row=3, col=3, width=40, height=4})
/// vim.wo[w1].statusline = vim.o.statusline
///
/// -- Buffer-relative float (travels as buffer is scrolled):
/// vim.api.nvim_open_win(0, false,
/// {relative='win', row=3, col=3, width=12, height=3})
/// ```
/// {relative='win', width=40, height=4, bufpos={100,10}})
///
/// Example: buffer-relative float (travels as buffer is scrolled)
///
/// ```lua
/// vim.api.nvim_open_win(0, false,
/// {relative='win', width=12, height=3, bufpos={100,10}})
/// ```
///
/// Example: vertical split left of the current window
///
/// ```lua
/// -- Vertical split left of the current window:
/// vim.api.nvim_open_win(0, false, { split = 'left', win = 0, })
/// ```
///

View File

@@ -314,9 +314,9 @@ M.funcs = {
always matters.
Example: >vim
call assert_equal('foo', 'bar', 'baz')
<Will add the following to |v:errors|:
test.vim line 12: baz: Expected 'foo' but got 'bar' ~
<Will add the following to |v:errors|: >
test.vim line 12: baz: Expected 'foo' but got 'bar'
<
]=],
name = 'assert_equal',
params = { { 'expected', 'any' }, { 'actual', 'any' }, { 'msg', 'any' } },
@@ -470,9 +470,9 @@ M.funcs = {
Example: >vim
call assert_match('^f.*o$', 'foobar')
<Will result in a string to be added to |v:errors|:
test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
<Will result in a string to be added to |v:errors|: >
test.vim line 12: Pattern '^f.*o$' does not match 'foobar'
<
]=],
name = 'assert_match',
params = { { 'pattern', 'string' }, { 'actual', 'string' }, { 'msg', 'string' } },
@@ -8300,54 +8300,54 @@ M.funcs = {
*E1500*
You cannot mix positional and non-positional arguments: >vim
echo printf("%s%1$s", "One", "Two")
< E1500: Cannot mix positional and non-positional arguments:
%s%1$s
" E1500: Cannot mix positional and non-positional arguments:
" %s%1$s
<
*E1501*
You cannot skip a positional argument in a format string: >vim
echo printf("%3$s%1$s", "One", "Two", "Three")
< E1501: format argument 2 unused in $-style format:
%3$s%1$s
" E1501: format argument 2 unused in $-style format:
" %3$s%1$s
<
*E1502*
You can re-use a [field-width] (or [precision]) argument: >vim
echo printf("%1$d at width %2$d is: %01$*2$d", 1, 2)
< 1 at width 2 is: 01
" 1 at width 2 is: 01
<
However, you can't use it as a different type: >vim
echo printf("%1$d at width %2$ld is: %01$*2$d", 1, 2)
< E1502: Positional argument 2 used as field width reused as
different type: long int/int
" E1502: Positional argument 2 used as field width reused as
" different type: long int/int
<
*E1503*
When a positional argument is used, but not the correct number
or arguments is given, an error is raised: >vim
echo printf("%1$d at width %2$d is: %01$*2$.*3$d", 1, 2)
< E1503: Positional argument 3 out of bounds: %1$d at width
%2$d is: %01$*2$.*3$d
" E1503: Positional argument 3 out of bounds: %1$d at width
" %2$d is: %01$*2$.*3$d
<
Only the first error is reported: >vim
echo printf("%01$*2$.*3$d %4$d", 1, 2)
< E1503: Positional argument 3 out of bounds: %01$*2$.*3$d
%4$d
" E1503: Positional argument 3 out of bounds: %01$*2$.*3$d
" %4$d
<
*E1504*
A positional argument can be used more than once: >vim
echo printf("%1$s %2$s %1$s", "One", "Two")
< One Two One
" One Two One
<
However, you can't use a different type the second time: >vim
echo printf("%1$s %2$s %1$d", "One", "Two")
< E1504: Positional argument 1 type used inconsistently:
int/string
" E1504: Positional argument 1 type used inconsistently:
" int/string
<
*E1505*
Various other errors that lead to a format string being
wrongly formatted lead to: >vim
echo printf("%1$d at width %2$d is: %01$*2$.3$d", 1, 2)
< E1505: Invalid format specifier: %1$d at width %2$d is:
%01$*2$.3$d
" E1505: Invalid format specifier: %1$d at width %2$d is:
" %01$*2$.3$d
<
*E1507*
This internal error indicates that the logic to parse a
positional format argument ran into a problem that couldn't be

View File

@@ -1047,6 +1047,7 @@ static const char *find_tty_option_end(const char *arg)
p++;
}
if (p[0] == 't' && p[1] == '_' && p[2] && p[3]) {
// "t_xx" ("t_Co") option.
p += 4;
} else if (delimit) {
// Search for delimiting >.

View File

@@ -5715,7 +5715,7 @@ local options = {
behaves like CTRL-C was typed.
Running into the limit often means that the pattern is very
inefficient or too complex. This may already happen with the pattern
"\(.\)*" on a very long line. ".*" works much better.
`\(.\)*` on a very long line. `.*` works much better.
Might also happen on redraw, when syntax rules try to match a complex
text structure.
Vim may run out of memory before hitting the 'maxmempattern' limit, in

View File

@@ -1814,9 +1814,7 @@ Dict commands_array(buf_T *buf, Arena *arena)
PUT_C(d, "complete", LUAREF_OBJ(api_new_luaref(cmd->uc_compl_luaref)));
} else {
char *cmd_compl = get_command_complete(cmd->uc_compl);
PUT_C(d, "complete", (cmd_compl == NULL
? NIL : CSTR_AS_OBJ(cmd_compl)));
PUT_C(d, "complete", (cmd_compl == NULL ? NIL : CSTR_AS_OBJ(cmd_compl)));
}
PUT_C(d, "complete_arg", cmd->uc_compl_arg == NULL
? NIL : CSTR_AS_OBJ(cmd->uc_compl_arg));