From 32f090182a72aa7b6e2009b612f1f2b1aabbd8b5 Mon Sep 17 00:00:00 2001 From: Vzaa Date: Wed, 24 Aug 2022 11:17:50 +0300 Subject: [PATCH 1/4] Don't pass args to vim.lsp.buf.format/formatting Args passed by nvim_buf_create_user_command to the callback creates errors with rust-analyzer on nvim 0.7.x and vim.lsp.buf.formatting. --- init.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 20f35d73..47a0abc2 100644 --- a/init.lua +++ b/init.lua @@ -289,7 +289,13 @@ local on_attach = function(_, bufnr) end, '[W]orkspace [L]ist Folders') -- Create a command `:Format` local to the LSP buffer - vim.api.nvim_buf_create_user_command(bufnr, 'Format', vim.lsp.buf.format or vim.lsp.buf.formatting, { desc = 'Format current buffer with LSP' }) + vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) + if vim.lsp.buf.format then + vim.lsp.buf.format() + elseif vim.lsp.buf.formatting then + vim.lsp.buf.formatting() + end + end, { desc = 'Format current buffer with LSP' }) end -- nvim-cmp supports additional completion capabilities From 5a1a819d34364e9c6458c53191eeb8c3567437b7 Mon Sep 17 00:00:00 2001 From: Vzaa Date: Wed, 24 Aug 2022 11:48:08 +0300 Subject: [PATCH 2/4] Move Telescope from master to 0.1.x branch Follow Telescope's README suggestion and use 0.1.x branch instead of master --- init.lua | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/init.lua b/init.lua index 47a0abc2..2cbb4749 100644 --- a/init.lua +++ b/init.lua @@ -9,22 +9,24 @@ end -- stylua: ignore start require('packer').startup(function(use) - use 'wbthomason/packer.nvim' -- Package manager - use 'tpope/vim-fugitive' -- Git commands in nvim - use 'tpope/vim-rhubarb' -- Fugitive-companion to interact with github - use { 'lewis6991/gitsigns.nvim', requires = { 'nvim-lua/plenary.nvim' } } -- Add git related info in the signs columns and popups - use 'numToStr/Comment.nvim' -- "gc" to comment visual regions/lines - use 'nvim-treesitter/nvim-treesitter' -- Highlight, edit, and navigate code - use 'nvim-treesitter/nvim-treesitter-textobjects' -- Additional textobjects for treesitter - use 'neovim/nvim-lspconfig' -- Collection of configurations for built-in LSP client - use 'williamboman/nvim-lsp-installer' -- Automatically install language servers to stdpath - use { 'hrsh7th/nvim-cmp', requires = { 'hrsh7th/cmp-nvim-lsp' } } -- Autocompletion - use { 'L3MON4D3/LuaSnip', requires = { 'saadparwaiz1/cmp_luasnip' } } -- Snippet Engine and Snippet Expansion - use 'mjlbach/onedark.nvim' -- Theme inspired by Atom - use 'nvim-lualine/lualine.nvim' -- Fancier statusline - use 'lukas-reineke/indent-blankline.nvim' -- Add indentation guides even on blank lines - use 'tpope/vim-sleuth' -- Detect tabstop and shiftwidth automatically - use { 'nvim-telescope/telescope.nvim', requires = { 'nvim-lua/plenary.nvim' } } -- Fuzzy Finder (files, lsp, etc) + use 'wbthomason/packer.nvim' -- Package manager + use 'tpope/vim-fugitive' -- Git commands in nvim + use 'tpope/vim-rhubarb' -- Fugitive-companion to interact with github + use { 'lewis6991/gitsigns.nvim', requires = { 'nvim-lua/plenary.nvim' } } -- Add git related info in the signs columns and popups + use 'numToStr/Comment.nvim' -- "gc" to comment visual regions/lines + use 'nvim-treesitter/nvim-treesitter' -- Highlight, edit, and navigate code + use 'nvim-treesitter/nvim-treesitter-textobjects' -- Additional textobjects for treesitter + use 'neovim/nvim-lspconfig' -- Collection of configurations for built-in LSP client + use 'williamboman/nvim-lsp-installer' -- Automatically install language servers to stdpath + use { 'hrsh7th/nvim-cmp', requires = { 'hrsh7th/cmp-nvim-lsp' } } -- Autocompletion + use { 'L3MON4D3/LuaSnip', requires = { 'saadparwaiz1/cmp_luasnip' } } -- Snippet Engine and Snippet Expansion + use 'mjlbach/onedark.nvim' -- Theme inspired by Atom + use 'nvim-lualine/lualine.nvim' -- Fancier statusline + use 'lukas-reineke/indent-blankline.nvim' -- Add indentation guides even on blank lines + use 'tpope/vim-sleuth' -- Detect tabstop and shiftwidth automatically + + -- Fuzzy Finder (files, lsp, etc) + use { 'nvim-telescope/telescope.nvim', branch = '0.1.x', requires = { 'nvim-lua/plenary.nvim' } } -- Fuzzy Finder Algorithm which requires local dependencies to be built. Only load if `make` is available use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', cond = vim.fn.executable "make" == 1 } From 510ca59a6c2307283ecf27699cc3a3cdadf50260 Mon Sep 17 00:00:00 2001 From: Ash Date: Thu, 1 Sep 2022 17:38:11 +0100 Subject: [PATCH 3/4] Added cpp to treesitter and ordered TS imports --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 2cbb4749..85aafad8 100644 --- a/init.lua +++ b/init.lua @@ -187,7 +187,7 @@ vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { de -- See `:help nvim-treesitter` require('nvim-treesitter.configs').setup { -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'lua', 'typescript', 'rust', 'go', 'python' }, + ensure_installed = {'c', 'cpp', 'go', 'lua', 'python', 'rust', 'typescript'}, highlight = { enable = true }, indent = { enable = true }, From 34ed3f0d0c69fe21b8c618f2663353aaf2e42f1d Mon Sep 17 00:00:00 2001 From: Sebastian Olsen Date: Sun, 7 Aug 2022 12:56:33 +0200 Subject: [PATCH 4/4] Replace nvim-lsp-installer with mason.nvim --- init.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 85aafad8..0cf3b453 100644 --- a/init.lua +++ b/init.lua @@ -17,7 +17,8 @@ require('packer').startup(function(use) use 'nvim-treesitter/nvim-treesitter' -- Highlight, edit, and navigate code use 'nvim-treesitter/nvim-treesitter-textobjects' -- Additional textobjects for treesitter use 'neovim/nvim-lspconfig' -- Collection of configurations for built-in LSP client - use 'williamboman/nvim-lsp-installer' -- Automatically install language servers to stdpath + use 'williamboman/mason.nvim' -- Manage external editor tooling i.e LSP servers + use 'williamboman/mason-lspconfig.nvim' -- Automatically install language servers to stdpath use { 'hrsh7th/nvim-cmp', requires = { 'hrsh7th/cmp-nvim-lsp' } } -- Autocompletion use { 'L3MON4D3/LuaSnip', requires = { 'saadparwaiz1/cmp_luasnip' } } -- Snippet Engine and Snippet Expansion use 'mjlbach/onedark.nvim' -- Theme inspired by Atom @@ -303,11 +304,14 @@ end -- nvim-cmp supports additional completion capabilities local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) +-- Setup mason so it can manage external tooling +require('mason').setup() + -- Enable the following language servers local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua' } -- Ensure the servers above are installed -require('nvim-lsp-installer').setup { +require('mason-lspconfig').setup { ensure_installed = servers, }