From b23382ee8e152e80f1b1fb56d665c5eb27b491a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 28 Apr 2023 08:11:44 +0200 Subject: [PATCH 1/2] feat(tmux): add keybinds option --- modules/profiles/base.nix | 13 +++++++++++++ modules/programs/tmux.nix | 28 ++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/modules/profiles/base.nix b/modules/profiles/base.nix index 6f2fb3f..e2d4b4b 100644 --- a/modules/profiles/base.nix +++ b/modules/profiles/base.nix @@ -64,6 +64,19 @@ in gpg.enable = true; navi.enable = true; tmux.enable = true; + tmux.keybinds = { + prefix = { + "-" = "split-window -v"; + "|" = "split-window -h"; + "C-l" = "send-keys C-l"; + "R" = "source-file $XDG_CONFIG_HOME/tmux/tmux.conf \\; display-message 'Reloaded tmux.conf'"; + }; + copy-mode-vi = { + "v" = "send -X begin-selection"; + "V" = "send -X select-line"; + "C-v" = "send -X rectangle-toggle"; + }; + }; }; }; diff --git a/modules/programs/tmux.nix b/modules/programs/tmux.nix index aba543a..00e91ed 100644 --- a/modules/programs/tmux.nix +++ b/modules/programs/tmux.nix @@ -9,7 +9,7 @@ let runtimeInputs = with pkgs; [ tmux findutils coreutils procps fd ]; text = '' #!/usr/bin/env bash - + options=$(fd -HIg '.git' ~/ --min-depth 1 --max-depth 5 --type d --prune --exec dirname {} | fzf --filter "''$*") if [[ -z $options ]]; then @@ -43,6 +43,22 @@ in options.my.programs.tmux = { enable = mkEnableOption "tmux"; autoAttach = mkEnableOption "autoAttach"; + keybinds = mkOption { + type = with types; attrsOf (attrsOf string); + default = { }; + description = "Keybinds for tmux"; + example = literalExample '' + { + prefix = { + "-" = "split-window -v"; + "|" = "split-window -h"; + }; + copy-mode-vi = { + "v" = "send -X begin-selection"; + }; + } + ''; + }; }; config = mkIf cfg.enable { @@ -64,6 +80,15 @@ in tmux-fzf yank ]; + extraConfig = + let + mkKeybind = table: mapAttrsToList (keybind: value: "bind-key -T ${table} '${keybind}' ${value}"); + keybinds = flatten (mapAttrsToList mkKeybind cfg.keybinds); + in + '' + # Keybinds + ${concatStringsSep "\n" keybinds} + ''; }; fzf.tmux.enableShellIntegration = true; fish.interactiveShellInit = @@ -80,7 +105,6 @@ in end end ''; - }; }; } From 35ddc6a33ccc4e1335fe508a053f1f99e4341809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 28 Apr 2023 08:12:15 +0200 Subject: [PATCH 2/2] feat: add tmux-vim-navigator --- modules/programs/nvim/default.nix | 1 + modules/programs/nvim/keybinds.lua | 8 -------- modules/programs/tmux.nix | 1 + 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/modules/programs/nvim/default.nix b/modules/programs/nvim/default.nix index 101343f..092636b 100644 --- a/modules/programs/nvim/default.nix +++ b/modules/programs/nvim/default.nix @@ -88,6 +88,7 @@ in promise-async vim-fugitive vim-lion + vim-tmux-navigator ] ++ pluginsWithConfig; }; }; diff --git a/modules/programs/nvim/keybinds.lua b/modules/programs/nvim/keybinds.lua index 0556448..d792a37 100644 --- a/modules/programs/nvim/keybinds.lua +++ b/modules/programs/nvim/keybinds.lua @@ -26,14 +26,6 @@ require("which-key").register({ }, }) --- fast window move -require("which-key").register({ - [""] = { "h", "Move window left" }, - [""] = { "j", "Move window down" }, - [""] = { "k", "Move window up" }, - [""] = { "l", "Move window right" }, -}) - -- tab require("which-key").register({ [""] = { diff --git a/modules/programs/tmux.nix b/modules/programs/tmux.nix index 00e91ed..912f7ad 100644 --- a/modules/programs/tmux.nix +++ b/modules/programs/tmux.nix @@ -78,6 +78,7 @@ in plugins = with pkgs.tmuxPlugins; [ sensible tmux-fzf + vim-tmux-navigator yank ]; extraConfig =