From c8917beb8ed65c6988dcb5b8a9157edde77819bd Mon Sep 17 00:00:00 2001 From: Maciej Lebiest Date: Tue, 14 Feb 2023 21:25:10 +0100 Subject: [PATCH] mason-lspconfig is kinda broken on first run --- lua/lazy-load.lua | 20 ++++++++++++-------- lua/plugins/mason-lspconfig.lua | 10 +++++++++- lua/plugins/treesitter.lua | 6 +++--- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/lua/lazy-load.lua b/lua/lazy-load.lua index 8fa6299..f82bf9e 100644 --- a/lua/lazy-load.lua +++ b/lua/lazy-load.lua @@ -6,25 +6,29 @@ require("lazy").setup({ keys = require('plugins.nvim-tree').keys }, { 'nvim-treesitter/nvim-treesitter', - config = require('plugins.treesitter').config, - build = ':TSUpdate', - priority = 200}, + -- treesitter need to be configured after load, + -- so let here be init, not config + init = require('plugins.treesitter'), + build = ':TSUpdate' }, -- neovim lsp plugins and depencencies { 'neovim/nvim-lspconfig', init = require('plugins.nvim-lspconfig').init, - priority = 100}, + priority = 60 }, { 'hrsh7th/cmp-nvim-lsp' }, { 'hrsh7th/cmp-buffer' }, { 'hrsh7th/cmp-cmdline' }, { 'hrsh7th/cmp-path' }, { 'hrsh7th/nvim-cmp', init = require('plugins.nvim-cmp').init, - dependencies = { { 'onsails/lspkind.nvim' } } }, + dependencies = { 'onsails/lspkind.nvim' } }, { 'williamboman/mason.nvim', - config = {} }, + config = {}, + priority = 30 }, + -- mason-lspconfig might need disabling on first run { 'williamboman/mason-lspconfig.nvim', config = require('plugins.mason-lspconfig').config, - dependencies = { 'williamboman/mason.nvim' } }, + dependencies = { 'williamboman/mason.nvim' }, + priority = 55 }, { 'mfussenegger/nvim-lint', init = require('plugins.nvim-lint').init }, {}, @@ -77,7 +81,7 @@ require("lazy").setup({ { 'olimorris/onedarkpro.nvim' }, { 'ellisonleao/gruvbox.nvim' }, { 'Mofiqul/dracula.nvim', - priority = 300}, + priority = 300 }, { 'vigoux/oak' }, { 'NLKNguyen/papercolor-theme' }, { 'bluz71/vim-moonfly-colors' }, diff --git a/lua/plugins/mason-lspconfig.lua b/lua/plugins/mason-lspconfig.lua index 0e90bdf..c7244e5 100644 --- a/lua/plugins/mason-lspconfig.lua +++ b/lua/plugins/mason-lspconfig.lua @@ -20,6 +20,14 @@ return { "yamlls", "lemminx", "marksman" - } + }, + -- Whether servers that are set up (via lspconfig) should be automatically installed if they're not already installed. + -- This setting has no relation with the `ensure_installed` setting. + -- Can either be: + -- - false: Servers are not automatically installed. + -- - true: All servers set up via lspconfig are automatically installed. + -- - { exclude: string[] }: All servers set up via lspconfig, except the ones provided in the list, are automatically installed. + -- Example: automatic_installation = { exclude = { "rust_analyzer", "solargraph" } } + automatic_installation = false, } } diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 5496287..8ea4ac1 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,5 +1,5 @@ -return { - config = { +return function() + require 'nvim-treesitter.configs'.setup { -- A list of parser names, or "all" ensure_installed = { "html", "dockerfile", "cpp", "css", "markdown", "c", "gitcommit", "bash", "phpdoc", "comment", "python", "http", "php", "regex", "json5", "lua", "gitattributes", "gitignore", "json", "git_rebase", "javascript", "perl", "sql", "yaml" }, @@ -41,4 +41,4 @@ return { additional_vim_regex_highlighting = false, -- default=false }, } -} +end