flocon/home/common/programs/wezterm.nix

73 lines
2.2 KiB
Nix
Raw Normal View History

2024-09-05 13:58:14 +00:00
{ inputs, pkgs, ... }:
{
programs.wezterm = {
enable = true;
2024-09-05 13:58:14 +00:00
package = inputs.wezterm.packages.${pkgs.system}.default;
extraConfig = ''
2024-09-05 13:58:14 +00:00
local w = require('wezterm')
2024-09-05 13:58:14 +00:00
local function is_vim(pane)
return pane:get_user_vars().IS_NVIM == 'true'
end
2024-09-05 13:58:14 +00:00
local direction_keys = {
h = 'Left',
j = 'Down',
k = 'Up',
l = 'Right',
}
2024-09-05 13:58:14 +00:00
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
win:perform_action({
SendKey = { key = key, mods = resize_or_move == 'resize' and 'META' or 'CTRL' },
}, pane)
else
2024-09-05 13:58:14 +00:00
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
2024-09-05 13:58:14 +00:00
end),
}
end
2024-09-05 13:58:14 +00:00
return {
2024-08-29 15:29:07 +00:00
front_end = "WebGpu",
enable_wayland = false,
hide_tab_bar_if_only_one_tab = true,
show_new_tab_button_in_tab_bar = false,
harfbuzz_features = { "ss01", "ss03" },
leader = { key = " ", mods = "CTRL", timeout_milliseconds = 1000 },
keys = {
2024-09-05 13:58:14 +00:00
{
mods = "LEADER",
key = "-",
action = wezterm.action.SplitVertical { domain = "CurrentPaneDomain" }
},
{
mods = "LEADER",
key = "=",
action = wezterm.action.SplitHorizontal { domain = "CurrentPaneDomain" }
},
split_nav('move', 'h'),
split_nav('move', 'j'),
split_nav('move', 'k'),
split_nav('move', 'l'),
split_nav('resize', 'h'),
split_nav('resize', 'j'),
split_nav('resize', 'k'),
split_nav('resize', 'l'),
},
2024-09-05 13:58:14 +00:00
}
'';
};
}