2025-01-15 11:57:09 +01:00
|
|
|
-- Exit if the language server isn't available
|
2025-06-19 18:05:22 +02:00
|
|
|
if vim.fn.executable('pylsp') ~= 1 and vim.fn.executable('mypy') ~= 1 and vim.fn.executable('ruff') then
|
2025-01-15 11:57:09 +01:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local root_files = {
|
|
|
|
'pyproject.toml',
|
|
|
|
'setup.py',
|
|
|
|
'setup.cfg',
|
|
|
|
'requirements.txt',
|
|
|
|
'Pipfile',
|
|
|
|
'pyrightconfig.json',
|
|
|
|
'.git',
|
|
|
|
}
|
|
|
|
|
|
|
|
vim.lsp.start({
|
|
|
|
name = 'python-lsp-server',
|
|
|
|
cmd = { "pylsp" },
|
|
|
|
root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]),
|
|
|
|
capabilities = require('user.lsp').make_client_capabilities(),
|
|
|
|
filetypes = { 'python' },
|
|
|
|
on_attach = function(client, bufnr)
|
|
|
|
require("nvim-navic").attach(client, bufnr)
|
|
|
|
require("workspace-diagnostics").populate_workspace_diagnostics(client, bufnr)
|
|
|
|
end,
|
|
|
|
settings = {
|
|
|
|
pylsp = {
|
|
|
|
plugins = {
|
|
|
|
mypy = { enabled = true, },
|
|
|
|
rope = { enabled = true, },
|
|
|
|
ruff = { enabled = true, },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
single_file_support = true
|
|
|
|
})
|