60 lines
1.7 KiB
Lua
60 lines
1.7 KiB
Lua
return {
|
|
{
|
|
"nvim-treesitter/nvim-treesitter",
|
|
lazy = false,
|
|
branch = "main",
|
|
dependencies = {
|
|
{
|
|
"JoosepAlviste/nvim-ts-context-commentstring",
|
|
opts = {
|
|
enable_autocmd = false,
|
|
},
|
|
},
|
|
{ "nvim-treesitter/nvim-treesitter-context" },
|
|
},
|
|
build = ":TSUpdate",
|
|
opts = {
|
|
auto_install = true,
|
|
highlight = { enable = true },
|
|
indent = { enable = true },
|
|
},
|
|
init = function()
|
|
-- HACK: for filetypes that doesn't start treesitter hightlight on it's own
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
pattern = { "gleam", "go", "kotlin" },
|
|
callback = function()
|
|
vim.treesitter.start()
|
|
end,
|
|
})
|
|
end,
|
|
},
|
|
{
|
|
"nvim-treesitter/nvim-treesitter-textobjects",
|
|
dependencies = { "nvim-treesitter" },
|
|
branch = "main",
|
|
config = function()
|
|
local ts_obj = require("nvim-treesitter-textobjects")
|
|
|
|
ts_obj.setup({
|
|
move = {
|
|
set_jumps = true,
|
|
},
|
|
})
|
|
|
|
vim.keymap.set({ "n", "x", "o" }, "]]", function()
|
|
ts_obj.move.goto_next({ "@block.outer", "@function.outer", "@class.outer" }, "textobjects")
|
|
end)
|
|
|
|
vim.keymap.set({ "n", "x", "o" }, "[[", function()
|
|
ts_obj.move.goto_previous({ "@block.outer", "@function.outer", "@class.outer" }, "textobjects")
|
|
end)
|
|
|
|
local ts_repeat_move = require("nvim-treesitter-textobjects.repeatable_move")
|
|
|
|
-- Repeat movement with ; and ,
|
|
-- ensure ; goes forward and , goes backward regardless of the last direction
|
|
vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move_opposite)
|
|
vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move)
|
|
end,
|
|
},
|
|
}
|