feat(nvim-treesitter.lua): add support for additional parsers (markdown_inline, markdown) to improve syntax highlighting capabilities

feat(nvim-treesitter.lua): enable textobjects for moving, selecting, and swapping code blocks to enhance code navigation and manipulation within the editor
This commit is contained in:
David Ibia
2024-03-10 12:22:11 +01:00
parent ef623f83ad
commit 99579eeab9

View File

@@ -1,6 +1,18 @@
require 'nvim-treesitter.configs'.setup { require("nvim-treesitter.configs").setup({
-- A list of parser names, or "all" (the five listed parsers should always be installed) -- A list of parser names, or "all" (the five listed parsers should always be installed)
ensure_installed = { "rust", "javascript", "typescript", "python", "c", "lua", "vim", "vimdoc", "query" }, ensure_installed = {
"rust",
"javascript",
"typescript",
"python",
"c",
"lua",
"vim",
"vimdoc",
"query",
"markdown_inline",
"markdown",
},
-- Install parsers synchronously (only applied to `ensure_installed`) -- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false, sync_install = false,
@@ -19,4 +31,39 @@ require 'nvim-treesitter.configs'.setup {
-- Instead of true it can also be a list of languages -- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false, additional_vim_regex_highlighting = false,
}, },
} textobjects = {
move = {
enable = true,
set_jumps = false, -- you can change this if you want.
goto_next_start = {
--- ... other keymaps
["]b"] = { query = "@code_cell.inner", desc = "next code block" },
},
goto_previous_start = {
--- ... other keymaps
["[b"] = { query = "@code_cell.inner", desc = "previous code block" },
},
},
select = {
enable = true,
lookahead = true, -- you can change this if you want
keymaps = {
--- ... other keymaps
["ib"] = { query = "@code_cell.inner", desc = "in block" },
["ab"] = { query = "@code_cell.outer", desc = "around block" },
},
},
swap = { -- Swap only works with code blocks that are under the same
-- markdown header
enable = true,
swap_next = {
--- ... other keymap
["<leader>sbl"] = "@code_cell.outer",
},
swap_previous = {
--- ... other keymap
["<leader>sbh"] = "@code_cell.outer",
},
},
},
})