Merge pull request #448 from AshrafMichail23/main

Defer Treesitter setup to improve startup time of nvim {filename}
This commit is contained in:
Chris Patti 2023-10-01 22:05:20 -04:00 committed by GitHub
commit f15af9b8be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 58 additions and 55 deletions

113
init.lua
View File

@ -321,69 +321,72 @@ vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc =
-- [[ Configure Treesitter ]] -- [[ Configure Treesitter ]]
-- See `:help nvim-treesitter` -- See `:help nvim-treesitter`
require('nvim-treesitter.configs').setup { -- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}'
-- Add languages to be installed here that you want installed for treesitter vim.defer_fn(function()
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim' }, require('nvim-treesitter.configs').setup {
-- Add languages to be installed here that you want installed for treesitter
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim' },
auto_install = false,
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
highlight = { enable = true }, auto_install = false,
indent = { enable = true },
incremental_selection = { highlight = { enable = true },
enable = true, indent = { enable = true },
keymaps = { incremental_selection = {
init_selection = '<c-space>',
node_incremental = '<c-space>',
scope_incremental = '<c-s>',
node_decremental = '<M-space>',
},
},
textobjects = {
select = {
enable = true, enable = true,
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
keymaps = { keymaps = {
-- You can use the capture groups defined in textobjects.scm init_selection = '<c-space>',
['aa'] = '@parameter.outer', node_incremental = '<c-space>',
['ia'] = '@parameter.inner', scope_incremental = '<c-s>',
['af'] = '@function.outer', node_decremental = '<M-space>',
['if'] = '@function.inner',
['ac'] = '@class.outer',
['ic'] = '@class.inner',
}, },
}, },
move = { textobjects = {
enable = true, select = {
set_jumps = true, -- whether to set jumps in the jumplist enable = true,
goto_next_start = { lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
[']m'] = '@function.outer', keymaps = {
[']]'] = '@class.outer', -- You can use the capture groups defined in textobjects.scm
['aa'] = '@parameter.outer',
['ia'] = '@parameter.inner',
['af'] = '@function.outer',
['if'] = '@function.inner',
['ac'] = '@class.outer',
['ic'] = '@class.inner',
},
}, },
goto_next_end = { move = {
[']M'] = '@function.outer', enable = true,
[']['] = '@class.outer', set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
[']m'] = '@function.outer',
[']]'] = '@class.outer',
},
goto_next_end = {
[']M'] = '@function.outer',
[']['] = '@class.outer',
},
goto_previous_start = {
['[m'] = '@function.outer',
['[['] = '@class.outer',
},
goto_previous_end = {
['[M'] = '@function.outer',
['[]'] = '@class.outer',
},
}, },
goto_previous_start = { swap = {
['[m'] = '@function.outer', enable = true,
['[['] = '@class.outer', swap_next = {
}, ['<leader>a'] = '@parameter.inner',
goto_previous_end = { },
['[M'] = '@function.outer', swap_previous = {
['[]'] = '@class.outer', ['<leader>A'] = '@parameter.inner',
},
}, },
}, },
swap = { }
enable = true, end, 0)
swap_next = {
['<leader>a'] = '@parameter.inner',
},
swap_previous = {
['<leader>A'] = '@parameter.inner',
},
},
},
}
-- Diagnostic keymaps -- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })