diff --git a/plugins/default.nix b/plugins/default.nix index 4b7040b9..7daf7608 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -86,6 +86,7 @@ ./utils/specs.nix ./utils/startify.nix ./utils/surround.nix + ./utils/tmux-navigator.nix ./utils/todo-comments.nix ./utils/undotree.nix ./utils/vim-bbye.nix diff --git a/plugins/utils/tmux-navigator.nix b/plugins/utils/tmux-navigator.nix new file mode 100644 index 00000000..c4539cb9 --- /dev/null +++ b/plugins/utils/tmux-navigator.nix @@ -0,0 +1,42 @@ +{ + config, + lib, + pkgs, + ... +} @ attrs: +with lib; let + cfg = config.plugins.tmux-navigator; + helpers = import ../helpers.nix {inherit lib;}; +in { + options.plugins.tmux-navigator = { + enable = mkEnableOption "Enable Tmux-Navigator (see https://github.com/christoomey/vim-tmux-navigator for tmux installation instruction)"; + + package = helpers.mkPackageOption "tmux-navigator" pkgs.vimPlugins.tmux-navigator; + + tmuxNavigatorSaveOnSwitch = helpers.mkNullOrOption (lib.types.enum [1 2]) '' + null: don't save on switch (default value) + 1: update (write the current buffer, but only if changed) + 2: wall (write all buffers) + ''; + + tmuxNavigatorDisableWhenZoomed = helpers.mkNullOrOption (lib.types.enum [1]) '' + null: unzoom when moving from Vim to another pane (default value) + 1: If the tmux window is zoomed, keep it zoomed when moving from Vim to another pane + ''; + + tmuxNavigatorNoWrap = helpers.mkNullOrOption (lib.types.enum [1]) '' + null: move past the edge of the screen, tmux/vim will wrap around to the opposite side (default value) + 1: disable wrap + ''; + }; + + config = mkIf cfg.enable { + extraPlugins = [cfg.package]; + + globals = { + tmux_navigator_save_on_switch = cfg.tmuxNavigatorSaveOnSwitch; + tmux_navigator_disable_when_zoomed = cfg.tmuxNavigatorDisableWhenZoomed; + tmux_navigator_no_wrap = cfg.tmuxNavigatorNoWrap; + }; + }; +} diff --git a/tests/test-sources/plugins/utils/tmux-navigator.nix b/tests/test-sources/plugins/utils/tmux-navigator.nix new file mode 100644 index 00000000..601bddac --- /dev/null +++ b/tests/test-sources/plugins/utils/tmux-navigator.nix @@ -0,0 +1,19 @@ +{ + # Empty configuration + empty = { + plugins.tmux-navigator.enable = true; + }; + + # Actiavte all settings + defaults = { + plugins.tmux-navigator = { + enable = true; + + tmuxNavigatorSaveOnSwitch = 2; + + tmuxNavigatorDisableWhenZoomed = 1; + + tmuxNavigatorNoWrap = 1; + }; + }; +}