From 03450108b34c5a4fac5efe65f1f0879a51f5ae60 Mon Sep 17 00:00:00 2001 From: Nick Zana Date: Sat, 5 Oct 2024 00:00:13 -0400 Subject: [PATCH] Add ruff python linter --- lua/lsp.lua | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index 1136b33..9e9c1e4 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -69,9 +69,33 @@ lsp.configure('clangd', {}) lsp.configure('pylsp', {}) +-- From https://docs.astral.sh/ruff/editors/setup/#neovim +lsp.configure('ruff', { + init_options = { + settings = { + -- Ruff language server settings go here + } + } +}) + +vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup('lsp_attach_disable_ruff_hover', { clear = true }), + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client == nil then + return + end + if client.name == 'ruff' then + -- Disable hover in favor of Pyright + client.server_capabilities.hoverProvider = false + end + end, + desc = 'LSP: Disable hover capability from Ruff', +}) + -- gopls lsp.configure('gopls', {}) -lsp.setup_servers({'rust_analyzer', 'html', 'texlab', 'clangd', 'pylsp', 'gopls', 'ts_ls'}) +lsp.setup_servers({'rust_analyzer', 'html', 'texlab', 'clangd', 'pylsp', 'gopls', 'ts_ls', 'ruff'}) lsp.setup()