Update lsp setup

This commit is contained in:
Zoe Roux
2022-07-16 19:01:55 +02:00
parent 850f93d6a1
commit a62ec798f5
2 changed files with 80 additions and 67 deletions

View File

@@ -21,3 +21,5 @@ alias "o"="l"
alias "k"="l"
alias ls="exa --group"
alias lg="exa --git-ignore"
alias llg="exa -l --git-ignore"

View File

@@ -1,65 +1,25 @@
local ok, lspconfig = pcall(require, "lspconfig")
local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer")
if not status_ok then
if not status_ok or not ok then
return
end
local server_settings = {
omnisharp = {
handlers = {
["textDocument/definition"] = require('omnisharp_extended').handler,
},
cmd_env = {
["OMNISHARP_FormattingOptions:EnableEditorConfigSupport"] = true,
["OMNISHARP_RoslynExtensionsOptions:enableAnalyzersSupport"] = true,
["OMNISHARP_RoslynExtensionsOptions:enableImportCompletion"] = true,
["OMNISHARP_RoslynExtensionsOptions:enableDecompilationSupport"] = true,
["OMNISHARP_msbuild:EnablePackageAutoRestore"] = true,
},
},
jsonls = {
settings = {
json = {
schemas = require('schemastore').json.schemas(),
},
},
},
sumneko_lua = {
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
workspace = {
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.stdpath("config") .. "/lua"] = true,
},
},
},
},
},
robotframework_ls = {
settings = {
robot = {
codeFormatter = "robotidy",
variables = {
RESOURCES = vim.fn.getcwd() .. "/tests/robot/",
},
},
}
},
ltex = {
settings = {
ltex = {
dictionary = {
en = { ":~/.cache/nvim/ltex.dictionary.en-us.txt" },
},
},
},
},
}
local util = require "lspconfig.util"
util.on_setup = util.add_hook_after(util.on_setup, function(config)
local opts = {
on_attach = require("lsp.handlers").on_attach,
capabilities = require("lsp.handlers").capabilities,
}
lsp_installer.settings({
if config.on_attach then
config.on_attach = util.add_hook_after(config.on_attach, opts.on_attach)
else
config.on_attach = opts.on_attach
end
config.capabilities = opts.capabilities
end)
lsp_installer.setup({
ui = {
icons = {
server_installed = "",
@@ -69,14 +29,65 @@ lsp_installer.settings({
}
})
lsp_installer.on_server_ready(function(server)
local opts = {
on_attach = require("lsp.handlers").on_attach,
capabilities = require("lsp.handlers").capabilities,
lspconfig.omnisharp.setup({
handlers = {
["textDocument/definition"] = require('omnisharp_extended').handler,
},
cmd_env = {
["OMNISHARP_FormattingOptions:EnableEditorConfigSupport"] = true,
["OMNISHARP_RoslynExtensionsOptions:enableAnalyzersSupport"] = true,
["OMNISHARP_RoslynExtensionsOptions:enableImportCompletion"] = true,
["OMNISHARP_RoslynExtensionsOptions:enableDecompilationSupport"] = true,
["OMNISHARP_msbuild:EnablePackageAutoRestore"] = true,
},
})
lspconfig.jsonls.setup({
settings = {
json = {
schemas = require('schemastore').json.schemas(),
},
},
})
lspconfig.sumneko_lua.setup({
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
workspace = {
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.stdpath("config") .. "/lua"] = true,
},
},
},
},
})
lspconfig.robotframework_ls.setup({
settings = {
robot = {
codeFormatter = "robotidy",
variables = {
RESOURCES = vim.fn.getcwd() .. "/tests/robot/",
},
},
}
opts = vim.tbl_deep_extend("force", server:get_default_options(), opts)
if server_settings[server.name] then
opts = vim.tbl_deep_extend("force", server_settings[server.name], opts)
end
server:setup(opts)
end)
})
lspconfig.ltex.setup({
settings = {
ltex = {
dictionary = {
en = { ":~/.cache/nvim/ltex.dictionary.en-us.txt" },
},
},
},
})
for _, server in ipairs(lsp_installer.get_installed_servers()) do
lspconfig[server.name].setup({})
end