-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Vim and Kate setup guide for ruff server
#11615
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b571d41
DOCS: add vim setup for ruff server
JaRoSchm 7ded481
DOCS: add kate setup for ruff server
JaRoSchm 7f58605
DOCS: add vim and kate to README of
JaRoSchm 25b3d35
Minor updates
dhruvmanila a21ec3a
Fix pre-commit
dhruvmanila ec9db33
Remove last line
charliermarsh 2a1f0d9
Minor twaeks
charliermarsh e4e1e99
Minor formatting
charliermarsh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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). | ||
2. Setup LSP Client [as desired](https://docs.kde.org/stable5/en/kate/kate/kate-application-plugin-lspclient.html). | ||
3. 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
## Vim Setup Guide for `ruff server` | ||
|
||
### Using `vim-lsp` | ||
|
||
1. Install [`vim-lsp`](https://github.com/prabirshrestha/vim-lsp). | ||
2. Setup `vim-lsp` [as desired](https://github.com/prabirshrestha/vim-lsp?tab=readme-ov-file#registering-servers). | ||
3. 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 [`vim-lsp`'s documentation](https://github.com/prabirshrestha/vim-lsp/blob/master/doc/vim-lsp.txt) for more details | ||
on how to configure the server from there. | ||
|
||
> \[!IMPORTANT\] | ||
> | ||
> If you have the older language server (`ruff-lsp`) configured in Vim, make 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 | ||
``` | ||
|
||
If you'd like to use Ruff exclusively for linting, formatting, and import organization, you can disable those capabilities for Pyright. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this requires an example configuration? Do you have that? If not, we can remove this part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took that from the Neovim setup guide. However, as noted in my post above, I don't use pyright personally, so I am not able to translate this part.
I am using
ruff server
in combination with pylsp. If this is helpful for someone, I could add the configuration necessary for this combination.