This commit is contained in:
♥ Minnie ♥ 2023-04-18 02:20:50 +08:00
parent c413d72684
commit 529d55e239

View file

@ -11,6 +11,46 @@ if wezterm.config_builder then
config = wezterm.config_builder() config = wezterm.config_builder()
end 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 -- Font
config.font = wezterm.font 'Fira Code' config.font = wezterm.font 'Fira Code'
config.font_size = 10.0 config.font_size = 10.0
@ -18,6 +58,14 @@ config.font_size = 10.0
-- Color scheme -- Color scheme
config.color_scheme = 'gruvbox_material_dark_hard' config.color_scheme = 'gruvbox_material_dark_hard'
-- Padding
config.window_padding = {
left = 20,
right = 20,
top = 20,
bottom = 0,
}
-- Tab bar appearance -- Tab bar appearance
config.use_fancy_tab_bar = false config.use_fancy_tab_bar = false
config.enable_tab_bar = true config.enable_tab_bar = true
@ -53,86 +101,27 @@ config.colors = {
-- Key Assignments -- Key Assignments
config.disable_default_key_bindings = true config.disable_default_key_bindings = true
config.keys = { config.keys = {
{ -- Tabs
key = 'v', { key = 't', mods = 'ALT', action = act.SpawnTab 'CurrentPaneDomain' },
mods = 'ALT', { key = 'w', mods = "ALT|CTRL", action = act.CloseCurrentTab { confirm = false } },
action = wezterm.action.SplitVertical { domain = 'CurrentPaneDomain' },
},
{ -- Panes
key = 'h', { key = 'v', mods = 'ALT', action = act.SplitVertical { domain = 'CurrentPaneDomain' } },
mods = 'ALT', { key = 'h', mods = 'ALT', action = act.SplitHorizontal { domain = 'CurrentPaneDomain' } },
action = wezterm.action.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') },
{ -- Clipboard
key = 'Tab', { key = 'X', mods = 'CTRL', action = act.ActivateCopyMode },
mods = 'ALT', { key = 'C', mods = 'CTRL', action = act.CopyTo 'ClipboardAndPrimarySelection' },
action = wezterm.action.SplitPane { { key = 'V', mods = 'CTRL', action = act.PasteFrom 'Clipboard' },
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',
},
} }
-- Bind tabs to number keys
for i = 1, 5 do for i = 1, 5 do
table.insert(config.keys, { table.insert(config.keys, {
key = tostring(i), key = tostring(i),
@ -141,13 +130,5 @@ for i = 1, 5 do
}) })
end end
-- Padding
config.window_padding = {
left = 20,
right = 20,
top = 20,
bottom = 0,
}
return config return config