diff --git a/crates/ruff_server/README.md b/crates/ruff_server/README.md index d130f57b7172c..dc4700f43fc5b 100644 --- a/crates/ruff_server/README.md +++ b/crates/ruff_server/README.md @@ -60,6 +60,14 @@ See the [Neovim setup guide](docs/setup/NEOVIM.md). See the [Helix setup guide](docs/setup//HELIX.md). +#### Vim + +See the [Vim setup guide](docs/setup/VIM.md). + +#### Kate + +See the [Kate setup guide](docs/setup/KATE.md). + ### Contributing If you're interested in contributing to `ruff server` - well, first of all, thank you! Second of all, you might find the diff --git a/crates/ruff_server/docs/setup/KATE.md b/crates/ruff_server/docs/setup/KATE.md new file mode 100644 index 0000000000000..7b828121fc739 --- /dev/null +++ b/crates/ruff_server/docs/setup/KATE.md @@ -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. diff --git a/crates/ruff_server/docs/setup/NEOVIM.md b/crates/ruff_server/docs/setup/NEOVIM.md index abb6b56490d5b..09e311ac43dad 100644 --- a/crates/ruff_server/docs/setup/NEOVIM.md +++ b/crates/ruff_server/docs/setup/NEOVIM.md @@ -19,7 +19,8 @@ on how to configure the server from there. #### 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`: +If you're using Ruff alongside another LSP (like Pyright), you may want to defer to that LSP for certain capabilities, +like `textDocument/hover`: ```lua local on_attach = function(client, bufnr) @@ -34,7 +35,8 @@ require('lspconfig').ruff.setup { } ``` -If you'd like to use Ruff exclusively for linting, formatting, and import organization, you can disable those capabilities for Pyright: +If you'd like to use Ruff exclusively for linting, formatting, and import organization, you can disable those +capabilities for Pyright: ```lua require('lspconfig').pyright.setup { diff --git a/crates/ruff_server/docs/setup/VIM.md b/crates/ruff_server/docs/setup/VIM.md new file mode 100644 index 0000000000000..5723243f2b2d2 --- /dev/null +++ b/crates/ruff_server/docs/setup/VIM.md @@ -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 +```