From 22e4ec8e50603ca4a281b5ee0b40a19cd84c80c5 Mon Sep 17 00:00:00 2001 From: Aditya Date: Wed, 6 Mar 2024 18:23:26 +0530 Subject: [PATCH] add none-ls --- config/default.nix | 4 + config/lsp/lspsaga.nix | 187 +++++++++++++++++++++++++++++++++++++ config/lsp/trouble.nix | 50 ++++++++++ config/none-ls/none-ls.nix | 90 ++++++++++++++++++ 4 files changed, 331 insertions(+) create mode 100644 config/lsp/lspsaga.nix create mode 100644 config/lsp/trouble.nix create mode 100644 config/none-ls/none-ls.nix diff --git a/config/default.nix b/config/default.nix index 5f9affd..90e185b 100644 --- a/config/default.nix +++ b/config/default.nix @@ -25,6 +25,10 @@ ./lsp/conform.nix ./lsp/fidget.nix ./lsp/lsp.nix + ./lsp/lspsaga.nix + ./lsp/trouble.nix + + ./none-ls/none-ls.nix ./dap/dap.nix diff --git a/config/lsp/lspsaga.nix b/config/lsp/lspsaga.nix new file mode 100644 index 0000000..73d6bb8 --- /dev/null +++ b/config/lsp/lspsaga.nix @@ -0,0 +1,187 @@ +{ + plugins.lspsaga = { + enable = true; + beacon = { + enable = true; + }; + ui = { + border = "rounded"; # One of none, single, double, rounded, solid, shadow + codeAction = "💡"; # Can be any symbol you want 💡 + }; + hover = { + openCmd = "!floorp"; # Choose your browser + openLink = "gx"; + }; + diagnostic = { + borderFollow = true; + diagnosticOnlyCurrent = false; + showCodeAction = true; + }; + symbolInWinbar = { + enable = true; # Breadcrumbs + }; + codeAction = { + extendGitSigns = false; + showServerName = true; + onlyInCursor = true; + numShortcut = true; + keys = { + exec = ""; + quit = ["" "q"]; + }; + }; + lightbulb = { + enable = false; + sign = false; + virtualText = true; + }; + implement = { + enable = false; + }; + rename = { + autoSave = false; + keys = { + exec = ""; + quit = ["" ""]; + select = "x"; + }; + }; + outline = { + autoClose = true; + autoPreview = true; + closeAfterJump = true; + layout = "normal"; # normal or float + winPosition = "right"; # left or right + keys = { + jump = "e"; + quit = "q"; + toggleOrJump = "o"; + }; + }; + scrollPreview = { + scrollDown = ""; + scrollUp = ""; + }; + }; + keymaps = [ + { + mode = "n"; + key = "gd"; + action = "Lspsaga finder def"; + options = { + desc = "Goto Definition"; + silent = true; + }; + } + { + mode = "n"; + key = "gr"; + action = "Lspsaga finder ref"; + options = { + desc = "Goto References"; + silent = true; + }; + } + + # { + # mode = "n"; + # key = "gD"; + # action = "Lspsaga show_line_diagnostics"; + # options = { + # desc = "Goto Declaration"; + # silent = true; + # }; + # } + + { + mode = "n"; + key = "gI"; + action = "Lspsaga finder imp"; + options = { + desc = "Goto Implementation"; + silent = true; + }; + } + + { + mode = "n"; + key = "gT"; + action = "Lspsaga peek_type_definition"; + options = { + desc = "Type Definition"; + silent = true; + }; + } + + { + mode = "n"; + key = "K"; + action = "Lspsaga hover_doc"; + options = { + desc = "Hover"; + silent = true; + }; + } + + { + mode = "n"; + key = "cw"; + action = "Lspsaga outline"; + options = { + desc = "Outline"; + silent = true; + }; + } + + { + mode = "n"; + key = "cr"; + action = "Lspsaga rename"; + options = { + desc = "Rename"; + silent = true; + }; + } + + { + mode = "n"; + key = "ca"; + action = "Lspsaga code_action"; + options = { + desc = "Code Action"; + silent = true; + }; + } + + { + mode = "n"; + key = "cd"; + action = "Lspsaga show_line_diagnostics"; + options = { + desc = "Line Diagnostics"; + silent = true; + }; + } + + { + mode = "n"; + key = "[d"; + action = "Lspsaga diagnostic_jump_next"; + options = { + desc = "Next Diagnostic"; + silent = true; + }; + } + + { + mode = "n"; + key = "]d"; + action = "Lspsaga diagnostic_jump_prev"; + options = { + desc = "Previous Diagnostic"; + silent = true; + }; + } + ]; +} + diff --git a/config/lsp/trouble.nix b/config/lsp/trouble.nix new file mode 100644 index 0000000..7bd3c78 --- /dev/null +++ b/config/lsp/trouble.nix @@ -0,0 +1,50 @@ +{ + plugins.trouble = { + enable = true; + autoClose = true; + }; + keymaps = [ + { + mode = "n"; + key = "x"; + action = "+diagnostics/quickfix"; + } + { + mode = "n"; + key = "xx"; + action = "TroubleToggle"; + options = { + silent = true; + desc = "Document Diagnostics (Trouble)"; + }; + } + { + mode = "n"; + key = "xX"; + action = "TroubleToggle workspace_diagnostics"; + options = { + silent = true; + desc = "Workspace Diagnostics (Trouble)"; + }; + } + { + mode = "n"; + key = "xt"; + action = "TroubleToggle todo"; + options = { + silent = true; + desc = "Todo (Trouble)"; + }; + } + { + mode = "n"; + key = "xQ"; + action = "TodoQuickFix"; + options = { + silent = true; + desc = "Quickfix List (Trouble)"; + }; + } + ]; +} + diff --git a/config/none-ls/none-ls.nix b/config/none-ls/none-ls.nix new file mode 100644 index 0000000..e5b76a2 --- /dev/null +++ b/config/none-ls/none-ls.nix @@ -0,0 +1,90 @@ +{ + plugins.none-ls = { + enable = true; + enableLspFormat = true; + updateInInsert = false; + onAttach = '' + function(client, bufnr) + if client.supports_method "textDocument/formatting" then + vim.api.nvim_clear_autocmds { group = augroup, buffer = bufnr } + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format { bufnr = bufnr } + end, + }) + end + end + ''; + sources = { + code_actions = { + eslint_d.enable = true; + gitsigns.enable = true; + statix.enable = true; + }; + diagnostics = { + checkstyle = { + enable = true; + }; + statix = { + enable = true; + }; + luacheck = { + enable = true; + }; + flake8 = { + enable = true; + }; + eslint_d = { + enable = true; + }; + }; + formatting = { + alejandra = { + enable = true; + }; + prettier = { + enable = true; + withArgs = '' + { + extra_args = { "--no-semi", "--single-quote" }, + } + ''; + }; + google_java_format = { + enable = true; + }; + rustfmt = { + enable = true; + }; + stylua = { + enable = true; + }; + black = { + enable = true; + withArgs = '' + { + extra_args = { "--fast" }, + } + ''; + }; + jq = { + enable = true; + }; + }; + }; + }; + # keymaps = [ + # { + # mode = [ "n" "v" ]; + # key = "cf"; + # action = "lua vim.lsp.buf.format()"; + # options = { + # silent = true; + # desc = "Format"; + # }; + # } + # ]; +} +