Neovim - 使用 Pyright 和 Pylsp 的 LSP 双重重命名问题

问题描述 投票:0回答:1

我使用

Pyright
LSP 作为主 LSP 服务器,并使用
pylsp
进行 pep8 验证,但重命名是否存在问题。它连续发生两次:一次来自
Pyright
,另一次来自
pylsp
。我的配置有什么问题以及如何禁用 pylsp 重命名?

也许有人可以解释如何正确设置 Rope,我尝试用 Rope 从 Pyright 移动到 pylsp,但它非常慢,大约 5 秒需要 Rope 创建自动完成,而 GoToDefinition 仅适用于我的方法,而不是 Pyright 中的所有库,而且 Rope 不能自动完成库方法,它仅适用于我编写的方法

{

"neovim/nvim-lspconfig",

config = function()

local lspconfig = require("lspconfig")

local capabilities = require('cmp_nvim_lsp').default_capabilities()

lspconfig.pyright.setup({

    capabilities = capabilities,

})

local venv_path = os.getenv('VIRTUAL_ENV')

local py_path = nil

-- decide which python executable to use for mypy

if venv_path ~= nil then

    py_path = venv_path .. "/bin/python3"

else

    py_path = ".venv/bin/python"

end

  

lspconfig.pylsp.setup({

    capabilities = capabilities,

    settings = {

        pylsp = {

            plugins = {

            black = { enabled = false },
            
            autopep8 = { enabled = false },
            
            yapf = { enabled = false },
            
            flake8 = {
            
                enabled = true,
                
                maxLineLength = 120
            
            },

            pylint = { enabled = false, executable = "pylint" },
            
            ruff = { enabled = false },
            
            pyflakes = { enabled = false },
            
            pycodestyle = { enabled = false },

            -- type checker
            
            pylsp_mypy = {
            
                enabled = false,
                
                overrides = { "--python-executable", py_path, true },
                
                report_progress = true,
                
                live_mode = false
            
            },

            -- auto-completion options
            
            jedi_completion = {
            
                enabled = false,
                
                fuzzy = true,
            
            },

            jedi_definition = {
            
                enabled = false,
            
            },

            rope_autoimport = {
            
                enabled = false,
            
                memory = true,
                
                completions = {
                
                    enabled = true
                
                },
            
                code_actions = {
                
                    enabled = true
                
                }
            
            },
            
            rope_completion = {
            
                enabled = false,
            
                eager = true
            
            },
            
            -- import sorting
            
            isort = { enabled = true },
            
        }

    }
})
  
neovim pyright pylsp
1个回答
0
投票

正如 @MonsieurMerso 建议的那样,我在初始化期间禁用了

on_attach
方法中的重命名
pyslp

  lspconfig.pylsp.setup({
    capabilities = capabilities,
    on_attach = function (client)
      client.server_capabilities.renameProvider = false
    end,
    ...
  })

© www.soinside.com 2019 - 2024. All rights reserved.