From 378c8b0be4fb290ad8f47fb137274d1f246a1ed6 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Thu, 14 Mar 2024 23:34:35 +0000 Subject: [PATCH] Improve LSP configuration * Add more recommended mappings * Add Python LSP support with PyRight and Ruff --- lua/plugins/completions.lua | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/lua/plugins/completions.lua b/lua/plugins/completions.lua index ef73a6c..5767a4a 100644 --- a/lua/plugins/completions.lua +++ b/lua/plugins/completions.lua @@ -38,8 +38,10 @@ return { 'clangd', 'cmake', 'jsonls', - 'lua_ls', 'lemminx', + 'lua_ls', + 'pyright', + 'ruff_lsp', 'vimls', 'yamlls', }, @@ -53,8 +55,7 @@ return { ['lua_ls'] = function() require('neodev').setup() - local lspconfig = require('lspconfig') - lspconfig.lua_ls.setup({ + require('lspconfig').lua_ls.setup({ settings = { Lua = { diagnostics = { @@ -64,7 +65,19 @@ return { } } }) - end + end, + + ['pyright'] = function() + require('lspconfig').pyright.setup({ + settings = { + pyright = { + -- Using Ruff's import organizer + disableOrganizeImports = true, + }, + } + }) + end, + }, }) @@ -110,13 +123,14 @@ return { vim.keymap.set('n', 'fi', require("actions-preview").code_actions, opts) - -- Goto definition mapping + -- Goto mappings + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) - -- TODO: nnoremap gt (coc-type-definition) - -- TODO: nnoremap gu (coc-references-used) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) -- Get references to symbol under cursor, store in quickfix window - vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) -- Refactoring mappings vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts)