help.lua 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. -- use treesitter over syntax (for highlighted code blocks)
  2. vim.treesitter.start()
  3. -- Add custom highlights for list in `:h highlight-groups`.
  4. local bufname = vim.fs.normalize(vim.api.nvim_buf_get_name(0))
  5. if vim.endswith(bufname, '/doc/syntax.txt') then
  6. require('vim.vimhelp').highlight_groups({
  7. { start = [[\*group-name\*]], stop = '^======', match = '^(%w+)\t' },
  8. { start = [[\*highlight-groups\*]], stop = '^======', match = '^(%w+)\t' },
  9. })
  10. elseif vim.endswith(bufname, '/doc/treesitter.txt') then
  11. require('vim.vimhelp').highlight_groups({
  12. {
  13. start = [[\*treesitter-highlight-groups\*]],
  14. stop = [[\*treesitter-highlight-spell\*]],
  15. match = '^@[%w%p]+',
  16. },
  17. })
  18. elseif vim.endswith(bufname, '/doc/diagnostic.txt') then
  19. require('vim.vimhelp').highlight_groups({
  20. { start = [[\*diagnostic-highlights\*]], stop = '^======', match = '^(%w+)' },
  21. })
  22. elseif vim.endswith(bufname, '/doc/lsp.txt') then
  23. require('vim.vimhelp').highlight_groups({
  24. { start = [[\*lsp-highlight\*]], stop = '^------', match = '^(%w+)' },
  25. { start = [[\*lsp-semantic-highlight\*]], stop = '^======', match = '^@[%w%p]+' },
  26. })
  27. end
  28. vim.keymap.set('n', 'gO', function()
  29. require('vim.vimhelp').show_toc()
  30. end, { buffer = 0, silent = true })
  31. vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '') .. '\n exe "nunmap <buffer> gO"'
  32. vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | call v:lua.vim.treesitter.stop()'