From 6592873f773b4c358ea950bfcfa8cbc3fc3bc8cc Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 8 Jun 2024 10:49:15 +0200 Subject: feat(help): use treesitter for table of contents Problem: Creating the table of contents for `gO` is complicated. Solution: Use treesitter instead. --- runtime/ftplugin/help.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'runtime/ftplugin/help.lua') diff --git a/runtime/ftplugin/help.lua b/runtime/ftplugin/help.lua index 67c417b1be..86e181504f 100644 --- a/runtime/ftplugin/help.lua +++ b/runtime/ftplugin/help.lua @@ -26,3 +26,7 @@ elseif vim.endswith(bufname, '/doc/lsp.txt') then { start = [[\*lsp-semantic-highlight\*]], stop = '^======', match = '^@[%w%p]+' }, }) end + +vim.keymap.set('n', 'gO', function() + require('vim.vimhelp').show_toc() +end, { buffer = 0, silent = true }) -- cgit From 8f5e90811025bcc652146168d5116f8d73fe8f81 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 1 Jul 2024 17:48:09 +0800 Subject: fix(runtime): update b:undo_ftplugin in Lua runtime files (#29529) Related to #29506, but adding vim.treesitter.stop() to b:undo_ftplugin doesn't solve the problem yet. --- runtime/ftplugin/help.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'runtime/ftplugin/help.lua') diff --git a/runtime/ftplugin/help.lua b/runtime/ftplugin/help.lua index 86e181504f..0628a3e9ca 100644 --- a/runtime/ftplugin/help.lua +++ b/runtime/ftplugin/help.lua @@ -30,3 +30,5 @@ end vim.keymap.set('n', 'gO', function() require('vim.vimhelp').show_toc() end, { buffer = 0, silent = true }) + +vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | nunmap gO' -- cgit From 12c9791e0fef7ee0d6cf6d3b828caa488d6347ea Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 3 Jul 2024 15:24:12 +0800 Subject: fix(runtime): stop treesitter highlight in b:undo_ftplugin (#29533) It seems that nvim-treesitter stops treesitter highlight when changing filetype, so it makes sense for builtin ftplugins to do this as well. Use :call and v:lua here to allow separation with '|'. --- runtime/ftplugin/help.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/ftplugin/help.lua') diff --git a/runtime/ftplugin/help.lua b/runtime/ftplugin/help.lua index 0628a3e9ca..6e643c967f 100644 --- a/runtime/ftplugin/help.lua +++ b/runtime/ftplugin/help.lua @@ -31,4 +31,5 @@ vim.keymap.set('n', 'gO', function() require('vim.vimhelp').show_toc() end, { buffer = 0, silent = true }) +vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | call v:lua.vim.treesitter.stop()' vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | nunmap gO' -- cgit From 50577534318bbf8c1e22e80a74baa3b20c131ea8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 23 Sep 2024 16:49:34 +0800 Subject: fix(runtime): treat b:undo_ftplugin consistently in Lua ftplugins (#30473) - Don't assume b:undo_ftplugin is set when first modifying it. - Don't assume b:undo_ftplugin already contains some resetting. --- runtime/ftplugin/help.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/ftplugin/help.lua') diff --git a/runtime/ftplugin/help.lua b/runtime/ftplugin/help.lua index 6e643c967f..eb66e34bc7 100644 --- a/runtime/ftplugin/help.lua +++ b/runtime/ftplugin/help.lua @@ -31,5 +31,5 @@ vim.keymap.set('n', 'gO', function() require('vim.vimhelp').show_toc() end, { buffer = 0, silent = true }) +vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '') .. '\n exe "nunmap gO"' vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | call v:lua.vim.treesitter.stop()' -vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | nunmap gO' -- cgit From 09d76afe84dd5b895e102dcd8df8ce6271bebfef Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 27 Sep 2024 08:53:30 -0700 Subject: feat(defaults): pretty :help headings #30544 Problem: Headings in :help do not stand out visually. Solution: Define a non-standard `@markup.heading.1.delimiter` group and special-case it in `highlight_group.c`. FUTURE: This is a cheap workaround until we have #25718 which will enable: - fully driven by `vimdoc/highlights.scm` instead of using highlight tricks (`guibg=bg guifg=bg guisp=fg`) - better support of "cterm" ('notermguicolors') --- runtime/ftplugin/help.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/ftplugin/help.lua') diff --git a/runtime/ftplugin/help.lua b/runtime/ftplugin/help.lua index eb66e34bc7..8d991be0e4 100644 --- a/runtime/ftplugin/help.lua +++ b/runtime/ftplugin/help.lua @@ -1,7 +1,7 @@ -- use treesitter over syntax (for highlighted code blocks) vim.treesitter.start() --- add custom highlights for list in `:h highlight-groups` +-- Add custom highlights for list in `:h highlight-groups`. local bufname = vim.fs.normalize(vim.api.nvim_buf_get_name(0)) if vim.endswith(bufname, '/doc/syntax.txt') then require('vim.vimhelp').highlight_groups({ -- cgit