forked from mrjones2014/smart-splits.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
58 lines (50 loc) · 2.61 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# this flake installs tmux and sets up a basic tmux config for testing the plugin integration
{
inputs = {
nixpkgs = { url = "github:nixos/nixpkgs/nixos-unstable"; };
flake-utils = { url = "github:numtide/flake-utils"; };
};
outputs = { nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
tmux_conf = pkgs.writeText "tmux.conf" ''
# Smart pane switching with awareness of Vim splits.
bind-key -n C-h if -F "#{@pane-is-vim}" 'send-keys C-h' 'select-pane -L'
bind-key -n C-j if -F "#{@pane-is-vim}" 'send-keys C-j' 'select-pane -D'
bind-key -n C-k if -F "#{@pane-is-vim}" 'send-keys C-k' 'select-pane -U'
bind-key -n C-l if -F "#{@pane-is-vim}" 'send-keys C-l' 'select-pane -R'
bind-key -n M-h if -F "#{@pane-is-vim}" 'send-keys M-h' 'resize-pane -L 3'
bind-key -n M-j if -F "#{@pane-is-vim}" 'send-keys M-j' 'resize-pane -D 3'
bind-key -n M-k if -F "#{@pane-is-vim}" 'send-keys M-k' 'resize-pane -U 3'
bind-key -n M-l if -F "#{@pane-is-vim}" 'send-keys M-l' 'resize-pane -R 3'
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 -F \"#{@pane-is-vim}\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if -F \"#{@pane-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
# split panes using | and -
bind | split-window -h -l 75 -c '#{pane_current_path}'
bind - split-window -v -l 25 -c '#{pane_current_path}'
# Make undercurls work properly in Neovim
# Undercurl support
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'
# Underscore colours - needs tmux-3.0
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
'';
in {
devShells.default = pkgs.mkShell {
name = "shell with tmux";
packages = with pkgs; [ tmux stylua luajitPackages.luacheck ];
shellHook = ''
alias tmux="tmux -f ${tmux_conf}"
alias :q="exit"
'';
};
});
}