tmux: format using nixfmt

This commit is contained in:
Robert Helgesson 2021-10-31 10:24:01 +01:00
parent e377556818
commit 34327e067f
No known key found for this signature in database
GPG Key ID: 36BDAA14C2797E89
2 changed files with 52 additions and 60 deletions

1
format
View File

@ -29,7 +29,6 @@ find . -name '*.nix' \
! -path ./modules/programs/bash.nix \ ! -path ./modules/programs/bash.nix \
! -path ./modules/programs/gpg.nix \ ! -path ./modules/programs/gpg.nix \
! -path ./modules/programs/ssh.nix \ ! -path ./modules/programs/ssh.nix \
! -path ./modules/programs/tmux.nix \
! -path ./modules/programs/zsh.nix \ ! -path ./modules/programs/zsh.nix \
! -path ./modules/services/gpg-agent.nix \ ! -path ./modules/services/gpg-agent.nix \
! -path ./modules/services/mpd.nix \ ! -path ./modules/services/mpd.nix \

View File

@ -23,11 +23,11 @@ let
}; };
}; };
defaultKeyMode = "emacs"; defaultKeyMode = "emacs";
defaultResize = 5; defaultResize = 5;
defaultShortcut = "b"; defaultShortcut = "b";
defaultTerminal = "screen"; defaultTerminal = "screen";
defaultShell = null; defaultShell = null;
boolToStr = value: if value then "on" else "off"; boolToStr = value: if value then "on" else "off";
@ -56,7 +56,8 @@ let
set -g status-keys ${cfg.keyMode} set -g status-keys ${cfg.keyMode}
set -g mode-keys ${cfg.keyMode} set -g mode-keys ${cfg.keyMode}
${optionalString (cfg.keyMode == "vi" && cfg.customPaneNavigationAndResize) '' ${optionalString
(cfg.keyMode == "vi" && cfg.customPaneNavigationAndResize) ''
bind h select-pane -L bind h select-pane -L
bind j select-pane -D bind j select-pane -D
bind k select-pane -U bind k select-pane -U
@ -68,21 +69,19 @@ let
bind -r L resize-pane -R ${toString cfg.resizeAmount} bind -r L resize-pane -R ${toString cfg.resizeAmount}
''} ''}
${if cfg.prefix != null ${if cfg.prefix != null then ''
then '' # rebind main key: ${cfg.prefix}
# rebind main key: ${cfg.prefix} unbind C-${defaultShortcut}
unbind C-${defaultShortcut} set -g prefix ${cfg.prefix}
set -g prefix ${cfg.prefix} bind ${cfg.prefix} send-prefix
bind ${cfg.prefix} send-prefix '' else
'' optionalString (cfg.shortcut != defaultShortcut) ''
else optionalString (cfg.shortcut != defaultShortcut) '' # rebind main key: C-${cfg.shortcut}
# rebind main key: C-${cfg.shortcut} unbind C-${defaultShortcut}
unbind C-${defaultShortcut} set -g prefix C-${cfg.shortcut}
set -g prefix C-${cfg.shortcut} bind ${cfg.shortcut} send-prefix
bind ${cfg.shortcut} send-prefix bind C-${cfg.shortcut} last-window
bind C-${cfg.shortcut} last-window ''}
''
}
${optionalString cfg.disableConfirmationPrompt '' ${optionalString cfg.disableConfirmationPrompt ''
bind-key & kill-window bind-key & kill-window
@ -96,18 +95,16 @@ let
''; '';
configPlugins = { configPlugins = {
assertions = [( assertions = [
let (let
hasBadPluginName = p: !(hasPrefix "tmuxplugin" (pluginName p)); hasBadPluginName = p: !(hasPrefix "tmuxplugin" (pluginName p));
badPlugins = filter hasBadPluginName cfg.plugins; badPlugins = filter hasBadPluginName cfg.plugins;
in in {
{ assertion = badPlugins == [ ];
assertion = badPlugins == []; message = ''Invalid tmux plugin (not prefixed with "tmuxplugins"): ''
message = + concatMapStringsSep ", " pluginName badPlugins;
"Invalid tmux plugin (not prefixed with \"tmuxplugins\"): " })
+ concatMapStringsSep ", " pluginName badPlugins; ];
}
)];
xdg.configFile."tmux/tmux.conf".text = '' xdg.configFile."tmux/tmux.conf".text = ''
# ============================================= # # ============================================= #
@ -115,21 +112,16 @@ let
# --------------------------------------------- # # --------------------------------------------- #
${(concatMapStringsSep "\n\n" (p: '' ${(concatMapStringsSep "\n\n" (p: ''
# ${pluginName p} # ${pluginName p}
# --------------------- # ---------------------
${p.extraConfig or ""} ${p.extraConfig or ""}
run-shell ${ run-shell ${if types.package.check p then p.rtp else p.plugin.rtp}
if types.package.check p
then p.rtp
else p.plugin.rtp
}
'') cfg.plugins)} '') cfg.plugins)}
# ============================================= # # ============================================= #
''; '';
}; };
in
{ in {
options = { options = {
programs.tmux = { programs.tmux = {
aggressiveResize = mkOption { aggressiveResize = mkOption {
@ -180,7 +172,7 @@ in
description = '' description = ''
Time in milliseconds for which tmux waits after an escape is Time in milliseconds for which tmux waits after an escape is
input. input.
''; '';
}; };
extraConfig = mkOption { extraConfig = mkOption {
@ -294,8 +286,9 @@ in
plugins = mkOption { plugins = mkOption {
type = with types; type = with types;
listOf (either package pluginModule) listOf (either package pluginModule) // {
// { description = "list of plugin packages or submodules"; }; description = "list of plugin packages or submodules";
};
description = '' description = ''
List of tmux plugins to be included at the end of your tmux List of tmux plugins to be included at the end of your tmux
configuration. The sensible plugin, however, is defaulted to configuration. The sensible plugin, however, is defaulted to
@ -322,22 +315,22 @@ in
}; };
}; };
config = mkIf cfg.enable ( config = mkIf cfg.enable (mkMerge ([
mkMerge ([ {
{ home.packages = [ cfg.package ]
home.packages = [ cfg.package ] ++ optional cfg.tmuxinator.enable pkgs.tmuxinator
++ optional cfg.tmuxinator.enable pkgs.tmuxinator ++ optional cfg.tmuxp.enable pkgs.tmuxp;
++ optional cfg.tmuxp.enable pkgs.tmuxp; }
}
(mkIf cfg.secureSocket {
home.sessionVariables = {
TMUX_TMPDIR = ''''${XDG_RUNTIME_DIR:-"/run/user/\$(id -u)"}'';
};
})
{ xdg.configFile."tmux/tmux.conf".text = mkBefore tmuxConf; } { xdg.configFile."tmux/tmux.conf".text = mkBefore tmuxConf; }
(mkIf (cfg.plugins != []) configPlugins) { xdg.configFile."tmux/tmux.conf".text = mkAfter cfg.extraConfig; }
{ xdg.configFile."tmux/tmux.conf".text = mkAfter cfg.extraConfig; }
]) (mkIf cfg.secureSocket {
); home.sessionVariables = {
TMUX_TMPDIR = ''''${XDG_RUNTIME_DIR:-"/run/user/\$(id -u)"}'';
};
})
(mkIf (cfg.plugins != [ ]) configPlugins)
]));
} }