nvim: Replace Mason with local language servers
This commit is contained in:
parent
212cbed679
commit
b62cdc7c64
3 changed files with 8 additions and 158 deletions
|
|
@ -1,147 +0,0 @@
|
|||
return {
|
||||
"williamboman/mason.nvim",
|
||||
enabled = true,
|
||||
dependencies = {
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
},
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"jdtls",
|
||||
"java-debug-adapter",
|
||||
"sonarlint-language-server",
|
||||
"gradle-language-server",
|
||||
"html-lsp",
|
||||
"json-lsp",
|
||||
"typos-lsp"
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup()
|
||||
|
||||
lspconfig = require "lspconfig"
|
||||
|
||||
-- Gradle
|
||||
lspconfig.gradle_ls.setup{}
|
||||
|
||||
-- HTML
|
||||
lspconfig.html.setup{
|
||||
settings = {
|
||||
html = {
|
||||
format = {
|
||||
tabSize = 4,
|
||||
insertSpaces = true,
|
||||
indentEmptyLines = false,
|
||||
indentInnerHtml = true,
|
||||
wrapLineLength = 120,
|
||||
wrapAttributes = 'preserve',
|
||||
wrapAttributesIndentSize = 4,
|
||||
preserveNewLines = true,
|
||||
maxPreserveNewLines = 1,
|
||||
indentScripts = "keep",
|
||||
extraLiners = "",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
-- JSON
|
||||
lspconfig.jsonls.setup{}
|
||||
|
||||
-- Go
|
||||
lspconfig.gopls.setup{
|
||||
settings = {
|
||||
gopls = {
|
||||
gofumpt = true,
|
||||
staticcheck = true,
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
unusedresult = true,
|
||||
unusedwrite = true,
|
||||
unusedvariable = true,
|
||||
useany = true,
|
||||
fieldalignment = false,
|
||||
nilness = true,
|
||||
shadow = true,
|
||||
},
|
||||
hints = {
|
||||
assignVariableTypes = true,
|
||||
compositeLiteralFields = true,
|
||||
compositeLiteralTypes = true,
|
||||
constantValues = true,
|
||||
functionTypeParameters = true,
|
||||
parameterNames = true,
|
||||
rangeVariableTypes = true,
|
||||
},
|
||||
codelenses = {
|
||||
gc_details = true,
|
||||
generate = true,
|
||||
regenerate_cgo = true,
|
||||
tidy = true,
|
||||
upgrade_dependency = true,
|
||||
vendor = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
-- Organize imports and format code on save
|
||||
vim.api.nvim_create_autocmd({"BufWritePre"}, {
|
||||
pattern = "*.go",
|
||||
callback = function()
|
||||
local params = vim.lsp.util.make_range_params()
|
||||
params.context = {only = {"source.organizeImports"}}
|
||||
local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params)
|
||||
for cid, res in pairs(result or {}) do
|
||||
for _, r in pairs(res.result or {}) do
|
||||
if r.edit then
|
||||
local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or "utf-16"
|
||||
vim.lsp.util.apply_workspace_edit(r.edit, enc)
|
||||
end
|
||||
end
|
||||
end
|
||||
vim.lsp.buf.format({async = false})
|
||||
end
|
||||
})
|
||||
|
||||
-- Python
|
||||
lspconfig.pylsp.setup{
|
||||
settings = {
|
||||
pylsp = {
|
||||
plugins = {
|
||||
autopep8 = {
|
||||
enabled = false,
|
||||
},
|
||||
yapf = {
|
||||
enabled = true,
|
||||
},
|
||||
pylint = {
|
||||
enabled = false,
|
||||
},
|
||||
pyflakes = {
|
||||
enabled = true,
|
||||
},
|
||||
pycodestyle = {
|
||||
enabled = true,
|
||||
ignore = {
|
||||
'E402',
|
||||
'W503',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
lspconfig.typos_lsp.setup({
|
||||
settings = {
|
||||
filetypes = {
|
||||
'java',
|
||||
'go'
|
||||
},
|
||||
},
|
||||
init_options = {
|
||||
diagnosticSeverity = "Info",
|
||||
}
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
@ -3,20 +3,18 @@ return {
|
|||
url = "https://gitlab.com/schrieveslaach/sonarlint.nvim",
|
||||
lazy = true,
|
||||
ft = {"java", "go", "html", "python"},
|
||||
dependencies = {
|
||||
"williamboman/mason.nvim"
|
||||
},
|
||||
config = function()
|
||||
require('sonarlint').setup({
|
||||
server = {
|
||||
cmd = {
|
||||
'sonarlint-language-server',
|
||||
'sonarlint-ls',
|
||||
'-stdio',
|
||||
'-analyzers',
|
||||
vim.fn.expand("$MASON/share/sonarlint-analyzers/sonarjava.jar"),
|
||||
vim.fn.expand("$MASON/share/sonarlint-analyzers/sonargo.jar"),
|
||||
vim.fn.expand("$MASON/share/sonarlint-analyzers/sonarhtml.jar"),
|
||||
vim.fn.expand("$MASON/share/sonarlint-analyzers/sonarpython.jar"),
|
||||
"/usr/share/java/sonarlint-ls/analyzers/sonarjava.jar",
|
||||
"/usr/share/java/sonarlint-ls/analyzers/sonargo.jar",
|
||||
"/usr/share/java/sonarlint-ls/analyzers/sonarhtml.jar",
|
||||
"/usr/share/java/sonarlint-ls/analyzers/sonarpython.jar",
|
||||
"/usr/share/java/sonarlint-ls/analyzers/sonarphp.jar",
|
||||
},
|
||||
settings = {
|
||||
sonarlint = {
|
||||
|
|
@ -41,4 +39,3 @@ return {
|
|||
end
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue