Skip to content

Unable to disable plugin #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
matthewsia98 opened this issue Jan 7, 2023 · 6 comments · Fixed by #12
Closed

Unable to disable plugin #11

matthewsia98 opened this issue Jan 7, 2023 · 6 comments · Fixed by #12

Comments

@matthewsia98
Copy link

Setting enabled key here does not affect anything.
However, setting ignore key causes ruff to ignore the specified key.

pylsp settings

    local lspconfig = require("lspconfig")
    lspconfig["pylsp"].setup({
        settings = {
            pylsp = {
                plugins = {
                    ruff = {
                        enabled = false,
                        ignore = {
                            "E741",
                        },
                    },
                },
            },
        },

Without ignore key
image

With ignore key
image

@jhossbach
Copy link
Member

jhossbach commented Jan 7, 2023

Hmm, this is odd indeed, I can reproduce this issue even when setting

@hookimpl
def pylsp_settings():
    return {
        "plugins": {
            "ruff": {
                "enabled": False,
            },
        }
    }

in the package itself. Do you have any idea @ccordoba12? I think pylsp is messing up here

@ccordoba12
Copy link
Member

ccordoba12 commented Jan 13, 2023

I checked this and (I don't know why), third-party plugins can only be disabled by passing their module names. So, the above configuration should be:

    local lspconfig = require("lspconfig")
    lspconfig["pylsp"].setup({
        settings = {
            pylsp = {
                plugins = {
                    pylsp_ruff = {
                        enabled = false,
                    },
                    ruff = {
                        ignore = {
                            "E741",
                        },
                    },
                },
            },
        },

That works for me in Spyder.

@ccordoba12
Copy link
Member

Ok, I understood what happens. Plugins are enabled/disabled according to their entry point names. In this case, that name is pylsp_ruff, not ruff:

[project.entry-points.pylsp]
pylsp_ruff = "pylsp_ruff.ruff_lint"

So, there are two possible solutions for this:

  1. Rename the entry option to be ruff. I think that's safe because the server only loads plugins decorated with @hookimpl.
  2. Rename the options namespace to be pylsp_ruff instead of ruff.

@jhossbach
Copy link
Member

Thanks for the help @ccordoba12! I'd rather stick to 1. to keep the plugin configurations consistent. Unfortunately I am unfamiliar with pluggy, changing the pyproject.toml in you code snippet to

[project.entry-points.pylsp]
ruff = "pylsp_ruff.ruff_lint"

doesn't fix it on my side. Am I missing something?

@ccordoba12 ccordoba12 changed the title Neovim unable to disable plugin Unable to disable plugin Jan 14, 2023
@ccordoba12
Copy link
Member

ccordoba12 commented Jan 14, 2023

Am I missing something?

Yes, changing the name is not enough. Afterwards, you need to uninstall the plugin and reinstall it again in development mode for the change to take effect.

I tested it locally and it works for me with Spyder, so I'll submit a PR for it.

@jhossbach
Copy link
Member

Right, that was it. Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants