mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
Add docs for Ruff language server (#12344)
## Summary This PR adds documentation for the Ruff language server. It mainly does the following: 1. Combines various READMEs containing instructions for different editor setup in their respective section on the online docs 2. Provide an enumerated list of server settings. Additionally, it also provides a section for VS Code specific options. 3. Adds a "Features" section which enumerates all the current capabilities of the native server For (2), the settings documentation is done manually but a future improvement (easier after `ruff-lsp` is deprecated) is to move the docs in to Rust struct and generate the documentation from the code itself. And, the VS Code extension specific options can be generated by diffing against the `package.json` in `ruff-vscode` repository. ### Structure 1. Setup: This section contains the configuration for setting up the language server for different editors 2. Features: This section contains a list of capabilities provided by the server along with short GIF to showcase it 3. Settings: This section contains an enumerated list of settings in a similar format to the one for the linter / formatter 4. Migrating from `ruff-lsp` > [!NOTE] > > The settings page is manually written but could possibly be auto-generated via a macro similar to `OptionsMetadata` on the `ClientSettings` struct resolves: #11217 ## Test Plan Generate and open the documentation locally using: 1. `python scripts/generate_mkdocs.py` 2. `mkdocs serve -f mkdocs.insiders.yml`
This commit is contained in:
parent
2e77b775b0
commit
648cca199b
15 changed files with 1254 additions and 731 deletions
|
@ -1,41 +1,3 @@
|
|||
## Vim Setup Guide for `ruff server`
|
||||
|
||||
### Using `vim-lsp`
|
||||
|
||||
1. Install [`vim-lsp`](https://github.com/prabirshrestha/vim-lsp).
|
||||
1. Setup `vim-lsp` [as desired](https://github.com/prabirshrestha/vim-lsp?tab=readme-ov-file#registering-servers).
|
||||
1. Finally, add this to your `.vimrc`:
|
||||
|
||||
```vim
|
||||
if executable('ruff')
|
||||
au User lsp_setup call lsp#register_server({
|
||||
\ 'name': 'ruff',
|
||||
\ 'cmd': {server_info->['ruff', 'server', '--preview']},
|
||||
\ 'allowlist': ['python'],
|
||||
\ 'workspace_config': {},
|
||||
\ })
|
||||
endif
|
||||
```
|
||||
|
||||
See the `vim-lsp` [documentation](https://github.com/prabirshrestha/vim-lsp/blob/master/doc/vim-lsp.txt) for more
|
||||
details on how to configure the language server.
|
||||
|
||||
> \[!IMPORTANT\]
|
||||
>
|
||||
> If Ruff's legacy language server (`ruff-lsp`) is configured in Vim, be sure to disable it to prevent any conflicts.
|
||||
|
||||
#### Tips
|
||||
|
||||
If you're using Ruff alongside another LSP (like Pyright), you may want to defer to that LSP for certain capabilities,
|
||||
like `textDocument/hover` by adding the following to the function `s:on_lsp_buffer_enabled()`:
|
||||
|
||||
```vim
|
||||
function! s:on_lsp_buffer_enabled() abort
|
||||
" add your keybindings here (see https://github.com/prabirshrestha/vim-lsp?tab=readme-ov-file#registering-servers)
|
||||
|
||||
let l:capabilities = lsp#get_server_capabilities('ruff')
|
||||
if !empty(l:capabilities)
|
||||
let l:capabilities.hoverProvider = v:false
|
||||
endif
|
||||
endfunction
|
||||
```
|
||||
This document has been moved to <https://docs.astral.sh/ruff/editors/setup/#vim>.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue