style(wezterm): reformat with stylua

This commit is contained in:
winston 2023-01-04 13:22:00 +01:00
parent 56ba8771a3
commit 8670166cba
Signed by: winston
GPG key ID: 3786770EDBC2B481
4 changed files with 271 additions and 186 deletions

View file

@ -50,80 +50,86 @@ end
-- custom tab bar
---@diagnostic disable-next-line: unused-local
wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_width)
local colours = config.resolved_palette.tab_bar
wezterm.on(
"format-tab-title",
function(tab, tabs, panes, config, hover, max_width)
local colours = config.resolved_palette.tab_bar
local active_tab_index = 0
for _, t in ipairs(tabs) do
if t.is_active == true then
active_tab_index = t.tab_index
local active_tab_index = 0
for _, t in ipairs(tabs) do
if t.is_active == true then
active_tab_index = t.tab_index
end
end
end
local rainbow = {
config.resolved_palette.ansi[2],
config.resolved_palette.indexed[16],
config.resolved_palette.ansi[4],
config.resolved_palette.ansi[3],
config.resolved_palette.ansi[5],
config.resolved_palette.ansi[6]
}
local rainbow = {
config.resolved_palette.ansi[2],
config.resolved_palette.indexed[16],
config.resolved_palette.ansi[4],
config.resolved_palette.ansi[3],
config.resolved_palette.ansi[5],
config.resolved_palette.ansi[6],
}
local i = (tab.tab_index) % 6
local active_bg = rainbow[i + 1]
local active_fg = colours.background
local inactive_bg = colours.inactive_tab.bg_color
local inactive_fg = colours.inactive_tab.fg_color
local new_tab_bg = colours.new_tab.bg_color
local i = tab.tab_index % 6
local active_bg = rainbow[i + 1]
local active_fg = colours.background
local inactive_bg = colours.inactive_tab.bg_color
local inactive_fg = colours.inactive_tab.fg_color
local new_tab_bg = colours.new_tab.bg_color
local s_bg, s_fg, e_bg, e_fg
local s_bg, s_fg, e_bg, e_fg
-- the last tab
if tab.tab_index == #tabs - 1 then
if tab.is_active then
-- the last tab
if tab.tab_index == #tabs - 1 then
if tab.is_active then
s_bg = active_bg
s_fg = active_fg
e_bg = new_tab_bg
e_fg = active_bg
else
s_bg = inactive_bg
s_fg = inactive_fg
e_bg = new_tab_bg
e_fg = inactive_bg
end
elseif tab.tab_index == active_tab_index - 1 then
s_bg = inactive_bg
s_fg = inactive_fg
e_bg = rainbow[(i + 1) % 6 + 1]
e_fg = inactive_bg
elseif tab.is_active then
s_bg = active_bg
s_fg = active_fg
e_bg = new_tab_bg
e_bg = inactive_bg
e_fg = active_bg
else
s_bg = inactive_bg
s_fg = inactive_fg
e_bg = new_tab_bg
e_bg = inactive_bg
e_fg = inactive_bg
end
elseif tab.tab_index == active_tab_index - 1 then
s_bg = inactive_bg
s_fg = inactive_fg
e_bg = rainbow[(i + 1) % 6 + 1]
e_fg = inactive_bg
elseif tab.is_active then
s_bg = active_bg
s_fg = active_fg
e_bg = inactive_bg
e_fg = active_bg
else
s_bg = inactive_bg
s_fg = inactive_fg
e_bg = inactive_bg
e_fg = inactive_bg
local tabi = wezterm.mux.get_tab(tab.tab_id)
local muxpanes = tabi:panes()
local count = #muxpanes == 1 and "" or #muxpanes
local index = tab.tab_index + 1 .. ": "
return {
{ Background = { Color = s_bg } },
{ Foreground = { Color = s_fg } },
{
Text = " " .. index .. tab.active_pane.title .. numberStyle(
count,
"superscript"
) .. " ",
},
{ Background = { Color = e_bg } },
{ Foreground = { Color = e_fg } },
{ Text = DIVIDERS.RIGHT },
}
end
local tabi = wezterm.mux.get_tab(tab.tab_id)
local muxpanes = tabi:panes()
local count = #muxpanes == 1 and "" or #muxpanes
local index = tab.tab_index + 1 .. ": "
return {
{ Background = { Color = s_bg } },
{ Foreground = { Color = s_fg } },
{
Text = " " .. index .. tab.active_pane.title .. numberStyle(count, "superscript") .. " ",
},
{ Background = { Color = e_bg } },
{ Foreground = { Color = e_fg } },
{ Text = DIVIDERS.RIGHT },
}
end)
)
local function arrContains(arr, val)
for _, v in ipairs(arr) do
@ -139,10 +145,17 @@ local nonpadded_apps = { "nvim", "btop", "btm" }
wezterm.on("smartpadding", function(window, pane)
local fgp = pane:get_foreground_process_info()
if fgp == nil then return
if fgp == nil then
return
elseif arrContains(nonpadded_apps, fgp.name) then
window:set_config_overrides({ window_padding = { left = 0, right = 0, top = 0, bottom = 0 } })
else window:set_config_overrides({ window_padding = wezterm.GLOBAL.smart_padding }) end
window:set_config_overrides({
window_padding = { left = 0, right = 0, top = 0, bottom = 0 },
})
else
window:set_config_overrides({
window_padding = wezterm.GLOBAL.smart_padding,
})
end
end)
-- custom status
@ -156,9 +169,12 @@ wezterm.on("update-status", function(window, pane)
local first_tab_active = window:mux_window():tabs_with_info()[1].is_active
local leader_text = ""
if window:leader_is_active() then leader_text = "" end
if window:leader_is_active() then
leader_text = ""
end
local divider_bg = first_tab_active and palette.ansi[2] or palette.tab_bar.inactive_tab.bg_color
local divider_bg = first_tab_active and palette.ansi[2]
or palette.tab_bar.inactive_tab.bg_color
window:set_left_status(wezterm.format({
{ Foreground = { Color = palette.background } },

View file

@ -0,0 +1,7 @@
column_width = 80
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferDouble"
collapse_simple_statement = "Never"
call_parentheses = "Always"

View file

@ -2,116 +2,178 @@ local wezterm = require("wezterm")
local act = wezterm.action
return {
-- use 'Backslash' to split horizontally
{
key = "\\",
mods = "LEADER",
action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }),
},
-- and 'Minus' to split vertically
{
key = "-",
mods = "LEADER",
action = act.SplitVertical({ domain = "CurrentPaneDomain" }),
},
-- 'hjkl' to move between panes
{ key = "h", mods = "LEADER", action = act.ActivatePaneDirection("Left")},
{ key = "j", mods = "LEADER", action = act.ActivatePaneDirection("Down")},
{ key = "k", mods = "LEADER", action = act.ActivatePaneDirection("Up") },
{ key = "l", mods = "LEADER", action = act.ActivatePaneDirection("Right") },
-- -- Shift + 'hjkl' to resize panes
{ key = "h", mods = "LEADER|SHIFT", action = act.AdjustPaneSize({"Left", 5}) },
{ key = "j", mods = "LEADER|SHIFT", action = act.AdjustPaneSize({"Down", 5}) },
{ key = "k", mods = "LEADER|SHIFT", action = act.AdjustPaneSize({"Up", 5}) },
{ key = "l", mods = "LEADER|SHIFT", action = act.AdjustPaneSize({"Right", 5}) },
-- numbers to navigate to tabs
{ key = "1", mods = "LEADER", action = act.ActivateTab(0) },
{ key = "2", mods = "LEADER", action = act.ActivateTab(1) },
{ key = "3", mods = "LEADER", action = act.ActivateTab(2) },
{ key = "4", mods = "LEADER", action = act.ActivateTab(3) },
{ key = "5", mods = "LEADER", action = act.ActivateTab(4) },
{ key = "6", mods = "LEADER", action = act.ActivateTab(5) },
{ key = "7", mods = "LEADER", action = act.ActivateTab(6) },
{ key = "8", mods = "LEADER", action = act.ActivateTab(7) },
{ key = "9", mods = "LEADER", action = act.ActivateTab(8) },
{ key = "9", mods = "LEADER", action = act.ActivateTab(9) },
{ key = "0", mods = "LEADER", action = act.ActivateTab(-1) },
{ key = "1", mods = "SUPER", action = act.ActivateTab(0) },
{ key = "2", mods = "SUPER", action = act.ActivateTab(1) },
{ key = "3", mods = "SUPER", action = act.ActivateTab(2) },
{ key = "4", mods = "SUPER", action = act.ActivateTab(3) },
{ key = "5", mods = "SUPER", action = act.ActivateTab(4) },
{ key = "6", mods = "SUPER", action = act.ActivateTab(5) },
{ key = "7", mods = "SUPER", action = act.ActivateTab(6) },
{ key = "8", mods = "SUPER", action = act.ActivateTab(7) },
{ key = "9", mods = "SUPER", action = act.ActivateTab(8) },
{ key = "9", mods = "SUPER", action = act.ActivateTab(9) },
{ key = "0", mods = "SUPER", action = act.ActivateTab(-1) },
-- 'c' to create a new tab
{ key = "c", mods = "LEADER", action = act.SpawnTab("CurrentPaneDomain") },
-- 'x' to kill the current pane
{ key = "x", mods = "LEADER", action = act.CloseCurrentPane({ confirm = true }) },
-- 'z' to toggle the zoom for the current pane
{ key = "z", mods = "LEADER", action = "TogglePaneZoomState" },
-- 'v' to visually select in the current pane
{ key = "v", mods = "LEADER", action = "ActivateCopyMode" },
-- 'r' to rotate panes
{ key = "r", mods = "LEADER", action = act.RotatePanes("Clockwise") },
{ key = " ", mods = "LEADER", action = act.QuickSelect },
{
key = "o",
mods = "LEADER",
action = act.QuickSelectArgs({
label = "open url",
patterns = {
"https?://\\S+",
},
action = wezterm.action_callback(function(window, pane)
local url = window:get_selection_text_for_pane(pane)
wezterm.open_with(url)
end),
}),
},
-- copypasta
{ key = "Enter", mods = "ALT", action = act.ToggleFullScreen },
-- use 'Backslash' to split horizontally
{
key = "\\",
mods = "LEADER",
action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }),
},
-- and 'Minus' to split vertically
{
key = "-",
mods = "LEADER",
action = act.SplitVertical({ domain = "CurrentPaneDomain" }),
},
-- 'hjkl' to move between panes
{ key = "h", mods = "LEADER", action = act.ActivatePaneDirection("Left") },
{ key = "j", mods = "LEADER", action = act.ActivatePaneDirection("Down") },
{ key = "k", mods = "LEADER", action = act.ActivatePaneDirection("Up") },
{ key = "l", mods = "LEADER", action = act.ActivatePaneDirection("Right") },
-- -- Shift + 'hjkl' to resize panes
{
key = "h",
mods = "LEADER|SHIFT",
action = act.AdjustPaneSize({ "Left", 5 }),
},
{
key = "j",
mods = "LEADER|SHIFT",
action = act.AdjustPaneSize({ "Down", 5 }),
},
{
key = "k",
mods = "LEADER|SHIFT",
action = act.AdjustPaneSize({ "Up", 5 }),
},
{
key = "l",
mods = "LEADER|SHIFT",
action = act.AdjustPaneSize({ "Right", 5 }),
},
-- numbers to navigate to tabs
{ key = "1", mods = "LEADER", action = act.ActivateTab(0) },
{ key = "2", mods = "LEADER", action = act.ActivateTab(1) },
{ key = "3", mods = "LEADER", action = act.ActivateTab(2) },
{ key = "4", mods = "LEADER", action = act.ActivateTab(3) },
{ key = "5", mods = "LEADER", action = act.ActivateTab(4) },
{ key = "6", mods = "LEADER", action = act.ActivateTab(5) },
{ key = "7", mods = "LEADER", action = act.ActivateTab(6) },
{ key = "8", mods = "LEADER", action = act.ActivateTab(7) },
{ key = "9", mods = "LEADER", action = act.ActivateTab(8) },
{ key = "9", mods = "LEADER", action = act.ActivateTab(9) },
{ key = "0", mods = "LEADER", action = act.ActivateTab(-1) },
{ key = "1", mods = "SUPER", action = act.ActivateTab(0) },
{ key = "2", mods = "SUPER", action = act.ActivateTab(1) },
{ key = "3", mods = "SUPER", action = act.ActivateTab(2) },
{ key = "4", mods = "SUPER", action = act.ActivateTab(3) },
{ key = "5", mods = "SUPER", action = act.ActivateTab(4) },
{ key = "6", mods = "SUPER", action = act.ActivateTab(5) },
{ key = "7", mods = "SUPER", action = act.ActivateTab(6) },
{ key = "8", mods = "SUPER", action = act.ActivateTab(7) },
{ key = "9", mods = "SUPER", action = act.ActivateTab(8) },
{ key = "9", mods = "SUPER", action = act.ActivateTab(9) },
{ key = "0", mods = "SUPER", action = act.ActivateTab(-1) },
-- 'c' to create a new tab
{ key = "c", mods = "LEADER", action = act.SpawnTab("CurrentPaneDomain") },
-- 'x' to kill the current pane
{
key = "x",
mods = "LEADER",
action = act.CloseCurrentPane({ confirm = true }),
},
-- 'z' to toggle the zoom for the current pane
{ key = "z", mods = "LEADER", action = "TogglePaneZoomState" },
-- 'v' to visually select in the current pane
{ key = "v", mods = "LEADER", action = "ActivateCopyMode" },
-- 'r' to rotate panes
{ key = "r", mods = "LEADER", action = act.RotatePanes("Clockwise") },
{ key = " ", mods = "LEADER", action = act.QuickSelect },
{
key = "o",
mods = "LEADER",
action = act.QuickSelectArgs({
label = "open url",
patterns = {
"https?://\\S+",
},
action = wezterm.action_callback(function(window, pane)
local url = window:get_selection_text_for_pane(pane)
wezterm.open_with(url)
end),
}),
},
-- copypasta
{ key = "Enter", mods = "ALT", action = act.ToggleFullScreen },
{ key = "-", mods = "CTRL", action = act.DecreaseFontSize },
{ key = "-", mods = "SUPER", action = act.DecreaseFontSize },
{ key = "=", mods = "CTRL", action = act.IncreaseFontSize },
{ key = "=", mods = "SUPER", action = act.IncreaseFontSize },
{ key = "0", mods = "CTRL", action = act.ResetFontSize },
{ key = "0", mods = "SUPER", action = act.ResetFontSize },
{ key = "-", mods = "CTRL", action = act.DecreaseFontSize },
{ key = "-", mods = "SUPER", action = act.DecreaseFontSize },
{ key = "=", mods = "CTRL", action = act.IncreaseFontSize },
{ key = "=", mods = "SUPER", action = act.IncreaseFontSize },
{ key = "0", mods = "CTRL", action = act.ResetFontSize },
{ key = "0", mods = "SUPER", action = act.ResetFontSize },
{ key = "c", mods = "SHIFT|CTRL", action = act.CopyTo("Clipboard") },
{ key = "c", mods = "SUPER", action = act.CopyTo("Clipboard") },
{ key = "v", mods = "SHIFT|CTRL", action = act.PasteFrom("Clipboard") },
{ key = "v", mods = "SUPER", action = act.PasteFrom("Clipboard") },
{ key = "c", mods = "SHIFT|CTRL", action = act.CopyTo("Clipboard") },
{ key = "c", mods = "SUPER", action = act.CopyTo("Clipboard") },
{ key = "v", mods = "SHIFT|CTRL", action = act.PasteFrom("Clipboard") },
{ key = "v", mods = "SUPER", action = act.PasteFrom("Clipboard") },
{ key = "f", mods = "SHIFT|CTRL", action = act.Search("CurrentSelectionOrEmptyString") },
{ key = "f", mods = "SUPER", action = act.Search("CurrentSelectionOrEmptyString") },
{
key = "f",
mods = "SHIFT|CTRL",
action = act.Search("CurrentSelectionOrEmptyString"),
},
{
key = "f",
mods = "SUPER",
action = act.Search("CurrentSelectionOrEmptyString"),
},
{ key = "l", mods = "SHIFT|CTRL", action = act.ShowDebugOverlay },
{ key = "l", mods = "SHIFT|CTRL", action = act.ShowDebugOverlay },
{ key = "p", mods = "LEADER", action = act.PaneSelect({ alphabet = "asdfghjkl;", mode = "Activate" }) },
{ key = "P", mods = "LEADER", action = act.PaneSelect({ alphabet = "asdfghjkl;", mode = "SwapWithActive" }) },
{
key = "p",
mods = "LEADER",
action = act.PaneSelect({ alphabet = "asdfghjkl;", mode = "Activate" }),
},
{
key = "P",
mods = "LEADER",
action = act.PaneSelect({
alphabet = "asdfghjkl;",
mode = "SwapWithActive",
}),
},
{ key = "p", mods = "SUPER", action = act.PaneSelect({ alphabet = "asdfghjkl;", mode = "Activate" }) },
{ key = "P", mods = "SUPER", action = act.PaneSelect({ alphabet = "asdfghjkl;", mode = "SwapWithActive" }) },
{ key = "R", mods = "LEADER", action = act.ReloadConfiguration },
{
key = "p",
mods = "SUPER",
action = act.PaneSelect({ alphabet = "asdfghjkl;", mode = "Activate" }),
},
{
key = "P",
mods = "SUPER",
action = act.PaneSelect({
alphabet = "asdfghjkl;",
mode = "SwapWithActive",
}),
},
{ key = "R", mods = "LEADER", action = act.ReloadConfiguration },
-- mostly OS defaults
{ key = "n", mods = "SHIFT|CTRL", action = act.SpawnWindow },
{ key = "n", mods = "SUPER", action = act.SpawnWindow },
{ key = "t", mods = "SHIFT|CTRL", action = act.SpawnTab("CurrentPaneDomain") },
{ key = "t", mods = "SUPER", action = act.SpawnTab("CurrentPaneDomain") },
{ key = "w", mods = "SHIFT|CTRL", action = act.CloseCurrentTab({ confirm = true }) },
{ key = "w", mods = "SUPER", action = act.CloseCurrentTab({ confirm = true }) },
{
key = "u",
mods = "SHIFT|CTRL",
action = act.CharSelect({
copy_on_select = true,
copy_to = "ClipboardAndPrimarySelection",
}),
},
-- mostly OS defaults
{ key = "n", mods = "SHIFT|CTRL", action = act.SpawnWindow },
{ key = "n", mods = "SUPER", action = act.SpawnWindow },
{
key = "t",
mods = "SHIFT|CTRL",
action = act.SpawnTab("CurrentPaneDomain"),
},
{ key = "t", mods = "SUPER", action = act.SpawnTab("CurrentPaneDomain") },
{
key = "w",
mods = "SHIFT|CTRL",
action = act.CloseCurrentTab({ confirm = true }),
},
{
key = "w",
mods = "SUPER",
action = act.CloseCurrentTab({ confirm = true }),
},
{
key = "u",
mods = "SHIFT|CTRL",
action = act.CharSelect({
copy_on_select = true,
copy_to = "ClipboardAndPrimarySelection",
}),
},
}

View file

@ -3,31 +3,31 @@ local wezterm = require("wezterm")
local M = {}
M.scheme_for_appearance = function(appearance, theme)
if string.match(wezterm.target_triple, "linux") then
return theme.dark
end
if appearance:find("Dark") then
return theme.dark
else
return theme.light
end
if string.match(wezterm.target_triple, "linux") then
return theme.dark
end
if appearance:find("Dark") then
return theme.dark
else
return theme.light
end
end
M.get_custom_colorschemes = function()
local oledppuccin = wezterm.color.get_builtin_schemes()["Catppuccin Mocha"]
oledppuccin.background = "#000000"
oledppuccin.tab_bar.background = "#040404"
oledppuccin.tab_bar.inactive_tab.bg_color = "#0f0f0f"
oledppuccin.tab_bar.new_tab.bg_color = "#080808"
local oledppuccin = wezterm.color.get_builtin_schemes()["Catppuccin Mocha"]
oledppuccin.background = "#000000"
oledppuccin.tab_bar.background = "#040404"
oledppuccin.tab_bar.inactive_tab.bg_color = "#0f0f0f"
oledppuccin.tab_bar.new_tab.bg_color = "#080808"
oledppuccin.ansi[6] = "#c6a0f6"
local latte = wezterm.color.get_builtin_schemes()["Catppuccin Latte"]
local latte = wezterm.color.get_builtin_schemes()["Catppuccin Latte"]
latte.ansi[6] = "#8839ef"
return {
["OLEDppuccin"] = oledppuccin,
return {
["OLEDppuccin"] = oledppuccin,
["Catppuccin Latte"] = latte,
}
}
end
return M