[nvim] move from pylps to pyright

This commit is contained in:
Piotr Domański 2024-10-17 22:58:51 +02:00
parent 58bdfd856c
commit 0d2f897a71

View file

@ -82,6 +82,44 @@ return {
lsp_attach = lsp_attach, lsp_attach = lsp_attach,
}) })
configs = {
pylsp = {
settings = {
pylsp = {
plugins = {
mypy = { enabled = true },
black = { enabled = true },
isort = { enabled = true, profile = "black" },
},
},
},
},
ruff_lsp = {
settings = {
args = {},
format = {
args = { "--line-length=120", "--config", "format.quote-style = 'single'" },
},
lint = {
-- args = { "--config", "lint.select = ['F', 'E']", "--config", "lint.ignore = ['E501']" }
}
}
},
pyright = {
settings = {
pyright = {
disableOptimizeImports = true,
},
python = {
analysis = {
typeCheckingMode = "basic",
autoImportCompletions = false,
}
}
}
}
}
require('mason').setup({}) require('mason').setup({})
require('mason-lspconfig').setup({ require('mason-lspconfig').setup({
-- Replace the language servers listed here -- Replace the language servers listed here
@ -89,29 +127,14 @@ return {
ensure_installed = { ensure_installed = {
"lua_ls", "lua_ls",
"gopls", "gopls",
"pylsp", "pyright",
"ruff_lsp", "ruff_lsp",
"ts_ls", "ts_ls",
"mypy"
}, },
handlers = { handlers = {
function(server_name) function(server_name)
lsp_config = {} require('lspconfig')[server_name].setup(configs[server_name] or {})
if server_name == "pylsp" then
lsp_config = {
settings = {
pylsp = {
plugins = {
mypy = { enabled = true },
black = { enabled = true },
isort = { enabled = true, profile = "black" },
},
},
},
}
end
require('lspconfig')[server_name].setup(lsp_config)
end, end,
} }
}) })