mirror of
https://github.com/neovim/neovim.git
synced 2026-04-19 22:10:45 +00:00
feat(treesitter): table of contents for checkhealth, markdown (#32282)
Problem: It's difficult to navigate large structured text files (vim help, checkhealth, Markdown). Solution: Support `gO` for table of contents and `]]`/`[[` for moving between headings for all these filetypes using treesitter queries. Refactor: colorization of highlight groups is moved to the `help` ftplugin while headings-related functionality is implemented in a private `vim.treesitter` module for possible future use for other filetypes.
This commit is contained in:
14
runtime/ftplugin/markdown.lua
Normal file
14
runtime/ftplugin/markdown.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
vim.keymap.set('n', 'gO', function()
|
||||
require('vim.treesitter._headings').show_toc()
|
||||
end, { buffer = 0, silent = true, desc = 'Show table of contents for current buffer' })
|
||||
|
||||
vim.keymap.set('n', ']]', function()
|
||||
require('vim.treesitter._headings').jump({ count = 1 })
|
||||
end, { buffer = 0, silent = false, desc = 'Jump to next section' })
|
||||
vim.keymap.set('n', '[[', function()
|
||||
require('vim.treesitter._headings').jump({ count = -1 })
|
||||
end, { buffer = 0, silent = false, desc = 'Jump to previous section' })
|
||||
|
||||
vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '')
|
||||
.. '\n exe "nunmap <buffer> gO"'
|
||||
.. '\n exe "nunmap <buffer> ]]" | exe "nunmap <buffer> [["'
|
||||
Reference in New Issue
Block a user