diff --git a/config/wezterm/wezterm.lua b/config/wezterm/wezterm.lua index 10dfc4e..ecdd0f1 100644 --- a/config/wezterm/wezterm.lua +++ b/config/wezterm/wezterm.lua @@ -11,6 +11,46 @@ if wezterm.config_builder then config = wezterm.config_builder() end +local function isViProcess(pane) + -- get_foreground_process_name On Linux, macOS and Windows, + -- the process can be queried to determine this path. Other operating systems + -- (notably, FreeBSD and other unix systems) are not currently supported + return pane:get_foreground_process_name():find('n?vim') ~= nil + -- return pane:get_title():find("n?vim") ~= nil +end + +local function conditionalActivatePane(window, pane, pane_direction, vim_direction) + if isViProcess(pane) then + window:perform_action( + -- This should match the keybinds you set in Neovim. + act.SendKey({ key = vim_direction, mods = 'ALT' }), + pane + ) + else + window:perform_action(act.ActivatePaneDirection(pane_direction), pane) + end +end + +wezterm.on('ActivatePaneDirection-right', function(window, pane) + conditionalActivatePane(window, pane, 'Right', 'l') +end) +wezterm.on('ActivatePaneDirection-left', function(window, pane) + conditionalActivatePane(window, pane, 'Left', 'h') +end) +wezterm.on('ActivatePaneDirection-up', function(window, pane) + conditionalActivatePane(window, pane, 'Up', 'k') +end) +wezterm.on('ActivatePaneDirection-down', function(window, pane) + conditionalActivatePane(window, pane, 'Down', 'j') +end) + +-- Do not check for or show window with update information +config.check_for_updates = false +config.show_update_window = false + +-- Set our default shell to hilbish +config.default_prog = { 'hilbish' } + -- Font config.font = wezterm.font 'Fira Code' config.font_size = 10.0 @@ -18,12 +58,20 @@ config.font_size = 10.0 -- Color scheme config.color_scheme = 'gruvbox_material_dark_hard' +-- Padding +config.window_padding = { + left = 20, + right = 20, + top = 20, + bottom = 0, +} + -- Tab bar appearance -config.use_fancy_tab_bar = false -config.enable_tab_bar = true +config.use_fancy_tab_bar = false +config.enable_tab_bar = true config.hide_tab_bar_if_only_one_tab = false -config.tab_bar_at_bottom = true -config.tab_max_width = 24 +config.tab_bar_at_bottom = true +config.tab_max_width = 24 -- Colors config.colors = { @@ -53,86 +101,27 @@ config.colors = { -- Key Assignments config.disable_default_key_bindings = true config.keys = { - { - key = 'v', - mods = 'ALT', - action = wezterm.action.SplitVertical { domain = 'CurrentPaneDomain' }, - }, + -- Tabs + { key = 't', mods = 'ALT', action = act.SpawnTab 'CurrentPaneDomain' }, + { key = 'w', mods = "ALT|CTRL", action = act.CloseCurrentTab { confirm = false } }, - { - key = 'h', - mods = 'ALT', - action = wezterm.action.SplitHorizontal { domain = 'CurrentPaneDomain' }, - }, + -- Panes + { key = 'v', mods = 'ALT', action = act.SplitVertical { domain = 'CurrentPaneDomain' } }, + { key = 'h', mods = 'ALT', action = act.SplitHorizontal { domain = 'CurrentPaneDomain' } }, + { key = 'x', mods = "ALT", action = act.CloseCurrentPane { confirm = false } }, + -- Navigation + { key = 'LeftArrow', mods = 'ALT', action = act.EmitEvent('ActivatePaneDirection-left' ) }, + { key = 'DownArrow', mods = 'ALT', action = act.EmitEvent('ActivatePaneDirection-down' ) }, + { key = 'UpArrow', mods = 'ALT', action = act.EmitEvent('ActivatePaneDirection-up' ) }, + { key = 'RightArrow', mods = 'ALT', action = act.EmitEvent('ActivatePaneDirection-right') }, - { - key = 'Tab', - mods = 'ALT', - action = wezterm.action.SplitPane { - direction = 'Down', - size = { Percent = 20 }, - }, - }, - - { - key = 'Backspace', - mods = 'ALT', - action = wezterm.action.CloseCurrentPane { confirm = false }, - }, - - { key = 'LeftArrow', - mods = 'ALT', - action = act.ActivatePaneDirection 'Left', - }, - - { - key = 'RightArrow', - mods = 'ALT', - action = act.ActivatePaneDirection 'Right', - }, - - { - key = 'UpArrow', - mods = 'ALT', - action = act.ActivatePaneDirection 'Up', - }, - - { - key = 'DownArrow', - mods = 'ALT', - action = act.ActivatePaneDirection 'Down', - }, - - { - key = 't', - mods = 'ALT', - action = act.SpawnTab 'CurrentPaneDomain', - }, - - { - key = 'w', - mods = "ALT|CTRL", - action = wezterm.action.CloseCurrentTab { confirm = false }, - }, - - { - key = 'X', - mods = 'CTRL', - action = wezterm.action.ActivateCopyMode, - }, - - { - key = 'C', - mods = 'CTRL', - action = wezterm.action.CopyTo 'ClipboardAndPrimarySelection', - }, - - { - key = 'V', - mods = 'CTRL', - action = act.PasteFrom 'Clipboard', - }, + -- Clipboard + { key = 'X', mods = 'CTRL', action = act.ActivateCopyMode }, + { key = 'C', mods = 'CTRL', action = act.CopyTo 'ClipboardAndPrimarySelection' }, + { key = 'V', mods = 'CTRL', action = act.PasteFrom 'Clipboard' }, } + +-- Bind tabs to number keys for i = 1, 5 do table.insert(config.keys, { key = tostring(i), @@ -141,13 +130,5 @@ for i = 1, 5 do }) end --- Padding -config.window_padding = { - left = 20, - right = 20, - top = 20, - bottom = 0, -} - return config