commit 25322a3a3b225c54f2fcec83654d9d2fc99ad543
parent a65202e6bd17f5daffaa2d2673128e6fc7b48d5d
Author: Yochem van Rosmalen <git@yochem.nl>
Date: Mon, 13 Oct 2025 20:08:37 +0200
fix(help): only set url for help files in $VIMRUNTIME #36165
Problem:
Checking if the tag is nvim-owned (defined in a $VIMRUNTIME/doc/*.txt
file) is too expensive for now without non-obvious workarounds
Solution:
Only set url extmarks for $VIMRUNTIME/doc/*.txt files.
Closes: #36163
Diffstat:
1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/runtime/ftplugin/help.lua b/runtime/ftplugin/help.lua
@@ -116,7 +116,9 @@ do
end
local url_ns = vim.api.nvim_create_namespace('nvim.help.urls')
-do
+local filepath = vim.fs.normalize(vim.api.nvim_buf_get_name(0))
+
+if vim.fs.relpath(vim.env.VIMRUNTIME, filepath) ~= nil then
local base = 'https://neovim.io/doc/user/helptag.html?tag='
local query = vim.treesitter.query.parse(
'vimdoc',
@@ -129,28 +131,17 @@ do
]]
)
- local function is_nvim_tag(tag)
- local tagsfile = vim.fs.joinpath(vim.env.VIMRUNTIME, 'doc', 'tags')
- local candidates = vim.fn.taglist('^' .. tag .. '$', tagsfile)
- if #candidates == 0 then
- return false
- end
- return vim.fs.relpath(vim.env.VIMRUNTIME, candidates[1].filename) ~= nil
- end
-
for _, match, _ in query:iter_matches(root, 0, 0, -1) do
for id, nodes in pairs(match) do
if query.captures[id] == 'helplink' then
for _, node in ipairs(nodes) do
local start_line, start_col, end_line, end_col = node:range()
local tag = vim.treesitter.get_node_text(node, 0)
- if is_nvim_tag(tag) then
- vim.api.nvim_buf_set_extmark(0, url_ns, start_line, start_col, {
- end_line = end_line,
- end_col = end_col,
- url = base .. vim.uri_encode(tag),
- })
- end
+ vim.api.nvim_buf_set_extmark(0, url_ns, start_line, start_col, {
+ end_line = end_line,
+ end_col = end_col,
+ url = base .. vim.uri_encode(tag),
+ })
end
end
end