95 lines
2.6 KiB
Lua
95 lines
2.6 KiB
Lua
return {{
|
|
"nvim-treesitter/nvim-treesitter",
|
|
event = { "BufReadPre", "BufNewFile" },
|
|
build = ":TSUpdate",
|
|
dependencies = {
|
|
"windwp/nvim-ts-autotag",
|
|
},
|
|
config = function()
|
|
-- import nvim-treesitter plugin
|
|
local treesitter = require("nvim-treesitter.configs")
|
|
|
|
-- configure treesitter
|
|
treesitter.setup({ -- enable syntax highlighting
|
|
highlight = {
|
|
enable = true,
|
|
},
|
|
-- enable indentation
|
|
indent = { enable = true },
|
|
-- enable autotagging (w/ nvim-ts-autotag plugin)
|
|
autotag = {
|
|
enable = true,
|
|
},
|
|
-- ensure these language parsers are installed
|
|
ensure_installed = {
|
|
"json",
|
|
"javascript",
|
|
"typescript",
|
|
"tsx",
|
|
"yaml",
|
|
"html",
|
|
"css",
|
|
"prisma",
|
|
"markdown",
|
|
"markdown_inline",
|
|
"graphql",
|
|
"bash",
|
|
"lua",
|
|
"vim",
|
|
"dockerfile",
|
|
"gitignore",
|
|
"query",
|
|
"vimdoc",
|
|
"c",
|
|
},
|
|
incremental_selection = {
|
|
enable = true,
|
|
keymaps = {
|
|
init_selection = "<C-space>",
|
|
node_incremental = "<C-space>",
|
|
scope_incremental = false,
|
|
node_decremental = "<bs>",
|
|
},
|
|
},
|
|
})
|
|
end,
|
|
},
|
|
{
|
|
"nvim-treesitter/nvim-treesitter-textobjects",
|
|
lazy = true,
|
|
dependencies = {
|
|
"nvim-treesitter/nvim-treesitter",
|
|
},
|
|
config = function()
|
|
require("nvim-treesitter.configs").setup({
|
|
textobjects = {
|
|
select = {
|
|
enable = true,
|
|
|
|
-- Automatically jump forward to textobj, similar to targets.vim
|
|
lookahead = true,
|
|
|
|
keymaps = {
|
|
-- You can use the capture groups defined in textobjects.scm
|
|
["af"] = "@function.outer",
|
|
["if"] = "@function.inner",
|
|
["ac"] = "@class.outer",
|
|
-- You can optionally set descriptions to the mappings (used in the desc parameter of
|
|
-- nvim_buf_set_keymap) which plugins like which-key display
|
|
["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" },
|
|
-- You can also use captures from other query groups like `locals.scm`
|
|
["as"] = { query = "@scope", query_group = "locals", desc = "Select language scope" },
|
|
},
|
|
selection_modes = {
|
|
['@parameter.outer'] = 'v', -- charwise
|
|
['@function.outer'] = 'V', -- linewise
|
|
['@class.outer'] = '<c-v>', -- blockwise
|
|
},
|
|
include_surrounding_whitespace = true,
|
|
},
|
|
},
|
|
})
|
|
end,
|
|
}
|
|
}
|