Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Tingelöf committed Oct 1, 2024
1 parent 3889218 commit a59f290
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 5 deletions.
1 change: 1 addition & 0 deletions templates/helix/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
theme = "onedark"
"ui.selection" = { bg = "#64005c" }

[keys.normal."+"]
m = ":run-shell-command make"
Expand Down
58 changes: 53 additions & 5 deletions templates/wezterm/wezterm.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,56 @@
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 } },
mods = mods,
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({
Expand Down Expand Up @@ -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",
Expand All @@ -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 } }) },
Expand All @@ -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 = {
{
Expand Down

0 comments on commit a59f290

Please sign in to comment.