diff options
author | Ashraf Michail <user@noemail.com> | 2023-09-30 00:35:22 +0000 |
---|---|---|
committer | Ashraf Michail <user@noemail.com> | 2023-09-30 00:35:22 +0000 |
commit | 4d5f24d6c1ecd1c77aded7fc4e59a329d27509b8 (patch) | |
tree | ae667c209c553397130b0b6094e5d5d0c815f997 /init.lua | |
parent | daf2dc38fc703f1226a18809187c6329292cf66c (diff) |
Defer Treesitter setup to improve startup time of nvim {filename}
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 113 |
1 files changed, 58 insertions, 55 deletions
@@ -321,69 +321,72 @@ vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = -- [[ Configure Treesitter ]] -- See `:help nvim-treesitter` -require('nvim-treesitter.configs').setup { - -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim' }, - - -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) - auto_install = false, - - highlight = { enable = true }, - indent = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '<c-space>', - node_incremental = '<c-space>', - scope_incremental = '<c-s>', - node_decremental = '<M-space>', - }, - }, - textobjects = { - select = { +-- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}' +vim.defer_fn(function() + require('nvim-treesitter.configs').setup { + -- Add languages to be installed here that you want installed for treesitter + ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim' }, + + -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) + auto_install = false, + + highlight = { enable = true }, + indent = { enable = true }, + incremental_selection = { enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim keymaps = { - -- 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', + init_selection = '<c-space>', + node_incremental = '<c-space>', + scope_incremental = '<c-s>', + node_decremental = '<M-space>', }, }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - [']m'] = '@function.outer', - [']]'] = '@class.outer', + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- 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 = { - [']M'] = '@function.outer', - [']['] = '@class.outer', + move = { + enable = true, + 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 = { - ['[m'] = '@function.outer', - ['[['] = '@class.outer', - }, - goto_previous_end = { - ['[M'] = '@function.outer', - ['[]'] = '@class.outer', + swap = { + enable = true, + swap_next = { + ['<leader>a'] = '@parameter.inner', + }, + swap_previous = { + ['<leader>A'] = '@parameter.inner', + }, }, }, - swap = { - enable = true, - swap_next = { - ['<leader>a'] = '@parameter.inner', - }, - swap_previous = { - ['<leader>A'] = '@parameter.inner', - }, - }, - }, -} + } +end, 0) -- Diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) |