From 9253604fdb7fd9b79e0479babf3413bf63606299 Mon Sep 17 00:00:00 2001 From: Oscar Wallberg Date: Mon, 5 May 2025 16:35:07 +0200 Subject: [PATCH] fix(wezterm): format lua code --- .config/wezterm/bindings.lua | 165 +++++++++++++++++++++++++---------- .config/wezterm/colors.lua | 75 ++++++++-------- .config/wezterm/events.lua | 35 ++++---- .config/wezterm/fonts.lua | 15 ++-- .config/wezterm/wezterm.lua | 3 +- stylua.toml | 10 +++ 6 files changed, 192 insertions(+), 111 deletions(-) create mode 100644 stylua.toml diff --git a/.config/wezterm/bindings.lua b/.config/wezterm/bindings.lua index 574fca2..f7aa60b 100644 --- a/.config/wezterm/bindings.lua +++ b/.config/wezterm/bindings.lua @@ -1,59 +1,59 @@ -local wezterm = require 'wezterm' +local wezterm = require("wezterm") local act = wezterm.action local M = {} M.keys = { - { key = 'Enter', mods = 'ALT', action = act.ToggleFullScreen }, - { key = '=', mods = 'CTRL', action = act.IncreaseFontSize }, - { key = '-', mods = 'CTRL', action = act.DecreaseFontSize }, - { key = '0', mods = 'CTRL', action = act.ResetFontSize }, - { key = 'C', mods = 'SHIFT|CTRL', action = act.CopyTo("Clipboard") }, - { key = 'V', mods = 'SHIFT|CTRL', action = act.PasteFrom("Clipboard") }, - { key = 'P', mods = 'SHIFT|CTRL', action = act.ActivateCommandPalette }, - { key = 'R', mods = 'SHIFT|CTRL', action = act.ReloadConfiguration }, - { key = 'F12', mods = 'NONE', action = act.ShowDebugOverlay }, + { key = "Enter", mods = "ALT", action = act.ToggleFullScreen }, + { key = "=", mods = "CTRL", action = act.IncreaseFontSize }, + { key = "-", mods = "CTRL", action = act.DecreaseFontSize }, + { key = "0", mods = "CTRL", action = act.ResetFontSize }, + { key = "C", mods = "SHIFT|CTRL", action = act.CopyTo("Clipboard") }, + { key = "V", mods = "SHIFT|CTRL", action = act.PasteFrom("Clipboard") }, + { key = "P", mods = "SHIFT|CTRL", action = act.ActivateCommandPalette }, + { key = "R", mods = "SHIFT|CTRL", action = act.ReloadConfiguration }, + { key = "F12", mods = "NONE", action = act.ShowDebugOverlay }, } M.mouse_bindings = { -- Open links { - event = { Up = { streak = 1, button = 'Left' } }, - mods = 'CTRL', + event = { Up = { streak = 1, button = "Left" } }, + mods = "CTRL", action = act.OpenLinkAtMouseCursor, }, -- Select text { - event = { Down = { streak = 1, button = 'Left' } }, - mods = 'CTRL', + event = { Down = { streak = 1, button = "Left" } }, + mods = "CTRL", action = act.SelectTextAtMouseCursor("Cell"), }, { - event = { Drag = { streak = 1, button = 'Left' } }, - mods = 'CTRL', + event = { Drag = { streak = 1, button = "Left" } }, + mods = "CTRL", action = act.ExtendSelectionToMouseCursor("Cell"), }, { - event = { Down = { streak = 1, button = 'Left' } }, - mods = 'CTRL|SHIFT', + event = { Down = { streak = 1, button = "Left" } }, + mods = "CTRL|SHIFT", action = act.ExtendSelectionToMouseCursor("Cell"), }, -- Select text in block mode { - event = { Down = { streak = 1, button = 'Left' } }, - mods = 'CTRL|ALT', + event = { Down = { streak = 1, button = "Left" } }, + mods = "CTRL|ALT", action = act.SelectTextAtMouseCursor("Block"), }, { - event = { Drag = { streak = 1, button = 'Left' } }, - mods = 'CTRL|ALT', + event = { Drag = { streak = 1, button = "Left" } }, + mods = "CTRL|ALT", action = act.ExtendSelectionToMouseCursor("Block"), }, { - event = { Down = { streak = 1, button = 'Left' } }, - mods = 'CTRL|ALT|SHIFT', + event = { Down = { streak = 1, button = "Left" } }, + mods = "CTRL|ALT|SHIFT", action = act.ExtendSelectionToMouseCursor("Block"), }, } @@ -70,42 +70,117 @@ M.key_tables = wezterm.gui.default_key_tables() -- }) function M.enable_multiplexing() - table.insert(M.keys, { key = "c", mods = "LEADER", action = act.SpawnTab("CurrentPaneDomain") }) - table.insert(M.keys, { key = '%', mods = "LEADER|SHIFT", action = act.SplitPane({ direction = "Down" }) }) - table.insert(M.keys, { key = '"', mods = "LEADER|SHIFT", action = act.SplitPane({ direction = "Right" }) }) - table.insert(M.keys, { key = "x", mods = "LEADER", action = act.CloseCurrentPane({ confirm = true }) }) - table.insert(M.keys, { key = "n", mods = "LEADER", action = act.ActivateTabRelative(1) }) - table.insert(M.keys, { key = "p", mods = "LEADER", action = act.ActivateTabRelative(-1) }) - table.insert(M.keys, { key = "h", mods = "LEADER", action = act.ActivatePaneDirection('Left') }) - table.insert(M.keys, { key = "l", mods = "LEADER", action = act.ActivatePaneDirection('Right') }) - table.insert(M.keys, { key = "k", mods = "LEADER", action = act.ActivatePaneDirection('Up') }) - table.insert(M.keys, { key = "j", mods = "LEADER", action = act.ActivatePaneDirection('Down') }) - table.insert(M.keys, { key = "[", mods = "LEADER", action = act.ActivateCopyMode }) - table.insert(M.keys, { key = '?', mods = 'LEADER|SHIFT', action = act.Search("CurrentSelectionOrEmptyString") }) + table.insert( + M.keys, + { + key = "c", + mods = "LEADER", + action = act.SpawnTab("CurrentPaneDomain"), + } + ) + table.insert( + M.keys, + { + key = "%", + mods = "LEADER|SHIFT", + action = act.SplitPane({ direction = "Down" }), + } + ) + table.insert( + M.keys, + { + key = '"', + mods = "LEADER|SHIFT", + action = act.SplitPane({ direction = "Right" }), + } + ) + table.insert( + M.keys, + { + key = "x", + mods = "LEADER", + action = act.CloseCurrentPane({ confirm = true }), + } + ) + table.insert( + M.keys, + { key = "n", mods = "LEADER", action = act.ActivateTabRelative(1) } + ) + table.insert( + M.keys, + { key = "p", mods = "LEADER", action = act.ActivateTabRelative(-1) } + ) + table.insert( + M.keys, + { + key = "h", + mods = "LEADER", + action = act.ActivatePaneDirection("Left"), + } + ) + table.insert( + M.keys, + { + key = "l", + mods = "LEADER", + action = act.ActivatePaneDirection("Right"), + } + ) + table.insert( + M.keys, + { key = "k", mods = "LEADER", action = act.ActivatePaneDirection("Up") } + ) + table.insert( + M.keys, + { + key = "j", + mods = "LEADER", + action = act.ActivatePaneDirection("Down"), + } + ) + table.insert( + M.keys, + { key = "[", mods = "LEADER", action = act.ActivateCopyMode } + ) + table.insert( + M.keys, + { + key = "?", + mods = "LEADER|SHIFT", + action = act.Search("CurrentSelectionOrEmptyString"), + } + ) for i = 1, 9 do - table.insert(M.keys, { key = tostring(i), mods = "LEADER", action = act.ActivateTab(i - 1) }) + table.insert( + M.keys, + { + key = tostring(i), + mods = "LEADER", + action = act.ActivateTab(i - 1), + } + ) end table.insert(M.mouse_bindings, { event = { Down = { streak = 1, button = { WheelUp = 1 } } }, - mods = 'NONE', - action = act.ScrollByLine(-3) + mods = "NONE", + action = act.ScrollByLine(-3), }) table.insert(M.mouse_bindings, { event = { Down = { streak = 1, button = { WheelDown = 1 } } }, - mods = 'NONE', - action = act.ScrollByLine(3) + mods = "NONE", + action = act.ScrollByLine(3), }) table.insert(M.mouse_bindings, { event = { Down = { streak = 1, button = { WheelUp = 1 } } }, - mods = 'ALT', - action = act.ScrollByPage(-1) + mods = "ALT", + action = act.ScrollByPage(-1), }) table.insert(M.mouse_bindings, { event = { Down = { streak = 1, button = { WheelDown = 1 } } }, - mods = 'ALT', - action = act.ScrollByPage(1) + mods = "ALT", + action = act.ScrollByPage(1), }) end diff --git a/.config/wezterm/colors.lua b/.config/wezterm/colors.lua index da024aa..10a3242 100644 --- a/.config/wezterm/colors.lua +++ b/.config/wezterm/colors.lua @@ -1,73 +1,72 @@ local my_colors = { - foreground = '#b2b2b2', - background = '#000000', - cursor_fg = '#000000', - cursor_bg = '#b2b2b2', - cursor_border = '#b2b2b2', - selection_fg = '#000000', - selection_bg = '#b2b2b2', - scrollbar_thumb = '#000000', - split = '#000000', + foreground = "#b2b2b2", + background = "#000000", + cursor_fg = "#000000", + cursor_bg = "#b2b2b2", + cursor_border = "#b2b2b2", + selection_fg = "#000000", + selection_bg = "#b2b2b2", + scrollbar_thumb = "#000000", + split = "#000000", ansi = { - '#2e3436', -- black - '#cc5555', -- red - '#4e9a06', -- green - '#c4a000', -- yellow - '#6465a4', -- blue - '#75507b', -- magenta - '#06989a', -- cyan - '#b2b2b2', -- white + "#2e3436", -- black + "#cc5555", -- red + "#4e9a06", -- green + "#c4a000", -- yellow + "#6465a4", -- blue + "#75507b", -- magenta + "#06989a", -- cyan + "#b2b2b2", -- white }, brights = { - '#555753', -- black - '#ff5555', -- red - '#8ae234', -- green - '#fce94f', -- yellow - '#739fcf', -- blue - '#ad7fa8', -- magenta - '#34e2e2', -- cyan - '#d3d7cf', -- white + "#555753", -- black + "#ff5555", -- red + "#8ae234", -- green + "#fce94f", -- yellow + "#739fcf", -- blue + "#ad7fa8", -- magenta + "#34e2e2", -- cyan + "#d3d7cf", -- white }, - compose_cursor = 'orange', + compose_cursor = "orange", tab_bar = { -- The color of the strip that goes along the top of the window -- (does not apply when fancy tab bar is in use) - background = '#000000', + background = "#000000", -- The active tab is the one that has focus in the window active_tab = { -- The color of the background area for the tab - bg_color = '#000000', + bg_color = "#000000", -- The color of the text for the tab - fg_color = '#c0c0c0', + fg_color = "#c0c0c0", }, -- Inactive tabs are the tabs that do not have focus inactive_tab = { - bg_color = '#000000', - fg_color = '#808080', + bg_color = "#000000", + fg_color = "#808080", }, -- You can configure some alternate styling when the mouse pointer -- moves over inactive tabs inactive_tab_hover = { - bg_color = '#000000', - fg_color = '#c0c0c0', + bg_color = "#000000", + fg_color = "#c0c0c0", -- The same options that were listed under the `active_tab` section above -- can also be used for `inactive_tab_hover`. }, - -- The new tab button that let you create new tabs new_tab = { - bg_color = '#000000', - fg_color = '#808080', + bg_color = "#000000", + fg_color = "#808080", }, new_tab_hover = { - bg_color = '#000000', - fg_color = '#c0c0c0', + bg_color = "#000000", + fg_color = "#c0c0c0", }, }, } diff --git a/.config/wezterm/events.lua b/.config/wezterm/events.lua index 158be23..1101ed2 100644 --- a/.config/wezterm/events.lua +++ b/.config/wezterm/events.lua @@ -3,25 +3,24 @@ local wezterm = require("wezterm") local M = {} function M.setup() - wezterm.on('format-window-title', function() return "WezTerm" end) - wezterm.on( - 'format-tab-title', - function(tab, _, _, _, _, _) - local title = tab.tab_title - if not title or #title <= 0 then - title = tab.active_pane.title - end - title = " " .. tab.tab_index + 1 .. ": " .. title - if tab.is_active then - title = title .. "*" - else - title = title .. " " - end - return { - { Text = title }, - } + wezterm.on("format-window-title", function() + return "WezTerm" + end) + wezterm.on("format-tab-title", function(tab, _, _, _, _, _) + local title = tab.tab_title + if not title or #title <= 0 then + title = tab.active_pane.title end - ) + title = " " .. tab.tab_index + 1 .. ": " .. title + if tab.is_active then + title = title .. "*" + else + title = title .. " " + end + return { + { Text = title }, + } + end) end return M diff --git a/.config/wezterm/fonts.lua b/.config/wezterm/fonts.lua index 886b9fb..1b0ff04 100644 --- a/.config/wezterm/fonts.lua +++ b/.config/wezterm/fonts.lua @@ -10,44 +10,43 @@ fonts.regular = wezterm.font({ family = family, weight = "Regular", stretch = "Normal", - style = "Normal" + style = "Normal", }) fonts.italic = wezterm.font({ family = family, weight = "Regular", stretch = "Normal", - style = "Italic" + style = "Italic", }) fonts.bold = wezterm.font({ family = family, weight = "Bold", stretch = "Normal", - style = "Normal" + style = "Normal", }) fonts.bolditalic = wezterm.font({ family = family, weight = "Bold", stretch = "Normal", - style = "Italic" + style = "Italic", }) fonts.rules = { italic = { intensity = "Normal", italic = true, - font = fonts.italic + font = fonts.italic, }, bold = { intensity = "Bold", italic = false, - font = fonts.bold + font = fonts.bold, }, bolditalic = { intensity = "Bold", italic = true, - font = fonts.bolditalic + font = fonts.bolditalic, }, } - return fonts diff --git a/.config/wezterm/wezterm.lua b/.config/wezterm/wezterm.lua index 91375e2..75b54e4 100644 --- a/.config/wezterm/wezterm.lua +++ b/.config/wezterm/wezterm.lua @@ -32,7 +32,6 @@ else config.default_prog = { "zsh" } end - -- Colors config.color_scheme = "moonfly" @@ -48,7 +47,7 @@ config.font_rules = { fonts.rules.bold, fonts.rules.bolditalic, } -config.harfbuzz_features = { 'calt=0' } +config.harfbuzz_features = { "calt=0" } -- Keybinding diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 0000000..fc11b0b --- /dev/null +++ b/stylua.toml @@ -0,0 +1,10 @@ +column_width = 80 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 4 +quote_style = "AutoPreferDouble" +call_parentheses = "Always" +collapse_simple_statement = "Never" + +[sort_requires] +enabled = true