Skip to content

Commit 7ce17b7

Browse files
authored
Add Vim and Kate setup guide for ruff server (#11615)
## Summary In the [roadmap for `ruff server`](#10581) support for vim and kate is listed. Therefore I added setup guides for them based on the neovim guide. As I don't use pyright I wasn't able to translate the corresponding part from the neovim guide. ## Test Plan Doesn't apply.
1 parent f9a6450 commit 7ce17b7

File tree

4 files changed

+78
-2
lines changed

4 files changed

+78
-2
lines changed

crates/ruff_server/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ See the [Neovim setup guide](docs/setup/NEOVIM.md).
6060

6161
See the [Helix setup guide](docs/setup//HELIX.md).
6262

63+
#### Vim
64+
65+
See the [Vim setup guide](docs/setup/VIM.md).
66+
67+
#### Kate
68+
69+
See the [Kate setup guide](docs/setup/KATE.md).
70+
6371
### Contributing
6472

6573
If you're interested in contributing to `ruff server` - well, first of all, thank you! Second of all, you might find the

crates/ruff_server/docs/setup/KATE.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## Kate Setup Guide for `ruff server`
2+
3+
1. Activate the [LSP Client plugin](https://docs.kde.org/stable5/en/kate/kate/plugins.html#kate-application-plugins).
4+
1. Setup LSP Client [as desired](https://docs.kde.org/stable5/en/kate/kate/kate-application-plugin-lspclient.html).
5+
1. Finally, add this to `Settings` -> `Configure Kate` -> `LSP Client` -> `User Server Settings`:
6+
7+
```json
8+
{
9+
"servers": {
10+
"python": {
11+
"command": ["ruff", "server", "--preview"],
12+
"url": "https://github.com/astral-sh/ruff",
13+
"highlightingModeRegex": "^Python$",
14+
"settings": {}
15+
}
16+
}
17+
}
18+
```
19+
20+
See [LSP Client documentation](https://docs.kde.org/stable5/en/kate/kate/kate-application-plugin-lspclient.html) for more details
21+
on how to configure the server from there.
22+
23+
> \[!IMPORTANT\]
24+
>
25+
> Kate's LSP Client plugin does not support multiple servers for the same language.

crates/ruff_server/docs/setup/NEOVIM.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ on how to configure the server from there.
1919
2020
#### Tips
2121

22-
If you're using Ruff alongside another LSP (like Pyright), you may want to defer to that LSP for certain capabilities, like `textDocument/hover`:
22+
If you're using Ruff alongside another LSP (like Pyright), you may want to defer to that LSP for certain capabilities,
23+
like `textDocument/hover`:
2324

2425
```lua
2526
local on_attach = function(client, bufnr)
@@ -34,7 +35,8 @@ require('lspconfig').ruff.setup {
3435
}
3536
```
3637

37-
If you'd like to use Ruff exclusively for linting, formatting, and import organization, you can disable those capabilities for Pyright:
38+
If you'd like to use Ruff exclusively for linting, formatting, and import organization, you can disable those
39+
capabilities for Pyright:
3840

3941
```lua
4042
require('lspconfig').pyright.setup {

crates/ruff_server/docs/setup/VIM.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## Vim Setup Guide for `ruff server`
2+
3+
### Using `vim-lsp`
4+
5+
1. Install [`vim-lsp`](https://github.com/prabirshrestha/vim-lsp).
6+
1. Setup `vim-lsp` [as desired](https://github.com/prabirshrestha/vim-lsp?tab=readme-ov-file#registering-servers).
7+
1. Finally, add this to your `.vimrc`:
8+
9+
```vim
10+
if executable('ruff')
11+
au User lsp_setup call lsp#register_server({
12+
\ 'name': 'ruff',
13+
\ 'cmd': {server_info->['ruff', 'server', '--preview']},
14+
\ 'allowlist': ['python'],
15+
\ 'workspace_config': {},
16+
\ })
17+
endif
18+
```
19+
20+
See the `vim-lsp` [documentation](https://github.com/prabirshrestha/vim-lsp/blob/master/doc/vim-lsp.txt) for more
21+
details on how to configure the language server.
22+
23+
> \[!IMPORTANT\]
24+
>
25+
> If Ruff's legacy language server (`ruff-lsp`) is configured in Vim, be sure to disable it to prevent any conflicts.
26+
27+
#### Tips
28+
29+
If you're using Ruff alongside another LSP (like Pyright), you may want to defer to that LSP for certain capabilities,
30+
like `textDocument/hover` by adding the following to the function `s:on_lsp_buffer_enabled()`:
31+
32+
```vim
33+
function! s:on_lsp_buffer_enabled() abort
34+
" add your keybindings here (see https://github.com/prabirshrestha/vim-lsp?tab=readme-ov-file#registering-servers)
35+
36+
let l:capabilities = lsp#get_server_capabilities('ruff')
37+
if !empty(l:capabilities)
38+
let l:capabilities.hoverProvider = v:false
39+
endif
40+
endfunction
41+
```

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy