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