feat: More user friendly language server installation

This commit is contained in:
nedia 2022-12-20 19:33:01 +13:00
parent 6dccf03fd2
commit b4173c7a4e
1 changed files with 50 additions and 47 deletions

View File

@ -3,7 +3,7 @@ local install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nv
local is_bootstrap = false
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
is_bootstrap = true
vim.fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
vim.fn.system { 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path }
vim.cmd [[packadd packer.nvim]]
end
@ -335,29 +335,27 @@ end
-- Setup mason so it can manage external tooling
require('mason').setup()
-- Enable the following language servers
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed
local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'gopls' }
-- Ensure the servers above are installed
require('mason-lspconfig').setup {
ensure_installed = servers,
}
-- nvim-cmp supports additional completion capabilities
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
for _, lsp in ipairs(servers) do
require('lspconfig')[lsp].setup {
on_attach = on_attach,
capabilities = capabilities,
-- Configure language servers
-- Automatically install language servers
-- Set up a default handler for language servers, and a custom one as an example
local mason_lspconfig = require 'mason-lspconfig'
mason_lspconfig.setup {
automatic_installation = true,
}
end
-- Turn on lsp status information
require('fidget').setup()
mason_lspconfig.setup_handlers {
-- Default handler
function(server_name)
require('lspconfig')[server_name].setup {
capabilities = capabilities,
on_attach = on_attach,
}
end,
['sumneko_lua'] = function()
-- Example custom configuration for lua
--
-- Make runtime files discoverable to the server
@ -388,6 +386,11 @@ require('lspconfig').sumneko_lua.setup {
},
},
}
end,
}
-- Turn on lsp status information
require('fidget').setup()
-- nvim-cmp setup
local cmp = require 'cmp'