diff --git a/templates/helix/config.toml b/templates/helix/config.toml index 6d3b302..171b05b 100644 --- a/templates/helix/config.toml +++ b/templates/helix/config.toml @@ -1,4 +1,5 @@ theme = "onedark" +"ui.selection" = { bg = "#64005c" } [keys.normal."+"] m = ":run-shell-command make" diff --git a/templates/wezterm/wezterm.lua b/templates/wezterm/wezterm.lua index 429f6aa..6d3b7c5 100644 --- a/templates/wezterm/wezterm.lua +++ b/templates/wezterm/wezterm.lua @@ -1,6 +1,8 @@ local wezterm = require("wezterm") local act = wezterm.action +local M = {} + local function make_mouse_binding(dir, streak, button, mods, action) return { event = { [dir] = { streak = streak, button = button } }, @@ -8,6 +10,47 @@ local function make_mouse_binding(dir, streak, button, mods, action) action = action, } end +---@param resize_or_move "resize" | "move" +---@param mods string +---@param key string +---@param dir "Right" | "Left" | "Up" | "Down" +function M.split_nav(resize_or_move, mods, key, dir) + local event = "SplitNav_" .. resize_or_move .. "_" .. dir + wezterm.on(event, function(win, pane) + if M.is_nvim(pane) then + -- pass the keys through to vim/nvim + win:perform_action({ SendKey = { key = key, mods = mods } }, pane) + else + if resize_or_move == "resize" then + win:perform_action({ AdjustPaneSize = { dir, 3 } }, pane) + else + local panes = pane:tab():panes_with_info() + local is_zoomed = false + for _, p in ipairs(panes) do + if p.is_zoomed then + is_zoomed = true + end + end + wezterm.log_info("is_zoomed: " .. tostring(is_zoomed)) + if is_zoomed then + dir = dir == "Up" or dir == "Right" and "Next" or "Prev" + wezterm.log_info("dir: " .. dir) + end + win:perform_action({ ActivatePaneDirection = dir }, pane) + win:perform_action({ SetPaneZoomState = is_zoomed }, pane) + end + end + end) + return { + key = key, + mods = mods, + action = wezterm.action.EmitEvent(event), + } +end + +function M.is_nvim(pane) + return pane:get_user_vars().IS_NVIM == "true" or pane:get_foreground_process_name():find("n?vim") +end return { font = wezterm.font_with_fallback({ @@ -52,7 +95,7 @@ return { tab_max_width = 50, disable_default_key_bindings = false, window_close_confirmation = "NeverPrompt", - selection_word_boundary = " \t\n*?_-.[]~=&;!#$%^(){}<>\"'", + selection_word_boundary = " \t\n{[}]():,\"'", keys = { { key = "s", @@ -72,10 +115,10 @@ return { mods = "ALT", action = wezterm.action({ ClearScrollback = "ScrollbackAndViewport" }), }, - { key = "LeftArrow", mods = "ALT", action = wezterm.action({ ActivatePaneDirection = "Left" }) }, - { key = "DownArrow", mods = "ALT", action = wezterm.action({ ActivatePaneDirection = "Down" }) }, - { key = "UpArrow", mods = "ALT", action = wezterm.action({ ActivatePaneDirection = "Up" }) }, - { key = "RightArrow", mods = "ALT", action = wezterm.action({ ActivatePaneDirection = "Right" }) }, + -- { key = "LeftArrow", mods = "ALT", action = wezterm.action({ ActivatePaneDirection = "Left" }) }, + -- { key = "DownArrow", mods = "ALT", action = wezterm.action({ ActivatePaneDirection = "Down" }) }, + -- { key = "UpArrow", mods = "ALT", action = wezterm.action({ ActivatePaneDirection = "Up" }) }, + -- { key = "RightArrow", mods = "ALT", action = wezterm.action({ ActivatePaneDirection = "Right" }) }, { key = "LeftArrow", mods = "ALT|SHIFT", action = wezterm.action({ AdjustPaneSize = { "Left", 5 } }) }, { key = "DownArrow", mods = "ALT|SHIFT", action = wezterm.action({ AdjustPaneSize = { "Down", 5 } }) }, { key = "UpArrow", mods = "ALT|SHIFT", action = wezterm.action({ AdjustPaneSize = { "Up", 5 } }) }, @@ -101,6 +144,11 @@ return { { key = "z", mods = "ALT", action = wezterm.action.TogglePaneZoomState }, { key = "n", mods = "CTRL|SHIFT", action = act.RotatePanes("Clockwise") }, { key = "w", mods = "ALT", action = wezterm.action.CloseCurrentPane({ confirm = true }) }, + + M.split_nav("move", "ALT", "LeftArrow", "Left"), + M.split_nav("move", "ALT", "DownArrow", "Down"), + M.split_nav("move", "ALT", "UpArrow", "Up"), + M.split_nav("move", "ALT", "RightArrow", "Right"), }, hyperlink_rules = { {