diff --git a/flake.lock b/flake.lock index 574e222..4deb585 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": { @@ -1855,6 +1871,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 c00e9b8..5c1723c 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 ]; }