From 8715b17db3b3ec0dc3c761959b39c217e34130b0 Mon Sep 17 00:00:00 2001 From: spike Date: Mon, 22 Aug 2022 16:19:41 +0200 Subject: [PATCH] treesitter-textobjects on own module --- lua/custom/plugins/configs/treesitter-to.lua | 68 ++++++++++++++++++ lua/plugins/configs/treesitter.lua | 75 -------------------- 2 files changed, 68 insertions(+), 75 deletions(-) create mode 100644 lua/custom/plugins/configs/treesitter-to.lua diff --git a/lua/custom/plugins/configs/treesitter-to.lua b/lua/custom/plugins/configs/treesitter-to.lua new file mode 100644 index 0000000..b1daea0 --- /dev/null +++ b/lua/custom/plugins/configs/treesitter-to.lua @@ -0,0 +1,68 @@ +local present, treesitter = pcall(require, "nvim-treesitter.configs") + +if not present then + return +end + +local options = { + + textobjects = { + enable = true, + + select = { + enable = true, + lookahead = true, + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["aC"] = "@class.outer", + ["iC"] = "@class.inner", + ["ac"] = "@conditional.outer", + ["ic"] = "@conditional.inner", + ["ae"] = "@block.outer", + ["ie"] = "@block.inner", + ["al"] = "@loop.outer", + ["il"] = "@loop.inner", + ["is"] = "@statement.inner", + ["as"] = "@statement.outer", + ["ad"] = "@comment.outer", + ["am"] = "@call.outer", + ["im"] = "@call.inner", + } + }, + + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + 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" + } + }, + + swap = { + enable = true, + swap_next = { + ["a"] = "@parameter.inner" + }, + swap_previous = { + ["A"] = "@parameter.inner" + } + } + } +} + +treesitter.setup(options) diff --git a/lua/plugins/configs/treesitter.lua b/lua/plugins/configs/treesitter.lua index cd75fc5..e23501a 100644 --- a/lua/plugins/configs/treesitter.lua +++ b/lua/plugins/configs/treesitter.lua @@ -9,86 +9,11 @@ require("base46").load_highlight "treesitter" local options = { ensure_installed = { "lua", - "go", - "rust", - "fish", - "bash", - "python", - "c", - "haskell", - "javascript", - "html", - "markdown", - "markdown_inline", - "make", - "sql", - "yaml", - "toml", - "vue", }, - highlight = { enable = true, use_languagetree = true, }, - - textobjects = { - enable = true, - - select = { - enable = true, - lookahead = true, - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["aC"] = "@class.outer", - ["iC"] = "@class.inner", - ["ac"] = "@conditional.outer", - ["ic"] = "@conditional.inner", - ["ae"] = "@block.outer", - ["ie"] = "@block.inner", - ["al"] = "@loop.outer", - ["il"] = "@loop.inner", - ["is"] = "@statement.inner", - ["as"] = "@statement.outer", - ["ad"] = "@comment.outer", - ["am"] = "@call.outer", - ["im"] = "@call.inner", - } - }, - - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - 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" - } - }, - - swap = { - enable = true, - swap_next = { - ["a"] = "@parameter.inner" - }, - swap_previous = { - ["A"] = "@parameter.inner" - } - } - } } -- check for any override