From 26793ef834a68e94880cde5d86ef003b177b2b33 Mon Sep 17 00:00:00 2001 From: "Gustavo L de Mello (Guz)" Date: Thu, 5 Dec 2024 19:25:19 -0300 Subject: [PATCH] feat: add treesitter configuration --- lua/dot013/plugins/init.lua | 1 + lua/dot013/plugins/treesitter.lua | 101 ++++++++++++++++++++++++++++++ neovim.nix | 4 +- 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 lua/dot013/plugins/treesitter.lua diff --git a/lua/dot013/plugins/init.lua b/lua/dot013/plugins/init.lua index 8a252f1..0276f71 100644 --- a/lua/dot013/plugins/init.lua +++ b/lua/dot013/plugins/init.lua @@ -1,6 +1,7 @@ return { { import = "dot013.plugins.appearance" }, { import = "dot013.plugins.navigation" }, + { import = "dot013.plugins.treesitter" }, -- Global Dependencies { "plenary.nvim", dep_of = { "telescope.nvim", "harpoon" } }, diff --git a/lua/dot013/plugins/treesitter.lua b/lua/dot013/plugins/treesitter.lua new file mode 100644 index 0000000..b927248 --- /dev/null +++ b/lua/dot013/plugins/treesitter.lua @@ -0,0 +1,101 @@ +return { + { + "nvim-treesitter", + dep_of = { "indent-blankline.nvim" }, + priority = 1000, + after = function() + require("nvim-treesitter.configs").setup({ + auto_install = false, + highlight = { enable = true }, + indent = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = "", + node_decremental = "", + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ["aa"] = "@parameter.outer", + ["ia"] = "@parameter.inner", + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + }, + }, + move = { + enable = true, + set_jumps = true, + goto_next_start = { + ["]m"] = "@function.outer", + ["]]"] = "@class.outer", + }, + goto_next_end = { + ["]M"] = "@function.outer", + ["]["] = "@class.outer", + }, + goto_previous_start = { + ["[m"] = "@function.outer", + ["[["] = "@class.outer", + }, + goto_previous_end = { + ["[M"] = "@function.outer", + ["[]"] = "@class.outer", + }, + }, + }, + textsubjects = { + enable = true, + prev_selection = ",", + keymaps = { + ["."] = "textsubjects-smart", + [";"] = "textsubjects-container-outer", + ["i;"] = "textsubjects-container-inner", + }, + }, + swap = { + enable = true, + swap_next = { + ["a"] = "@parameter.inner", + }, + swap_previous = { + ["A"] = "@parameter.inner", + }, + }, + playground = { + enable = true, + disable = {}, + updatetime = 25, + persist_queries = false, + keybindings = { + toggle_query_editor = "o", + toggle_hl_groups = "i", + toggle_injected_languages = "t", + toggle_anonymous_nodes = "a", + toggle_language_display = "I", + focus_language = "f", + unfocus_language = "F", + update = "R", + goto_node = "", + show_help = "?", + }, + }, + query_linter = { + enable = true, + use_virtual_text = true, + lint_events = { "BugWrite", "CursorHold" }, + }, + }) + end, + }, + -- Treesitter dependencies + { "nvim-treesitter-textobjects", dep_of = { "nvim-treesitter" } }, + { "nvim-treesitter-textsubjects", dep_of = { "nvim-treesitter" } }, +} diff --git a/neovim.nix b/neovim.nix index 09276cd..a629dd2 100644 --- a/neovim.nix +++ b/neovim.nix @@ -12,6 +12,9 @@ catppuccin-nvim indent-blankline-nvim lze + nvim-treesitter.withAllGrammars + nvim-treesitter-textobjects + nvim-treesitter-textsubjects (vimUtils.buildVimPlugin { name = "dot013.nvim"; src = ./.; @@ -26,7 +29,6 @@ nvim-web-devicons telescope-nvim telescope-fzf-native-nvim - nvim-treesitter.withAllGrammars tmux-nvim ];