Files
neovim/runtime/ftplugin/help.lua
zeertzjq 8f5e908110 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.
2024-07-01 17:48:09 +08:00

35 lines
1.3 KiB
Lua

-- use treesitter over syntax (for highlighted code blocks)
vim.treesitter.start()
-- 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({
{ start = [[\*group-name\*]], stop = '^======', match = '^(%w+)\t' },
{ start = [[\*highlight-groups\*]], stop = '^======', match = '^(%w+)\t' },
})
elseif vim.endswith(bufname, '/doc/treesitter.txt') then
require('vim.vimhelp').highlight_groups({
{
start = [[\*treesitter-highlight-groups\*]],
stop = [[\*treesitter-highlight-spell\*]],
match = '^@[%w%p]+',
},
})
elseif vim.endswith(bufname, '/doc/diagnostic.txt') then
require('vim.vimhelp').highlight_groups({
{ start = [[\*diagnostic-highlights\*]], stop = '^======', match = '^(%w+)' },
})
elseif vim.endswith(bufname, '/doc/lsp.txt') then
require('vim.vimhelp').highlight_groups({
{ start = [[\*lsp-highlight\*]], stop = '^------', match = '^(%w+)' },
{ 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 })
vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | nunmap <buffer> gO'