update nvim-treesitter to main

This commit is contained in:
Alexander Navarro 2025-09-04 10:46:28 -04:00
parent 41f458954a
commit 7e24245690
3 changed files with 60 additions and 49 deletions

View file

@ -1,50 +1,60 @@
return {
{
"nvim-treesitter/nvim-treesitter",
lazy = false,
branch = "master",
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 },
},
},
{
"nvim-treesitter/nvim-treesitter-textobjects",
dependencies = { "nvim-treesitter", },
config = function()
require 'nvim-treesitter.configs'.setup({
textobjects = {
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next = {
["]]"] = { query = { "@block.outer", "@function.outer", "@class.outer", } },
},
goto_previous = {
["[["] = { query = { "@block.outer", "@function.outer", "@class.outer", } },
}
},
},
})
{
"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" },
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")
local ts_repeat_move = require "nvim-treesitter.textobjects.repeatable_move"
ts_obj.setup({
move = {
set_jumps = true,
},
})
-- 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_previous)
vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_next)
end
}
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,
},
}