Added tmux and neovim bar integration

This commit is contained in:
Alejandro Angulo 2023-03-29 19:56:27 -07:00
parent 7b1a711969
commit d1063519b5
Signed by: alejandro-angulo
GPG key ID: 75579581C74554B6
5 changed files with 98 additions and 33 deletions

View file

@ -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;

21
modules/apps/neovim/theme Normal file
View file

@ -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]"

View file

@ -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]"

View file

@ -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 ""
);
};
};
};

View file

@ -24,6 +24,11 @@ in {
default = {};
description = "A set of files to be managed by home-manager's <option>xdg.configFile</option>.";
};
dataFile = mkOption {
type = attrs;
default = {};
description = "A set of files to be managed by home-manager's <option>xdg.dataFile</option>.";
};
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 = {