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 lsp_server = vim.lsp.start({ name = 'pyright', cmd = {'pyright-langserver', '--stdio'}, filetypes = { 'python' }, root_dir = root_dir, single_file_support = false, settings = { python = { analysis = { autoSearchPaths = true, useLibraryCodeForTypes = true, diagnosticMode = 'openFilesOnly', }, }, }, }) vim.lsp.buf_attach_client(buf, lsp_server)