From d1063519b55b1fab4f1e23ebf5a7849d5527745b Mon Sep 17 00:00:00 2001 From: Alejandro Angulo Date: Wed, 29 Mar 2023 19:56:27 -0700 Subject: [PATCH] Added tmux and neovim bar integration --- modules/apps/neovim/default.nix | 9 ++++ modules/apps/neovim/theme | 21 ++++++++++ modules/apps/neovim/tmux_theme | 21 ++++++++++ modules/apps/tmux/default.nix | 74 ++++++++++++++++++--------------- modules/home/default.nix | 6 +++ 5 files changed, 98 insertions(+), 33 deletions(-) create mode 100644 modules/apps/neovim/theme create mode 100644 modules/apps/neovim/tmux_theme diff --git a/modules/apps/neovim/default.nix b/modules/apps/neovim/default.nix index 346642c..eeb1fd2 100644 --- a/modules/apps/neovim/default.nix +++ b/modules/apps/neovim/default.nix @@ -10,11 +10,20 @@ with lib; let in { options.aa.apps.neovim = with types; { enable = mkEnableOption "neovim"; + + tmuxThemePath = mkOption { + type = str; + default = "vim-tmuxline/tmux_theme"; + description = "Where to store tmux theme generated by vim-tmuxline"; + }; }; config = mkIf cfg.enable { environment.systemPackages = with pkgs; [fzf fd]; + aa.home.dataFile = { + ${cfg.tmuxThemePath}.source = ./tmux_theme; + }; aa.home.extraOptions = { programs.neovim = { enable = true; diff --git a/modules/apps/neovim/theme b/modules/apps/neovim/theme new file mode 100644 index 0000000..bacd15a --- /dev/null +++ b/modules/apps/neovim/theme @@ -0,0 +1,21 @@ +# This tmux statusbar config was created by tmuxline.vim +# on Wed, 29 Mar 2023 + +set -g status-justify "left" +set -g status "on" +set -g status-left-style "none" +set -g message-command-style "fg=#a89984,bg=#504945" +set -g status-right-style "none" +set -g pane-active-border-style "fg=#504945" +set -g status-style "none,bg=#32302f" +set -g message-style "fg=#a89984,bg=#504945" +set -g pane-border-style "fg=#32302f" +set -g status-right-length "100" +set -g status-left-length "100" +setw -g window-status-activity-style "none" +setw -g window-status-separator "" +setw -g window-status-style "none,fg=#928374,bg=#32302f" +set -g status-left "#[fg=#928374,bg=#32302f] #S #[fg=#32302f,bg=#32302f,nobold,nounderscore,noitalics]" +set -g status-right "#[fg=#32302f,bg=#32302f,nobold,nounderscore,noitalics]#[fg=#928374,bg=#32302f] %Y-%m-%d  %H:%M #[fg=#32302f,bg=#32302f,nobold,nounderscore,noitalics]#[fg=#928374,bg=#32302f] #h " +setw -g window-status-format "#[fg=#928374,bg=#32302f] #I #[fg=#928374,bg=#32302f] #W " +setw -g window-status-current-format "#[fg=#32302f,bg=#504945,nobold,nounderscore,noitalics]#[fg=#a89984,bg=#504945] #I #[fg=#a89984,bg=#504945] #W #[fg=#504945,bg=#32302f,nobold,nounderscore,noitalics]" diff --git a/modules/apps/neovim/tmux_theme b/modules/apps/neovim/tmux_theme new file mode 100644 index 0000000..bacd15a --- /dev/null +++ b/modules/apps/neovim/tmux_theme @@ -0,0 +1,21 @@ +# This tmux statusbar config was created by tmuxline.vim +# on Wed, 29 Mar 2023 + +set -g status-justify "left" +set -g status "on" +set -g status-left-style "none" +set -g message-command-style "fg=#a89984,bg=#504945" +set -g status-right-style "none" +set -g pane-active-border-style "fg=#504945" +set -g status-style "none,bg=#32302f" +set -g message-style "fg=#a89984,bg=#504945" +set -g pane-border-style "fg=#32302f" +set -g status-right-length "100" +set -g status-left-length "100" +setw -g window-status-activity-style "none" +setw -g window-status-separator "" +setw -g window-status-style "none,fg=#928374,bg=#32302f" +set -g status-left "#[fg=#928374,bg=#32302f] #S #[fg=#32302f,bg=#32302f,nobold,nounderscore,noitalics]" +set -g status-right "#[fg=#32302f,bg=#32302f,nobold,nounderscore,noitalics]#[fg=#928374,bg=#32302f] %Y-%m-%d  %H:%M #[fg=#32302f,bg=#32302f,nobold,nounderscore,noitalics]#[fg=#928374,bg=#32302f] #h " +setw -g window-status-format "#[fg=#928374,bg=#32302f] #I #[fg=#928374,bg=#32302f] #W " +setw -g window-status-current-format "#[fg=#32302f,bg=#504945,nobold,nounderscore,noitalics]#[fg=#a89984,bg=#504945] #I #[fg=#a89984,bg=#504945] #W #[fg=#504945,bg=#32302f,nobold,nounderscore,noitalics]" diff --git a/modules/apps/tmux/default.nix b/modules/apps/tmux/default.nix index 7274bd7..38f4104 100644 --- a/modules/apps/tmux/default.nix +++ b/modules/apps/tmux/default.nix @@ -7,6 +7,7 @@ }: with lib; let cfg = config.aa.apps.tmux; + user_cfg = config.home-manager.users.${config.aa.user.name}; in { options.aa.apps.tmux = with types; { enable = mkEnableOption "tmux"; @@ -35,45 +36,52 @@ in { vim-tmux-navigator ]; - extraConfig = '' - # Color fix - # set-option -ga terminal-overrides ",alacritty:Tc,xterm-256color:Tc" + extraConfig = + '' + # Color fix + # set-option -ga terminal-overrides ",alacritty:Tc,xterm-256color:Tc" - # Scrolling with mouse wheel scrolls output instead of previous commands - setw -g mouse on + # Scrolling with mouse wheel scrolls output instead of previous commands + setw -g mouse on - # Open panes in the same directory - bind c new-window -c "#{pane_current_path}" - bind '"' split-window -c "#{pane_current_path}" - bind % split-window -h -c "#{pane_current_path}" + # Open panes in the same directory + bind c new-window -c "#{pane_current_path}" + bind '"' split-window -c "#{pane_current_path}" + bind % split-window -h -c "#{pane_current_path}" - # Eye Candy - # set -g @plugin 'mattdavis90/base16-tmux' - # set -g @colors-base16 'darktooth' + # Eye Candy + # set -g @plugin 'mattdavis90/base16-tmux' + # set -g @colors-base16 'darktooth' - # Integration with tmuxline.vim - source-file ~/theme + # Smart pane switching with awareness of Vim splits. + # See: https://github.com/christoomey/vim-tmux-navigator + is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ + | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?\\.?g?(view|n?vim?x?)(-wrapped)?(diff)?$'" + bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L' + bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D' + bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U' + bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R' + tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")' + if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \ + "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'" + if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \ + "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'" - # Smart pane switching with awareness of Vim splits. - # See: https://github.com/christoomey/vim-tmux-navigator - is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ - | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?\\.?g?(view|n?vim?x?)(-wrapped)?(diff)?$'" - bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L' - bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D' - bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U' - bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R' - tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")' - if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \ - "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'" - if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \ - "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'" + bind-key -T copy-mode-vi 'C-h' select-pane -L + bind-key -T copy-mode-vi 'C-j' select-pane -D + bind-key -T copy-mode-vi 'C-k' select-pane -U + bind-key -T copy-mode-vi 'C-l' select-pane -R + bind-key -T copy-mode-vi 'C-\' select-pane -l + '' + + ( + if config.aa.apps.neovim.enable + then '' - bind-key -T copy-mode-vi 'C-h' select-pane -L - bind-key -T copy-mode-vi 'C-j' select-pane -D - bind-key -T copy-mode-vi 'C-k' select-pane -U - bind-key -T copy-mode-vi 'C-l' select-pane -R - bind-key -T copy-mode-vi 'C-\' select-pane -l - ''; + # Integration with tmuxline.vim + source-file ${user_cfg.xdg.dataHome}/${config.aa.apps.neovim.tmuxThemePath} + '' + else "" + ); }; }; }; diff --git a/modules/home/default.nix b/modules/home/default.nix index 1609c2d..637f035 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -24,6 +24,11 @@ in { default = {}; description = "A set of files to be managed by home-manager's ."; }; + dataFile = mkOption { + type = attrs; + default = {}; + description = "A set of files to be managed by home-manager's ."; + }; extraOptions = mkOption { type = attrs; default = {}; @@ -37,6 +42,7 @@ in { home.file = mkAliasDefinitions options.aa.home.file; xdg.enable = true; xdg.configFile = mkAliasDefinitions options.aa.home.configFile; + xdg.dataFile = mkAliasDefinitions options.aa.home.dataFile; }; home-manager = {