diff --git a/home/common/programs/wezterm.nix b/home/common/programs/wezterm.nix deleted file mode 100644 index 3c1d976..0000000 --- a/home/common/programs/wezterm.nix +++ /dev/null @@ -1,71 +0,0 @@ -{ inputs, pkgs, ... }: -{ - programs.wezterm = { - enable = true; - package = inputs.wezterm.packages.${pkgs.system}.default; - extraConfig = '' - local w = require('wezterm') - - local function is_vim(pane) - return pane:get_user_vars().IS_NVIM == 'true' - 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 - 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 { - enable_wayland = true, - 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 = { - { - 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'), - }, - } - ''; - }; -} diff --git a/modules/default.nix b/modules/default.nix index dcf66f6..bddba9d 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -6,6 +6,7 @@ _: ./nvidia.nix ./gnome.nix ./gaming.nix + ./wezterm.nix ./stylix.nix ]; } diff --git a/modules/wezterm.nix b/modules/wezterm.nix new file mode 100644 index 0000000..c7c564f --- /dev/null +++ b/modules/wezterm.nix @@ -0,0 +1,84 @@ +{ config, lib, inputs, username, ... }: +let +cfg = config.modules.wezterm; +in +{ + options = { + modules.wezterm = { + enable = lib.mkEnableOption "enable wezterm"; + }; + }; + config = lib.mkIf cfg.enable { + home-manager.users.${username} = { + programs.wezterm = { + enable = true; + # package = inputs.wezterm.packages.${pkgs.system}.default; + extraConfig = '' + local w = require('wezterm') + + local function is_vim(pane) + return pane:get_user_vars().IS_NVIM == 'true' + 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 + 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 { + enable_wayland = false, + front_end = "WebGpu", + 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 = { + { + 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'), + }, + } + ''; + }; + }; + }; +}