move server config to easy to extend style
This commit is contained in:
parent
aa660e64ce
commit
07c684b283
70
init.lua
70
init.lua
@ -332,63 +332,57 @@ local on_attach = function(_, bufnr)
|
|||||||
end, { desc = 'Format current buffer with LSP' })
|
end, { desc = 'Format current buffer with LSP' })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local runtime_path = vim.split(package.path, ';')
|
||||||
|
table.insert(runtime_path, 'lua/?.lua')
|
||||||
|
table.insert(runtime_path, 'lua/?/init.lua')
|
||||||
|
|
||||||
|
-- Enable the following language servers
|
||||||
|
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
||||||
|
-- Add any additional override configuration in the following tables. They will be passed to
|
||||||
|
-- the `settings` field of the server config
|
||||||
|
local servers = {
|
||||||
|
clangd = {},
|
||||||
|
gopls = {},
|
||||||
|
pyright = {},
|
||||||
|
rust_analyzer = {},
|
||||||
|
tsserver = {},
|
||||||
|
|
||||||
|
sumneko_lua = {
|
||||||
|
Lua = {
|
||||||
|
runtime = { version = 'LuaJIT', path = runtime_path },
|
||||||
|
diagnostics = { globals = { 'vim' } },
|
||||||
|
workspace = {
|
||||||
|
library = vim.api.nvim_get_runtime_file('', true),
|
||||||
|
checkThirdParty = false,
|
||||||
|
},
|
||||||
|
telemetry = { enable = false },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
-- Setup mason so it can manage external tooling
|
-- Setup mason so it can manage external tooling
|
||||||
require('mason').setup()
|
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
|
-- Ensure the servers above are installed
|
||||||
require('mason-lspconfig').setup {
|
require('mason-lspconfig').setup {
|
||||||
ensure_installed = servers,
|
ensure_installed = vim.tbl_keys(servers),
|
||||||
}
|
}
|
||||||
|
|
||||||
-- nvim-cmp supports additional completion capabilities
|
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
||||||
|
|
||||||
for _, lsp in ipairs(servers) do
|
for lsp, settings in ipairs(servers) do
|
||||||
require('lspconfig')[lsp].setup {
|
require('lspconfig')[lsp].setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
|
settings = settings,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Turn on lsp status information
|
-- Turn on lsp status information
|
||||||
require('fidget').setup()
|
require('fidget').setup()
|
||||||
|
|
||||||
-- Example custom configuration for lua
|
|
||||||
--
|
|
||||||
-- Make runtime files discoverable to the server
|
|
||||||
local runtime_path = vim.split(package.path, ';')
|
|
||||||
table.insert(runtime_path, 'lua/?.lua')
|
|
||||||
table.insert(runtime_path, 'lua/?/init.lua')
|
|
||||||
|
|
||||||
require('lspconfig').sumneko_lua.setup {
|
|
||||||
on_attach = on_attach,
|
|
||||||
capabilities = capabilities,
|
|
||||||
settings = {
|
|
||||||
Lua = {
|
|
||||||
runtime = {
|
|
||||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT)
|
|
||||||
version = 'LuaJIT',
|
|
||||||
-- Setup your lua path
|
|
||||||
path = runtime_path,
|
|
||||||
},
|
|
||||||
diagnostics = {
|
|
||||||
globals = { 'vim' },
|
|
||||||
},
|
|
||||||
workspace = {
|
|
||||||
library = vim.api.nvim_get_runtime_file('', true),
|
|
||||||
checkThirdParty = false,
|
|
||||||
},
|
|
||||||
-- Do not send telemetry data containing a randomized but unique identifier
|
|
||||||
telemetry = { enable = false },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
-- nvim-cmp setup
|
-- nvim-cmp setup
|
||||||
local cmp = require 'cmp'
|
local cmp = require 'cmp'
|
||||||
local luasnip = require 'luasnip'
|
local luasnip = require 'luasnip'
|
||||||
|
Loading…
Reference in New Issue
Block a user