diff --git a/.gitignore b/.gitignore index 121ea04..5e0be38 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ result .config +.direnv diff --git a/flake.lock b/flake.lock index df4f993..abf9e2e 100644 --- a/flake.lock +++ b/flake.lock @@ -785,6 +785,7 @@ "sqls-nvim": "sqls-nvim", "telescope": "telescope", "tidalcycles": "tidalcycles", + "tmux-navigator": "tmux-navigator", "todo-comments": "todo-comments", "tokyonight": "tokyonight", "trouble": "trouble", @@ -923,6 +924,22 @@ "type": "github" } }, + "tmux-navigator": { + "flake": false, + "locked": { + "lastModified": 1673311166, + "narHash": "sha256-gF1b5aBQTNQm2hCY5aR+RSU4cCNG356Yg6uPnlgqS4o=", + "owner": "christoomey", + "repo": "vim-tmux-navigator", + "rev": "cdd66d6a37d991bba7997d593586fc51a5b37aa8", + "type": "github" + }, + "original": { + "owner": "christoomey", + "repo": "vim-tmux-navigator", + "type": "github" + } + }, "todo-comments": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index b342a9f..9ec161e 100644 --- a/flake.nix +++ b/flake.nix @@ -178,6 +178,12 @@ flake = false; }; + # tmux-navigator + tmux-navigator = { + url = "github:christoomey/vim-tmux-navigator"; + flake = false; + }; + # Rust crates crates-nvim = { url = "github:Saecki/crates.nvim"; diff --git a/modules/lib/types-plugin.nix b/modules/lib/types-plugin.nix index aabc6de..30fcebf 100644 --- a/modules/lib/types-plugin.nix +++ b/modules/lib/types-plugin.nix @@ -43,6 +43,7 @@ with lib; let "open-browser" "plantuml-syntax" "plantuml-previewer" + "tmux-navigator" ]; pluginsType = with types; listOf (nullOr (either (enum availablePlugins) package)); diff --git a/modules/modules.nix b/modules/modules.nix index 3ea7604..f9b1446 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -22,6 +22,7 @@ ./telescope ./git ./plantuml + ./tmux ]; pkgsModule = {config, ...}: { diff --git a/modules/tmux/default.nix b/modules/tmux/default.nix new file mode 100644 index 0000000..ba9ca16 --- /dev/null +++ b/modules/tmux/default.nix @@ -0,0 +1,51 @@ +{ + pkgs, + lib, + config, + ... +}: +with lib; +with builtins; let + cfg = config.vim.tmux-navigator; +in { + options.vim = { + tmux-navigator = { + enable = mkOption { + type = types.bool; + default = false; + description = "enable tmux-navigator, this plugin will only work together with tmuxPlugins.vim-tmux-navigator"; + }; + + autosave-on-leave = mkOption { + type = types.enum ["disabled" "update" "wall"]; + default = "disabled"; + description = "enable autosave when navigating to tmux"; + }; + + disable-when-zoomed = mkOption { + type = types.bool; + default = false; + description = "disable navigator when the tmux pane is zoomed"; + }; + + preserve-zoom = mkOption { + type = types.bool; + default = false; + description = "preserve zoom when moving from "; + }; + }; + }; + + config = mkIf cfg.enable { + vim.startPlugins = [ + "tmux-navigator" + ]; + + vim.configRC.tmux-navigator = nvim.dag.entryAnywhere '' + ${optionalString (cfg.autosave-on-leave == "update") "let g:tmux_navigator_save_on_switch = 1"} + ${optionalString (cfg.autosave-on-leave == "wall") "let g:tmux_navigator_save_on_switch = 2"} + ${optionalString (cfg.disable-when-zoomed) "let g:tmux_navigator_disable_when_zoomed = 1"} + ${optionalString (cfg.preserve-zoom) "let g:tmux_navigator_preserve_zoom = 1"} + ''; + }; +}