diff options
| author | JP Appel <jeanpierre.appel01@gmail.com> | 2024-08-22 17:49:24 -0400 |
|---|---|---|
| committer | JP Appel <jeanpierre.appel01@gmail.com> | 2024-08-22 18:04:41 -0400 |
| commit | 72a36d40d50f47134a1ffbf5f995e168451ac6a2 (patch) | |
| tree | 9e0bfc87a92507f17bcd6a78c657212f41ebb283 /nvim/lua/plugins/lsp.lua | |
| parent | 935d6645c4d94835e60b583d2856960a098fd783 (diff) | |
configuration for basedpyright and ruff
Diffstat (limited to 'nvim/lua/plugins/lsp.lua')
| -rw-r--r-- | nvim/lua/plugins/lsp.lua | 61 |
1 files changed, 52 insertions, 9 deletions
diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index 217802a..b0b1ac6 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -3,8 +3,24 @@ local lspconfig = { lazy = false, dependencies = { 'williamboman/mason.nvim', - 'williamboman/mason-lspconfig' + 'williamboman/mason-lspconfig.nvim' }, + config = function() + 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 BasedPyright + client.server_capabilities.hoverProvider = false + end + end, + desc = 'LSP: Disable hover capability from Ruff', + }) + end, keys = { { 'gd', @@ -16,7 +32,7 @@ local lspconfig = { }, { '<leader>r', - function () + function() vim.lsp.buf.rename() end, mode = 'n', @@ -27,20 +43,20 @@ local lspconfig = { function() vim.lsp.buf.format() end, - mode = {'n', 'v'}, + mode = { 'n', 'v' }, desc = "Format code" }, { '<leader>la', - function () + function() vim.lsp.buf.code_action() end, - mode = {'n', 's'}, + mode = { 'n', 's' }, desc = "Show code actions" }, { '<leader>lr', - function () + function() vim.lsp.buf.references() end, mode = 'n', @@ -48,7 +64,7 @@ local lspconfig = { }, { '<C-h>', - function () + function() vim.lsp.buf.signature_help() end, mode = 'i', @@ -59,7 +75,8 @@ local lspconfig = { local mason = { 'williamboman/mason.nvim', - opts = {} + opts = {}, + build = ":MasonUpdate" } local mason_lspconfig = { @@ -68,12 +85,22 @@ local mason_lspconfig = { 'williamboman/mason.nvim', }, opts = { + ensure_installed = { + "basedpyright", + "clangd", + "cssls", + "gopls", + "html", + "ruff", + "tsserver" + + }, handlers = { function(server_name) require('lspconfig')[server_name].setup({}) end }, - ["lua_ls"] = function () + ["lua_ls"] = function() require('lspconfig').lua_ls.setup({ settings = { Lua = { @@ -83,6 +110,22 @@ local mason_lspconfig = { } } }) + end, + ["basedpyright"] = function() + require('lspconfig').setup({ + settings = { + pyright = { + -- defer to ruff for import oranization + disableOrganizeImports = true, + }, + python = { + analysis = { + -- Ignore all files for analysis to exclusively use Ruff for linting + ignore = { '*' }, + }, + }, + }, + }) end } } |
