aboutsummaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorChris Patti <feoh@feoh.org>2023-10-01 22:05:20 -0400
committerGitHub <noreply@github.com>2023-10-01 22:05:20 -0400
commitf15af9b8be96f7231c184e0e8636f5732ebda9e9 (patch)
tree517df1b794ea82c19c3cb81e13dcaf1cbbff15a8 /init.lua
parent313bd75ca04cb2cef48a79ac3ad697a1b9a2daab (diff)
parent4d5f24d6c1ecd1c77aded7fc4e59a329d27509b8 (diff)
Merge pull request #448 from AshrafMichail23/main
Defer Treesitter setup to improve startup time of nvim {filename}
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua113
1 files changed, 58 insertions, 55 deletions
diff --git a/init.lua b/init.lua
index 5257113..e5bc576 100644
--- a/init.lua
+++ b/init.lua
@@ -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' })