From 0de6489930a32bab60a061845e7b1afedf3d32eb Mon Sep 17 00:00:00 2001 From: rootiest Date: Wed, 6 Nov 2024 10:32:47 -0500 Subject: [PATCH] style: enhance window decorations for improved visual appeal --- .gitignore | 1 + config/colors.lua | 1 - config/keys.lua | 66 +++++++++++++++++++-------------- config/platform.lua | 6 +++ config/window.lua | 26 +++++++++++-- funcs.lua | 89 +++++++++++++++++++++++++++++++++++++++++++++ plugins/neovim.lua | 32 ++++++++++++++++ plugins/tabline.lua | 20 ++++++++-- plugs.lua | 2 + 9 files changed, 208 insertions(+), 35 deletions(-) create mode 100644 plugins/neovim.lua diff --git a/.gitignore b/.gitignore index 6d7874c..bda96e3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ dev/ user/ dev.lua user.lua +plugins/tunicodes/ diff --git a/config/colors.lua b/config/colors.lua index 5f1032b..4408afa 100644 --- a/config/colors.lua +++ b/config/colors.lua @@ -10,7 +10,6 @@ local cur_hour = wezterm.time.now():format("%H") local hour_angle = require("funcs").get_hour_angle(cur_hour) - --- catppuccin theme ---@see catppuccin_documentation https://github.com/catppuccin/wezterm local function get_colorscheme(appearance) diff --git a/config/keys.lua b/config/keys.lua index cdf037d..cd31982 100644 --- a/config/keys.lua +++ b/config/keys.lua @@ -5,7 +5,16 @@ local wezterm = WEZTERM local act = wezterm.action +-- Set up some reference values +local Chord = "SHIFT|CTRL" +local LeaderChord = "LEADER|SHIFT|CTRL" +local LeaderShift = "LEADER|SHIFT" +local LeaderCtrl = "LEADER|CTRL" + +local FuzzyLaunch = "FUZZY|TABS|DOMAINS|WORKSPACES|COMMANDS|LAUNCH_MENU_ITEMS|KEY_ASSIGNMENTS" + local resurrect = wezterm.plugin.require("https://github.com/MLFlexer/resurrect.wezterm") +local tunicodes = require("plugins/tunicodes") local opts = { -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Leader key ━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -13,20 +22,20 @@ local opts = { -- ━━━━━━━━━━━━━━━━━━━━━━━━━ Global Key Mappings ━━━━━━━━━━━━━━━━━━━━━ keys = { -- Close window - { key = "q", mods = "LEADER|SHIFT|CTRL", action = act.QuitApplication }, + { key = "q", mods = LeaderChord, action = act.QuitApplication }, -- Split pane - { key = "|", mods = "LEADER|SHIFT", action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }) }, - { key = "_", mods = "LEADER|SHIFT", action = act.SplitVertical({ domain = "CurrentPaneDomain" }) }, + { key = "|", mods = LeaderShift, action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }) }, + { key = "_", mods = LeaderShift, action = act.SplitVertical({ domain = "CurrentPaneDomain" }) }, -- Move pane - { key = "h", mods = "SHIFT|CTRL", action = act.ActivatePaneDirection("Left") }, - { key = "j", mods = "SHIFT|CTRL", action = act.ActivatePaneDirection("Down") }, - { key = "k", mods = "SHIFT|CTRL", action = act.ActivatePaneDirection("Up") }, - { key = "l", mods = "SHIFT|CTRL", action = act.ActivatePaneDirection("Right") }, + { key = "h", mods = Chord, action = act.ActivatePaneDirection("Left") }, + { key = "j", mods = Chord, action = act.ActivatePaneDirection("Down") }, + { key = "k", mods = Chord, action = act.ActivatePaneDirection("Up") }, + { key = "l", mods = Chord, action = act.ActivatePaneDirection("Right") }, -- Move pane to new window { key = "!", - mods = "LEADER | SHIFT", + mods = LeaderShift, action = wezterm.action_callback(function(_, pane) pane:move_to_new_window() end), @@ -35,7 +44,7 @@ local opts = { -- Toggle pane zoom { key = "z", - mods = "SHIFT|CTRL", + mods = Chord, action = act.TogglePaneZoomState, }, { @@ -43,10 +52,12 @@ local opts = { mods = "LEADER", action = act.TogglePaneZoomState, }, + -- Reload Config + { key = "F5", mods = "LEADER", action = act.ReloadConfiguration }, -- Close pane { key = "q", mods = "LEADER", action = act.CloseCurrentPane({ confirm = true }) }, - { key = "q", mods = "SHIFT|CTRL", action = act.CloseCurrentPane({ confirm = true }) }, + { key = "q", mods = Chord, action = act.CloseCurrentPane({ confirm = true }) }, -- Resize pane { key = "h", mods = "ALT", action = act.AdjustPaneSize({ "Left", 1 }) }, @@ -59,45 +70,45 @@ local opts = { -- Tab Manipulation { key = "PageUp", mods = "CTRL", action = act.ActivateTabRelative(1) }, - { key = "PageUp", mods = "SHIFT|CTRL", action = act.MoveTabRelative(1) }, + { key = "PageUp", mods = Chord, action = act.MoveTabRelative(1) }, { key = "PageDown", mods = "CTRL", action = act.ActivateTabRelative(-1) }, - { key = "PageDown", mods = "SHIFT|CTRL", action = act.MoveTabRelative(-1) }, + { key = "PageDown", mods = Chord, action = act.MoveTabRelative(-1) }, { -- Quick launch key = "x", - mods = "LEADER|CTRL", + mods = LeaderCtrl, action = act.ShowLauncherArgs({ title = "Quick Launch", - flags = "FUZZY|TABS|DOMAINS|WORKSPACES|COMMANDS|LAUNCH_MENU_ITEMS|KEY_ASSIGNMENTS", + flags = FuzzyLaunch, }), }, -- Search { key = "f", mods = "LEADER", action = act.Search("CurrentSelectionOrEmptyString") }, - { key = "f", mods = "SHIFT|CTRL", action = act.Search("CurrentSelectionOrEmptyString") }, + { key = "f", mods = Chord, action = act.Search("CurrentSelectionOrEmptyString") }, -- Miscellaneous - { key = "a", mods = "LEADER|CTRL", action = act.SendKey({ key = "a", mods = "CTRL" }) }, + { key = "a", mods = LeaderCtrl, action = act.SendKey({ key = "a", mods = "CTRL" }) }, { key = ";", mods = "CTRL", action = act.ActivateCommandPalette }, { key = "F1", mods = "LEADER", action = act.ShowDebugOverlay }, { key = "u", - mods = "LEADER|CTRL", + mods = LeaderCtrl, action = act.AttachDomain("SSH:aws-discord"), }, { key = "s", - mods = "LEADER|CTRL", + mods = LeaderCtrl, action = act.ShowLauncherArgs({ title = "Connect to SSH server", flags = "FUZZY|DOMAINS" }), }, - { key = "z", mods = "LEADER|CTRL", action = act.TogglePaneZoomState }, - { key = "n", mods = "LEADER|CTRL", action = act.SpawnWindow }, + { key = "z", mods = LeaderCtrl, action = act.TogglePaneZoomState }, + { key = "n", mods = LeaderCtrl, action = act.SpawnWindow }, { key = "x", mods = "LEADER", action = act.ActivateCopyMode }, -- Naming { -- Rename [W]orkspace key = "w", - mods = "LEADER|CTRL", + mods = LeaderCtrl, action = act.PromptInputLine({ description = "Enter new name for the workspace:", action = wezterm.action_callback(function(window, _, line) @@ -109,12 +120,13 @@ local opts = { }, { -- Rename [T]ab key = "t", - mods = "LEADER|CTRL", + mods = LeaderCtrl, action = act.PromptInputLine({ description = "Enter new name for the tab:", action = wezterm.action_callback(function(_, pane, line) if line then local tab = pane:tab() + ---@diagnostic disable-next-line: need-check-nil tab:set_title(line) end end), @@ -171,6 +183,11 @@ local opts = { end) end), }, + { -- [.] Insert Unicode and Emoji symbols + key = ".", + mods = LeaderCtrl, + action = tunicodes.DefaultAction, + }, }, -- ━━━━━━━━━━━━━━━━━━━━━━ Conditional Key Mappings ━━━━━━━━━━━━━━━━━━━ @@ -218,11 +235,6 @@ local opts = { mods = "CTRL", action = act.OpenLinkAtMouseCursor, }, - -- { -- Ctrl+Double-Left-Click: (Up) Open Hyperlink - -- event = { Up = { streak = 2, button = "Left" } }, - -- mods = "CTRL", - -- action = act.OpenLinkAtMouseCursor, - -- }, { -- Ctrl+WheelUp: Go to previous tab event = { Down = { streak = 1, button = { WheelUp = 1 } } }, mods = "CTRL", diff --git a/config/platform.lua b/config/platform.lua index fa5767e..22cdbe9 100644 --- a/config/platform.lua +++ b/config/platform.lua @@ -27,6 +27,12 @@ end if myos == "win" then opts.default_prog = { "pwsh.exe" } opts.term = "xterm-256color" + opts.front_end = "WebGpu" + opts.prefer_egl = true + opts.window_background_opacity = 0 + opts.win32_system_backdrop = "Mica" + opts.use_fancy_tab_bar = false + opts.window_decorations = "INTEGRATED_BUTTONS|RESIZE" elseif myos == "mac" then opts.default_prog = { "zsh" } else diff --git a/config/window.lua b/config/window.lua index f130042..e88023c 100644 --- a/config/window.lua +++ b/config/window.lua @@ -19,13 +19,33 @@ local opts = { -- Window Decorations window_decorations = "TITLE | RESIZE", + --window_decorations = "INTEGRATED_BUTTONS|TITLE|RESIZE", + integrated_title_buttons = { "Hide", "Maximize", "Close" }, + window_frame = { + inactive_titlebar_bg = "#353535", + active_titlebar_bg = "#2b2042", + inactive_titlebar_fg = "#cccccc", + active_titlebar_fg = "#ffffff", + inactive_titlebar_border_bottom = "#2b2042", + active_titlebar_border_bottom = "#2b2042", + button_fg = "#cccccc", + button_bg = "#2b2042", + button_hover_fg = "#ffffff", + button_hover_bg = "#3b3052", + }, -- Visual Bell visual_bell = { - fade_in_duration_ms = 75, - fade_out_duration_ms = 75, - target = "CursorColor", + fade_in_function = "EaseIn", + fade_in_duration_ms = 150, + fade_out_function = "EaseOut", + fade_out_duration_ms = 150, }, + --{ + -- fade_in_duration_ms = 75, + -- fade_out_duration_ms = 75, + -- target = "CursorColor", + --}, -- Audible Bell audible_bell = "SystemBeep", diff --git a/funcs.lua b/funcs.lua index 6878aa5..0584159 100644 --- a/funcs.lua +++ b/funcs.lua @@ -130,4 +130,93 @@ function M.complementary_color(hex_color) return string.format("#%02x%02x%02x", complementary_r, complementary_g, complementary_b) end +---@function Helper function to check if a value exists in a table +---@param tab table The table to search in +---@param val any The value to search for in the table +---@return boolean exists True if the value is found in the table, false otherwise +function M.has_value(tab, val) + for _, value in ipairs(tab) do + if value == val then + return true + end + end + return false +end + +---@function Function to send a notification using toastify +---@param title string The title of the notification +---@param body? string The body of the notification +---@param timeout? number Time in milliseconds before the notification expires +---@param options? table A table containing additional optional settings for the notification +function M.notify(title, body, timeout, options) + -- Default values for optional fields + -- Initialize 'options' as an empty table if not provided + options = options or {} + + -- Retrieve specific options from the 'options' table, or set to nil/default if not provided + local app_name = options.app_name or nil + local categories = options.categories or nil + local icon = options.icon or nil + local sound_name = options.sound_name or nil + local urgency = options.urgency or "normal" -- Default urgency is 'normal' + local hint = options.hint or nil + local debug = options.debug and "--debug" or nil -- Add '--debug' flag if debug is true + + -- Allowed urgency levels for validation + local allowed_urgency = { "low", "normal", "critical" } + -- If the provided urgency is not one of the allowed values, default to 'normal' + if not M.has_value(allowed_urgency, urgency) then + urgency = "normal" + end + + -- Start building the command as a table of strings (to execute via wezterm) + -- 'toastify send' is the base command, with 'title' as a required argument + local cmd = { "toastify", "send", title } + + -- Append the body if provided (body is optional) + if body then + table.insert(cmd, body) + end + + -- Append the timeout if provided (timeout is optional) + if timeout then + table.insert(cmd, "--expire-time") + table.insert(cmd, tostring(timeout)) -- Convert to string for command execution + end + + -- Append optional arguments if provided, using the corresponding flag + if app_name then + table.insert(cmd, "--app-name") + table.insert(cmd, app_name) + end + if categories then + table.insert(cmd, "--categories") + table.insert(cmd, categories) + end + if icon then + table.insert(cmd, "--icon") + table.insert(cmd, icon) + end + if sound_name then + table.insert(cmd, "--sound-name") + table.insert(cmd, sound_name) + end + if hint then + table.insert(cmd, "--hint") + table.insert(cmd, hint) + end + -- Append the '--debug' flag if debug mode is enabled + if debug then + table.insert(cmd, debug) + end + + -- Always include the urgency flag with the validated urgency value + table.insert(cmd, "--urgency") + table.insert(cmd, urgency) + + -- Execute the command using wezterm's built-in child process runner + -- 'wezterm.run_child_process' takes a table of strings and executes it as a command + wezterm.run_child_process(cmd) +end + return M diff --git a/plugins/neovim.lua b/plugins/neovim.lua new file mode 100644 index 0000000..674d882 --- /dev/null +++ b/plugins/neovim.lua @@ -0,0 +1,32 @@ +-- ╭─────────────────────────────────────────────────────────╮ +-- │ Neovim │ +-- ╰─────────────────────────────────────────────────────────╯ + +local M = {} + +local wezterm = WEZTERM + +wezterm.on("user-var-changed", function(window, pane, name, value) + local overrides = window:get_config_overrides() or {} + if name == "ZEN_MODE" then + local incremental = value:find("+") + local number_value = tonumber(value) + if incremental ~= nil then + while number_value > 0 do + window:perform_action(wezterm.action.IncreaseFontSize, pane) + number_value = number_value - 1 + end + overrides.enable_tab_bar = false + elseif number_value < 0 then + window:perform_action(wezterm.action.ResetFontSize, pane) + overrides.font_size = nil + overrides.enable_tab_bar = true + else + overrides.font_size = number_value + overrides.enable_tab_bar = false + end + end + window:set_config_overrides(overrides) +end) + +return M diff --git a/plugins/tabline.lua b/plugins/tabline.lua index ecabf99..ae0b7d3 100644 --- a/plugins/tabline.lua +++ b/plugins/tabline.lua @@ -1,3 +1,4 @@ +local wezterm = WEZTERM local config = CONFIG local types = require("types") local funcs = require("funcs") @@ -5,6 +6,10 @@ local batteries = BATTERIES local tabline = WEZTERM.plugin.require("https://github.com/michaelbrusegard/tabline.wez") +wezterm.on("bell", function(_, pane) + wezterm.log_info("the bell was rung in pane " .. pane:pane_id() .. "!") +end) + local tab_opts = { options = { icons_enabled = true, @@ -55,7 +60,14 @@ local tab_opts = { "/", { "cwd", padding = { left = 0, right = 1 } }, WEZTERM.nerdfonts.ple_left_half_circle_thin, - { "process", padding = { left = 0, right = 0 } }, + { + "process", + process_to_icon = { + ["discordo"] = { WEZTERM.nerdfonts.md_discord, color = { fg = "#a5e3a0" } }, + ["iamb"] = { WEZTERM.nerdfonts.md_chat, color = { fg = "#E78284" } }, + }, + padding = { left = 0, right = 0 }, + }, }, tab_inactive = { { @@ -79,9 +91,9 @@ local tab_opts = { padding = { left = 1, right = 0 }, icons_enabled = false, }, - { "parent", padding = { left = 0, right = 0 } }, - "/", - { "cwd", padding = { left = 0, right = 1 } }, + -- { "parent", padding = { left = 0, right = 0 } }, + -- "/", + -- { "cwd", padding = { left = 0, right = 1 } }, { "process", icons_only = true, padding = { left = 0, right = 0 } }, }, tabline_x = {}, diff --git a/plugs.lua b/plugs.lua index cf18234..88c08ce 100644 --- a/plugs.lua +++ b/plugs.lua @@ -9,6 +9,8 @@ local plugins = { "resurrect", "smart_splits", "tabline", + "neovim", + "tunicodes", -- "sessionizer", --"plugin_mgr", }