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 +++++++++++++++++++++-- .config/nvim/lua/custom/plugins/TODO-lsp-saga.lua | 51 ----------------------- .config/nvim/lua/custom/plugins/lsp.lua | 5 +-- .config/nvim/plugin/keymaps.lua | 1 - 4 files changed, 49 insertions(+), 59 deletions(-) delete mode 100644 .config/nvim/lua/custom/plugins/TODO-lsp-saga.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' }) diff --git a/.config/nvim/lua/custom/plugins/TODO-lsp-saga.lua b/.config/nvim/lua/custom/plugins/TODO-lsp-saga.lua deleted file mode 100644 index edbe855..0000000 --- a/.config/nvim/lua/custom/plugins/TODO-lsp-saga.lua +++ /dev/null @@ -1,51 +0,0 @@ -return { - 'nvimdev/lspsaga.nvim', - dependencies = { - 'nvim-treesitter/nvim-treesitter', - 'nvim-tree/nvim-web-devicons', - }, - config = function() - 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', - }, - }) - local diagnostic = require('lspsaga.diagnostic') - - vim.keymap.set('n', 'K', ':Lspsaga hover_doc', { desc = 'Display Docs' }) - 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', function() - diagnostic:goto_next({ severity = vim.diagnostic.severity.WARN }) - end, { desc = '[G]oto [E]rror' }) - vim.keymap.set('n', 'gE', function() - diagnostic:goto_prev({ severity = vim.diagnostic.severity.WARN }) - end, { desc = '[G]oto [E]rror (prev)' }) - vim.keymap.set( - 'n', - 'dw', - 'Lspsaga show_workspace_diagnostics ++normal', - { desc = '[D]iagnostics for [W]orkspace' } - ) - - vim.keymap.set({ 'n', 't' }, '', 'Lspsaga term_toggle', { desc = '[T]erminal' }) - end, -} diff --git a/.config/nvim/lua/custom/plugins/lsp.lua b/.config/nvim/lua/custom/plugins/lsp.lua index 77e4499..f64fd09 100644 --- a/.config/nvim/lua/custom/plugins/lsp.lua +++ b/.config/nvim/lua/custom/plugins/lsp.lua @@ -14,10 +14,7 @@ return { { 'nvimdev/lspsaga.nvim', - dependencies = { - 'nvim-treesitter/nvim-treesitter', - 'nvim-tree/nvim-web-devicons', - }, + dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, }, { 'folke/lazydev.nvim', diff --git a/.config/nvim/plugin/keymaps.lua b/.config/nvim/plugin/keymaps.lua index 0221834..f3de068 100644 --- a/.config/nvim/plugin/keymaps.lua +++ b/.config/nvim/plugin/keymaps.lua @@ -7,7 +7,6 @@ local function unbind(mode, keymap) end -- Misc -set('n', 'q:', ':', { noremap = true }) -- disables opening some window if q was accidentally typed before : set({ 'n', 'i' }, '', 'ggVG', { desc = 'Visually Highlight [A]ll' }) set('n', '', 'nohlsearch', silent) set({ 'i', 'c' }, '', function() -- cgit v1.3.1