From b571d410f37e081ca5b1486abb2e6bb35a408411 Mon Sep 17 00:00:00 2001 From: Jan Robert Schmidt Date: Thu, 30 May 2024 10:17:14 +0200 Subject: [PATCH 1/8] DOCS: add vim setup for ruff server --- crates/ruff_server/docs/setup/VIM.md | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 crates/ruff_server/docs/setup/VIM.md diff --git a/crates/ruff_server/docs/setup/VIM.md b/crates/ruff_server/docs/setup/VIM.md new file mode 100644 index 0000000000000..c0232de960336 --- /dev/null +++ b/crates/ruff_server/docs/setup/VIM.md @@ -0,0 +1,42 @@ +## 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 [`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. From 7ded4819757f2d7a43eca3079ff077050859a8e0 Mon Sep 17 00:00:00 2001 From: Jan Robert Schmidt Date: Thu, 30 May 2024 10:28:04 +0200 Subject: [PATCH 2/8] DOCS: add kate setup for ruff server --- crates/ruff_server/docs/setup/KATE.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 crates/ruff_server/docs/setup/KATE.md diff --git a/crates/ruff_server/docs/setup/KATE.md b/crates/ruff_server/docs/setup/KATE.md new file mode 100644 index 0000000000000..370982f8d2f7f --- /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`'s 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. From 7f58605ab5ab921d5f85f000b5666f6c0153b9a7 Mon Sep 17 00:00:00 2001 From: Jan Robert Schmidt Date: Thu, 30 May 2024 10:28:42 +0200 Subject: [PATCH 3/8] DOCS: add vim and kate to README of --- crates/ruff_server/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) 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 From 25b3d352d87099785bf0f6303371e37edde51cae Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Fri, 31 May 2024 12:37:33 +0530 Subject: [PATCH 4/8] Minor updates --- crates/ruff_server/docs/setup/KATE.md | 8 ++++---- crates/ruff_server/docs/setup/VIM.md | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/ruff_server/docs/setup/KATE.md b/crates/ruff_server/docs/setup/KATE.md index 370982f8d2f7f..5ead5f46c67d3 100644 --- a/crates/ruff_server/docs/setup/KATE.md +++ b/crates/ruff_server/docs/setup/KATE.md @@ -1,8 +1,8 @@ ## 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: +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 { @@ -17,7 +17,7 @@ } ``` -See [`LSP Client`'s documentation](https://docs.kde.org/stable5/en/kate/kate/kate-application-plugin-lspclient.html) for more details +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\] diff --git a/crates/ruff_server/docs/setup/VIM.md b/crates/ruff_server/docs/setup/VIM.md index c0232de960336..562bdbceddf3b 100644 --- a/crates/ruff_server/docs/setup/VIM.md +++ b/crates/ruff_server/docs/setup/VIM.md @@ -3,8 +3,8 @@ ### 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`: +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') From a21ec3aeb3216e4024f0dea58cd3292b28d149a4 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Fri, 31 May 2024 12:40:37 +0530 Subject: [PATCH 5/8] Fix pre-commit --- crates/ruff_server/docs/setup/KATE.md | 4 ++-- crates/ruff_server/docs/setup/VIM.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/ruff_server/docs/setup/KATE.md b/crates/ruff_server/docs/setup/KATE.md index 5ead5f46c67d3..30e107a1ddff9 100644 --- a/crates/ruff_server/docs/setup/KATE.md +++ b/crates/ruff_server/docs/setup/KATE.md @@ -1,8 +1,8 @@ ## 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: +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 { diff --git a/crates/ruff_server/docs/setup/VIM.md b/crates/ruff_server/docs/setup/VIM.md index 562bdbceddf3b..c0232de960336 100644 --- a/crates/ruff_server/docs/setup/VIM.md +++ b/crates/ruff_server/docs/setup/VIM.md @@ -3,8 +3,8 @@ ### 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`: +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') From ec9db336db40ff48ce65093d35dc8f680aae7abc Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 31 May 2024 15:01:40 -0400 Subject: [PATCH 6/8] Remove last line --- crates/ruff_server/docs/setup/VIM.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/ruff_server/docs/setup/VIM.md b/crates/ruff_server/docs/setup/VIM.md index c0232de960336..72f9b92bae324 100644 --- a/crates/ruff_server/docs/setup/VIM.md +++ b/crates/ruff_server/docs/setup/VIM.md @@ -38,5 +38,3 @@ function! s:on_lsp_buffer_enabled() abort endif endfunction ``` - -If you'd like to use Ruff exclusively for linting, formatting, and import organization, you can disable those capabilities for Pyright. From 2a1f0d951fe977ffcfdfa844eee0edf0876f831b Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 31 May 2024 15:03:22 -0400 Subject: [PATCH 7/8] Minor twaeks --- crates/ruff_server/docs/setup/VIM.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/ruff_server/docs/setup/VIM.md b/crates/ruff_server/docs/setup/VIM.md index 72f9b92bae324..5723243f2b2d2 100644 --- a/crates/ruff_server/docs/setup/VIM.md +++ b/crates/ruff_server/docs/setup/VIM.md @@ -17,16 +17,17 @@ if executable('ruff') 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. +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 you have the older language server (`ruff-lsp`) configured in Vim, make sure to disable it to prevent any conflicts. +> 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()`: +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 From e4e1e99514a408bd1801c26598ec96b8d26ae2f8 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 31 May 2024 15:04:13 -0400 Subject: [PATCH 8/8] Minor formatting --- crates/ruff_server/docs/setup/KATE.md | 2 +- crates/ruff_server/docs/setup/NEOVIM.md | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/ruff_server/docs/setup/KATE.md b/crates/ruff_server/docs/setup/KATE.md index 30e107a1ddff9..7b828121fc739 100644 --- a/crates/ruff_server/docs/setup/KATE.md +++ b/crates/ruff_server/docs/setup/KATE.md @@ -2,7 +2,7 @@ 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: +1. Finally, add this to `Settings` -> `Configure Kate` -> `LSP Client` -> `User Server Settings`: ```json { 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 {