From 54476b5a8bea713eb0480b4f3a66478cc15ef813 Mon Sep 17 00:00:00 2001 From: Ben Mayer <90480641+Libadoxon@users.noreply.github.com> Date: Thu, 20 Feb 2025 17:50:26 +0100 Subject: [PATCH 1/5] languages/go: add gofmt, golines and gofumpt formatter (#654) --- docs/release-notes/rl-0.8.md | 1 + modules/plugins/languages/go.nix | 58 ++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 621e976f..63be2209 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -170,3 +170,4 @@ [Libadoxon](https://github.com/Libadoxon) - Add [git-conflict](https://github.com/akinsho/git-conflict.nvim) plugin for resolving git conflicts +- Add formatters for go: [gofmt](https://go.dev/blog/gofmt), [golines](https://github.com/segmentio/golines) and [gofumpt](https://github.com/mvdan/gofumpt) diff --git a/modules/plugins/languages/go.nix b/modules/plugins/languages/go.nix index e0eded0d..3ac9ae77 100644 --- a/modules/plugins/languages/go.nix +++ b/modules/plugins/languages/go.nix @@ -34,6 +34,43 @@ }; }; + defaultFormat = "gofmt"; + formats = { + gofmt = { + package = pkgs.go; + nullConfig = '' + table.insert( + ls_sources, + null_ls.builtins.formatting.gofmt.with({ + command = "${cfg.format.package}/bin/gofmt", + }) + ) + ''; + }; + gofumpt = { + package = pkgs.gofumpt; + nullConfig = '' + table.insert( + ls_sources, + null_ls.builtins.formatting.gofumpt.with({ + command = "${cfg.format.package}/bin/gofumpt", + }) + ) + ''; + }; + golines = { + package = pkgs.golines; + nullConfig = '' + table.insert( + ls_sources, + null_ls.builtins.formatting.golines.with({ + command = "${cfg.format.package}/bin/golines", + }) + ) + ''; + }; + }; + defaultDebugger = "delve"; debuggers = { delve = { @@ -67,6 +104,22 @@ in { }; }; + format = { + enable = mkEnableOption "Go formatting" // {default = config.vim.languages.enableFormat;}; + + type = mkOption { + description = "Go formatter to use"; + type = enum (attrNames formats); + default = defaultFormat; + }; + + package = mkOption { + description = "Go formatter package"; + type = package; + default = formats.${cfg.format.type}.package; + }; + }; + dap = { enable = mkOption { description = "Enable Go Debug Adapter via nvim-dap-go plugin"; @@ -99,6 +152,11 @@ in { vim.lsp.lspconfig.sources.go-lsp = servers.${cfg.lsp.server}.lspConfig; }) + (mkIf cfg.format.enable { + vim.lsp.null-ls.enable = true; + vim.lsp.null-ls.sources.go-format = formats.${cfg.format.type}.nullConfig; + }) + (mkIf cfg.dap.enable { vim = { startPlugins = ["nvim-dap-go"]; From 4aac51ec19fef16703bc6f3c27f2482071025b12 Mon Sep 17 00:00:00 2001 From: MaxMur <31189199+TheMaxMur@users.noreply.github.com> Date: Fri, 21 Feb 2025 16:29:45 +0300 Subject: [PATCH 2/5] languages/flutter: Update pin name for match (#658) --- modules/wrapper/build/config.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/wrapper/build/config.nix b/modules/wrapper/build/config.nix index 1f14b3a6..d145f798 100644 --- a/modules/wrapper/build/config.nix +++ b/modules/wrapper/build/config.nix @@ -45,7 +45,7 @@ pluginBuilders = { nvim-treesitter = buildTreesitterPlug config.vim.treesitter.grammars; flutter-tools-patched = buildPlug { - pname = "flutter-tools"; + pname = "flutter-tools-nvim"; patches = [./patches/flutter-tools.patch]; # Disable failing require check hook checks From 5fbc72d697e53c8d4ff3cb8b7bbc60b6c96ffd02 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Fri, 21 Feb 2025 14:44:05 +0100 Subject: [PATCH 3/5] git/git-conflict: avoid shadowing builtin keybinds (#651) * git/git-conflict: avoid shadowing builtin keybinds * docs: update release notes --------- Co-authored-by: raf --- docs/release-notes/rl-0.8.md | 5 +++++ modules/plugins/git/git-conflict/git-conflict.nix | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 63be2209..93e93e8d 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -1,5 +1,10 @@ # Release 0.8 {#sec-release-0.8} +## Breaking changes + +- `git-conflict` keybinds are now prefixed with `` to avoid conflicting + with builtins + [NotAShelf](https://github.com/notashelf): [typst-preview.nvim]: https://github.com/chomosuke/typst-preview.nvim diff --git a/modules/plugins/git/git-conflict/git-conflict.nix b/modules/plugins/git/git-conflict/git-conflict.nix index bffb926c..44ab79c5 100644 --- a/modules/plugins/git/git-conflict/git-conflict.nix +++ b/modules/plugins/git/git-conflict/git-conflict.nix @@ -12,10 +12,10 @@ in { setupOpts = mkPluginSetupOption "git-conflict" {}; mappings = { - ours = mkMappingOption "Choose Ours [Git-Conflict]" "co"; - theirs = mkMappingOption "Choose Theirs [Git-Conflict]" "ct"; - both = mkMappingOption "Choose Both [Git-Conflict]" "cb"; - none = mkMappingOption "Choose None [Git-Conflict]" "c0"; + ours = mkMappingOption "Choose Ours [Git-Conflict]" "co"; + theirs = mkMappingOption "Choose Theirs [Git-Conflict]" "ct"; + both = mkMappingOption "Choose Both [Git-Conflict]" "cb"; + none = mkMappingOption "Choose None [Git-Conflict]" "c0"; prevConflict = mkMappingOption "Go to the previous Conflict [Git-Conflict]" "]x"; nextConflict = mkMappingOption "Go to the next Conflict [Git-Conflict]" "[x"; }; From b9941583fdf452566d5694eb8106a19202ec3f62 Mon Sep 17 00:00:00 2001 From: Joe Hanson Date: Sat, 22 Feb 2025 10:41:38 -0600 Subject: [PATCH 4/5] utility/multicursors-nvim: init #610) * feat: add multicursors-nvim plugin multicursors-nvim with hydra dependency and static config. * add most used default options * add more descriptions and refine * disable debug mode * maximal by default * add multicursors addition to changelog * Update modules/plugins/hydra/hydra.nix place hydra plugin in utility folder Co-authored-by: raf * clean up hydra config and implementation * mention hydra dependency addition * update to using npins instead of flake based additions. --------- Co-authored-by: raf Co-authored-by: raf --- configuration.nix | 2 +- docs/release-notes/rl-0.8.md | 6 + modules/plugins/hydra/config.nix | 22 +++ modules/plugins/hydra/default.nix | 6 + modules/plugins/hydra/hydra.nix | 7 + modules/plugins/utility/default.nix | 1 + .../plugins/utility/multicursors/config.nix | 36 +++++ .../plugins/utility/multicursors/default.nix | 6 + .../utility/multicursors/multicursors.nix | 126 ++++++++++++++++++ npins/sources.json | 30 +++++ 10 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 modules/plugins/hydra/config.nix create mode 100644 modules/plugins/hydra/default.nix create mode 100644 modules/plugins/hydra/hydra.nix create mode 100644 modules/plugins/utility/multicursors/config.nix create mode 100644 modules/plugins/utility/multicursors/default.nix create mode 100644 modules/plugins/utility/multicursors/multicursors.nix diff --git a/configuration.nix b/configuration.nix index c7b0f288..35dffca5 100644 --- a/configuration.nix +++ b/configuration.nix @@ -183,7 +183,7 @@ isMaximal: { leap.enable = true; precognition.enable = isMaximal; }; - + multicursors.enable = isMaximal; images = { image-nvim.enable = false; }; diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 93e93e8d..a5a791d8 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -159,6 +159,12 @@ - Add support for [nixd](https://github.com/nix-community/nixd) language server. +[jahanson](https://github.com/jahanson): + +- Add [multicursors.nvim](https://github.com/smoka7/multicursors.nvim) to + available plugins, under `vim.utility.multicursors`. +- Add [hydra.nvim](https://github.com/nvimtools/hydra.nvim) as dependency for + `multicursors.nvim` and lazy loads by default. [folospior](https://github.com/folospior) - Fix plugin name for lsp/lspkind. diff --git a/modules/plugins/hydra/config.nix b/modules/plugins/hydra/config.nix new file mode 100644 index 00000000..bc5b2de8 --- /dev/null +++ b/modules/plugins/hydra/config.nix @@ -0,0 +1,22 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + cfg = config.vim.hydra; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = []; + lazy.plugins.hydra = { + package = "hydra.nvim"; + setupModule = "hydra"; + inherit (cfg) setupOpts; + + event = ["DeferredUIEnter"]; + cmd = ["MCstart" "MCvisual" "MCclear" "MCpattern" "MCvisualPattern" "MCunderCursor"]; + }; + }; + }; +} diff --git a/modules/plugins/hydra/default.nix b/modules/plugins/hydra/default.nix new file mode 100644 index 00000000..d35f4d7c --- /dev/null +++ b/modules/plugins/hydra/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./hydra.nix + ./config.nix + ]; +} diff --git a/modules/plugins/hydra/hydra.nix b/modules/plugins/hydra/hydra.nix new file mode 100644 index 00000000..59287a7b --- /dev/null +++ b/modules/plugins/hydra/hydra.nix @@ -0,0 +1,7 @@ +{lib, ...}: let + inherit (lib.options) mkEnableOption; +in { + options.vim.utility.hydra = { + enable = mkEnableOption "utility for creating custom submodes and menus [nvimtools/hydra.nvim]"; + }; +} diff --git a/modules/plugins/utility/default.nix b/modules/plugins/utility/default.nix index 372a4f53..4abb4515 100644 --- a/modules/plugins/utility/default.nix +++ b/modules/plugins/utility/default.nix @@ -8,6 +8,7 @@ ./icon-picker ./images ./motion + ./multicursors ./new-file-template ./outline ./preview diff --git a/modules/plugins/utility/multicursors/config.nix b/modules/plugins/utility/multicursors/config.nix new file mode 100644 index 00000000..8eaa3e28 --- /dev/null +++ b/modules/plugins/utility/multicursors/config.nix @@ -0,0 +1,36 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + cfg = config.vim.utility.multicursors; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = ["hydra-nvim"]; + lazy.plugins."multicursors-nvim" = { + package = "multicursors-nvim"; + setupModule = "multicursors"; + inherit (cfg) setupOpts; + + event = ["DeferredUIEnter"]; + cmd = ["MCstart" "MCvisual" "MCclear" "MCpattern" "MCvisualPattern" "MCunderCursor"]; + keys = [ + { + mode = ["v" "n"]; + key = "mcs"; + action = ":MCstart"; + desc = "Create a selection for selected text or word under the cursor [multicursors.nvim]"; + } + { + mode = ["v" "n"]; + key = "mcp"; + action = ":MCpattern"; + desc = "Create a selection for pattern entered [multicursors.nvim]"; + } + ]; + }; + }; + }; +} diff --git a/modules/plugins/utility/multicursors/default.nix b/modules/plugins/utility/multicursors/default.nix new file mode 100644 index 00000000..a1ddac8e --- /dev/null +++ b/modules/plugins/utility/multicursors/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./multicursors.nix + ./config.nix + ]; +} diff --git a/modules/plugins/utility/multicursors/multicursors.nix b/modules/plugins/utility/multicursors/multicursors.nix new file mode 100644 index 00000000..d533b8a9 --- /dev/null +++ b/modules/plugins/utility/multicursors/multicursors.nix @@ -0,0 +1,126 @@ +{lib, ...}: let + inherit (lib.types) bool int str; + inherit (lib.nvim.types) mkPluginSetupOption; + inherit (lib.options) mkOption mkEnableOption; + hintConfig = {lib, ...}: { + options = { + float_opts = mkOption { + description = "The options for the floating hint window"; + type = lib.types.submodule { + options = { + border = mkOption { + type = lib.types.str; + default = "none"; + description = "The border style for the hint window"; + }; + }; + }; + }; + position = mkOption { + type = lib.types.str; + default = "bottom"; + description = "The position of the hint window"; + }; + }; + }; + generateHints = {lib, ...}: { + options = { + normal = mkOption { + type = lib.types.bool; + description = "Generate hints for the normal mode"; + default = true; + }; + insert = mkOption { + type = lib.types.bool; + description = "Generate hints for the insert mode"; + default = true; + }; + extend = mkOption { + type = lib.types.bool; + description = "Generate hints for the extend mode"; + default = true; + }; + config = mkOption { + description = "The configuration for generating hints for multicursors.nvim"; + type = lib.types.submodule { + options = { + column_count = mkOption { + type = lib.types.nullOr int; + description = "The number of columns to use for the hint window"; + default = null; + }; + max_hint_length = mkOption { + type = int; + description = "The maximum length of the hint"; + default = 25; + }; + }; + }; + default = { + column_count = null; + max_hint_length = 25; + }; + }; + }; + }; +in { + options.vim.utility.multicursors = { + enable = mkEnableOption "multicursors.nvim plugin (vscode like multiple cursors)"; + + setupOpts = mkPluginSetupOption "multicursors" { + DEBUG_MODE = mkOption { + type = bool; + default = false; + description = "Enable debug mode."; + }; + create_commands = mkOption { + type = bool; + default = true; + description = "Create Multicursor user commands"; + }; + updatetime = mkOption { + type = int; + default = 50; + description = "The time in milliseconds to wait before updating the cursor in insert mode"; + }; + nowait = mkOption { + type = bool; + description = "Don't wait for the cursor to move before updating the cursor"; + default = true; + }; + mode_keys = mkOption { + type = lib.types.attrsOf str; + description = "The keys to use for each mode"; + default = { + insert = "i"; + append = "a"; + change = "c"; + extend = "e"; + }; + }; + hint_config = mkOption { + type = lib.types.submodule hintConfig; + description = "The configuration for the hint window"; + default = { + float_opts = { + border = "none"; + }; + position = "bottom"; + }; + }; + generate_hints = mkOption { + type = lib.types.submodule generateHints; + description = "The configuration for generating hints"; + default = { + normal = true; + insert = true; + extend = true; + config = { + column_count = null; + max_hint_length = 25; + }; + }; + }; + }; + }; +} diff --git a/npins/sources.json b/npins/sources.json index d6fb562f..4bbaa056 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -507,6 +507,21 @@ "url": "https://github.com/phaazon/hop.nvim/archive/1a1eceafe54b5081eae4cb91c723abd1d450f34b.tar.gz", "hash": "08h18cam2yr57qvfsnf1bra28vbl6013wlchnr5crb757xw8aysa" }, + "hydra-nvim": { + "type": "GitRelease", + "repository": { + "type": "GitHub", + "owner": "nvimtools", + "repo": "hydra.nvim" + }, + "pre_releases": false, + "version_upper_bound": null, + "release_prefix": null, + "version": "v1.0.2", + "revision": "8578056a2226ed49fc608167edc143a87f75d809", + "url": "https://api.github.com/repos/nvimtools/hydra.nvim/tarball/v1.0.2", + "hash": "13f04pmqrfl65xx9bfkdak6ll57s94anaw7nqd0fm5hp50b7c6j3" + }, "icon-picker-nvim": { "type": "Git", "repository": { @@ -1202,6 +1217,21 @@ "url": "https://github.com/mvllow/modes.nvim/archive/c7a4b1b383606832aab150902719bd5eb5cdb2b0.tar.gz", "hash": "1hy3ghscf8hfmg487p9b8cwd0y8nsi8j24kq2ir3vhd82gqhl4ja" }, + "multicursors-nvim": { + "type": "GitRelease", + "repository": { + "type": "GitHub", + "owner": "smoka7", + "repo": "multicursors.nvim" + }, + "pre_releases": false, + "version_upper_bound": null, + "release_prefix": null, + "version": "v2.0.0", + "revision": "782820896b1691ed664e4c24f1cd9793dcb33dfb", + "url": "https://api.github.com/repos/smoka7/multicursors.nvim/tarball/v2.0.0", + "hash": "171aysqsyapw434xkibxv69p5fkwha4addkqfdssdm0wq9n9cm4q" + }, "neo-tree-nvim": { "type": "Git", "repository": { From b248b5af59ffdfaf9f6fdd400a114f60718f0b31 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 22 Feb 2025 20:08:06 +0300 Subject: [PATCH 5/5] utility/multicursors: stylistic changes after #610 --- configuration.nix | 7 +- .../utility/multicursors/multicursors.nix | 68 +++++++++++-------- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/configuration.nix b/configuration.nix index 35dffca5..692337db 100644 --- a/configuration.nix +++ b/configuration.nix @@ -173,17 +173,18 @@ isMaximal: { utility = { ccc.enable = false; vim-wakatime.enable = false; - icon-picker.enable = isMaximal; - surround.enable = isMaximal; diffview-nvim.enable = true; yanky-nvim.enable = false; + icon-picker.enable = isMaximal; + surround.enable = isMaximal; leetcode-nvim.enable = isMaximal; + multicursors.enable = isMaximal; + motion = { hop.enable = true; leap.enable = true; precognition.enable = isMaximal; }; - multicursors.enable = isMaximal; images = { image-nvim.enable = false; }; diff --git a/modules/plugins/utility/multicursors/multicursors.nix b/modules/plugins/utility/multicursors/multicursors.nix index d533b8a9..5ba35daf 100644 --- a/modules/plugins/utility/multicursors/multicursors.nix +++ b/modules/plugins/utility/multicursors/multicursors.nix @@ -1,61 +1,69 @@ {lib, ...}: let - inherit (lib.types) bool int str; - inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.options) mkOption mkEnableOption; - hintConfig = {lib, ...}: { + inherit (lib.types) attrsOf nullOr bool int str submodule; + inherit (lib.nvim.types) mkPluginSetupOption; + + hintConfig = { options = { float_opts = mkOption { description = "The options for the floating hint window"; - type = lib.types.submodule { + type = submodule { options = { border = mkOption { - type = lib.types.str; + type = str; default = "none"; description = "The border style for the hint window"; }; }; }; }; + position = mkOption { - type = lib.types.str; + type = str; default = "bottom"; description = "The position of the hint window"; }; }; }; - generateHints = {lib, ...}: { + + generateHints = { options = { normal = mkOption { - type = lib.types.bool; + type = bool; + default = true; description = "Generate hints for the normal mode"; - default = true; }; + insert = mkOption { - type = lib.types.bool; + type = bool; + default = true; description = "Generate hints for the insert mode"; - default = true; }; + extend = mkOption { - type = lib.types.bool; - description = "Generate hints for the extend mode"; + type = bool; default = true; + description = "Generate hints for the extend mode"; }; + config = mkOption { description = "The configuration for generating hints for multicursors.nvim"; - type = lib.types.submodule { + type = submodule { options = { column_count = mkOption { - type = lib.types.nullOr int; - description = "The number of columns to use for the hint window"; + type = nullOr int; default = null; + description = "The number of columns to use for the hint window"; }; + max_hint_length = mkOption { type = int; - description = "The maximum length of the hint"; default = 25; + description = "The maximum length of the hint"; }; }; }; + default = { column_count = null; max_hint_length = 25; @@ -65,7 +73,7 @@ }; in { options.vim.utility.multicursors = { - enable = mkEnableOption "multicursors.nvim plugin (vscode like multiple cursors)"; + enable = mkEnableOption "vscode like multiple cursors [multicursor.nvim]"; setupOpts = mkPluginSetupOption "multicursors" { DEBUG_MODE = mkOption { @@ -73,44 +81,47 @@ in { default = false; description = "Enable debug mode."; }; + create_commands = mkOption { type = bool; default = true; description = "Create Multicursor user commands"; }; + updatetime = mkOption { type = int; default = 50; description = "The time in milliseconds to wait before updating the cursor in insert mode"; }; + nowait = mkOption { type = bool; - description = "Don't wait for the cursor to move before updating the cursor"; default = true; + description = "Don't wait for the cursor to move before updating the cursor"; }; + mode_keys = mkOption { - type = lib.types.attrsOf str; - description = "The keys to use for each mode"; + type = attrsOf str; default = { insert = "i"; append = "a"; change = "c"; extend = "e"; }; + description = "The keys to use for each mode"; }; + hint_config = mkOption { - type = lib.types.submodule hintConfig; - description = "The configuration for the hint window"; + type = submodule hintConfig; default = { - float_opts = { - border = "none"; - }; + float_opts.border = "none"; position = "bottom"; }; + description = "The configuration for the hint window"; }; + generate_hints = mkOption { - type = lib.types.submodule generateHints; - description = "The configuration for generating hints"; + type = submodule generateHints; default = { normal = true; insert = true; @@ -120,6 +131,7 @@ in { max_hint_length = 25; }; }; + description = "The configuration for generating hints"; }; }; };