Skip to content

Commit 58a8724

Browse files
feohsfrick
authored andcommitted
Merge pull request nvim-lua#448 from AshrafMichail23/main
Defer Treesitter setup to improve startup time of nvim {filename}
2 parents fa01ea0 + deccbc8 commit 58a8724

File tree

1 file changed

+47
-36
lines changed

1 file changed

+47
-36
lines changed

init.lua

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ require('nvim-treesitter.configs').setup {
336336
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'java', 'json', 'yaml', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim' },
337337

338338
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
339-
auto_install = true,
339+
auto_install = false,
340340

341341
highlight = { enable = true },
342342
indent = { enable = true },
@@ -352,48 +352,59 @@ require('nvim-treesitter.configs').setup {
352352
textobjects = {
353353
select = {
354354
enable = true,
355-
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
356355
keymaps = {
357-
-- You can use the capture groups defined in textobjects.scm
358-
['aa'] = '@parameter.outer',
359-
['ia'] = '@parameter.inner',
360-
['af'] = '@function.outer',
361-
['if'] = '@function.inner',
362-
['ac'] = '@class.outer',
363-
['ic'] = '@class.inner',
356+
init_selection = '<c-space>',
357+
node_incremental = '<c-space>',
358+
scope_incremental = '<c-s>',
359+
node_decremental = '<M-space>',
364360
},
365361
},
366-
move = {
367-
enable = true,
368-
set_jumps = true, -- whether to set jumps in the jumplist
369-
goto_next_start = {
370-
[']m'] = '@function.outer',
371-
[']]'] = '@class.outer',
372-
},
373-
goto_next_end = {
374-
[']M'] = '@function.outer',
375-
[']['] = '@class.outer',
362+
textobjects = {
363+
select = {
364+
enable = true,
365+
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
366+
keymaps = {
367+
-- You can use the capture groups defined in textobjects.scm
368+
['aa'] = '@parameter.outer',
369+
['ia'] = '@parameter.inner',
370+
['af'] = '@function.outer',
371+
['if'] = '@function.inner',
372+
['ac'] = '@class.outer',
373+
['ic'] = '@class.inner',
374+
},
376375
},
377-
goto_previous_start = {
378-
['[m'] = '@function.outer',
379-
['[['] = '@class.outer',
376+
move = {
377+
enable = true,
378+
set_jumps = true, -- whether to set jumps in the jumplist
379+
goto_next_start = {
380+
[']m'] = '@function.outer',
381+
[']]'] = '@class.outer',
382+
},
383+
goto_next_end = {
384+
[']M'] = '@function.outer',
385+
[']['] = '@class.outer',
386+
},
387+
goto_previous_start = {
388+
['[m'] = '@function.outer',
389+
['[['] = '@class.outer',
390+
},
391+
goto_previous_end = {
392+
['[M'] = '@function.outer',
393+
['[]'] = '@class.outer',
394+
},
380395
},
381-
goto_previous_end = {
382-
['[M'] = '@function.outer',
383-
['[]'] = '@class.outer',
396+
swap = {
397+
enable = true,
398+
swap_next = {
399+
['<leader>a'] = '@parameter.inner',
400+
},
401+
swap_previous = {
402+
['<leader>A'] = '@parameter.inner',
403+
},
384404
},
385405
},
386-
swap = {
387-
enable = true,
388-
swap_next = {
389-
['<leader>a'] = '@parameter.inner',
390-
},
391-
swap_previous = {
392-
['<leader>A'] = '@parameter.inner',
393-
},
394-
},
395-
},
396-
}
406+
}
407+
end, 0)
397408

398409
-- Diagnostic keymaps
399410
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })

0 commit comments

Comments
 (0)