fix(runtime): conceal paths in help, man ToC loclist #33764

Problem:
The check for concealing paths in TOCs in the qf syntax file fails
because the TOC tile has changed.

Solution:
Force the qf syntax file to be reloaded after the qf_toc variable
has been set, so that the it can apply the correct settings.

Using the explicit qf_toc key, already used in the syntax file, instead
of the title is less prone to breaking.

It was also already being set for man pages but it had no effect because
the syntax file had already been loaded when the variable was set.

Fixes #33733

(cherry picked from commit f048298e9a)
This commit is contained in:
Michele Campeotto
2025-05-03 16:06:22 +02:00
committed by github-actions[bot]
parent 6b69b3217b
commit 2b2a3449f7
2 changed files with 6 additions and 0 deletions

View File

@ -810,6 +810,8 @@ function M.show_toc()
fn.setloclist(0, {}, 'a', { title = 'Table of contents' })
vim.cmd.lopen()
vim.w.qf_toc = bufname
-- reload syntax file after setting qf_toc variable
vim.bo.filetype = 'qf'
end
return M

View File

@ -86,6 +86,7 @@ end
--- Shows an Outline (table of contents) of the current buffer, in the loclist.
function M.show_toc()
local bufnr = api.nvim_get_current_buf()
local bufname = api.nvim_buf_get_name(bufnr)
local headings = get_headings(bufnr)
if #headings == 0 then
return
@ -102,6 +103,9 @@ function M.show_toc()
vim.fn.setloclist(0, headings, ' ')
vim.fn.setloclist(0, {}, 'a', { title = 'Table of contents' })
vim.cmd.lopen()
vim.w.qf_toc = bufname
-- reload syntax file after setting qf_toc variable
vim.bo.filetype = 'qf'
end
--- Jump to section