From 25322a3a3b225c54f2fcec83654d9d2fc99ad543 Mon Sep 17 00:00:00 2001 From: Yochem van Rosmalen Date: Mon, 13 Oct 2025 20:08:37 +0200 Subject: [PATCH] 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 --- runtime/ftplugin/help.lua | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/runtime/ftplugin/help.lua b/runtime/ftplugin/help.lua index 0379bd0c97..f02a441249 100644 --- 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