Closed jklaiho closed 3 weeks ago
That's more of a request for the core LSP package and there already is a request like that: https://github.com/sublimelsp/LSP/issues/2161
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.ruff
as 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"}]
},
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 - https://github.com/sublimelsp/LSP/issues/1356
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 toonSave
instead ofonType
. 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.