fix(build): vimdoc tags are not validated #32801

Problem:
"make lintdoc" is not validating vimdoc (:help) tags.

Solution:
- Call `lang_tree:parse()` to init the parser.
- Load netrw 🤢 explicitly, since it was moved to `pack/dist/opt/`.
- Fix invalid help tags.
This commit is contained in:
Justin M. Keyes
2025-03-09 10:27:28 -07:00
committed by GitHub
parent 903242f160
commit 34a2bfdcc5
14 changed files with 33 additions and 31 deletions

View File

@@ -1420,8 +1420,8 @@ vimrc file again).
*FileExplorer* *FileExplorer*
There is one group that is recognized by Vim: FileExplorer. If this group There is one group that is recognized by Vim: FileExplorer. If this group
exists Vim assumes that editing a directory is possible and will trigger a exists Vim assumes that editing a directory is possible and will trigger a
plugin that lists the files in that directory. This is used by the |netrw| plugin that lists the files in that directory. This is used by directory
plugin. This allows you to do: > browser plugins. This allows you to do: >
browse edit browse edit
============================================================================== ==============================================================================
@@ -1695,7 +1695,7 @@ and "++ff=" argument that are effective. These should be used for the command
that reads/writes the file. The |v:cmdbang| variable is one when "!" was that reads/writes the file. The |v:cmdbang| variable is one when "!" was
used, zero otherwise. used, zero otherwise.
See the $VIMRUNTIME/plugin/netrwPlugin.vim for examples. See the $VIMRUNTIME/pack/dist/opt/netrw/plugin/netrwPlugin.vim for examples.
============================================================================== ==============================================================================
11. Disabling autocommands *autocmd-disable* 11. Disabling autocommands *autocmd-disable*

View File

@@ -376,10 +376,10 @@ Where possible, these patterns apply to _both_ Lua and the API:
- See |vim.lsp.inlay_hint.enable()| and |vim.lsp.inlay_hint.is_enabled()| - See |vim.lsp.inlay_hint.enable()| and |vim.lsp.inlay_hint.is_enabled()|
for a reference implementation of these "best practices". for a reference implementation of these "best practices".
- NOTE: open questions: https://github.com/neovim/neovim/issues/28603 - NOTE: open questions: https://github.com/neovim/neovim/issues/28603
- Transformation functions should also have a filter functionality when - Transformation functions should also have "filter" functionality (when
appropriate. That is, when the function returns a nil value it "filters" its appropriate): when the function returns a nil value it excludes (filters
input, otherwise the transformed value is used. out) its input, else the transformed value is used.
- Example: |vim.diagnostic.config.format()| - Example: See the format() field of |vim.diagnostic.Opts.Float|.
API DESIGN GUIDELINES *dev-api* API DESIGN GUIDELINES *dev-api*

View File

@@ -1496,9 +1496,8 @@ Or, when starting gvim from a shell: >
Note that if a FileChangedShell autocommand is defined you will not get a Note that if a FileChangedShell autocommand is defined you will not get a
warning message or prompt. The autocommand is expected to handle this. warning message or prompt. The autocommand is expected to handle this.
There is no warning for a directory (e.g., with |netrw-browse|). But you do There is no warning for a directory. But you do get warned if you started
get warned if you started editing a new file and it was created as a directory editing a new file and it was created as a directory later.
later.
When Vim notices the timestamp of a file has changed, and the file is being When Vim notices the timestamp of a file has changed, and the file is being
edited in a buffer but has not changed, Vim checks if the contents of the file edited in a buffer but has not changed, Vim checks if the contents of the file

View File

@@ -180,11 +180,11 @@ Standard plugins ~
*standard-plugin-list* *standard-plugin-list*
|pi_gzip.txt| Reading and writing compressed files |pi_gzip.txt| Reading and writing compressed files
|pi_msgpack.txt| msgpack utilities |pi_msgpack.txt| msgpack utilities
|pi_netrw.txt| Reading and writing files over a network
|pi_paren.txt| Highlight matching parens |pi_paren.txt| Highlight matching parens
|pi_spec.txt| Filetype plugin to work with rpm spec files |pi_spec.txt| Filetype plugin to work with rpm spec files
|pi_tar.txt| Tar file explorer |pi_tar.txt| Tar file explorer
|pi_zip.txt| Zip archive explorer |pi_zip.txt| Zip archive explorer
|netrw| Reading and writing files over a network
Local additions ~ Local additions ~
*local-additions* *local-additions*

View File

@@ -786,8 +786,7 @@ tag char note action in Normal mode ~
|gu| gu{motion} 2 make Nmove text lowercase |gu| gu{motion} 2 make Nmove text lowercase
|gv| gv reselect the previous Visual area |gv| gv reselect the previous Visual area
|gw| gw{motion} 2 format Nmove text and keep cursor |gw| gw{motion} 2 format Nmove text and keep cursor
|netrw-gx| gx execute application for file name under the |gx| gx execute application for filepath at cursor
cursor (only with |netrw| plugin)
|g@| g@{motion} call 'operatorfunc' |g@| g@{motion} call 'operatorfunc'
|g~| g~{motion} 2 swap case for Nmove text |g~| g~{motion} 2 swap case for Nmove text
|g<Down>| g<Down> 1 same as "gj" |g<Down>| g<Down> 1 same as "gj"

View File

@@ -643,8 +643,8 @@ Also see the 'infercase' option if you want to adjust the case of the match.
When inserting a selected candidate word from the |popup-menu|, the part of When inserting a selected candidate word from the |popup-menu|, the part of
the candidate word that does not match the query is highlighted using the candidate word that does not match the query is highlighted using
|hl-ComplMatchIns|. If fuzzy is enabled in 'completopt', highlighting will not |hl-ComplMatchIns|. If fuzzy is enabled in 'completeopt', highlighting will
be applied. not be applied.
*complete_CTRL-E* *complete_CTRL-E*
When completion is active you can use CTRL-E to stop it and go back to the When completion is active you can use CTRL-E to stop it and go back to the

View File

@@ -86,19 +86,17 @@ Bit operations
y = bit.tobit(x) *bit.tobit()* y = bit.tobit(x) *bit.tobit()*
Normalizes a number to the numeric range for bit operations and returns Normalizes a number to the numeric range for bit operations and returns
it. This function is usually not needed since all bit operations already it. This function is usually not needed since all bit operations already
normalize all of their input arguments. Check the |luabit-semantics| for normalize all of their input arguments. See |lua-bit-semantics|.
details.
Example: >lua Example: >lua
print(0xffffffff) --> 4294967295 (*) print(0xffffffff) --> 4294967295 (see Note)
print(bit.tobit(0xffffffff)) --> -1 print(bit.tobit(0xffffffff)) --> -1
printx(bit.tobit(0xffffffff)) --> 0xffffffff printx(bit.tobit(0xffffffff)) --> 0xffffffff
print(bit.tobit(0xffffffff + 1)) --> 0 print(bit.tobit(0xffffffff + 1)) --> 0
print(bit.tobit(2^40 + 1234)) --> 1234 print(bit.tobit(2^40 + 1234)) --> 1234
< <
(*) See the treatment of |lua-bit-hex-literals| for an explanation why the Note: |lua-bit-hex-literals| explains why the numbers printed in the first
printed numbers in the first two lines differ (if your Lua installation two lines differ (if your Lua installation uses a double number type).
uses a double number type).
y = bit.tohex(x [,n]) *bit.tohex()* y = bit.tohex(x [,n]) *bit.tohex()*
Converts its first argument to a hex string. The number of hex digits is Converts its first argument to a hex string. The number of hex digits is
@@ -369,7 +367,7 @@ strongly advised not to rely on undefined or implementation-defined behavior.
- Non-integral numbers may be rounded or truncated in an - Non-integral numbers may be rounded or truncated in an
implementation-defined way. This means the result could differ between implementation-defined way. This means the result could differ between
different BitOp versions, different Lua VMs, on different platforms or different BitOp versions, different Lua VMs, on different platforms or
even between interpreted vs. compiled code (as in |LuaJIT|). Avoid even between interpreted vs. compiled code (as in LuaJIT). Avoid
passing fractional numbers to bitwise functions. Use `math.floor()` or passing fractional numbers to bitwise functions. Use `math.floor()` or
`math.ceil()` to get defined behavior. `math.ceil()` to get defined behavior.
- Lua provides auto-coercion of string arguments to numbers by default. This - Lua provides auto-coercion of string arguments to numbers by default. This

View File

@@ -4505,7 +4505,7 @@ A jump table for the options with a short description can be found at |Q_op|.
set path=,, set path=,,
< - A directory name may end in a ':' or '/'. < - A directory name may end in a ':' or '/'.
- Environment variables are expanded |:set_env|. - Environment variables are expanded |:set_env|.
- When using |netrw.vim| URLs can be used. For example, adding - When using |netrw| URLs can be used. For example, adding
"https://www.vim.org" will make ":find index.html" work. "https://www.vim.org" will make ":find index.html" work.
- Search upwards and downwards in a directory tree using "*", "**" and - Search upwards and downwards in a directory tree using "*", "**" and
";". See |file-searching| for info and syntax. ";". See |file-searching| for info and syntax.

View File

@@ -4816,7 +4816,7 @@ interface and syntax highlighting. In rough order of importance, these are
- standard syntax |group-name|s (in addition, syntax files can define - standard syntax |group-name|s (in addition, syntax files can define
language-specific groups, which are prefixed with the language name) language-specific groups, which are prefixed with the language name)
- |diagnostic-highlights| - |diagnostic-highlights|
- |tree-sitter-highlight-groups| - |treesitter-highlight-groups|
- |lsp-semantic-highlight| groups - |lsp-semantic-highlight| groups
- |lsp-highlight| of symbols and references - |lsp-highlight| of symbols and references

View File

@@ -789,7 +789,7 @@ must handle.
"" (empty) Unknown (consider a |feature-request|) "" (empty) Unknown (consider a |feature-request|)
"bufwrite" |:write| message "bufwrite" |:write| message
"confirm" Message preceding a prompt (|:confirm|, "confirm" Message preceding a prompt (|:confirm|,
|confirm()|, |inputlist()|, |z=,|, …) |confirm()|, |inputlist()|, |z=|, …)
"emsg" Error (|errors|, internal error, |:throw|, …) "emsg" Error (|errors|, internal error, |:throw|, …)
"echo" |:echo| message "echo" |:echo| message
"echomsg" |:echomsg| message "echomsg" |:echomsg| message

View File

@@ -4640,7 +4640,7 @@ vim.go.pm = vim.go.patchmode
--- ``` --- ```
--- - A directory name may end in a ':' or '/'. --- - A directory name may end in a ':' or '/'.
--- - Environment variables are expanded `:set_env`. --- - Environment variables are expanded `:set_env`.
--- - When using `netrw.vim` URLs can be used. For example, adding --- - When using `netrw` URLs can be used. For example, adding
--- "https://www.vim.org" will make ":find index.html" work. --- "https://www.vim.org" will make ":find index.html" work.
--- - Search upwards and downwards in a directory tree using "*", "**" and --- - Search upwards and downwards in a directory tree using "*", "**" and
--- ";". See `file-searching` for info and syntax. --- ";". See `file-searching` for info and syntax.

View File

@@ -10,8 +10,10 @@
print('Running lintdoc ...') print('Running lintdoc ...')
-- gen_help_html requires :helptags to be generated on $VIMRUNTIME/doc -- gen_help_html.lua requires helptags to be generated in $VIMRUNTIME/doc.
-- :helptags checks for duplicate tags. -- :helptags also checks for duplicate tags.
-- 🤢 Load netrw so its tags are generated by :helptags.
vim.cmd [[ packadd netrw ]]
vim.cmd [[ helptags ALL ]] vim.cmd [[ helptags ALL ]]
require('src.gen.gen_help_html').run_validate() require('src.gen.gen_help_html').run_validate()

View File

@@ -778,6 +778,7 @@ local function parse_buf(fname, text, parser_path)
vim.treesitter.language.add('vimdoc', { path = parser_path }) vim.treesitter.language.add('vimdoc', { path = parser_path })
end end
local lang_tree = assert(vim.treesitter.get_parser(buf, nil, { error = false })) local lang_tree = assert(vim.treesitter.get_parser(buf, nil, { error = false }))
lang_tree:parse()
return lang_tree, buf return lang_tree, buf
end end
@@ -1397,6 +1398,9 @@ function M.validate(help_dir, include, parser_path)
local files_to_errors = {} ---@type table<string, string[]> local files_to_errors = {} ---@type table<string, string[]>
ensure_runtimepath() ensure_runtimepath()
tagmap = get_helptags(vim.fs.normalize(help_dir)) tagmap = get_helptags(vim.fs.normalize(help_dir))
--- XXX: Append tags from netrw, until we remove it...
local netrwtags = get_helptags(vim.fs.normalize('$VIMRUNTIME/pack/dist/opt/netrw/doc/'))
tagmap = vim.tbl_extend('keep', tagmap, netrwtags)
helpfiles = get_helpfiles(help_dir, include) helpfiles = get_helpfiles(help_dir, include)
parser_path = parser_path and vim.fs.normalize(parser_path) or nil parser_path = parser_path and vim.fs.normalize(parser_path) or nil
@@ -1424,7 +1428,7 @@ function M.validate(help_dir, include, parser_path)
} }
end end
--- Validates vimdoc files on $VIMRUNTIME. and print human-readable error messages if fails. --- Validates vimdoc files in $VIMRUNTIME, and prints error messages on failure.
--- ---
--- If this fails, try these steps (in order): --- If this fails, try these steps (in order):
--- 1. Fix/cleanup the :help docs. --- 1. Fix/cleanup the :help docs.
@@ -1464,7 +1468,7 @@ function M.test_gen(help_dir)
print('doc path = ' .. vim.uv.fs_realpath(help_dir)) print('doc path = ' .. vim.uv.fs_realpath(help_dir))
-- Because gen() is slow (~30s), this test is limited to a few files. -- Because gen() is slow (~30s), this test is limited to a few files.
local input = { 'help.txt', 'index.txt', 'nvim.txt' } local input = { 'api.txt', 'index.txt', 'nvim.txt' }
local rv = M.gen(help_dir, tmpdir, input) local rv = M.gen(help_dir, tmpdir, input)
eq(#input, #rv.helpfiles) eq(#input, #rv.helpfiles)
eq(0, rv.err_count, 'parse errors in :help docs') eq(0, rv.err_count, 'parse errors in :help docs')

View File

@@ -6236,7 +6236,7 @@ local options = {
set path=,, set path=,,
< - A directory name may end in a ':' or '/'. < - A directory name may end in a ':' or '/'.
- Environment variables are expanded |:set_env|. - Environment variables are expanded |:set_env|.
- When using |netrw.vim| URLs can be used. For example, adding - When using |netrw| URLs can be used. For example, adding
"https://www.vim.org" will make ":find index.html" work. "https://www.vim.org" will make ":find index.html" work.
- Search upwards and downwards in a directory tree using "*", "**" and - Search upwards and downwards in a directory tree using "*", "**" and
";". See |file-searching| for info and syntax. ";". See |file-searching| for info and syntax.