replace tmux with wezterm and add smart-splits navigation to neovim
This commit is contained in:
parent
47ed2f02a9
commit
4d53c1848b
7 changed files with 198 additions and 54 deletions
|
@ -12,6 +12,7 @@
|
|||
./plugins/neo-tree.nix
|
||||
./plugins/which-key.nix
|
||||
./plugins/project-nvim.nix
|
||||
./plugins/smart-splits.nix
|
||||
./plugins/misc.nix
|
||||
];
|
||||
|
||||
|
|
|
@ -4,6 +4,5 @@
|
|||
programs.nixvim.plugins = {
|
||||
nvim-autopairs.enable = true;
|
||||
direnv.enable = true;
|
||||
tmux-navigator.enable = true;
|
||||
};
|
||||
}
|
||||
|
|
117
home/base/programs/nixvim/plugins/smart-splits.nix
Normal file
117
home/base/programs/nixvim/plugins/smart-splits.nix
Normal file
|
@ -0,0 +1,117 @@
|
|||
{
|
||||
programs.nixvim = {
|
||||
plugins.smart-splits = {
|
||||
enable = true;
|
||||
settings = {
|
||||
ignored_events = [
|
||||
"BufEnter"
|
||||
"WinEnter"
|
||||
];
|
||||
resize_mode = {
|
||||
quit_key = "<ESC>";
|
||||
resize_keys = [
|
||||
"h"
|
||||
"j"
|
||||
"k"
|
||||
"l"
|
||||
];
|
||||
silent = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
keymaps = [
|
||||
{
|
||||
action = "<cmd>lua require('smart-splits').resize_left()<CR>";
|
||||
key = "<A-h>";
|
||||
options = {
|
||||
desc = "Resize split to the left";
|
||||
};
|
||||
}
|
||||
{
|
||||
action = "<cmd>lua require('smart-splits').resize_down()<CR>";
|
||||
key = "<A-j>";
|
||||
options = {
|
||||
desc = "Resize split downwards";
|
||||
};
|
||||
}
|
||||
{
|
||||
action = "<cmd>lua require('smart-splits').resize_up()<CR>";
|
||||
key = "<A-k>";
|
||||
options = {
|
||||
desc = "Resize split upwards";
|
||||
};
|
||||
}
|
||||
{
|
||||
action = "<cmd>lua require('smart-splits').resize_right()<CR>";
|
||||
key = "<A-l>";
|
||||
options = {
|
||||
desc = "Resize split to the right";
|
||||
};
|
||||
}
|
||||
{
|
||||
action = "<cmd>lua require('smart-splits').move_cursor_left()<CR>";
|
||||
key = "<C-h>";
|
||||
options = {
|
||||
desc = "Move cursor to the left split";
|
||||
};
|
||||
}
|
||||
{
|
||||
action = "<cmd>lua require('smart-splits').move_cursor_down()<CR>";
|
||||
key = "<C-j>";
|
||||
options = {
|
||||
desc = "Move cursor to the downward split";
|
||||
};
|
||||
}
|
||||
{
|
||||
action = "<cmd>lua require('smart-splits').move_cursor_up()<CR>";
|
||||
key = "<C-k>";
|
||||
options = {
|
||||
desc = "Move cursor to the upward split";
|
||||
};
|
||||
}
|
||||
{
|
||||
action = "<cmd>lua require('smart-splits').move_cursor_right()<CR>";
|
||||
key = "<C-l>";
|
||||
options = {
|
||||
desc = "Move cursor to the right split";
|
||||
};
|
||||
}
|
||||
{
|
||||
action = "<cmd>lua require('smart-splits').move_cursor_previous()<CR>";
|
||||
key = "<C-\\>";
|
||||
options = {
|
||||
desc = "Move cursor to the previous split";
|
||||
};
|
||||
}
|
||||
{
|
||||
action = "<cmd>lua require('smart-splits').swap_buf_left()<CR>";
|
||||
key = "<leader><leader>h>";
|
||||
options = {
|
||||
desc = "Swap buffer to the left";
|
||||
};
|
||||
}
|
||||
{
|
||||
action = "<cmd>lua require('smart-splits').swap_buf_down()<CR>";
|
||||
key = "<leader><leader>j>";
|
||||
options = {
|
||||
desc = "Swap buffer downwards";
|
||||
};
|
||||
}
|
||||
{
|
||||
action = "<cmd>lua require('smart-splits').swap_buf_up()<CR>";
|
||||
key = "<leader><leader>k>";
|
||||
options = {
|
||||
desc = "Swap buffer upwards";
|
||||
};
|
||||
}
|
||||
{
|
||||
action = "<cmd>lua require('smart-splits').swap_buf_right()<CR>";
|
||||
key = "<leader><leader>l>";
|
||||
options = {
|
||||
desc = "Swap buffer to the right";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
|
@ -4,13 +4,87 @@
|
|||
programs.wezterm = {
|
||||
enable = true;
|
||||
extraConfig = ''
|
||||
local wezterm = require 'wezterm'
|
||||
local w = require('wezterm')
|
||||
|
||||
-- if you are *NOT* lazy-loading smart-splits.nvim (recommended)
|
||||
local function is_vim(pane)
|
||||
-- this is set by the plugin, and unset on ExitPre in Neovim
|
||||
return pane:get_user_vars().IS_NVIM == 'true'
|
||||
end
|
||||
|
||||
-- if you *ARE* lazy-loading smart-splits.nvim (not recommended)
|
||||
-- you have to use this instead, but note that this will not work
|
||||
-- in all cases (e.g. over an SSH connection). Also note that
|
||||
-- `pane:get_foreground_process_name()` can have high and highly variable
|
||||
-- latency, so the other implementation of `is_vim()` will be more
|
||||
-- performant as well.
|
||||
local function is_vim(pane)
|
||||
-- This gsub is equivalent to POSIX basename(3)
|
||||
-- Given "/foo/bar" returns "bar"
|
||||
-- Given "c:\\foo\\bar" returns "bar"
|
||||
local process_name = string.gsub(pane:get_foreground_process_name(), '(.*[/\\])(.*)', '%2')
|
||||
return process_name == 'nvim' or process_name == 'vim'
|
||||
end
|
||||
|
||||
local direction_keys = {
|
||||
h = 'Left',
|
||||
j = 'Down',
|
||||
k = 'Up',
|
||||
l = 'Right',
|
||||
}
|
||||
|
||||
local function split_nav(resize_or_move, key)
|
||||
return {
|
||||
key = key,
|
||||
mods = resize_or_move == 'resize' and 'META' or 'CTRL',
|
||||
action = w.action_callback(function(win, pane)
|
||||
if is_vim(pane) then
|
||||
-- pass the keys through to vim/nvim
|
||||
win:perform_action({
|
||||
SendKey = { key = key, mods = resize_or_move == 'resize' and 'META' or 'CTRL' },
|
||||
}, pane)
|
||||
else
|
||||
if resize_or_move == 'resize' then
|
||||
win:perform_action({ AdjustPaneSize = { direction_keys[key], 3 } }, pane)
|
||||
else
|
||||
win:perform_action({ ActivatePaneDirection = direction_keys[key] }, pane)
|
||||
end
|
||||
end
|
||||
end),
|
||||
}
|
||||
end
|
||||
|
||||
return {
|
||||
front_end = "WebGpu",
|
||||
enable_tab_bar = false,
|
||||
hide_tab_bar_if_only_one_tab = true,
|
||||
show_new_tab_button_in_tab_bar = false,
|
||||
enable_wayland = false,
|
||||
harfbuzz_features = { "ss01", "ss03" },
|
||||
|
||||
leader = { key = " ", mods = "CTRL", timeout_milliseconds = 1000 },
|
||||
|
||||
keys = {
|
||||
{
|
||||
mods = "LEADER",
|
||||
key = "-",
|
||||
action = wezterm.action.SplitVertical { domain = "CurrentPaneDomain" }
|
||||
},
|
||||
{
|
||||
mods = "LEADER",
|
||||
key = "=",
|
||||
action = wezterm.action.SplitHorizontal { domain = "CurrentPaneDomain" }
|
||||
},
|
||||
-- move between split panes
|
||||
split_nav('move', 'h'),
|
||||
split_nav('move', 'j'),
|
||||
split_nav('move', 'k'),
|
||||
split_nav('move', 'l'),
|
||||
-- resize panes
|
||||
split_nav('resize', 'h'),
|
||||
split_nav('resize', 'j'),
|
||||
split_nav('resize', 'k'),
|
||||
split_nav('resize', 'l'),
|
||||
},
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
./starship.nix
|
||||
./zoxide.nix
|
||||
./direnv.nix
|
||||
./tmux.nix
|
||||
./zellij.nix
|
||||
];
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ in
|
|||
fish_vi_key_bindings # Enable Vi mode
|
||||
fish_config theme choose "Catppuccin Frappe"
|
||||
'';
|
||||
shellAbbrs = { cd = "z"; ngc = "sudo nix-collect-garbage -d"; tmux = "tmux new -A -s main"; };
|
||||
shellAbbrs = { cd = "z"; ngc = "sudo nix-collect-garbage -d"; };
|
||||
plugins = [ { name = "fzf"; src = pkgs.fishPlugins.fzf.src; } ];
|
||||
};
|
||||
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
programs.tmux = {
|
||||
enable = true;
|
||||
prefix = "C-space";
|
||||
escapeTime = 10;
|
||||
clock24 = true;
|
||||
keyMode = "vi";
|
||||
mouse = true;
|
||||
baseIndex = 1;
|
||||
extraConfig = ''
|
||||
set-option -a terminal-features "''${TERM}:RGB"
|
||||
'';
|
||||
plugins = with pkgs; [
|
||||
{
|
||||
plugin = tmuxPlugins.catppuccin;
|
||||
extraConfig = ''
|
||||
set -g @catppuccin_window_left_separator ""
|
||||
set -g @catppuccin_window_right_separator " "
|
||||
set -g @catppuccin_window_middle_separator " █"
|
||||
set -g @catppuccin_window_number_position "right"
|
||||
|
||||
set -g @catppuccin_window_default_fill "number"
|
||||
set -g @catppuccin_window_default_text "#W"
|
||||
|
||||
set -g @catppuccin_window_current_fill "number"
|
||||
set -g @catppuccin_window_current_text "#W"
|
||||
|
||||
set -g @catppuccin_status_modules_right "directory user host session"
|
||||
set -g @catppuccin_status_left_separator " "
|
||||
set -g @catppuccin_status_right_separator ""
|
||||
set -g @catppuccin_status_fill "icon"
|
||||
set -g @catppuccin_status_connect_separator "no"
|
||||
|
||||
set -g @catppuccin_directory_text "#{pane_current_path}"
|
||||
|
||||
set -g @catppuccin_flavor 'frappe'
|
||||
'';
|
||||
}
|
||||
tmuxPlugins.vim-tmux-navigator
|
||||
tmuxPlugins.yank
|
||||
];
|
||||
};
|
||||
programs.fzf.tmux.enableShellIntegration = true;
|
||||
}
|
Loading…
Reference in a new issue