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"; + }; + }; +}