From 2b2a3449f78b5ea984e012147709625e0fc78532 Mon Sep 17 00:00:00 2001 From: Michele Campeotto Date: Sat, 3 May 2025 16:06:22 +0200 Subject: [PATCH] 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 f048298e9abc3081a1ed170cc5d45c8af9130ce9) --- runtime/lua/man.lua | 2 ++ runtime/lua/vim/treesitter/_headings.lua | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua index 61950f184e..8f47757c2f 100644 --- a/runtime/lua/man.lua +++ b/runtime/lua/man.lua @@ -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 diff --git a/runtime/lua/vim/treesitter/_headings.lua b/runtime/lua/vim/treesitter/_headings.lua index bfa468ad88..7cd9dfa4b0 100644 --- a/runtime/lua/vim/treesitter/_headings.lua +++ b/runtime/lua/vim/treesitter/_headings.lua @@ -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