From 35aa851231c6dfcd6ba451e72970e686ba5fef30 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 11 Jul 2022 12:47:36 +0000 Subject: [PATCH] neovim tree-sitter textobject selections --- modules/editor/neovim/lua/packer/syntax.lua | 34 +++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/modules/editor/neovim/lua/packer/syntax.lua b/modules/editor/neovim/lua/packer/syntax.lua index 5a44ec0..418a9e7 100644 --- a/modules/editor/neovim/lua/packer/syntax.lua +++ b/modules/editor/neovim/lua/packer/syntax.lua @@ -28,6 +28,40 @@ M.packer = function(use) end, }) + -- Syntax-aware Textobjects + use({ + "nvim-treesitter/nvim-treesitter-textobjects", + requires = { "nvim-treesitter/nvim-treesitter" }, + config = function() + require("nvim-treesitter.configs").setup({ + textobjects = { + select = { + enable = true, + lookahead = true, -- Jump forward automatically + keymaps = { + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + ["al"] = "@loop.outer", + ["il"] = "@loop.inner", + ["aa"] = "@call.outer", + ["ia"] = "@call.inner", + ["ar"] = "@parameter.outer", + ["ir"] = "@parameter.inner", + ["aC"] = "@comment.outer", + ["iC"] = "@comment.outer", + ["a/"] = "@comment.outer", + ["i/"] = "@comment.outer", + ["a;"] = "@statement.outer", + ["i;"] = "@statement.outer", + }, + }, + }, + }) + end, + }) + -- Additional syntax sources use("bfontaine/Brewfile.vim") --- Brewfile syntax use("chr4/nginx.vim") --- Nginx syntax