diff --git a/flake.lock b/flake.lock index be4be61..9e589b8 100644 --- a/flake.lock +++ b/flake.lock @@ -110,14 +110,16 @@ }, "nekowinston-nur": { "inputs": { - "nixpkgs": "nixpkgs" + "nixpkgs": [ + "nixpkgs-unstable" + ] }, "locked": { - "lastModified": 1676351500, - "narHash": "sha256-hqoge5a3xQwtmKkhDKyEbbD7mqZ40ag12LzrwFtXEDk=", + "lastModified": 1677884572, + "narHash": "sha256-gUNEbGK6uq2qY41N9MHqXKPwDuzuTMkmd+UtAHvXeUo=", "owner": "nekowinston", "repo": "nur", - "rev": "b56911487277ebc9f8ea36e175cc6a91f1edb68b", + "rev": "16fd8cf78df90179ad418aee3911b5b8967ca07a", "type": "github" }, "original": { @@ -128,16 +130,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1675940568, - "narHash": "sha256-epG6pOT9V0kS+FUqd7R6/CWkgnZx2DMT5Veqo+y6G3c=", - "owner": "NixOS", + "lastModified": 1677624842, + "narHash": "sha256-4DF9DbDuK4/+KYx0L6XcPBeDHUFVCtzok2fWtwXtb5w=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "6ccc4a59c3f1b56d039d93da52696633e641bc71", + "rev": "d70f5cd5c3bef45f7f52698f39e7cc7a89daa7f0", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", + "owner": "nixos", + "ref": "nixos-22.11", "repo": "nixpkgs", "type": "github" } @@ -191,22 +193,6 @@ } }, "nixpkgs_2": { - "locked": { - "lastModified": 1677624842, - "narHash": "sha256-4DF9DbDuK4/+KYx0L6XcPBeDHUFVCtzok2fWtwXtb5w=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "d70f5cd5c3bef45f7f52698f39e7cc7a89daa7f0", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-22.11", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_3": { "locked": { "lastModified": 1671271357, "narHash": "sha256-xRJdLbWK4v2SewmSStYrcLa0YGJpleufl44A19XSW8k=", @@ -222,7 +208,7 @@ "type": "github" } }, - "nixpkgs_4": { + "nixpkgs_3": { "locked": { "lastModified": 1677468890, "narHash": "sha256-V4MPvt4PKaHSInRLWpaF8ICdC91SH+5bdd0FGxalJIg=", @@ -258,7 +244,7 @@ "flake-compat": "flake-compat", "flake-utils": "flake-utils_2", "gitignore": "gitignore", - "nixpkgs": "nixpkgs_3", + "nixpkgs": "nixpkgs_2", "nixpkgs-stable": "nixpkgs-stable" }, "locked": { @@ -281,7 +267,7 @@ "flake-utils": "flake-utils", "home-manager": "home-manager", "nekowinston-nur": "nekowinston-nur", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable", "nur": "nur", "pre-commit-hooks": "pre-commit-hooks", @@ -290,7 +276,7 @@ }, "sops": { "inputs": { - "nixpkgs": "nixpkgs_4", + "nixpkgs": "nixpkgs_3", "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { diff --git a/flake.nix b/flake.nix index b59d2c1..70a809f 100644 --- a/flake.nix +++ b/flake.nix @@ -16,6 +16,7 @@ }; nur.url = "github:nix-community/NUR"; nekowinston-nur.url = "github:nekowinston/nur"; + nekowinston-nur.inputs.nixpkgs.follows = "nixpkgs-unstable"; sops.url = "github:Mic92/sops-nix"; # dev @@ -44,7 +45,11 @@ nur = import nur { nurpkgs = prev; pkgs = prev; - repoOverrides = {nekowinston = import nekowinston-nur {pkgs = prev;};}; + repoOverrides = { + nekowinston = import nekowinston-nur { + pkgs = import nixpkgs-unstable {system = prev.system;}; + }; + }; }; }; in diff --git a/home/apps/i3.nix b/home/apps/i3.nix index d9d0a1d..b6f12f6 100644 --- a/home/apps/i3.nix +++ b/home/apps/i3.nix @@ -160,7 +160,7 @@ in { } ]; workspaceAutoBackAndForth = true; - terminal = "${lib.getExe pkgs.wezterm} start --always-new-process"; + terminal = "wezterm start --always-new-process"; menu = ""; keybindings = let mod = config.xsession.windowManager.i3.config.modifier; diff --git a/home/apps/rice.nix b/home/apps/rice.nix index 1587e3c..d98ef2a 100644 --- a/home/apps/rice.nix +++ b/home/apps/rice.nix @@ -47,7 +47,7 @@ in { enable = true; font = "Berkeley Mono 14"; extraConfig.icon-theme = "Papirus-Dark"; - terminal = "${lib.getExe pkgs.wezterm}"; + terminal = "wezterm"; theme = ./rofi/theme.rasi; }; } diff --git a/home/apps/wezterm/bar.lua b/home/apps/wezterm/bar.lua index 60dd31b..1515115 100644 --- a/home/apps/wezterm/bar.lua +++ b/home/apps/wezterm/bar.lua @@ -172,7 +172,6 @@ wezterm.on("smartpadding", function(window, pane) end) -- custom status ----@diagnostic disable-next-line: unused-local wezterm.on("update-status", function(window, pane) if wezterm.GLOBAL.smart_padding ~= nil then wezterm.emit("smartpadding", window, pane) @@ -186,6 +185,15 @@ wezterm.on("update-status", function(window, pane) leader_text = "  " end + local mode_text = "" + local mode = window:active_key_table() + local modes = { + resize_mode = "RESIZE", + } + if modes[mode] ~= nil then + mode_text = modes[mode] + end + local divider_bg = first_tab_active and palette.ansi[2] or palette.tab_bar.inactive_tab.bg_color @@ -193,6 +201,9 @@ wezterm.on("update-status", function(window, pane) { Foreground = { Color = palette.background } }, { Background = { Color = palette.ansi[5] } }, { Text = leader_text }, + { Attribute = { Intensity = "Bold" } }, + { Text = mode_text }, + "ResetAttributes", { Background = { Color = divider_bg } }, { Foreground = { Color = palette.ansi[5] } }, { Text = DIVIDERS.RIGHT }, @@ -200,8 +211,8 @@ wezterm.on("update-status", function(window, pane) local time = wezterm.time.now():format("%H:%M") local sun_is_up = wezterm.time.now():sun_times(48.2, 16.366667).up - local icon = sun_is_up and " " or "" - local text = string.format(" %s %s", icon, time) + local icon = sun_is_up and " " or " " + local text = string.format("%s %s", icon, time) window:set_right_status(wezterm.format({ { Background = { Color = palette.tab_bar.background } }, diff --git a/home/apps/wezterm/fonts.lua b/home/apps/wezterm/fonts.lua index 47fe809..ffb5388 100644 --- a/home/apps/wezterm/fonts.lua +++ b/home/apps/wezterm/fonts.lua @@ -2,35 +2,28 @@ local wezterm = require("wezterm") local M = {} -M.get_font = function(name) - -- fonts I like, with the settings I prefer - -- kept separately from the rest of the config so that I can easily change them - local fonts = { - berkeley = { - font = { - family = "Berkeley Mono", - -- weight = "Bold", - }, - size = 16, +-- fonts I like, with the settings I prefer +-- kept separately from the rest of the config so that I can easily change them +local fonts = { + berkeley = { + font = "Berkeley Mono", + size = 16, + }, + comic = { + font = "Comic Code Ligatures", + size = 16, + }, + victor = { + font = { + family = "Victor Mono", + weight = "DemiBold", + harfbuzz_features = { "ss02=1" }, }, - comic = { - font = "Comic Code Ligatures", - size = 18, - }, - fantasque = { - font = "Fantasque Sans Mono", - size = 20, - }, - victor = { - font = { - family = "Victor Mono", - weight = "DemiBold", - harfbuzz_features = { "ss02=1" }, - }, - size = 18, - }, - } + size = 15, + }, +} +M.get_font = function(name) return { font = wezterm.font_with_fallback({ fonts[name].font, @@ -40,4 +33,17 @@ M.get_font = function(name) } end +wezterm.on("switch-font", function(window, _) + local next_font = next(fonts, wezterm.GLOBAL.font) + if next_font == nil then + next_font = next(fonts) + end + wezterm.GLOBAL.font = next_font + + window:set_config_overrides({ + font = M.get_font(next_font).font, + font_size = M.get_font(next_font).size, + }) +end) + return M diff --git a/home/apps/wezterm/keys.lua b/home/apps/wezterm/keys.lua index c23ef89..dfbbbf6 100644 --- a/home/apps/wezterm/keys.lua +++ b/home/apps/wezterm/keys.lua @@ -51,10 +51,9 @@ map("l", "LEADER|SHIFT", act.AdjustPaneSize({ "Right", 5 })) -- spawn & close map("c", "LEADER", act.SpawnTab("CurrentPaneDomain")) map("x", "LEADER", act.CloseCurrentPane({ confirm = true })) -map("t", "SHIFT|CTRL", act.SpawnTab("CurrentPaneDomain")) -map("t", "SUPER", act.SpawnTab("CurrentPaneDomain")) -map("w", "SHIFT|CTRL", act.CloseCurrentTab({ confirm = true })) -map("w", "SUPER", act.CloseCurrentTab({ confirm = true })) +map("t", { "SHIFT|CTRL", "SUPER" }, act.SpawnTab("CurrentPaneDomain")) +map("w", { "SHIFT|CTRL", "SUPER" }, act.CloseCurrentTab({ confirm = true })) +map("n", { "SHIFT|CTRL", "SUPER" }, act.SpawnWindow) -- zoom states map("z", { "LEADER", "SUPER" }, act.TogglePaneZoomState) map("Z", { "LEADER", "SUPER" }, toggleTabBar) @@ -64,26 +63,59 @@ map("c", { "SHIFT|CTRL", "SUPER" }, act.CopyTo("Clipboard")) map("v", { "SHIFT|CTRL", "SUPER" }, act.PasteFrom("Clipboard")) map("f", { "SHIFT|CTRL", "SUPER" }, act.Search("CurrentSelectionOrEmptyString")) -- rotation -map("r", { "LEADER", "SUPER" }, act.RotatePanes("Clockwise")) +map("e", { "LEADER", "SUPER" }, act.RotatePanes("Clockwise")) -- pickers map(" ", "LEADER", act.QuickSelect) map("o", { "LEADER", "SUPER" }, openUrl) map("p", { "LEADER", "SUPER" }, act.PaneSelect({ alphabet = "asdfghjkl;" })) map("R", { "LEADER", "SUPER" }, act.ReloadConfiguration) map("u", "SHIFT|CTRL", act.CharSelect) +map("p", { "SHIFT|CTRL", "SHIFT|SUPER" }, act.ActivateCommandPalette) -- view map("Enter", "ALT", act.ToggleFullScreen) map("-", { "CTRL", "SUPER" }, act.DecreaseFontSize) map("=", { "CTRL", "SUPER" }, act.IncreaseFontSize) map("0", { "CTRL", "SUPER" }, act.ResetFontSize) --- OS defaults -map("n", "SHIFT|CTRL", act.SpawnWindow) -map("n", "SUPER", act.SpawnWindow) +-- switch fonts +map("f", "LEADER", act.EmitEvent("switch-font")) -- debug map("l", "SHIFT|CTRL", act.ShowDebugOverlay) +map( + "r", + { "LEADER", "SUPER" }, + act.ActivateKeyTable({ + name = "resize_mode", + one_shot = false, + }) +) + +local key_tables = { + resize_mode = { + { key = "h", action = act.AdjustPaneSize({ "Left", 1 }) }, + { key = "j", action = act.AdjustPaneSize({ "Down", 1 }) }, + { key = "k", action = act.AdjustPaneSize({ "Up", 1 }) }, + { key = "l", action = act.AdjustPaneSize({ "Right", 1 }) }, + { key = "LeftArrow", action = act.AdjustPaneSize({ "Left", 1 }) }, + { key = "DownArrow", action = act.AdjustPaneSize({ "Down", 1 }) }, + { key = "UpArrow", action = act.AdjustPaneSize({ "Up", 1 }) }, + { key = "RightArrow", action = act.AdjustPaneSize({ "Right", 1 }) }, + }, +} + +-- add a common escape sequence to all key tables +for k, _ in pairs(key_tables) do + table.insert(key_tables[k], { key = "Escape", action = "PopKeyTable" }) + table.insert(key_tables[k], { key = "Enter", action = "PopKeyTable" }) + table.insert( + key_tables[k], + { key = "c", mods = "CTRL", action = "PopKeyTable" } + ) +end + return { leader = { key = "s", mods = "CTRL", timeout_milliseconds = 5000 }, keys = shortcuts, disable_default_key_bindings = true, + key_tables = key_tables, } diff --git a/home/apps/wezterm/wezterm.lua b/home/apps/wezterm/wezterm.lua index 36e1b5b..b2cdc27 100644 --- a/home/apps/wezterm/wezterm.lua +++ b/home/apps/wezterm/wezterm.lua @@ -2,10 +2,11 @@ local wezterm = require("wezterm") local theme = require("theme") require("bar") -local font = require("fonts").get_font("berkeley") wezterm.GLOBAL = { + font = "berkeley", enable_tab_bar = true, } +local font = require("fonts").get_font(wezterm.GLOBAL.font) local options = { set_environment_variables = { diff --git a/home/apps/zsh.nix b/home/apps/zsh.nix index 72c3646..fc7acc2 100644 --- a/home/apps/zsh.nix +++ b/home/apps/zsh.nix @@ -59,6 +59,7 @@ in { for conf in "${functionsDir}"/**/*.zsh; do source "$conf" done + [[ "$TERM_PROGRAM" == "WezTerm" ]] && TERM=wezterm ''; envExtra = '' diff --git a/home/default.nix b/home/default.nix index 3841c78..3f0660e 100644 --- a/home/default.nix +++ b/home/default.nix @@ -51,7 +51,7 @@ in { nur.repos.nekowinston.org-stats (nerdfonts.override {fonts = ["NerdFontsSymbolsOnly"];}) victor-mono - unstable.wezterm + nur.repos.nekowinston.wezterm-nightly ] ++ lib.optionals isLinux [ _1password-gui