vim: small refactor to simplify LSP
This commit is contained in:
parent
af48377e84
commit
e7ccffd50c
1 changed files with 16 additions and 18 deletions
|
@ -12,19 +12,13 @@ M.event = {
|
||||||
}
|
}
|
||||||
|
|
||||||
M.config = function()
|
M.config = function()
|
||||||
local extend = function(tbl, ...)
|
|
||||||
for _, other in ipairs({...}) do
|
|
||||||
tbl = vim.tbl_deep_extend('force', tbl, other or {})
|
|
||||||
end
|
|
||||||
return tbl
|
|
||||||
end
|
|
||||||
|
|
||||||
local border = { border = 'rounded' }
|
local border = { border = 'rounded' }
|
||||||
|
|
||||||
local opts = {
|
local default_opts = {
|
||||||
capabilities = extend(
|
capabilities = vim.tbl_deep_extend(
|
||||||
|
'force',
|
||||||
vim.lsp.protocol.make_client_capabilities(),
|
vim.lsp.protocol.make_client_capabilities(),
|
||||||
vim.F.npcall(function() require('cmp_nvim_lsp').default_capabilities() end)
|
vim.F.npcall(function() require('cmp_nvim_lsp').default_capabilities() end) or {}
|
||||||
),
|
),
|
||||||
|
|
||||||
handlers = {
|
handlers = {
|
||||||
|
@ -59,11 +53,12 @@ M.config = function()
|
||||||
require('mason').setup { ui = border }
|
require('mason').setup { ui = border }
|
||||||
require('mason-lspconfig').setup {
|
require('mason-lspconfig').setup {
|
||||||
handlers = {
|
handlers = {
|
||||||
--[[ default = ]] function(server)
|
--[[default =]] function(server)
|
||||||
require('lspconfig')[server].setup(opts)
|
require('lspconfig')[server].setup(default_opts)
|
||||||
end,
|
end,
|
||||||
lua_ls = function()
|
|
||||||
require('lspconfig').lua_ls.setup(extend(opts, {
|
lua_ls = function(--[[server]]_)
|
||||||
|
local opts = vim.tbl_deep_extend('force', default_opts, {
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
-- I'm using lua only inside neovim, so the runtime is LuaJIT.
|
-- I'm using lua only inside neovim, so the runtime is LuaJIT.
|
||||||
|
@ -79,10 +74,12 @@ M.config = function()
|
||||||
telemetry = { enable = false },
|
telemetry = { enable = false },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}))
|
})
|
||||||
|
require('lspconfig').lua_ls.setup(opts)
|
||||||
end,
|
end,
|
||||||
omnisharp = function()
|
|
||||||
require('lspconfig').omnisharp.setup(extend(opts, {
|
omnisharp = function(--[[server]]_)
|
||||||
|
local opts = vim.tbl_deep_extend('force', default_opts, {
|
||||||
-- Use .editoconfig for code style, naming convention and analyzer settings.
|
-- Use .editoconfig for code style, naming convention and analyzer settings.
|
||||||
enable_editorconfig_support = true,
|
enable_editorconfig_support = true,
|
||||||
|
|
||||||
|
@ -98,7 +95,8 @@ M.config = function()
|
||||||
handlers = {
|
handlers = {
|
||||||
['textDocument/definition'] = require('omnisharp_extended').handler,
|
['textDocument/definition'] = require('omnisharp_extended').handler,
|
||||||
},
|
},
|
||||||
}))
|
})
|
||||||
|
require('lspconfig').omnisharp.setup(opts)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue