ruff/crates/ruff_server/src
Dhruv Manilawala 9dc226be97
Add supported commands in server capabilities (#11850)
## Summary

This PR updates the server capabilities to include the commands that
Ruff supports. This is similar to how there's a list of possible code
actions supported by the server.

I noticed this when I was trying to find whether Helix supported
workspace commands or not based on Jane's comment
(https://github.com/astral-sh/ruff/pull/11831#discussion_r1634984921)
and I found the `:lsp-workspace-command` in the editor but it didn't
show up anything in the picker.

So, I looked at the implementation in Helix
(9c479e6d2d/helix-term/src/commands/typed.rs (L1372-L1384))
which made me realize that Ruff doesn't provide this in its
capabilities. Currently, this does require `ruff` to be first in the
list of language servers in the user config but that should be resolved
by https://github.com/helix-editor/helix/pull/10176. So, the following
config should work:

```toml
[[language]]
name = "python"
# Ruff should come first until https://github.com/helix-editor/helix/pull/10176 is released
language-servers = ["ruff", "pyright"]
```

## Test Plan

1. Neovim's server capabilities output should include the supported
commands:

```
  executeCommandProvider = {                                                                                                                          
    commands = { "ruff.applyFormat", "ruff.applyAutofix", "ruff.applyOrganizeImports", "ruff.printDebugInformation" },                                
    workDoneProgress = false                                                                                                                          
  },
```

2. Helix should now display the commands to pick from when
`:lsp-workspace-command` is invoked:

<img width="832" alt="Screenshot 2024-06-13 at 08 47 14"
src="https://github.com/astral-sh/ruff/assets/67177269/09048ecd-c974-4e09-ab56-9482ff3d780b">
2024-06-13 09:32:43 +05:30
..
edit Rename document module to text_document (#11571) 2024-05-27 18:32:21 +02:00
server Add supported commands in server capabilities (#11850) 2024-06-13 09:32:43 +05:30
session `ruff server`: Introduce the `ruff.printDebugInformation` command (#11831) 2024-06-11 11:42:46 -07:00
edit.rs `ruff server`: Add support for documents not exist on disk (#11588) 2024-05-31 08:34:10 +02:00
fix.rs Use real file path when available in `ruff server` (#11800) 2024-06-07 22:48:53 -07:00
format.rs `ruff server`: Formatting a document with syntax problems no longer spams a visible error popup (#11745) 2024-06-04 17:18:21 -07:00
lib.rs `ruff server`: Tracing system now respects log level and trace level, with options to log to a file (#11747) 2024-06-11 11:29:47 -07:00
lint.rs Build `CommentRanges` outside the parser (#11792) 2024-06-09 09:55:17 +00:00
message.rs `ruff server`: Tracing system now respects log level and trace level, with options to log to a file (#11747) 2024-06-11 11:29:47 -07:00
server.rs Add supported commands in server capabilities (#11850) 2024-06-13 09:32:43 +05:30
session.rs `ruff server`: Introduce the `ruff.printDebugInformation` command (#11831) 2024-06-11 11:42:46 -07:00
trace.rs `ruff server`: Tracing system now respects log level and trace level, with options to log to a file (#11747) 2024-06-11 11:29:47 -07:00