Skip to content
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

Linting to only trigger on demand and/or while saving? #67

Closed
jklaiho opened this issue Jul 23, 2024 · 3 comments
Closed

Linting to only trigger on demand and/or while saving? #67

jklaiho opened this issue Jul 23, 2024 · 3 comments

Comments

@jklaiho
Copy link

jklaiho commented Jul 23, 2024

I would love the ability to only trigger linting when I hit a specific key combo, instead of automatically while I'm typing. The linting errors and warnings that pop up while typing code that will eventually be valid are annoying and distracting, IMHO. I ended up ignoring W293 to stop the worst offender: Ruff nagging me about whitespace on an empty line when I press Enter and get auto-indentation.

In addition, an option to lint automatically when saving would be really nice. Ruff seems to have a VS Code specific setting called lint.run, which you can set to onSave instead of onType. Would something like this be possible to implement for LSP-ruff?

I've looked through a bunch of docs and haven't found an option for either of these; sorry if I've missed something.

@rchl
Copy link
Member

rchl commented Jul 23, 2024

That's more of a request for the core LSP package and there already is a request like that: sublimelsp/LSP#2161

@jklaiho
Copy link
Author

jklaiho commented Jul 23, 2024

OK, fair enough; I'm new at this LSP business and don't really know what type of issues belong where. I guess this can be closed.

I had another request in mind: being able to sort imports with a hotkey. Should that go here or the core LSP?

Some context to maybe save me from creating the issue altogether, my apologies that it's unrelated to this one: the README lists source.organizeImports and source.organizeImports.ruffas possible "code actions on save"—if it's already possible to bind these to key combos, I don't know how. This attempt didn't work:

    {
        "keys": ["super+ctrl+i"],
        "command": "lsp_code_actions",
        "context": [{"key": "lsp.session_with_capability", "operand": "source.organizeImports"}]
    },

@rchl
Copy link
Member

rchl commented Nov 8, 2024

Since we have issue in LSP, this one is redundant.

The keybinding you are looking for would look something like:

    {
        "keys": ["super+ctrl+i"],
        "command": "lsp_code_actions",
        "args": {"only_kinds": ["source"]},
        "context": [{"key": "lsp.session_with_capability", "operand": "codeActionProvider.codeActionKinds"}]
    },

You can find that example in the default LSP keybindings (commented out).

EDIT: Although invoking specific code action is currently not possible - sublimelsp/LSP#1356

@rchl rchl closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2024
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

No branches or pull requests

2 participants