2023-04-01 21:29:47 +02:00
|
|
|
-- {{{ Import stuff & create config object
|
|
|
|
local wezterm = require("wezterm")
|
2023-12-10 19:45:28 +01:00
|
|
|
local colorscheme = require("nix.colorscheme") -- injected by nix!
|
2023-04-01 21:29:47 +02:00
|
|
|
|
|
|
|
-- This table will hold the configuration.
|
|
|
|
local config = {}
|
|
|
|
|
|
|
|
-- In newer versions of wezterm, use the config_builder which will
|
|
|
|
-- help provide clearer error messages
|
|
|
|
if wezterm.config_builder then
|
|
|
|
config = wezterm.config_builder()
|
|
|
|
end
|
|
|
|
-- }}}
|
|
|
|
|
|
|
|
local font_size = 20.0
|
|
|
|
|
|
|
|
-- {{{ Theming
|
2024-04-29 15:50:59 +02:00
|
|
|
local themeMap = {
|
|
|
|
["Gruvbox light, soft"] = "Gruvbox light, soft (base16)",
|
|
|
|
["Gruvbox dark, soft"] = "Gruvbox dark, soft (base16)",
|
|
|
|
}
|
|
|
|
|
|
|
|
config.color_scheme = themeMap[colorscheme.name]
|
|
|
|
config.colors = {}
|
|
|
|
-- config.colors = wezterm.color.load_base16_scheme(colorscheme.source)
|
2023-04-01 21:29:47 +02:00
|
|
|
|
|
|
|
-- {{{ Window frame
|
|
|
|
config.window_frame = {
|
2023-12-10 19:45:28 +01:00
|
|
|
font = wezterm.font({ family = colorscheme.fonts.sansSerif }),
|
2024-04-13 22:42:29 +02:00
|
|
|
font_size = font_size - 3,
|
2024-04-27 21:38:06 +02:00
|
|
|
active_titlebar_bg = "none",
|
|
|
|
inactive_titlebar_bg = "none",
|
2024-04-13 22:42:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
config.window_padding = {
|
|
|
|
left = "1cell",
|
|
|
|
right = "1cell",
|
|
|
|
top = "0.4cell",
|
|
|
|
bottom = "0.4cell",
|
2023-04-01 21:29:47 +02:00
|
|
|
}
|
|
|
|
-- }}}
|
|
|
|
-- {{{ Tab bar colors
|
|
|
|
config.colors.tab_bar = {
|
2024-04-27 21:38:06 +02:00
|
|
|
background = "none",
|
2023-04-01 21:29:47 +02:00
|
|
|
active_tab = {
|
2024-04-13 22:42:29 +02:00
|
|
|
bg_color = colorscheme.transparency.terminal.base00,
|
|
|
|
fg_color = colorscheme.base05,
|
2023-04-01 21:29:47 +02:00
|
|
|
},
|
|
|
|
inactive_tab = {
|
2024-04-27 21:38:06 +02:00
|
|
|
bg_color = "none",
|
2023-04-01 21:29:47 +02:00
|
|
|
fg_color = colorscheme.base05,
|
|
|
|
},
|
|
|
|
inactive_tab_hover = {
|
2024-04-27 21:38:06 +02:00
|
|
|
bg_color = colorscheme.base00,
|
2023-04-01 21:29:47 +02:00
|
|
|
fg_color = colorscheme.base05,
|
|
|
|
},
|
|
|
|
new_tab = {
|
|
|
|
bg_color = colorscheme.base02,
|
|
|
|
fg_color = colorscheme.base05,
|
|
|
|
},
|
|
|
|
new_tab_hover = {
|
|
|
|
bg_color = colorscheme.base02,
|
|
|
|
fg_color = colorscheme.base05,
|
|
|
|
italic = true,
|
|
|
|
},
|
2024-04-13 22:42:29 +02:00
|
|
|
|
|
|
|
-- The color of the inactive tab bar edge/divider
|
|
|
|
inactive_tab_edge = "none",
|
2023-04-01 21:29:47 +02:00
|
|
|
}
|
|
|
|
-- }}}
|
2023-11-10 17:28:14 +01:00
|
|
|
-- {{{ Other visual things
|
2024-04-13 22:42:29 +02:00
|
|
|
config.window_background_opacity = colorscheme.transparency.terminal.value
|
2023-08-13 04:15:32 +02:00
|
|
|
-- }}}
|
2023-04-01 21:29:47 +02:00
|
|
|
-- }}}
|
|
|
|
-- {{{ Main config options
|
|
|
|
config.automatically_reload_config = true
|
2024-02-26 14:24:31 +01:00
|
|
|
config.warn_about_missing_glyphs = false
|
2023-12-10 12:55:54 +01:00
|
|
|
config.check_for_updates = false
|
2023-11-10 17:28:14 +01:00
|
|
|
|
|
|
|
-- {{{ Fonts
|
|
|
|
config.adjust_window_size_when_changing_font_size = false -- Makes it work with fixed window sizes.
|
2023-04-01 21:29:47 +02:00
|
|
|
config.font_size = font_size
|
2023-12-10 19:45:28 +01:00
|
|
|
config.font = wezterm.font(colorscheme.fonts.monospace)
|
2023-11-10 17:28:14 +01:00
|
|
|
-- }}}
|
|
|
|
-- {{{ Tab bar
|
2024-04-13 22:42:29 +02:00
|
|
|
config.tab_bar_at_bottom = false
|
2023-11-10 17:28:14 +01:00
|
|
|
config.use_fancy_tab_bar = true
|
|
|
|
config.hide_tab_bar_if_only_one_tab = true
|
2024-04-13 22:42:29 +02:00
|
|
|
config.show_tab_index_in_tab_bar = false
|
|
|
|
config.show_new_tab_button_in_tab_bar = false
|
2023-11-10 17:28:14 +01:00
|
|
|
-- }}}
|
|
|
|
-- {{{ Keycodes
|
2023-12-10 19:45:28 +01:00
|
|
|
config.disable_default_key_bindings = false
|
2023-05-18 01:56:19 +02:00
|
|
|
-- config.enable_kitty_keyboard = true -- Let's apps recognise more distinct keys
|
|
|
|
config.enable_csi_u_key_encoding = true -- For some reason I need this for all keybinds to work inside neovim.
|
|
|
|
-- }}}
|
2023-11-10 17:28:14 +01:00
|
|
|
-- }}}
|
2023-05-18 01:56:19 +02:00
|
|
|
-- {{{ Keybinds
|
2024-01-31 02:59:03 +01:00
|
|
|
local function unmap(key, mods)
|
|
|
|
return {
|
|
|
|
key = key,
|
|
|
|
mods = mods,
|
|
|
|
action = wezterm.action.DisableDefaultAssignment,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2024-02-29 12:45:25 +01:00
|
|
|
local function bind_if(cond, key, mods, action)
|
|
|
|
local function callback(win, pane)
|
|
|
|
if cond(pane) then
|
|
|
|
win:perform_action(action, pane)
|
|
|
|
else
|
|
|
|
win:perform_action(
|
|
|
|
wezterm.action.SendKey({ key = key, mods = mods }),
|
|
|
|
pane
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return { key = key, mods = mods, action = wezterm.action_callback(callback) }
|
|
|
|
end
|
|
|
|
|
|
|
|
-- {{{ Detect nvim processes
|
|
|
|
local function is_inside_vim(pane)
|
|
|
|
local tty = pane:get_tty_name()
|
|
|
|
if tty == nil then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
local success, _, _ = wezterm.run_child_process({
|
|
|
|
"sh",
|
|
|
|
"-c",
|
|
|
|
"ps -o state= -o comm= -t"
|
|
|
|
.. wezterm.shell_quote_arg(tty)
|
|
|
|
.. " | "
|
|
|
|
.. "grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?)(diff)?$'",
|
|
|
|
})
|
|
|
|
|
|
|
|
return success
|
|
|
|
end
|
|
|
|
|
|
|
|
local function is_outside_vim(pane)
|
|
|
|
return not is_inside_vim(pane)
|
|
|
|
end
|
|
|
|
-- }}}
|
|
|
|
|
2023-12-10 19:45:28 +01:00
|
|
|
config.keys = {
|
|
|
|
-- {{{ Disable certain default keybinds
|
2024-01-31 02:59:03 +01:00
|
|
|
unmap("f", "CTRL|SHIFT"),
|
|
|
|
unmap("w", "CTRL|SHIFT"),
|
|
|
|
unmap("Enter", "ALT"),
|
2023-12-10 19:45:28 +01:00
|
|
|
-- }}}
|
2024-02-29 12:45:25 +01:00
|
|
|
-- {{{ Nvim nevigation keybinds
|
|
|
|
bind_if(
|
|
|
|
is_outside_vim,
|
|
|
|
"h",
|
|
|
|
"CTRL",
|
|
|
|
wezterm.action.ActivatePaneDirection("Left")
|
|
|
|
),
|
|
|
|
bind_if(
|
|
|
|
is_outside_vim,
|
|
|
|
"j",
|
|
|
|
"CTRL",
|
|
|
|
wezterm.action.ActivatePaneDirection("Down")
|
|
|
|
),
|
|
|
|
bind_if(
|
|
|
|
is_outside_vim,
|
|
|
|
"k",
|
|
|
|
"CTRL",
|
|
|
|
wezterm.action.ActivatePaneDirection("Up")
|
|
|
|
),
|
|
|
|
bind_if(
|
|
|
|
is_outside_vim,
|
|
|
|
"l",
|
|
|
|
"CTRL",
|
|
|
|
wezterm.action.ActivatePaneDirection("Right")
|
|
|
|
),
|
|
|
|
-- }}}
|
2023-12-10 19:45:28 +01:00
|
|
|
}
|
2023-04-01 21:29:47 +02:00
|
|
|
-- }}}
|
|
|
|
|
|
|
|
-- and finally, return the configuration to wezterm
|
|
|
|
return config
|