From 784e43407284db6897c0f786fd35081945479c29 Mon Sep 17 00:00:00 2001 From: jasmine Date: Mon, 19 May 2025 10:37:38 +0800 Subject: [PATCH] update wezterm configuration --- flake.lock | 40 +-- .../features/desktop/wezterm/wezterm.lua | 282 +++++++++--------- 2 files changed, 157 insertions(+), 165 deletions(-) diff --git a/flake.lock b/flake.lock index f2670d0..8d82d95 100644 --- a/flake.lock +++ b/flake.lock @@ -406,11 +406,11 @@ ] }, "locked": { - "lastModified": 1746171682, - "narHash": "sha256-EyXUNSa+H+YvGVuQJP1nZskXAowxKYp79RNUsNdQTj4=", + "lastModified": 1747020534, + "narHash": "sha256-D/6rkiC6w2p+4SwRiVKrWIeYzun8FBg7NlMKMwQMxO0=", "owner": "nix-community", "repo": "home-manager", - "rev": "50eee705bbdbac942074a8c120e8194185633675", + "rev": "b4bbdc6fde16fc2051fcde232f6e288cd22007ca", "type": "github" }, "original": { @@ -494,11 +494,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1746669743, - "narHash": "sha256-QxWruaCkxR4Qb8a9dGKvnxwu0y4WHZ/Ib+dDKWPOoNQ=", + "lastModified": 1747015534, + "narHash": "sha256-xWZ9OlyNPs4bU81cctlqiuZREhe1rD4j4GuLoh2nd4M=", "owner": "Infinidoge", "repo": "nix-minecraft", - "rev": "195c6e72f08f4efcd0309c1c5a18305d93ed0567", + "rev": "540f19177d1b41719731da8d9a91366d0732a6e7", "type": "github" }, "original": { @@ -555,11 +555,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1746461020, - "narHash": "sha256-7+pG1I9jvxNlmln4YgnlW4o+w0TZX24k688mibiFDUE=", + "lastModified": 1746904237, + "narHash": "sha256-3e+AVBczosP5dCLQmMoMEogM57gmZ2qrVSrmq9aResQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "3730d8a308f94996a9ba7c7138ede69c1b9ac4ae", + "rev": "d89fc19e405cb2d55ce7cc114356846a0ee5e956", "type": "github" }, "original": { @@ -602,11 +602,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1746557022, - "narHash": "sha256-QkNoyEf6TbaTW5UZYX0OkwIJ/ZMeKSSoOMnSDPQuol0=", + "lastModified": 1746810718, + "narHash": "sha256-VljtYzyttmvkWUKTVJVW93qAsJsrBbgAzy7DdnJaQfI=", "owner": "nixos", "repo": "nixpkgs", - "rev": "1d3aeb5a193b9ff13f63f4d9cc169fb88129f860", + "rev": "0c0bf9c057382d5f6f63d54fd61f1abd5e1c2f63", "type": "github" }, "original": { @@ -703,11 +703,11 @@ "nixvim": "nixvim_2" }, "locked": { - "lastModified": 1746001276, - "narHash": "sha256-kdRCPAC9ZTvNvm1/01TmzRDEWB633vfWCFZsy29qK+I=", + "lastModified": 1747618644, + "narHash": "sha256-R+c3ckEhMtUXgD8VBqVpvciUBSVFjIb6tQlpwyrLLxo=", "ref": "refs/heads/master", - "rev": "6e4433ca3d2038f8094b0c3f170dd9fcd9e9acef", - "revCount": 61, + "rev": "e8ff6ac5f304f3c315d681c4cb744ba746f22e92", + "revCount": 79, "type": "git", "url": "https://git.sajenim.dev/jasmine/nixvim-config.git" }, @@ -997,11 +997,11 @@ "nixpkgs": "nixpkgs_9" }, "locked": { - "lastModified": 1747014850, - "narHash": "sha256-kF0JEhlFXtsUuCnajxIehiTx2QzFX1u7UklgYrDtTew=", + "lastModified": 1747573922, + "narHash": "sha256-GMKR9QEOEeSoK0OatKJ2WCCKthNmutz0S9S5xUjuUNo=", "ref": "refs/heads/master", - "rev": "1c496f9adf0402ead829c2654d498b6e338c5883", - "revCount": 30, + "rev": "33520339829508fe790817a57e6c54507e9d1eb0", + "revCount": 33, "type": "git", "url": "https://git.sajenim.dev/jasmine/xmonad-config.git" }, diff --git a/home-manager/sajenim/features/desktop/wezterm/wezterm.lua b/home-manager/sajenim/features/desktop/wezterm/wezterm.lua index 6198b16..ebe7cfb 100644 --- a/home-manager/sajenim/features/desktop/wezterm/wezterm.lua +++ b/home-manager/sajenim/features/desktop/wezterm/wezterm.lua @@ -1,180 +1,172 @@ -- Pull in the wezterm API local wezterm = require("wezterm") -local act = wezterm.action --- This table will hold the configuration. -local config = {} +-- Log warnings or generate errors if we define an invalid configuration option +local config = wezterm.config_builder() --- 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 +-- Install plugins +local smart_splits = wezterm.plugin.require("https://github.com/mrjones2014/smart-splits.nvim") --- This function returns the suggested title for a tab. --- It prefers the title that was set via `tab:set_title()` --- or `wezterm cli set-tab-title`, but falls back to the --- title of the active pane in that tab. -function tab_title(tab_info) - local title = tab_info.tab_title - -- if the tab title is explicitly set, take that - if title and #title > 0 then - return title - end - -- Otherwise, use the title from the active pane - -- in that tab - return tab_info.active_pane.title -end - -wezterm.on( - 'format-tab-title', - function(tab, tabs, panes, config, hover, max_width) - local title = tab_title(tab) - return { - { Text = ' ' .. title .. '' } - } -end) +-- +-- General configuration options. +-- -- Do not check for or show window with update information config.check_for_updates = false ---| Font configuration +-- Font configuration config.font = wezterm.font("Fisa Code") config.font_size = 10.0 ---| Enable gruvbox colour scheme +-- Enable gruvbox colour scheme config.color_scheme = "gruvbox_material_dark_medium" ---| Pad window borders +-- Pad window borders config.window_padding = { - left = 10, - right = 10, - top = 10, + left = 10, + right = 10, + top = 10, bottom = 10, } ---| Disable modern tab bar +-- +-- Tab bar configuration options. +-- + +-- Disable modern tab bar config.use_fancy_tab_bar = false config.tab_max_width = 32 ---| Tab bar colors +-- Tab bar colors config.colors = { - tab_bar = { + tab_bar = { background = "#32302f", active_tab = { - bg_color = "#32302f", - fg_color = "#7daea3", - intensity = "Bold", - italic = true - }, + bg_color = "#32302f", + fg_color = "#7daea3", + intensity = "Bold", + italic = true, + }, inactive_tab = { - bg_color = "#32302f", - fg_color = "#a89984", - intensity = "Bold", - italic = true - }, + bg_color = "#32302f", + fg_color = "#a89984", + intensity = "Bold", + italic = true, + }, inactive_tab_hover = { - bg_color = "#32302f", - fg_color = "#a89984", - intensity = "Bold", - italic = true - }, + bg_color = "#32302f", + fg_color = "#a89984", + intensity = "Bold", + italic = true, + }, new_tab = { - bg_color = "#32302f", - fg_color = "#a89984", - intensity = "Bold", - italic = true - }, + bg_color = "#32302f", + fg_color = "#a89984", + intensity = "Bold", + italic = true, + }, new_tab_hover = { - bg_color = "#32302f", - fg_color = "#a89984", - intensity = "Bold", - italic = true - } - } + bg_color = "#32302f", + fg_color = "#a89984", + intensity = "Bold", + italic = true, + }, + }, } ---| Key assignments -config.keys = { - { -- Spawn new tab - key = "Enter", - mods = "ALT", - action = act.SpawnTab("CurrentPaneDomain") - }, +-- +-- Keymaps configuration. +-- - { -- Focus previous tab - key = "LeftArrow", - mods = "ALT", - action = act.ActivateTabRelative(-1) - }, - - { -- Focus next tab - key = "RightArrow", - mods = "ALT", - action = act.ActivateTabRelative(1) - }, - - { -- Split pane vertically - key = "v", - mods = "ALT", - action = act.SplitVertical({domain = "CurrentPaneDomain"}) - }, - - { -- Split pane horizontally - key = "s", - mods = "ALT", - action = act.SplitHorizontal({domain = "CurrentPaneDomain"}) - }, - - { -- Move pane split down - key = "PageDown", - mods = "ALT", - action = act.AdjustPaneSize({"Down", 5}) - }, - - { -- Move pane split up - key = "PageUp", - mods = "ALT", - action = act.AdjustPaneSize({"Up", 5}) - }, - - { -- Focus next pane - key = "DownArrow", - mods = "ALT", - action = act.ActivatePaneDirection("Next") - }, - - { -- Focus previous pane - key = "UpArrow", - mods = "ALT", - action = act.ActivatePaneDirection("Prev") - }, - - { -- Close pane - key = "Escape", - mods = "ALT", - action = act.CloseCurrentPane({confirm = false}) - }, - - { -- Activate vi copy mode - key = "X", - mods = "CTRL", - action = act.ActivateCopyMode - }, - - { -- Paste from clipboard - key = "V", - mods = "CTRL", - action = act.PasteFrom("Clipboard") - }, - - { -- This lets us unify delete word across programs - key = "Backspace", - mods = "CTRL", - action = act.SendKey({key = "w", mods = "CTRL"}) - }, -} -- Disable the default keybindings config.disable_default_key_bindings = true +-- Setup leader key +config.leader = { key = "Space", mods = "CTRL", timeout_milliseconds = 1000 } + +-- General keymaps +config.keys = { + -- + -- Tab management + -- + + { -- Spawn new tab + key = "Enter", + mods = "LEADER", + action = wezterm.action.SpawnTab("CurrentPaneDomain"), + }, + + { -- Focus previous tab + key = "PageUp", + mods = "CTRL", + action = wezterm.action.ActivateTabRelative(-1), + }, + + { -- Focus next tab + key = "PageDown", + mods = "CTRL", + action = wezterm.action.ActivateTabRelative(1), + }, + + -- + -- Pane management + -- + + { -- Split pane vertically + key = "v", + mods = "LEADER", + action = wezterm.action.SplitVertical({ domain = "CurrentPaneDomain" }), + }, + + { -- Split pane horizontally + key = "s", + mods = "LEADER", + action = wezterm.action.SplitHorizontal({ domain = "CurrentPaneDomain" }), + }, + + { -- Close pane + key = "q", + mods = "LEADER", + action = wezterm.action.CloseCurrentPane({ confirm = false }), + }, + + -- + -- Copy / Paste + -- + + { -- Activate vi copy mode + key = "x", + mods = "LEADER", + action = wezterm.action.ActivateCopyMode, + }, + + { -- Paste from clipboard + key = "p", + mods = "LEADER", + action = wezterm.action.PasteFrom("Clipboard"), + }, + + -- + -- Miscellaneous + -- + + { -- This lets us unify delete word across programs + key = "Backspace", + mods = "CTRL", + action = wezterm.action.SendKey({ key = "w", mods = "CTRL" }), + }, +} + +-- +-- Enable neovim integration +-- + +smart_splits.apply_to_config(config, { + direction_keys = { "LeftArrow", "DownArrow", "UpArrow", "RightArrow" }, + modifiers = { + move = "CTRL", + resize = "CTRL|ALT", + }, +}) + return config