From 7ea66629e9bba26c5b03dc6639cee2fc1693f8fe Mon Sep 17 00:00:00 2001 From: rootiest Date: Mon, 21 Oct 2024 05:48:19 -0400 Subject: [PATCH] style: tidy up configuration and remove unnecessary comments --- config/window.lua | 2 +- funcs.lua | 13 ++++++++++-- menus.lua | 45 +++++++++++++++++++++++++++++++++++++++++ plugins/sessionizer.lua | 11 ++++++++++ plugs.lua | 1 + wezterm.lua | 6 +++++- 6 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 menus.lua create mode 100644 plugins/sessionizer.lua diff --git a/config/window.lua b/config/window.lua index 603ffca..f130042 100644 --- a/config/window.lua +++ b/config/window.lua @@ -31,7 +31,7 @@ local opts = { audible_bell = "SystemBeep", -- Terminal Variable - term = "wezterm", + -- term = "wezterm", --Honor kitty protocol inputs enable_kitty_keyboard = true, diff --git a/funcs.lua b/funcs.lua index 5c59ebd..6878aa5 100644 --- a/funcs.lua +++ b/funcs.lua @@ -7,13 +7,22 @@ local M = {} local wezterm = WEZTERM local types = require("types") --- Set the leader icon -wezterm.on("update-status", function(window, _) +-- Update status event +wezterm.on("update-status", function(window, pane) + -- Set the leader icon if window:leader_is_active() then types.leader.icon = types.leader.on else types.leader.icon = types.leader.off end + + -- Set the TERM + local tty = pane:get_tty_name() + if tty then + CONFIG.term = "wezterm" + else + CONFIG.term = "xterm-256color" + end end) ---@function Function to render the leader icon diff --git a/menus.lua b/menus.lua new file mode 100644 index 0000000..43f8763 --- /dev/null +++ b/menus.lua @@ -0,0 +1,45 @@ +-- ╭─────────────────────────────────────────────────────────╮ +-- │ Menus │ +-- ╰─────────────────────────────────────────────────────────╯ + +local wezterm = WEZTERM +local launch_menu = {} + +if wezterm.target_triple == "x86_64-pc-windows-msvc" then + table.insert(launch_menu, { + label = "PowerShell", + args = { "powershell.exe", "-NoLogo" }, + }) + + -- Find installed visual studio version(s) and add their compilation + -- environment command prompts to the menu + for _, vsvers in ipairs(wezterm.glob("Microsoft Visual Studio/20*", "C:/Program Files (x86)")) do + local year = vsvers:gsub("Microsoft Visual Studio/", "") + table.insert(launch_menu, { + label = "x64 Native Tools VS " .. year, + args = { + "cmd.exe", + "/k", + "C:/Program Files (x86)/" .. vsvers .. "/BuildTools/VC/Auxiliary/Build/vcvars64.bat", + }, + }) + end +end + +-- Set up btop launcher +if wezterm.target_triple ~= "x86_64-pc-windows-msvc" then + table.insert(launch_menu, { + label = "btop", + args = { "btop" }, + }) +end + +-- Set up btop launcher split using wezterm cli +if wezterm.target_triple ~= "x86_64-pc-windows-msvc" then + table.insert(launch_menu, { + label = "btop split", + args = { "wezterm", "cli", "split-pane", "--", "btop" }, + }) +end + +return launch_menu diff --git a/plugins/sessionizer.lua b/plugins/sessionizer.lua new file mode 100644 index 0000000..2e992c1 --- /dev/null +++ b/plugins/sessionizer.lua @@ -0,0 +1,11 @@ +-- ╭─────────────────────────────────────────────────────────╮ +-- │ Sessionizer │ +-- ╰─────────────────────────────────────────────────────────╯ + +local wezterm = WEZTERM +local config = CONFIG + +SESSIONIZER = wezterm.plugin.require("https://github.com/mikkasendke/sessionizer.wezterm") +if SESSIONIZER then + SESSIONIZER.apply_to_config(config) +end diff --git a/plugs.lua b/plugs.lua index 49a2ada..cf18234 100644 --- a/plugs.lua +++ b/plugs.lua @@ -9,6 +9,7 @@ local plugins = { "resurrect", "smart_splits", "tabline", + -- "sessionizer", --"plugin_mgr", } diff --git a/wezterm.lua b/wezterm.lua index bdc988f..132d0f2 100644 --- a/wezterm.lua +++ b/wezterm.lua @@ -11,7 +11,7 @@ -- https://github.com/wez/wezterm/ -- Load WezTerm module -WEZTERM = require("wezterm") +WEZTERM = require("wezterm") --[[@as Wezterm]] -- Load Config Builder CONFIG = WEZTERM.config_builder() @@ -35,10 +35,14 @@ require("plugs") -- Encrypt Sessions require("encryption") +-- Load Menus +CONFIG.launch_menu = require("menus") + --------- Update Plugins ---------- ---Running this may cause slowdowns ----------------------------------- -- WEZTERM.plugin.update_all() ---- +-- print(WEZTERM.plugin.list()) ----------------------------------- -- Return configuration