From 0926ae96711839f3d37b7c9ee058b26b0f3e5685 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 11 May 2022 10:04:33 +0100 Subject: [PATCH] feat(nvim): add Treesitter text objects --- roles/neovim/files/after/plugin/treesitter.lua | 15 ++++++++++++++- roles/neovim/files/lua/opdavies/plugins.lua | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/roles/neovim/files/after/plugin/treesitter.lua b/roles/neovim/files/after/plugin/treesitter.lua index 3050de2..3b0f2a6 100644 --- a/roles/neovim/files/after/plugin/treesitter.lua +++ b/roles/neovim/files/after/plugin/treesitter.lua @@ -17,7 +17,20 @@ configs.setup { }, matchup = { enable = true, - } + }, + textobjects = { + select = { + enable = true, + lookahead = true, + + keymaps = { + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + }, + }, + }, } local nmap = require "opdavies.keymap".nmap diff --git a/roles/neovim/files/lua/opdavies/plugins.lua b/roles/neovim/files/lua/opdavies/plugins.lua index 612e80b..35ff263 100644 --- a/roles/neovim/files/lua/opdavies/plugins.lua +++ b/roles/neovim/files/lua/opdavies/plugins.lua @@ -71,6 +71,7 @@ return packer.startup(function() "nvim-treesitter/nvim-treesitter", run = ":TSUpdate", } + use 'nvim-treesitter/nvim-treesitter-textobjects' -- Completion use {