From f4e0bf174eab077a3a424878cc9b37ad428b84b9 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Tue, 24 Aug 2021 09:33:47 -0400 Subject: chore(pyright): align root with pylsp (#1175) --- lua/lspconfig/pyright.lua | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'lua') diff --git a/lua/lspconfig/pyright.lua b/lua/lspconfig/pyright.lua index c0ea13e3..a41284fb 100644 --- a/lua/lspconfig/pyright.lua +++ b/lua/lspconfig/pyright.lua @@ -7,15 +7,6 @@ if vim.fn.has 'win32' == 1 then bin_name = bin_name .. '.cmd' end -local root_files = { - 'setup.py', - 'pyproject.toml', - 'setup.cfg', - 'requirements.txt', - 'pyrightconfig.json', - '.git', -} - local function organize_imports() local params = { command = 'pyright.organizeimports', @@ -28,8 +19,16 @@ configs[server_name] = { default_config = { cmd = { bin_name, '--stdio' }, filetypes = { 'python' }, - root_dir = function(filename) - return util.root_pattern(unpack(root_files))(filename) or util.path.dirname(filename) + root_dir = function(fname) + local root_files = { + 'pyproject.toml', + 'setup.py', + 'setup.cfg', + 'requirements.txt', + 'Pipfile', + 'pyrightconfig.json', + } + return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestory(fname) or util.path.dirname(fname) end, settings = { python = { -- cgit v1.2.3-70-g09d2