-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
4 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
## Kate Setup Guide for `ruff server` | ||
|
||
1. Activate the [LSP Client plugin](https://docs.kde.org/stable5/en/kate/kate/plugins.html#kate-application-plugins). | ||
1. Setup LSP Client [as desired](https://docs.kde.org/stable5/en/kate/kate/kate-application-plugin-lspclient.html). | ||
1. Finally, add this to `Settings` -> `Configure Kate` -> `LSP Client` -> `User Server Settings`: | ||
|
||
```json | ||
{ | ||
"servers": { | ||
"python": { | ||
"command": ["ruff", "server", "--preview"], | ||
"url": "https://github.com/astral-sh/ruff", | ||
"highlightingModeRegex": "^Python$", | ||
"settings": {} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
See [LSP Client documentation](https://docs.kde.org/stable5/en/kate/kate/kate-application-plugin-lspclient.html) for more details | ||
on how to configure the server from there. | ||
|
||
> \[!IMPORTANT\] | ||
> | ||
> Kate's LSP Client plugin does not support multiple servers for the same language. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
## 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 | ||
``` |