From 067b523897d1fe30300c9b51da691a5171ebad95 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:25:39 +0300 Subject: [PATCH] feat: apply new module format to lsp plugins --- modules/lsp/{lsp.nix => config.nix} | 0 modules/lsp/default.nix | 16 +++--- .../{lightbulb.nix => lightbulb/config.nix} | 6 --- modules/lsp/lightbulb/default.nix | 6 +++ modules/lsp/lightbulb/lightbulb.nix | 16 ++++++ .../config.nix} | 10 ++-- modules/lsp/lsp-signature/default.nix | 6 +++ modules/lsp/lsp-signature/lsp-signature.nix | 16 ++++++ modules/lsp/lspsaga/config.nix | 52 +++++++++++++++++++ modules/lsp/lspsaga/default.nix | 6 +++ modules/lsp/{ => lspsaga}/lspsaga.nix | 0 modules/lsp/module.nix | 16 ++++++ .../config.nix} | 6 --- modules/lsp/nvim-code-action-menu/default.nix | 6 +++ .../nvim-code-action-menu.nix | 16 ++++++ .../lsp/{trouble.nix => trouble/config.nix} | 6 --- modules/lsp/trouble/default.nix | 6 +++ modules/lsp/trouble/trouble.nix | 16 ++++++ 18 files changed, 175 insertions(+), 31 deletions(-) rename modules/lsp/{lsp.nix => config.nix} (100%) rename modules/lsp/{lightbulb.nix => lightbulb/config.nix} (78%) create mode 100644 modules/lsp/lightbulb/default.nix create mode 100644 modules/lsp/lightbulb/lightbulb.nix rename modules/lsp/{lsp-signature.nix => lsp-signature/config.nix} (66%) create mode 100644 modules/lsp/lsp-signature/default.nix create mode 100644 modules/lsp/lsp-signature/lsp-signature.nix create mode 100644 modules/lsp/lspsaga/config.nix create mode 100644 modules/lsp/lspsaga/default.nix rename modules/lsp/{ => lspsaga}/lspsaga.nix (100%) create mode 100644 modules/lsp/module.nix rename modules/lsp/{nvim-code-action-menu.nix => nvim-code-action-menu/config.nix} (71%) create mode 100644 modules/lsp/nvim-code-action-menu/default.nix create mode 100644 modules/lsp/nvim-code-action-menu/nvim-code-action-menu.nix rename modules/lsp/{trouble.nix => trouble/config.nix} (86%) create mode 100644 modules/lsp/trouble/default.nix create mode 100644 modules/lsp/trouble/trouble.nix diff --git a/modules/lsp/lsp.nix b/modules/lsp/config.nix similarity index 100% rename from modules/lsp/lsp.nix rename to modules/lsp/config.nix diff --git a/modules/lsp/default.nix b/modules/lsp/default.nix index 00c751d..0caa22c 100644 --- a/modules/lsp/default.nix +++ b/modules/lsp/default.nix @@ -5,11 +5,15 @@ ... }: { imports = [ - ./lsp.nix - ./lspsaga.nix - ./nvim-code-action-menu.nix - ./trouble.nix - ./lsp-signature.nix - ./lightbulb.nix + # nvim lsp support + ./config.nix + ./module.nix + + # lsp plugins + ./lspsaga + ./nvim-code-action-menu + ./trouble + ./lsp-signature + ./lightbulb ]; } diff --git a/modules/lsp/lightbulb.nix b/modules/lsp/lightbulb/config.nix similarity index 78% rename from modules/lsp/lightbulb.nix rename to modules/lsp/lightbulb/config.nix index cbd7622..f8b628f 100644 --- a/modules/lsp/lightbulb.nix +++ b/modules/lsp/lightbulb/config.nix @@ -8,12 +8,6 @@ with lib; with builtins; let cfg = config.vim.lsp; in { - options.vim.lsp = { - lightbulb = { - enable = mkEnableOption "lightbulb for code actions. Requires emoji font"; - }; - }; - config = mkIf (cfg.enable && cfg.lightbulb.enable) { vim.startPlugins = ["nvim-lightbulb"]; diff --git a/modules/lsp/lightbulb/default.nix b/modules/lsp/lightbulb/default.nix new file mode 100644 index 0000000..883944a --- /dev/null +++ b/modules/lsp/lightbulb/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./lightbulb.nix + ./config.nix + ]; +} diff --git a/modules/lsp/lightbulb/lightbulb.nix b/modules/lsp/lightbulb/lightbulb.nix new file mode 100644 index 0000000..0caef2b --- /dev/null +++ b/modules/lsp/lightbulb/lightbulb.nix @@ -0,0 +1,16 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.lsp; +in { + options.vim.lsp = { + lightbulb = { + enable = mkEnableOption "lightbulb for code actions. Requires emoji font"; + }; + }; +} diff --git a/modules/lsp/lsp-signature.nix b/modules/lsp/lsp-signature/config.nix similarity index 66% rename from modules/lsp/lsp-signature.nix rename to modules/lsp/lsp-signature/config.nix index 1d77040..7296a2c 100644 --- a/modules/lsp/lsp-signature.nix +++ b/modules/lsp/lsp-signature/config.nix @@ -8,14 +8,10 @@ with lib; with builtins; let cfg = config.vim.lsp; in { - options.vim.lsp = { - lspSignature = { - enable = mkEnableOption "lsp signature viewer"; - }; - }; - config = mkIf (cfg.enable && cfg.lspSignature.enable) { - vim.startPlugins = ["lsp-signature"]; + vim.startPlugins = [ + "lsp-signature" + ]; vim.luaConfigRC.lsp-signature = nvim.dag.entryAnywhere '' -- Enable lsp signature viewer diff --git a/modules/lsp/lsp-signature/default.nix b/modules/lsp/lsp-signature/default.nix new file mode 100644 index 0000000..0449a9e --- /dev/null +++ b/modules/lsp/lsp-signature/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./lsp-signature.nix + ./config.nix + ]; +} diff --git a/modules/lsp/lsp-signature/lsp-signature.nix b/modules/lsp/lsp-signature/lsp-signature.nix new file mode 100644 index 0000000..c954454 --- /dev/null +++ b/modules/lsp/lsp-signature/lsp-signature.nix @@ -0,0 +1,16 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.lsp; +in { + options.vim.lsp = { + lspSignature = { + enable = mkEnableOption "lsp signature viewer"; + }; + }; +} diff --git a/modules/lsp/lspsaga/config.nix b/modules/lsp/lspsaga/config.nix new file mode 100644 index 0000000..db8ac6b --- /dev/null +++ b/modules/lsp/lspsaga/config.nix @@ -0,0 +1,52 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.lsp; +in { + config = mkIf (cfg.enable && cfg.lspsaga.enable) { + vim.startPlugins = ["lspsaga"]; + + vim.vnoremap = { + "ca" = ":lua require('lspsaga.codeaction').range_code_action()"; + }; + + vim.nnoremap = + { + "lf" = "lua require'lspsaga.provider'.lsp_finder()"; + "lh" = "lua require('lspsaga.hover').render_hover_doc()"; + "" = "lua require('lspsaga.action').smart_scroll_with_saga(1)"; + "" = "lua require('lspsaga.action').smart_scroll_with_saga(-1)"; + "lr" = "lua require'lspsaga.rename'.rename()"; + "ld" = "lua require'lspsaga.provider'.preview_definition()"; + "ll" = "lua require'lspsaga.diagnostic'.show_line_diagnostics()"; + "lc" = "lua require'lspsaga.diagnostic'.show_cursor_diagnostics()"; + "lp" = "lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_prev()"; + "ln" = "lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_next()"; + } + // ( + if (!cfg.nvimCodeActionMenu.enable) + then { + "ca" = "lua require('lspsaga.codeaction').code_action()"; + } + else {} + ) + // ( + if (!cfg.lspSignature.enable) + then { + "ls" = "lua require('lspsaga.signaturehelp').signature_help()"; + } + else {} + ); + + vim.luaConfigRC.lspsage = nvim.dag.entryAnywhere '' + -- Enable lspsaga + local saga = require 'lspsaga' + saga.init_lsp_saga() + ''; + }; +} diff --git a/modules/lsp/lspsaga/default.nix b/modules/lsp/lspsaga/default.nix new file mode 100644 index 0000000..29cf580 --- /dev/null +++ b/modules/lsp/lspsaga/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./lspsaga.nix + ./config.nix + ]; +} diff --git a/modules/lsp/lspsaga.nix b/modules/lsp/lspsaga/lspsaga.nix similarity index 100% rename from modules/lsp/lspsaga.nix rename to modules/lsp/lspsaga/lspsaga.nix diff --git a/modules/lsp/module.nix b/modules/lsp/module.nix new file mode 100644 index 0000000..513ec53 --- /dev/null +++ b/modules/lsp/module.nix @@ -0,0 +1,16 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.lsp; +in { + options.vim.lsp = { + /* + ... + */ + }; +} diff --git a/modules/lsp/nvim-code-action-menu.nix b/modules/lsp/nvim-code-action-menu/config.nix similarity index 71% rename from modules/lsp/nvim-code-action-menu.nix rename to modules/lsp/nvim-code-action-menu/config.nix index ac8b8d6..e814af1 100644 --- a/modules/lsp/nvim-code-action-menu.nix +++ b/modules/lsp/nvim-code-action-menu/config.nix @@ -8,12 +8,6 @@ with lib; with builtins; let cfg = config.vim.lsp; in { - options.vim.lsp = { - nvimCodeActionMenu = { - enable = mkEnableOption "nvim code action menu"; - }; - }; - config = mkIf (cfg.enable && cfg.nvimCodeActionMenu.enable) { vim.startPlugins = ["nvim-code-action-menu"]; diff --git a/modules/lsp/nvim-code-action-menu/default.nix b/modules/lsp/nvim-code-action-menu/default.nix new file mode 100644 index 0000000..665cf92 --- /dev/null +++ b/modules/lsp/nvim-code-action-menu/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./nvim-code-action-menu.nix + ./config.nix + ]; +} diff --git a/modules/lsp/nvim-code-action-menu/nvim-code-action-menu.nix b/modules/lsp/nvim-code-action-menu/nvim-code-action-menu.nix new file mode 100644 index 0000000..4b7a3be --- /dev/null +++ b/modules/lsp/nvim-code-action-menu/nvim-code-action-menu.nix @@ -0,0 +1,16 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.lsp; +in { + options.vim.lsp = { + nvimCodeActionMenu = { + enable = mkEnableOption "nvim code action menu"; + }; + }; +} diff --git a/modules/lsp/trouble.nix b/modules/lsp/trouble/config.nix similarity index 86% rename from modules/lsp/trouble.nix rename to modules/lsp/trouble/config.nix index a96ce5d..d3efd30 100644 --- a/modules/lsp/trouble.nix +++ b/modules/lsp/trouble/config.nix @@ -8,12 +8,6 @@ with lib; with builtins; let cfg = config.vim.lsp; in { - options.vim.lsp = { - trouble = { - enable = mkEnableOption "trouble diagnostics viewer"; - }; - }; - config = mkIf (cfg.enable && cfg.trouble.enable) { vim.startPlugins = ["trouble"]; diff --git a/modules/lsp/trouble/default.nix b/modules/lsp/trouble/default.nix new file mode 100644 index 0000000..3a5d2cb --- /dev/null +++ b/modules/lsp/trouble/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./trouble.nix + ./config.nix + ]; +} diff --git a/modules/lsp/trouble/trouble.nix b/modules/lsp/trouble/trouble.nix new file mode 100644 index 0000000..63334f0 --- /dev/null +++ b/modules/lsp/trouble/trouble.nix @@ -0,0 +1,16 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.lsp; +in { + options.vim.lsp = { + trouble = { + enable = mkEnableOption "trouble diagnostics viewer"; + }; + }; +}