Skip to content

Commit a83bc43

Browse files
feohsfrick
authored andcommitted
Merge pull request nvim-lua#455 from Anthony-Fiddes/fix-mason-setup
Fix Mason setup bug and run stylua
2 parents 58a8724 + 6df772f commit a83bc43

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

init.lua

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ require('lazy').setup({
8181
'neovim/nvim-lspconfig',
8282
dependencies = {
8383
-- Automatically install LSPs to stdpath for neovim
84-
{ 'williamboman/mason.nvim', config = true },
84+
'williamboman/mason.nvim',
8585
'williamboman/mason-lspconfig.nvim',
8686

8787
-- Useful status updates for LSP
@@ -178,7 +178,7 @@ require('lazy').setup({
178178
'lukas-reineke/indent-blankline.nvim',
179179
-- Enable `lukas-reineke/indent-blankline.nvim`
180180
-- See `:help indent_blankline.txt`
181-
main = "ibl",
181+
main = 'ibl',
182182
opts = {},
183183
},
184184

@@ -331,26 +331,18 @@ vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc =
331331

332332
-- [[ Configure Treesitter ]]
333333
-- See `:help nvim-treesitter`
334-
require('nvim-treesitter.configs').setup {
335-
-- Add languages to be installed here that you want installed for treesitter
336-
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'java', 'json', 'yaml', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim' },
337-
338-
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
339-
auto_install = false,
340-
341-
highlight = { enable = true },
342-
indent = { enable = true },
343-
incremental_selection = {
344-
enable = true,
345-
keymaps = {
346-
init_selection = '<c-space>',
347-
node_incremental = '<c-space>',
348-
scope_incremental = '<c-s>',
349-
node_decremental = '<M-space>',
350-
},
351-
},
352-
textobjects = {
353-
select = {
334+
-- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}'
335+
vim.defer_fn(function()
336+
require('nvim-treesitter.configs').setup {
337+
-- Add languages to be installed here that you want installed for treesitter
338+
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim' },
339+
340+
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
341+
auto_install = false,
342+
343+
highlight = { enable = true },
344+
indent = { enable = true },
345+
incremental_selection = {
354346
enable = true,
355347
keymaps = {
356348
init_selection = '<c-space>',
@@ -459,15 +451,20 @@ local on_attach = function(_, bufnr)
459451
end
460452

461453
-- document existing key chains
462-
require('which-key').register({
454+
require('which-key').register {
463455
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
464456
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
465457
['<leader>g'] = { name = '[G]it', _ = 'which_key_ignore' },
466458
['<leader>h'] = { name = 'More git', _ = 'which_key_ignore' },
467459
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
468460
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
469461
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
470-
})
462+
}
463+
464+
-- mason-lspconfig requires that these setup functions are called in this order
465+
-- before setting up the servers.
466+
require('mason').setup()
467+
require('mason-lspconfig').setup()
471468

472469
-- Enable the following language servers
473470
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.

0 commit comments

Comments
 (0)