From d6d569c53e52e6122161159f179bdd789b438d61 Mon Sep 17 00:00:00 2001 From: Laszlo Bacsi Date: Mon, 16 Jun 2025 13:56:46 +0200 Subject: [PATCH 1/2] utility/smart-splits: init --- configuration.nix | 1 + docs/release-notes/rl-0.8.md | 5 ++ modules/plugins/utility/default.nix | 1 + .../plugins/utility/smart-splits/config.nix | 51 +++++++++++++++++++ .../plugins/utility/smart-splits/default.nix | 6 +++ .../utility/smart-splits/smart-splits.nix | 37 ++++++++++++++ 6 files changed, 101 insertions(+) create mode 100644 modules/plugins/utility/smart-splits/config.nix create mode 100644 modules/plugins/utility/smart-splits/default.nix create mode 100644 modules/plugins/utility/smart-splits/smart-splits.nix diff --git a/configuration.nix b/configuration.nix index 2995fee8..6f26f040 100644 --- a/configuration.nix +++ b/configuration.nix @@ -191,6 +191,7 @@ isMaximal: { surround.enable = isMaximal; leetcode-nvim.enable = isMaximal; multicursors.enable = isMaximal; + smart-splits.enable = isMaximal; motion = { hop.enable = true; diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 979586ac..a1a967ff 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -431,5 +431,10 @@ [lackac](https://github.com/lackac): [solarized.nvim]: https://github.com/maxmx03/solarized.nvim +[smart-splits.nvim]: https://github.com/mrjones2014/smart-splits.nvim - Add [solarized.nvim] theme with support for multiple variants + +- Add [smart-splits.nvim] for navigating between Neovim windows and terminal multiplexer panes. + Available at `vim.utility.smart-splits`. + diff --git a/modules/plugins/utility/default.nix b/modules/plugins/utility/default.nix index e3ae7c5e..8069b6c1 100644 --- a/modules/plugins/utility/default.nix +++ b/modules/plugins/utility/default.nix @@ -19,6 +19,7 @@ ./outline ./preview ./sleuth + ./smart-splits ./snacks-nvim ./surround ./telescope diff --git a/modules/plugins/utility/smart-splits/config.nix b/modules/plugins/utility/smart-splits/config.nix new file mode 100644 index 00000000..552bc7ac --- /dev/null +++ b/modules/plugins/utility/smart-splits/config.nix @@ -0,0 +1,51 @@ +{ + pkgs, + config, + options, + lib, + ... +}: let + inherit (lib.modules) mkIf; + + cfg = config.vim.utility.smart-splits; + inherit (options.vim.utility.smart-splits) keymaps; + mkSmartSplitKey = act: let + key = cfg.keymaps.${act}; + in + lib.optional (key != null) { + inherit key; + desc = keymaps.${act}.description; + action = ''function() require('smart-splits').${act}() end''; + mode = "n"; + lua = true; + }; +in { + config = mkIf cfg.enable { + vim.lazy.plugins = { + ${pkgs.vimPlugins.smart-splits-nvim.pname} = { + package = pkgs.vimPlugins.smart-splits-nvim; + setupModule = "smart-splits"; + inherit (cfg) setupOpts; + + # plugin needs to be loaded right after startup so that the multiplexer detects vim running in the pane + event = ["DeferredUIEnter"]; + + keys = lib.flatten [ + (mkSmartSplitKey "resize_left") + (mkSmartSplitKey "resize_down") + (mkSmartSplitKey "resize_up") + (mkSmartSplitKey "resize_right") + (mkSmartSplitKey "move_cursor_left") + (mkSmartSplitKey "move_cursor_down") + (mkSmartSplitKey "move_cursor_up") + (mkSmartSplitKey "move_cursor_right") + (mkSmartSplitKey "move_cursor_previous") + (mkSmartSplitKey "swap_buf_left") + (mkSmartSplitKey "swap_buf_down") + (mkSmartSplitKey "swap_buf_up") + (mkSmartSplitKey "swap_buf_right") + ]; + }; + }; + }; +} diff --git a/modules/plugins/utility/smart-splits/default.nix b/modules/plugins/utility/smart-splits/default.nix new file mode 100644 index 00000000..a994da8f --- /dev/null +++ b/modules/plugins/utility/smart-splits/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./config.nix + ./smart-splits.nix + ]; +} diff --git a/modules/plugins/utility/smart-splits/smart-splits.nix b/modules/plugins/utility/smart-splits/smart-splits.nix new file mode 100644 index 00000000..dd5c55a3 --- /dev/null +++ b/modules/plugins/utility/smart-splits/smart-splits.nix @@ -0,0 +1,37 @@ +{lib, ...}: let + inherit (lib.options) mkOption; + inherit (lib.types) bool; + inherit (lib.nvim.types) mkPluginSetupOption; + inherit (lib.nvim.binds) mkMappingOption; +in { + options.vim.utility.smart-splits = { + enable = mkOption { + type = bool; + default = false; + description = '' + Whether to enable smart-splits.nvim, a Neovim plugin for smart, + seamless, directional navigation and resizing of splits. + + Supports tmux, Wezterm, Kitty, and Zellij multiplexer integrations. + ''; + }; + + setupOpts = mkPluginSetupOption "smart-splits" {}; + + keymaps = { + resize_left = mkMappingOption "Resize Window/Pane Left" ""; + resize_down = mkMappingOption "Resize Window/Pane Down" ""; + resize_up = mkMappingOption "Resize Window/Pane Up" ""; + resize_right = mkMappingOption "Resize Window/Pane Right" ""; + move_cursor_left = mkMappingOption "Focus Window/Pane on the Left" ""; + move_cursor_down = mkMappingOption "Focus Window/Pane Below" ""; + move_cursor_up = mkMappingOption "Focus Window/Pane Above" ""; + move_cursor_right = mkMappingOption "Focus Window/Pane on the Right" ""; + move_cursor_previous = mkMappingOption "Focus Previous Window/Pane" ""; + swap_buf_left = mkMappingOption "Swap Buffer Left" "h"; + swap_buf_down = mkMappingOption "Swap Buffer Down" "j"; + swap_buf_up = mkMappingOption "Swap Buffer Up" "k"; + swap_buf_right = mkMappingOption "Swap Buffer Right" "l"; + }; + }; +} From 8483a6de972586ff661916cd6faba667da3e4ce7 Mon Sep 17 00:00:00 2001 From: Laszlo Bacsi Date: Mon, 16 Jun 2025 21:13:43 +0200 Subject: [PATCH 2/2] utility/smart-splits: get plugin from github instead of nixpkgs --- modules/plugins/utility/smart-splits/config.nix | 6 +++--- modules/plugins/utility/smart-splits/default.nix | 2 +- npins/sources.json | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/modules/plugins/utility/smart-splits/config.nix b/modules/plugins/utility/smart-splits/config.nix index 552bc7ac..c175d7ac 100644 --- a/modules/plugins/utility/smart-splits/config.nix +++ b/modules/plugins/utility/smart-splits/config.nix @@ -21,9 +21,9 @@ }; in { config = mkIf cfg.enable { - vim.lazy.plugins = { - ${pkgs.vimPlugins.smart-splits-nvim.pname} = { - package = pkgs.vimPlugins.smart-splits-nvim; + vim = { + lazy.plugins.smart-splits = { + package = "smart-splits"; setupModule = "smart-splits"; inherit (cfg) setupOpts; diff --git a/modules/plugins/utility/smart-splits/default.nix b/modules/plugins/utility/smart-splits/default.nix index a994da8f..2b38462e 100644 --- a/modules/plugins/utility/smart-splits/default.nix +++ b/modules/plugins/utility/smart-splits/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./smart-splits.nix diff --git a/npins/sources.json b/npins/sources.json index b5d796c4..455e1bd6 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -2232,6 +2232,22 @@ "url": "https://github.com/mrcjkb/rustaceanvim/archive/a0c8e9698ef90bcfdf42806a38bf55b612b65b18.tar.gz", "hash": "1j63qpal1n8m9kj3fdjjw81ljbsqjzph65q2cacwm5ziwi2xvncx" }, + "smart-splits": { + "type": "GitRelease", + "repository": { + "type": "GitHub", + "owner": "mrjones2014", + "repo": "smart-splits.nvim" + }, + "pre_releases": false, + "version_upper_bound": null, + "release_prefix": null, + "submodules": false, + "version": "v2.0.1", + "revision": "7c9bc1cfc0582c8c6851c38bb3338db644039cf7", + "url": "https://api.github.com/repos/mrjones2014/smart-splits.nvim/tarball/v2.0.1", + "hash": "0lhwkb07pdfi7dx9kbzynh0dxivhiryngkiy4565hyhxapfis5v7" + }, "smartcolumn-nvim": { "type": "Git", "repository": {