From 669614aec82951fba06c72ca921060535901e073 Mon Sep 17 00:00:00 2001 From: azurelotus0926 Date: Tue, 13 Feb 2024 21:15:56 +0530 Subject: [PATCH] Update Neovim documentation (#385) ## Summary Update Neovim documentation with the following changes: - Fix the code to disable hover capability. Earlier, it would disable for _every_ language server while we only want to disable it for `ruff-lsp`. - Add an example to disable diagnostics and import sorting from Pyright. fixes: #384 --- README.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 35eebb5..60dff71 100644 --- a/README.md +++ b/README.md @@ -127,8 +127,10 @@ LSP for certain capabilities, like `textDocument/hover`: ```lua local on_attach = function(client, bufnr) - -- Disable hover in favor of Pyright - client.server_capabilities.hoverProvider = false + if client.name == 'ruff_lsp' then + -- Disable hover in favor of Pyright + client.server_capabilities.hoverProvider = false + end end require('lspconfig').ruff_lsp.setup { @@ -136,6 +138,27 @@ require('lspconfig').ruff_lsp.setup { } ``` +And, if you'd like to use Ruff exclusively for linting, formatting, and organizing imports, you can +disable those capabilities in Pyright: + +```lua +require('lspconfig').pyright.setup { + on_attach = on_attach, + settings = { + pyright = { + -- Using Ruff's import organizer + disableOrganizeImports = true, + }, + python = { + analysis = { + -- Ignore all files for analysis to exclusively use Ruff for linting + ignore = { '*' }, + }, + }, + }, +} +``` + Ruff also integrates with [`coc.nvim`](https://github.com/neoclide/coc.nvim/wiki/Language-servers#using-ruff-lsp): ```json