Update nvim plugins

This commit is contained in:
Martin Larsson 2026-03-23 00:07:26 +01:00
parent f779732115
commit d1178fbe59
2 changed files with 58 additions and 52 deletions

View file

@ -1,6 +1,20 @@
local function ts_select(query)
return function() require("nvim-treesitter-textobjects.select").select_textobject(query, "textobjects") end
end
local function ts_move_prev(query)
return function() require("nvim-treesitter-textobjects.move").goto_previous_start(query, "textobjects") end
end
local function ts_move_next(query)
return function() require("nvim-treesitter-textobjects.move").goto_next_start(query, "textobjects") end
end
-- TODO: Move away from master branch after updating to Neovim 0.12 and use the rewrite
return {
"nvim-treesitter/nvim-treesitter",
event = { "BufReadPre", "BufNewFile" },
branch = "master",
build = ":TSUpdate",
dependencies = {
{
@ -11,8 +25,45 @@ return {
trim_scope = "inner", -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer'
}
},
"nvim-treesitter/nvim-treesitter-textobjects",
"OXY2DEV/markview.nvim",
{
"nvim-treesitter/nvim-treesitter-textobjects",
branch = "main",
init = function()
-- Disable entire built-in ftplugin mappings to avoid conflicts.
-- See https://github.com/neovim/neovim/tree/master/runtime/ftplugin for built-in ftplugins.
vim.g.no_plugin_maps = true
end,
opts = {
select = {
lookahead = true,
},
move = {
set_jumps = true,
},
},
keys = {
-- select
{ "ic", ts_select("@class.inner"), mode = { "x", "o" } },
{ "ac", ts_select("@class.outer"), mode = { "x", "o" } },
{ "ii", ts_select("@conditional.inner"), mode = { "x", "o" } },
{ "ai", ts_select("@conditional.outer"), mode = { "x", "o" } },
{ "if", ts_select("@function.inner"), mode = { "x", "o" } },
{ "af", ts_select("@function.outer"), mode = { "x", "o" } },
{ "il", ts_select("@loop.inner"), mode = { "x", "o" } },
{ "al", ts_select("@loop.outer"), mode = { "x", "o" } },
{ "ia", ts_select("@attribute.inner"), mode = { "x", "o" } },
{ "aa", ts_select("@attribute.outer"), mode = { "x", "o" } },
-- move
{ "[f", ts_move_prev("@function.outer"), mode = { "n", "x", "o" } },
{ "[i", ts_move_prev("@conditional.outer"), mode = { "n", "x", "o" } },
{ "[c", ts_move_prev("@class.outer"), mode = { "n", "x", "o" } },
{ "[l", ts_move_prev("@loop.outer"), mode = { "n", "x", "o" } },
{ "]f", ts_move_next("@function.outer"), mode = { "n", "x", "o" } },
{ "]i", ts_move_next("@conditional.outer"), mode = { "n", "x", "o" } },
{ "]c", ts_move_next("@class.outer"), mode = { "n", "x", "o" } },
{ "]l", ts_move_next("@loop.outer"), mode = { "n", "x", "o" } },
},
},
},
config = function()
require("nvim-treesitter.configs").setup({
@ -59,55 +110,11 @@ return {
"jsonc",
},
sync_install = false,
-- This can be updated to a list of languages instead of defaulting to true
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
indent = { enable = true },
incremental_selection = {
enable = false,
keymaps = {
init_selection = "<cr>",
node_incremental = "<cr>",
scope_incremental = false,
node_decremental = "<bs>",
},
},
textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
["ic"] = { query = "@class.inner" },
["ac"] = { query = "@class.outer" },
["ii"] = { query = "@conditional.inner" },
["ai"] = { query = "@conditional.outer" },
["if"] = { query = "@function.inner" },
["af"] = { query = "@function.outer" },
["il"] = { query = "@loop.inner" },
["al"] = { query = "@loop.outer" },
["ia"] = { query = "@attribute.inner" },
["aa"] = { query = "@attribute.outer" },
},
},
move = {
enable = true,
set_jumps = true,
goto_previous_start = {
["[f"] = "@function.outer",
["[i"] = "@conditional.outer",
["[c"] = "@class.outer",
["[l"] = "@loop.outer",
},
goto_next_start = {
["]f"] = "@function.outer",
["]i"] = "@conditional.outer",
["]c"] = "@class.outer",
["]l"] = "@loop.outer",
},
},
},
})
end
}