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.

51 lines
1.0 KiB
Lua

local has_pyright = nil
-- These are files that are typically located in the root directory of a Python
-- project
local root_files = {
'pyrightconfig.json',
'.git',
'setup.py',
'setup.cfg',
'requirements.txt',
'Pipfile',
'pyproject.toml',
}
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_cmd = {'pyright-langserver', '--stdio'}
local pyright = vim.lsp.start({
name = 'pyright',
cmd = pyright_cmd,
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)