You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1009 B
Lua

local has_pyright = nil
-- These are files that are typically located in the root directory of a Python
-- project
local root_files = {
'pyproject.toml',
'setup.py',
'setup.cfg',
'requirements.txt',
'Pipfile',
'pyrightconfig.json',
'.git',
}
local buf = vim.api.nvim_get_current_buf()
local root_dir = vim.fs.root(buf, root_files)
local git_dir = vim.fs.root(buf, {'.git'})
local pyright = vim.lsp.start({
name = 'pyright',
cmd = {'pyright-langserver', '--stdio'},
filetypes = { 'python' },
root_dir = root_dir,
single_file_support = true,
settings = {
python = {
analysis = {
autoSearchPaths = true,
useLibraryCodeForTypes = true,
diagnosticMode = 'openFilesOnly',
},
},
},
})
vim.lsp.buf_attach_client(buf, pyright)
local ruff = vim.lsp.start({
name = 'ruff',
cmd = {'ruff', 'server'},
filetypes = { 'python' },
root_dir = root_dir,
single_file_support = true,
settings = {},
})
vim.lsp.buf_attach_client(buf, ruff)