feat: add treesitter-textobjects and treesitter-textsubjects
This commit is contained in:
parent
3db99aeeb1
commit
6da6c47747
25
lua/config/treesitter-textobjects.lua
Normal file
25
lua/config/treesitter-textobjects.lua
Normal file
@ -0,0 +1,25 @@
|
||||
-- suggested config for selecting text
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
-- Automatically jump forward to textobj, similar to targets.vim
|
||||
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",
|
||||
-- Or you can define your own textobjects like this
|
||||
-- ["iF"] = {
|
||||
-- python = "(function_definition) @function",
|
||||
-- cpp = "(function_definition) @function",
|
||||
-- c = "(function_definition) @function",
|
||||
-- java = "(method_declaration) @function",
|
||||
-- },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
9
lua/config/treesitter-textsubjects.lua
Normal file
9
lua/config/treesitter-textsubjects.lua
Normal file
@ -0,0 +1,9 @@
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
textsubjects = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
['\''] = 'textsubjects-smart',
|
||||
[';'] = 'textsubjects-container-outer',
|
||||
}
|
||||
},
|
||||
}
|
@ -3,8 +3,6 @@
|
||||
|
||||
---@diagnostic disable-next-line: unused-local
|
||||
local function usePlugins(use, use_rocks)
|
||||
use {"ray-x/lsp_signature.nvim", config = [[require 'config.lspsignature']]}
|
||||
|
||||
-- Packer can manage itself
|
||||
use 'wbthomason/packer.nvim'
|
||||
|
||||
@ -25,12 +23,29 @@ local function usePlugins(use, use_rocks)
|
||||
-- Allow repeating
|
||||
use 'tpope/vim-repeat'
|
||||
|
||||
-- Tree-sitter
|
||||
-- Treesitter
|
||||
use {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
config = [[require 'config.treesitter']],
|
||||
branch = '0.5-compat',
|
||||
run = ':TSUpdate'
|
||||
}
|
||||
use {
|
||||
'nvim-treesitter/playground',
|
||||
requires = 'nvim-treesitter/nvim-treesitter',
|
||||
cmd = "TSPlaygroundToggle"
|
||||
}
|
||||
use {
|
||||
'RRethy/nvim-treesitter-textsubjects',
|
||||
requires = 'nvim-treesitter/nvim-treesitter',
|
||||
config = [[require 'config.treesitter-textsubjects']],
|
||||
}
|
||||
use {
|
||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||
requires = 'nvim-treesitter/nvim-treesitter',
|
||||
config = [[require 'config.treesitter-textobjects']],
|
||||
branch = '0.5-compat'
|
||||
}
|
||||
|
||||
-- Dev icons
|
||||
use {'kyazdani42/nvim-web-devicons', config = [[require('nvim-web-devicons').setup()]]}
|
||||
@ -95,6 +110,7 @@ local function usePlugins(use, use_rocks)
|
||||
}
|
||||
|
||||
-- LSP utils
|
||||
use {"ray-x/lsp_signature.nvim", config = [[require 'config.lspsignature']]}
|
||||
use {
|
||||
'RishabhRD/nvim-lsputils',
|
||||
config = [[require 'config.lsputils']],
|
||||
@ -170,6 +186,10 @@ local function usePlugins(use, use_rocks)
|
||||
|
||||
-- Load project specific settings from exrc
|
||||
use { 'jenterkin/vim-autosource', config = [[require 'config.autosource']] }
|
||||
|
||||
-- Training plugins
|
||||
-- use 'tjdevries/train.nvim'
|
||||
-- use 'ThePrimeagen/vim-be-good'
|
||||
end
|
||||
|
||||
-- Register custom commands for plugin manager
|
||||
@ -180,14 +200,6 @@ vim.cmd [[command! PackerSync packadd packer.nvim | lua require('plugins').sync(
|
||||
vim.cmd [[command! PackerClean packadd packer.nvim | lua require('plugins').clean()]]
|
||||
vim.cmd [[command! PackerCompile source lua/plugins.lua | packadd packer.nvim | lua require('plugins').compile()]]
|
||||
|
||||
-- Run "PackerCompile" whenever this file is updated
|
||||
vim.cmd [[
|
||||
augroup packer_user_config
|
||||
autocmd!
|
||||
autocmd BufWritePost plugins.lua source <afile> | PackerCompile
|
||||
augroup end
|
||||
]]
|
||||
|
||||
-- Bootstrap packer.nvim. If packer.nvim is not installed, install it.
|
||||
local function bootstrap()
|
||||
local fn = vim.fn
|
||||
|
Loading…
Reference in New Issue
Block a user