@@ -27,7 +27,6 @@ Use your favorite package manager to install. The dependency treesitter main bra
2727
2828### vim-plug
2929``` viml
30- Plug 'nvim-treesitter/nvim-treesitter'
3130Plug 'neovim/nvim-lspconfig'
3231Plug 'ray-x/go.nvim'
3332Plug 'ray-x/guihua.lua' ; required if you using treesitter main branch
@@ -38,7 +37,6 @@ Plug 'ray-x/guihua.lua' ; required if you using treesitter main branch
3837use ' ray-x/go.nvim'
3938use ' ray-x/guihua.lua' -- required if using treesitter main branch
4039use ' neovim/nvim-lspconfig'
41- use ' nvim-treesitter/nvim-treesitter'
4240```
4341## Default Configuration
4442
@@ -139,7 +137,6 @@ require('go').setup({
139137 dap_retries = 20 , -- see dap option max_retries
140138 dap_enrich_config = nil , -- see dap option enrich_config
141139 build_tags = " tag1,tag2" , -- set default build tags
142- textobjects = true , -- enable default text objects through treesittter-text-objects
143140 test_runner = ' go' , -- one of {`go`, `dlv`, `ginkgo`, `gotestsum`}
144141 verbose_tests = true , -- set to add verbose flag to tests deprecated, see '-v' option
145142 run_in_floaterm = false , -- set to true to run in a float window. :GoTermClose closes the floatterm
@@ -202,102 +199,66 @@ This will override your global `go.nvim` setup
202199
203200## Text Object
204201
205- I did not provide textobject support in the plugin. Please use treesitter textobject plugin. My treesitter config:
202+ I did not provide textobject support in the plugin. Please use treesitter textobject plugin.
206203
207204``` lua
208- require " nvim-treesitter.configs" .setup {
209- incremental_selection = {
210- enable = enable ,
211- keymaps = {
212- -- mappings for incremental selection (visual mappings)
213- init_selection = " gnn" , -- maps in normal mode to init the node/scope selection
214- node_incremental = " grn" , -- increment to the upper named parent
215- scope_incremental = " grc" , -- increment to the upper scope (as defined in locals.scm)
216- node_decremental = " grm" -- decrement to the previous node
217- }
218- },
205+ --- https://github.com/nvim-treesitter/nvim-treesitter-textobjects
206+ require (" nvim-treesitter-textobjects" ).setup {
207+ move = {
208+ -- whether to set jumps in the jumplist
209+ set_jumps = true ,
210+ },
211+ }
219212
220- textobjects = {
221- -- syntax-aware textobjects
222- enable = enable ,
223- lsp_interop = {
224- enable = enable ,
225- peek_definition_code = {
226- [" DF" ] = " @function.outer" ,
227- [" DF" ] = " @class.outer"
228- }
229- },
230- keymaps = {
231- [" iL" ] = {
232- -- you can define your own textobjects directly here
233- go = " (function_definition) @function" ,
234- },
235- -- or you use the queries from supported languages with textobjects.scm
236- [" af" ] = " @function.outer" ,
237- [" if" ] = " @function.inner" ,
238- [" aC" ] = " @class.outer" ,
239- [" iC" ] = " @class.inner" ,
240- [" ac" ] = " @conditional.outer" ,
241- [" ic" ] = " @conditional.inner" ,
242- [" ae" ] = " @block.outer" ,
243- [" ie" ] = " @block.inner" ,
244- [" al" ] = " @loop.outer" ,
245- [" il" ] = " @loop.inner" ,
246- [" is" ] = " @statement.inner" ,
247- [" as" ] = " @statement.outer" ,
248- [" ad" ] = " @comment.outer" ,
249- [" am" ] = " @call.outer" ,
250- [" im" ] = " @call.inner"
251- },
252- move = {
253- enable = enable ,
254- set_jumps = true , -- whether to set jumps in the jumplist
255- goto_next_start = {
256- [" ]m" ] = " @function.outer" ,
257- [" ]]" ] = " @class.outer"
258- },
259- goto_next_end = {
260- [" ]M" ] = " @function.outer" ,
261- [" ][" ] = " @class.outer"
262- },
263- goto_previous_start = {
264- [" [m" ] = " @function.outer" ,
265- [" [[" ] = " @class.outer"
266- },
267- goto_previous_end = {
268- [" [M" ] = " @function.outer" ,
269- [" []" ] = " @class.outer"
270- }
271- },
272- select = {
273- enable = enable ,
274- keymaps = {
275- -- You can use the capture groups defined in textobjects.scm
276- [" af" ] = " @function.outer" ,
277- [" if" ] = " @function.inner" ,
278- [" ac" ] = " @class.outer" ,
279- [" ic" ] = " @class.inner" ,
280- -- Or you can define your own textobjects like this
281- [" iF" ] = {
282- python = " (function_definition) @function" ,
283- cpp = " (function_definition) @function" ,
284- c = " (function_definition) @function" ,
285- java = " (method_declaration) @function" ,
286- go = " (method_declaration) @function"
287- }
288- }
289- },
290- swap = {
291- enable = enable ,
292- swap_next = {
293- [" <leader>a" ] = " @parameter.inner"
294- },
295- swap_previous = {
296- [" <leader>A" ] = " @parameter.inner"
297- }
298- }
299- }
300- }
213+ -- keymaps
214+ -- You can use the capture groups defined in `textobjects.scm`
215+ vim .keymap .set ({ " n" , " x" , " o" }, " ]m" , function ()
216+ require (" nvim-treesitter-textobjects.move" ).goto_next_start (" @function.outer" , " textobjects" )
217+ end )
218+ vim .keymap .set ({ " n" , " x" , " o" }, " ]]" , function ()
219+ require (" nvim-treesitter-textobjects.move" ).goto_next_start (" @class.outer" , " textobjects" )
220+ end )
221+ -- You can also pass a list to group multiple queries.
222+ vim .keymap .set ({ " n" , " x" , " o" }, " ]o" , function ()
223+ require (" nvim-treesitter-textobjects.move" ).goto_next_start ({" @loop.inner" , " @loop.outer" }, " textobjects" )
224+ end )
225+ -- You can also use captures from other query groups like `locals.scm` or `folds.scm`
226+ vim .keymap .set ({ " n" , " x" , " o" }, " ]s" , function ()
227+ require (" nvim-treesitter-textobjects.move" ).goto_next_start (" @local.scope" , " locals" )
228+ end )
229+ vim .keymap .set ({ " n" , " x" , " o" }, " ]z" , function ()
230+ require (" nvim-treesitter-textobjects.move" ).goto_next_start (" @fold" , " folds" )
231+ end )
232+
233+ vim .keymap .set ({ " n" , " x" , " o" }, " ]M" , function ()
234+ require (" nvim-treesitter-textobjects.move" ).goto_next_end (" @function.outer" , " textobjects" )
235+ end )
236+ vim .keymap .set ({ " n" , " x" , " o" }, " ][" , function ()
237+ require (" nvim-treesitter-textobjects.move" ).goto_next_end (" @class.outer" , " textobjects" )
238+ end )
239+
240+ vim .keymap .set ({ " n" , " x" , " o" }, " [m" , function ()
241+ require (" nvim-treesitter-textobjects.move" ).goto_previous_start (" @function.outer" , " textobjects" )
242+ end )
243+ vim .keymap .set ({ " n" , " x" , " o" }, " [[" , function ()
244+ require (" nvim-treesitter-textobjects.move" ).goto_previous_start (" @class.outer" , " textobjects" )
245+ end )
246+
247+ vim .keymap .set ({ " n" , " x" , " o" }, " [M" , function ()
248+ require (" nvim-treesitter-textobjects.move" ).goto_previous_end (" @function.outer" , " textobjects" )
249+ end )
250+ vim .keymap .set ({ " n" , " x" , " o" }, " []" , function ()
251+ require (" nvim-treesitter-textobjects.move" ).goto_previous_end (" @class.outer" , " textobjects" )
252+ end )
253+
254+ -- Go to either the start or the end, whichever is closer.
255+ -- Use if you want more granular movements
256+ vim .keymap .set ({ " n" , " x" , " o" }, " ]d" , function ()
257+ require (" nvim-treesitter-textobjects.move" ).goto_next (" @conditional.outer" , " textobjects" )
258+ end )
259+ vim .keymap .set ({ " n" , " x" , " o" }, " [d" , function ()
260+ require (" nvim-treesitter-textobjects.move" ).goto_previous (" @conditional.outer" , " textobjects" )
261+ end )
301262```
302263
303264</details >
@@ -460,7 +421,6 @@ enable the gopls. If you want to use your own gopls setup, you can set it to fal
460421 ' ray-x/go.nvim' ,
461422 dependencies = {
462423 ' ray-x/guihua.lua' , -- optional
463- ' nvim-treesitter/nvim-treesitter' ,
464424 ' neovim/nvim-lspconfig' ,
465425 },
466426 opts = {} -- by default lsp_cfg = false
@@ -559,7 +519,6 @@ The following vimrc will enable all features provided by go.nvim
559519set termguicolors
560520call plug#begin('~/.vim/plugged')
561521Plug 'neovim/nvim-lspconfig'
562- Plug 'nvim-treesitter/nvim-treesitter'
563522
564523Plug 'mfussenegger/nvim-dap'
565524Plug 'rcarriga/nvim-dap-ui'
0 commit comments