From 0652aa92543b458b890ce234c78c02166c45d8f2 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Thu, 11 Jul 2024 22:03:09 +0300 Subject: Neovim: configured lspsaga --- .config/nvim/lua/custom/lsp.lua | 51 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) (limited to '.config/nvim/lua/custom/lsp.lua') diff --git a/.config/nvim/lua/custom/lsp.lua b/.config/nvim/lua/custom/lsp.lua index ff85390..e5943cc 100644 --- a/.config/nvim/lua/custom/lsp.lua +++ b/.config/nvim/lua/custom/lsp.lua @@ -17,6 +17,25 @@ require('lsp_signature').setup({ hint_enable = false, }) +require('lspsaga').setup({ + lightbulb = { + enable = false, + sign = false, + virtual_text = true, + }, + implement = { + sign = false, + virtual_text = true, + }, + floaterm = { + height = 0.7, + width = 0.7, + }, + outline = { + layout = 'float', + }, +}) + -- NOTE: A list of language servers (and potentially their config) -- Accepts either true to enable, false to disable or a table with settings local servers = { @@ -93,7 +112,8 @@ vim.api.nvim_create_autocmd('LspAttach', { end, }) --- TODO: Understand what this is +-- TODO: Decide if you want to use conform or not +-- -- -- Autoformatting Setup -- require('conform').setup({ -- formatters_by_ft = { @@ -115,13 +135,38 @@ require('lsp_lines').setup() vim.diagnostic.config({ virtual_text = false }) vim.keymap.set('', 'dt', require('lsp_lines').toggle, { desc = '[D]iagnostics [T]oggle inline' }) --- LSP Keybindings +local lspsaga_diagnostic = require('lspsaga.diagnostic') local builtin = require('telescope.builtin') +local severity = vim.diagnostic.severity +local show_workspace_diagnostics = 'Lspsaga show_workspace_diagnostics ++normal' +local function next_diagnostic(diagnostic_severity) + return function() + lspsaga_diagnostic:goto_next({ severity = diagnostic_severity }) + end +end +local function prev_diagnostic(diagnostic_severity) + return function() + lspsaga_diagnostic:goto_prev({ severity = diagnostic_severity }) + end +end + +-- LSP Keybindings vim.keymap.set('n', 'gd', builtin.lsp_definitions, { desc = '[G]oto [D]efinition' }) vim.keymap.set('n', 'gu', builtin.lsp_references, { desc = '[G]oto [U]sages' }) vim.keymap.set('n', 'gi', builtin.lsp_implementations, { desc = '[G]oto [I]mplementations' }) -- vim.keymap.set('n', 'gt', builtin.lsp_type_definitions, { desc = '[G]oto [T]ype Definitions' }) -vim.keymap.set('n', 'gw', builtin.diagnostics, { desc = '[G]oto [W]arnings' }) +-- vim.keymap.set('n', 'gw', builtin.diagnostics, { desc = '[G]oto [W]arnings' }) vim.keymap.set('n', 'ds', builtin.lsp_document_symbols, { desc = '[D]ocument [S]symbols' }) vim.keymap.set('n', 'ps', builtin.lsp_workspace_symbols, { desc = '[P]roject [S]ymbols' }) vim.keymap.set({ 'n', 'i' }, '', vim.lsp.buf.signature_help, { desc = 'List [P]arameters' }) +vim.keymap.set('n', 'K', 'Lspsaga hover_doc', { desc = 'Documentation' }) +vim.keymap.set('n', 'R', 'Lspsaga rename', { desc = '[R]ename' }) +-- vim.keymap.set('n', 'os', 'Lspsaga outline', { desc = '[T]erminal' }) +vim.keymap.set({ 'n', 'i' }, '', 'Lspsaga code_action', { desc = 'Code Actions' }) +vim.keymap.set('n', 'ca', 'Lspsaga code_action', { desc = '[C]ode [A]ctions' }) +vim.keymap.set('n', 'ge', next_diagnostic(severity.ERROR), { desc = '[G]oto [E]rror' }) +vim.keymap.set('n', 'gE', prev_diagnostic(severity.ERROR), { desc = '[G]oto [E]rror (prev)' }) +vim.keymap.set('n', 'gw', next_diagnostic(severity.ERROR), { desc = '[G]oto [W]arning' }) +vim.keymap.set('n', 'gW', prev_diagnostic(severity.ERROR), { desc = '[G]oto [W]arning (prev)' }) +vim.keymap.set('n', 'dw', show_workspace_diagnostics, { desc = '[D]iagnostics for [W]orkspace' }) +vim.keymap.set({ 'n', 't' }, '', 'Lspsaga term_toggle', { desc = '[T]erminal' }) -- cgit v1.3.1