From 346e6f535ed4349a4afae8a3b95f87949e4fe73c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Jul 2024 16:51:21 +0300 Subject: [PATCH 1/3] plugins/lsp: add code-actions module; add fastaction.nvim --- flake.lock | 17 ++++++++++ flake.nix | 5 +++ modules/plugins/lsp/code-actions/default.nix | 10 ++++++ .../code-actions/fastaction-nvim/config.nix | 34 +++++++++++++++++++ .../fastaction-nvim/fastaction-nvim.nix | 15 ++++++++ modules/plugins/lsp/default.nix | 4 ++- 6 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 modules/plugins/lsp/code-actions/default.nix create mode 100644 modules/plugins/lsp/code-actions/fastaction-nvim/config.nix create mode 100644 modules/plugins/lsp/code-actions/fastaction-nvim/fastaction-nvim.nix diff --git a/flake.lock b/flake.lock index 4601bc1..98cf20b 100644 --- a/flake.lock +++ b/flake.lock @@ -571,6 +571,22 @@ "type": "github" } }, + "plugin-fastaction-nvim": { + "flake": false, + "locked": { + "lastModified": 1721396662, + "narHash": "sha256-L7na78FsE+QHlEwxMpiwQcoOPhtmrknvdTZfzUoDANI=", + "owner": "Chaitanyabsprip", + "repo": "fastaction.nvim", + "rev": "2384dea7ba81d2709d0bee0e4bc7a8831ff13a9d", + "type": "github" + }, + "original": { + "owner": "Chaitanyabsprip", + "repo": "fastaction.nvim", + "type": "github" + } + }, "plugin-fidget-nvim": { "flake": false, "locked": { @@ -1839,6 +1855,7 @@ "plugin-dracula": "plugin-dracula", "plugin-dressing-nvim": "plugin-dressing-nvim", "plugin-elixir-tools": "plugin-elixir-tools", + "plugin-fastaction-nvim": "plugin-fastaction-nvim", "plugin-fidget-nvim": "plugin-fidget-nvim", "plugin-flutter-tools": "plugin-flutter-tools", "plugin-gesture-nvim": "plugin-gesture-nvim", diff --git a/flake.nix b/flake.nix index 0290638..c9b4ea3 100644 --- a/flake.nix +++ b/flake.nix @@ -138,6 +138,11 @@ flake = false; }; + plugin-fastaction-nvim = { + url = "github:Chaitanyabsprip/fastaction.nvim"; + flake = false; + }; + plugin-lsp-signature = { url = "github:ray-x/lsp_signature.nvim"; flake = false; diff --git a/modules/plugins/lsp/code-actions/default.nix b/modules/plugins/lsp/code-actions/default.nix new file mode 100644 index 0000000..af6070b --- /dev/null +++ b/modules/plugins/lsp/code-actions/default.nix @@ -0,0 +1,10 @@ +{lib, ...}: let + inherit (lib.options) mkEnableOption; +in { + imports = [ + ./fastaction-nvim + ]; + options.vim.lsp.code-actions = { + enable = mkEnableOption "code-actions. Setting this to `false` will disable all code action plugins."; + }; +} diff --git a/modules/plugins/lsp/code-actions/fastaction-nvim/config.nix b/modules/plugins/lsp/code-actions/fastaction-nvim/config.nix new file mode 100644 index 0000000..391cf68 --- /dev/null +++ b/modules/plugins/lsp/code-actions/fastaction-nvim/config.nix @@ -0,0 +1,34 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding; + + cfg = config.vim.lsp.code-actions; + self = import ./fastaction-nvim.nix {inherit lib;}; + + mappingDefinitions = self.options.vim.lsp.code-actions.fastaction-nvim.mappings; + mappings = addDescriptionsToMappings cfg.fastaction-nvim.mappings mappingDefinitions; +in { + config = mkIf (cfg.enable && cfg.fastaction-nvim.enable) { + vim = { + startPlugins = ["fastaction-nvim"]; + + maps = { + normal = mkMerge [ + (mkSetLuaBinding mappings.code_action "require('fastaction').code_action") + (mkSetLuaBinding mappings.range_action "require('fastaction').range_code_action") + ]; + }; + + pluginRC.fastaction-nvim = entryAnywhere '' + -- Enable trouble diagnostics viewer + require('fastaction').setup(${toLuaObject cfg.fastaction-nvim.setupOpts}) + ''; + }; + }; +} diff --git a/modules/plugins/lsp/code-actions/fastaction-nvim/fastaction-nvim.nix b/modules/plugins/lsp/code-actions/fastaction-nvim/fastaction-nvim.nix new file mode 100644 index 0000000..c9e0b95 --- /dev/null +++ b/modules/plugins/lsp/code-actions/fastaction-nvim/fastaction-nvim.nix @@ -0,0 +1,15 @@ +{lib, ...}: let + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.types) mkPluginSetupOption; + inherit (lib.nvim.binds) mkMappingOption; +in { + options.vim.lsp.code-actions.fastaction-nvim = { + enable = mkEnableOption "code actions for Neovim via fastaction.nvim"; + setupOpts = mkPluginSetupOption "fastaction-nvim" {}; + + mappings = { + code_action = mkMappingOption "Displays code action popup [Fastaction.nvim]" "cfa"; + range_action = mkMappingOption " Displays code actions for visual range [Fastaction.nvim]" "cra"; + }; + }; +} diff --git a/modules/plugins/lsp/default.nix b/modules/plugins/lsp/default.nix index f8408aa..61f3145 100644 --- a/modules/plugins/lsp/default.nix +++ b/modules/plugins/lsp/default.nix @@ -10,12 +10,14 @@ # lsp plugins ./lspsaga - ./nvim-code-action-menu ./trouble ./lsp-signature ./lightbulb ./lspkind ./lsplines ./nvim-docs-view + + # Code Actions + ./code-actions ]; } From 97dabab4d94d20397391d55976ec69cee0e6895c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Jul 2024 16:51:51 +0300 Subject: [PATCH 2/3] deprecate nvimCodeActionMenu --- configuration.nix | 7 +++- modules/extra/deprecations.nix | 7 ++++ .../fastaction-nvim}/default.nix | 2 +- .../lsp/nvim-code-action-menu/config.nix | 37 ------------------- .../nvim-code-action-menu.nix | 20 ---------- 5 files changed, 14 insertions(+), 59 deletions(-) rename modules/plugins/lsp/{nvim-code-action-menu => code-actions/fastaction-nvim}/default.nix (55%) delete mode 100644 modules/plugins/lsp/nvim-code-action-menu/config.nix delete mode 100644 modules/plugins/lsp/nvim-code-action-menu/nvim-code-action-menu.nix diff --git a/configuration.nix b/configuration.nix index b0c613b..35cb0bd 100644 --- a/configuration.nix +++ b/configuration.nix @@ -17,11 +17,16 @@ isMaximal: { lspkind.enable = false; lightbulb.enable = true; lspsaga.enable = false; - nvimCodeActionMenu.enable = isMaximal; trouble.enable = true; lspSignature.enable = true; lsplines.enable = isMaximal; nvim-docs-view.enable = isMaximal; + + # Code Actions + code-actions = { + enable = true; + fastaction-nvim.enable = true; + }; }; debugger = { diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix index cb06380..8809092 100644 --- a/modules/extra/deprecations.nix +++ b/modules/extra/deprecations.nix @@ -7,5 +7,12 @@ in { Tidalcycles language support has been removed as of 2024-06-06 as it was long unmaintained. If you depended on this functionality, please open an issue. '') + + # 2024-07-20 + (mkRemovedOptionModule ["vim" "lsp" "nvimCodeActionMenu"] '' + nvimCodeActionMenu has been deprecated and archived upstream. As of 0.7, code-actions will be + available under `vim.lsp.code-actions.enable` and `vim.lsp.code.actions..enable`. + Please take a look at the nvf manual for more details. + '') ]; } diff --git a/modules/plugins/lsp/nvim-code-action-menu/default.nix b/modules/plugins/lsp/code-actions/fastaction-nvim/default.nix similarity index 55% rename from modules/plugins/lsp/nvim-code-action-menu/default.nix rename to modules/plugins/lsp/code-actions/fastaction-nvim/default.nix index f94dd22..ecac8b8 100644 --- a/modules/plugins/lsp/nvim-code-action-menu/default.nix +++ b/modules/plugins/lsp/code-actions/fastaction-nvim/default.nix @@ -1,6 +1,6 @@ { imports = [ - ./nvim-code-action-menu.nix ./config.nix + ./fastaction-nvim.nix ]; } diff --git a/modules/plugins/lsp/nvim-code-action-menu/config.nix b/modules/plugins/lsp/nvim-code-action-menu/config.nix deleted file mode 100644 index 9acc34d..0000000 --- a/modules/plugins/lsp/nvim-code-action-menu/config.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ - config, - lib, - ... -}: let - inherit (lib.modules) mkIf; - inherit (lib.nvim.dag) entryAnywhere; - inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings pushDownDefault; - - cfg = config.vim.lsp; - - self = import ./nvim-code-action-menu.nix {inherit lib;}; - mappingDefinitions = self.options.vim.lsp.nvimCodeActionMenu.mappings; - mappings = addDescriptionsToMappings cfg.nvimCodeActionMenu.mappings mappingDefinitions; -in { - config = mkIf (cfg.enable && cfg.nvimCodeActionMenu.enable) { - vim = { - startPlugins = ["nvim-code-action-menu"]; - - maps.normal = mkSetBinding mappings.open ":CodeActionMenu"; - - binds.whichKey.register = pushDownDefault { - "c" = "+CodeAction"; - }; - - pluginRC.code-action-menu = entryAnywhere '' - -- border configuration - vim.g.code_action_menu_window_border = '${config.vim.ui.borders.plugins.code-action-menu.style}' - - -- show individual sections of the code action menu - ${lib.optionalString cfg.nvimCodeActionMenu.show.details "vim.g.code_action_menu_show_details = true"} - ${lib.optionalString cfg.nvimCodeActionMenu.show.diff "vim.g.code_action_menu_show_diff = true"} - ${lib.optionalString cfg.nvimCodeActionMenu.show.actionKind "vim.g.code_action_menu_show_action_kind = true"} - ''; - }; - }; -} diff --git a/modules/plugins/lsp/nvim-code-action-menu/nvim-code-action-menu.nix b/modules/plugins/lsp/nvim-code-action-menu/nvim-code-action-menu.nix deleted file mode 100644 index c303f7c..0000000 --- a/modules/plugins/lsp/nvim-code-action-menu/nvim-code-action-menu.nix +++ /dev/null @@ -1,20 +0,0 @@ -{lib, ...}: let - inherit (lib.options) mkEnableOption; - inherit (lib.nvim.binds) mkMappingOption; -in { - options.vim.lsp = { - nvimCodeActionMenu = { - enable = mkEnableOption "nvim code action menu"; - - show = { - details = mkEnableOption "Show details" // {default = true;}; - diff = mkEnableOption "Show diff" // {default = true;}; - actionKind = mkEnableOption "Show action kind" // {default = true;}; - }; - - mappings = { - open = mkMappingOption "Open code action menu [nvim-code-action-menu]" "ca"; - }; - }; - }; -} From 3935189b7931e10b78f0ab3ac01a7e654b86aeb6 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Jul 2024 17:24:00 +0300 Subject: [PATCH 3/3] fastaction-nvim: move range_code_action to visual maps --- .../lsp/code-actions/fastaction-nvim/config.nix | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/plugins/lsp/code-actions/fastaction-nvim/config.nix b/modules/plugins/lsp/code-actions/fastaction-nvim/config.nix index 391cf68..f6424c6 100644 --- a/modules/plugins/lsp/code-actions/fastaction-nvim/config.nix +++ b/modules/plugins/lsp/code-actions/fastaction-nvim/config.nix @@ -3,10 +3,10 @@ lib, ... }: let - inherit (lib.modules) mkIf mkMerge; + inherit (lib.modules) mkIf; inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.lua) toLuaObject; - inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding; + inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding pushDownDefault; cfg = config.vim.lsp.code-actions; self = import ./fastaction-nvim.nix {inherit lib;}; @@ -18,11 +18,13 @@ in { vim = { startPlugins = ["fastaction-nvim"]; + binds.whichKey.register = pushDownDefault { + "c" = "Code Actions"; + }; + maps = { - normal = mkMerge [ - (mkSetLuaBinding mappings.code_action "require('fastaction').code_action") - (mkSetLuaBinding mappings.range_action "require('fastaction').range_code_action") - ]; + normal = mkSetLuaBinding mappings.code_action "require('fastaction').code_action"; + visual = mkSetLuaBinding mappings.range_action "require('fastaction').range_code_action"; }; pluginRC.fastaction-nvim = entryAnywhere ''