1

I am using Pyright LSP as main LSP server and pylsp for pep8 validation but is there problem with renaming. It happens 2 times a row: one from Pyright and another from pylsp. What is wrong in my config and how to disable pylsp renaming?

And maybe someone can explain how to properly setup Rope, i tried to move from pyright to pylsp with rope, but it extremely slow, something about 5 seconds needs Rope to create autocompletion and GoToDefinition works only for my methods, instead all libs in Pyright, also Rope cannot autocomplete libs methods, it works only for methods written by me

{

"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 },
            
        }

    }
})
  
2
  • Please format the code snippet properly. Excessive whitespace makes it hard to read. Commented Jun 15, 2024 at 4:09
  • 1
    You can pass a custom handler that will do nothing in case of rename action on oneo f your lsp configurations. Commented Jun 18, 2024 at 7:43

1 Answer 1

2

As @MonsieurMerso advised, I disabled renaming in on_attach method during initialization pyslp

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.