From 8b577024a01da8891eb0a92b02d10726b261c05e Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Thu, 7 Dec 2023 10:22:35 +0100 Subject: [PATCH] Worf: various updates: nvim-telescope, yabai, sketchybar, builders --- base.nix | 3 +- common/sketchybar-app-font.nix | 14 ++ home/alacritty.nix | 334 +++++++++++++++++++++++++++++++++ home/neovim.nix | 13 +- home/zsh.nix | 6 +- hosts/worf/configuration.nix | 4 +- hosts/worf/home.nix | 3 +- hosts/worf/yabai.nix | 68 ++++++- 8 files changed, 433 insertions(+), 12 deletions(-) create mode 100644 common/sketchybar-app-font.nix create mode 100644 home/alacritty.nix diff --git a/base.nix b/base.nix index 723f43d..f577ca6 100644 --- a/base.nix +++ b/base.nix @@ -1,7 +1,6 @@ { config, lib, pkgs, inputs, values, ... }: { - boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; @@ -43,13 +42,13 @@ environment.systemPackages = with pkgs; [ bat bottom - unstable.eza git gnugrep gnutar ripgrep rsync tree + unstable.eza wget ]; diff --git a/common/sketchybar-app-font.nix b/common/sketchybar-app-font.nix new file mode 100644 index 0000000..f537e25 --- /dev/null +++ b/common/sketchybar-app-font.nix @@ -0,0 +1,14 @@ +{ lib, stdenvNoCC, fetchurl }: + +stdenvNoCC.mkDerivation rec { + name = "sketchybar-app-font"; + version = "1.0.20"; + src = fetchurl { + url = "https://github.com/kvndrsslr/sketchybar-app-font/releases/download/v${version}/sketchybar-app-font.ttf"; + hash = "sha256-pf3SSxzlNIdbXXHfRauFCnrVUMOd5J9sSUE9MsfWrwo="; + }; + phases = [ "installPhase" ]; + installPhase = '' + install -Dm644 $src $out/share/fonts/sketchybar-app-font/Regular.ttf + ''; +} diff --git a/home/alacritty.nix b/home/alacritty.nix new file mode 100644 index 0000000..1a285b4 --- /dev/null +++ b/home/alacritty.nix @@ -0,0 +1,334 @@ +{ pkgs, lib, inputs, config, ...}: +{ + programs.alacritty = { + enable = true; + settings = { + env = { + TERM = "xterm-256color"; + }; + + window = { + padding = { + x = 4; + y = 4; + }; + + decorations = "none"; # full/none/transparent/buttonless + + # Transparency: + # opacity = 0.95; + }; + + scrolling = { + history = 9999; + multiplier = 3; + }; + + # Font configuration (changes require restart) + font = { + normal = { + family = "Hack Nerd Font Mono"; + style = "Regular"; + }; + + bold = { + family = "Hack Nerd Font Mono"; + style = "Bold"; + }; + + italic = { + family = "Hack Nerd Font Mono"; + style = "Italic"; + }; + + size = 14; + }; + + draw_bold_text_with_bright_colors = true; + + colors = { + # # Tomorrow Night Bright + # primary = { + # background = "0x141414"; + # foreground = "0xeaeaea"; + # }; + + # cursor = { + # text = "0x000000"; + # cursor = "0xffffff"; + # }; + + # normal = { + # black = "0x000000"; + # red = "0xd54e53"; + # green = "0x82de37"; + # yellow = "0xe6c547"; + # blue = "0x7aa6da"; + # magenta = "0xc397d8"; + # cyan = "0x70c0ba"; + # white = "0xffffff"; + # }; + + # bright = { + # black = "0x666666"; + # red = "0xff3334"; + # green = "0x8bd45d"; + # yellow = "0xe7c547"; + # blue = "0x7aa6da"; + # magenta = "0xb77ee0"; + # cyan = "0x54ced6"; + # white = "0xffffff"; + # }; + + # Nord: + primary = { + background = "0x2e3440"; + foreground = "0xd8dee9"; + dim_foreground = "0xa5abb6"; + }; + + cursor = { + text = "0x2e3440"; + cursor = "0xd8dee9"; + }; + + vi_mode_cursor = { + text = "0x2e3440"; + cursor = "0xd8dee9"; + }; + + selection = { + text = "CellForeground"; + background = "0x4c566a"; + }; + + normal = { + black = "0x3b4252"; + red = "0xbf616a"; + green = "0xa3be8c"; + yellow = "0xebcb8b"; + blue = "0x81a1c1"; + magenta = "0xb48ead"; + cyan = "0x88c0d0"; + white = "0xe5e9f0"; + }; + + bright = { + black = "0x4c566a"; + red = "0xbf616a"; + green = "0xa3be8c"; + yellow = "0xebcb8b"; + blue = "0x81a1c1"; + magenta = "0xb48ead"; + cyan = "0x8fbcbb"; + white = "0xeceff4"; + }; + + dim = { + black = "0x373e4d"; + red = "0x94545d"; + green = "0x809575"; + yellow = "0xb29e75"; + blue = "0x68809a"; + magenta = "0x8c738c"; + cyan = "0x6d96a5"; + white = "0xaeb3bb"; + }; + + + + # Indexed Colors + # + # The indexed colors include all colors from 16 to 256. + # When these are not set, they're filled with sensible defaults. + # + # Example: + # `- { index: 16, color: '0xff00ff' }` + # + # indexed_colors: [] + }; + + visual_bell = { + animation = "EaseOutExpo"; + color = "0xffffff"; + duration = 200; + }; + + # Key bindings + # + # Key bindings are specified as a list of objects. Each binding will specify a + # key and modifiers required to trigger it, terminal modes where the binding is + # applicable, and what should be done when the key binding fires. It can either + # send a byte sequence to the running application (`chars`), execute a + # predefined action (`action`) or fork and execute a specified command plus + # arguments (`command`). + # + # Bindings are always filled by default, but will be replaced when a new binding + # with the same triggers is defined. To unset a default binding, it can be + # mapped to the `None` action. + # + # Example: + # `- { key: V, mods: Control|Shift, action: Paste }` + # + # Available fields: + # - key + # - mods (optional) + # - chars | action | command (exactly one required) + # - mode (optional) + # + # Values for `key`: + # - `A` -> `Z` + # - `F1` -> `F12` + # - `Key1` -> `Key0` + # + # A full list with available key codes can be found here: + # https://docs.rs/glutin/*/glutin/enum.VirtualKeyCode.html#variants + # + # Instead of using the name of the keys, the `key` field also supports using + # the scancode of the desired key. Scancodes have to be specified as a + # decimal number. + # This command will allow you to display the hex scancodes for certain keys: + # `showkey --scancodes` + # + # Values for `mods`: + # - Command + # - Control + # - Option + # - Super + # - Shift + # - Alt + # + # Multiple `mods` can be combined using `|` like this: `mods: Control|Shift`. + # Whitespace and capitalization is relevant and must match the example. + # + # Values for `chars`: + # The `chars` field writes the specified string to the terminal. This makes + # it possible to pass escape sequences. + # To find escape codes for bindings like `PageUp` ("\x1b[5~"), you can run + # the command `showkey -a` outside of tmux. + # Note that applications use terminfo to map escape sequences back to + # keys. It is therefore required to update the terminfo when + # changing an escape sequence. + # + # Values for `action`: + # - Paste + # - PasteSelection + # - Copy + # - IncreaseFontSize + # - DecreaseFontSize + # - ResetFontSize + # - ScrollPageUp + # - ScrollPageDown + # - ScrollLineUp + # - ScrollLineDown + # - ScrollToTop + # - ScrollToBottom + # - ClearHistory + # - Hide + # - Quit + # - ClearLogNotice + # - SpawnNewInstance + # - ToggleFullscreen + # - None + # + # Values for `action` (macOS only): + # - ToggleSimpleFullscreen: Enters fullscreen without occupying another space + # + # Values for `command`: + # The `command` field must be a map containing a `program` string and + # an `args` array of command line parameter strings. + # + # Example: + # `command: { program: "alacritty", args: ["-e", "vttest"] }` + # + # Values for `mode`: + # - ~AppCursor + # - AppCursor + # - ~AppKeypad + # - AppKeypad + # + # key_bindings: + # - { key: V, mods: Alt, action: Paste } + # - { key: C, mods: Alt, action: Copy } + # - { key: Q, mods: Alt, action: Quit } + # - { key: N, mods: Alt, action: SpawnNewInstance } + # - { key: Return, mods: Alt, action: ToggleFullscreen } + + # - { key: Home, chars: "\x1bOH", mode: AppCursor } + # - { key: Home, chars: "\x1b[H", mode: ~AppCursor } + # - { key: End, chars: "\x1bOF", mode: AppCursor } + # - { key: End, chars: "\x1b[F", mode: ~AppCursor } + # - { key: Equals, mods: Alt, action: IncreaseFontSize } + # - { key: Minus, mods: Alt, action: DecreaseFontSize } + # - { key: Minus, mods: Alt|Shift, action: ResetFontSize } + # - { key: PageUp, mods: Shift, chars: "\x1b[5;2~" } + # - { key: PageUp, mods: Control, chars: "\x1b[5;5~" } + # - { key: PageUp, chars: "\x1b[5~" } + # - { key: PageDown, mods: Shift, chars: "\x1b[6;2~" } + # - { key: PageDown, mods: Control, chars: "\x1b[6;5~" } + # - { key: PageDown, chars: "\x1b[6~" } + # - { key: Left, mods: Shift, chars: "\x1b[1;2D" } + # - { key: Left, mods: Control, chars: "\x1b[1;5D" } + # - { key: Left, mods: Alt, chars: "\x1b[1;3D" } + # - { key: Left, chars: "\x1b[D", mode: ~AppCursor } + # - { key: Left, chars: "\x1bOD", mode: AppCursor } + # - { key: Right, mods: Shift, chars: "\x1b[1;2C" } + # - { key: Right, mods: Control, chars: "\x1b[1;5C" } + # - { key: Right, mods: Alt, chars: "\x1b[1;3C" } + # - { key: Right, chars: "\x1b[C", mode: ~AppCursor } + # - { key: Right, chars: "\x1bOC", mode: AppCursor } + # - { key: Up, mods: Shift, chars: "\x1b[1;2A" } + # - { key: Up, mods: Control, chars: "\x1b[1;5A" } + # - { key: Up, mods: Alt, chars: "\x1b[1;3A" } + # - { key: Up, chars: "\x1b[A", mode: ~AppCursor } + # - { key: Up, chars: "\x1bOA", mode: AppCursor } + # - { key: Down, mods: Shift, chars: "\x1b[1;2B" } + # - { key: Down, mods: Control, chars: "\x1b[1;5B" } + # - { key: Down, mods: Alt, chars: "\x1b[1;3B" } + # - { key: Down, chars: "\x1b[B", mode: ~AppCursor } + # - { key: Down, chars: "\x1bOB", mode: AppCursor } + # - { key: Tab, mods: Shift, chars: "\x1b[Z" } + # - { key: F1, chars: "\x1bOP" } + # - { key: F2, chars: "\x1bOQ" } + # - { key: F3, chars: "\x1bOR" } + # - { key: F4, chars: "\x1bOS" } + # - { key: F5, chars: "\x1b[15~" } + # - { key: F6, chars: "\x1b[17~" } + # - { key: F7, chars: "\x1b[18~" } + # - { key: F8, chars: "\x1b[19~" } + # - { key: F9, chars: "\x1b[20~" } + # - { key: F10, chars: "\x1b[21~" } + # - { key: F11, chars: "\x1b[23~" } + # - { key: F12, chars: "\x1b[24~" } + # - { key: Back, chars: "\x7f" } + # - { key: Back, mods: Alt, chars: "\x1b\x7f" } + # - { key: Insert, chars: "\x1b[2~" } + # - { key: Delete, chars: "\x1b[3~" } + + + + mouse = { + double_click = { threshold = 300; }; + triple_click = { threshold = 300; }; + hide_when_typing = false; + }; + + selection = { + semantic_escape_chars = ",│`|:\"' ()[]{}<>"; + save_to_clipboard = false; + }; + + mouse_bindings = [ + { mouse = "Middle"; action = "PasteSelection"; } + ]; + + cursor = { + style = "Block"; + blinking = true; + unfocused_hollow = true; + }; + + dynamic_title = true; + }; + }; +} diff --git a/home/neovim.nix b/home/neovim.nix index 96240d2..61cbb19 100644 --- a/home/neovim.nix +++ b/home/neovim.nix @@ -16,6 +16,7 @@ nerdtree nerdtree-git-plugin vim-devicons + telescope-nvim nvim-lspconfig copilot-vim @@ -96,7 +97,17 @@ autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif " List and switch buffers on Ctrl+k - nnoremap :set nomore :ls :set more :b + " nnoremap :set nomore :ls :set more :b + nnoremap !echo "Did you mean C-a?" + + " Telescope-settings + nnoremap ff Telescope find_files + nnoremap fg Telescope live_grep + nnoremap fb Telescope buffers + nnoremap fh Telescope help_tags + nnoremap Telescope buffers + nnoremap Telescope find_files + nnoremap Telescope live_grep " Show trailing whitespace highlight ExtraWhitespace ctermbg=red guibg=red diff --git a/home/zsh.nix b/home/zsh.nix index 2929dc8..75d2e5b 100644 --- a/home/zsh.nix +++ b/home/zsh.nix @@ -21,10 +21,10 @@ "terminal" "editor" "history" - "directory" + # "directory" "spectrum" - "utility" - "completion" + # "utility" + # "completion" "git" "autosuggestions" "syntax-highlighting" diff --git a/hosts/worf/configuration.nix b/hosts/worf/configuration.nix index 80ac00b..b8f6351 100644 --- a/hosts/worf/configuration.nix +++ b/hosts/worf/configuration.nix @@ -55,9 +55,10 @@ systemPackages = with pkgs; [ findutils gnugrep + jq ripgrep - wget sshfs + wget ]; variables = { @@ -82,6 +83,7 @@ font-awesome fira-code hack-font + (nerdfonts.override { fonts = [ "Hack" diff --git a/hosts/worf/home.nix b/hosts/worf/home.nix index 8da8b84..da34b44 100644 --- a/hosts/worf/home.nix +++ b/hosts/worf/home.nix @@ -6,10 +6,11 @@ }: { imports = [ ./../../home/base.nix + ./../../home/alacritty.nix ]; home.packages = with pkgs; [ - alacritty + # alacritty emacs iterm2 spotify diff --git a/hosts/worf/yabai.nix b/hosts/worf/yabai.nix index a4b7214..6f8698b 100644 --- a/hosts/worf/yabai.nix +++ b/hosts/worf/yabai.nix @@ -1,23 +1,35 @@ - { config, pkgs, lib, ... }: let cfg = config.services.yabai; + sketchybar-app-font = pkgs.callPackage ./../../common/sketchybar-app-font.nix {}; in { services.yabai = { enable = true; + package = pkgs.unstable.yabai; enableScriptingAddition = true; config = { layout = "bsp"; debug_output = "on"; focus_follows_mouse = "autoraise"; mouse_follows_focus = "off"; + window_placement = "second_child"; window_opacity = "off"; + window_border = "on"; + window_border_width = 1; + window_border_blur = "off"; + normal_window_border_color = "0xff404066"; + active_window_border_color = "0xffff2020"; + + window_border_radius = 0; + # top_padding = 10; # bottom_padding = 10; # left_padding = 10; # right_padding = 10; - window_gap = 10; + window_gap = 0; + + external_bar = "all:40:0"; }; }; @@ -27,6 +39,7 @@ in { mod = "alt"; mod2 = "alt + ctrl"; mod3 = "alt + shift"; + mod4 = "alt + cmd"; in '' # Move window focus ${mod} - j : yabai -m window --focus south @@ -59,11 +72,58 @@ in { ${mod2} - 6 : yabai -m window --space 6 ${mod2} - 7 : yabai -m window --space 7 - # Misc + # Switch spaces + ctrl - left : yabai -m space --focus prev + ctrl - right : yabai -m space --focus next + ctrl - 1 : yabai -m space --focus 1 + ctrl - 2 : yabai -m space --focus 2 + ctrl - 3 : yabai -m space --focus 3 + ctrl - 4 : yabai -m space --focus 4 + ctrl - 5 : yabai -m space --focus 5 + ctrl - 6 : yabai -m space --focus 6 + ctrl - 7 : yabai -m space --focus 7 + + # Resize windows + ${mod2} - j : yabai -m window --resize bottom:0:20 + ${mod2} - k : yabai -m window --resize bottom:0:-20 + ${mod2} - h : yabai -m window --resize right:-20:0 + ${mod2} - l : yabai -m window --resize right:20:0 + + ${mod2} - down : yabai -m window --resize bottom:0:20 + ${mod2} - up : yabai -m window --resize bottom:0:-20 + ${mod2} - left : yabai -m window --resize right:-20:0 + ${mod2} - right : yabai -m window --resize right:20:0 + + # Move windows to different displays + ${mod2} + cmd - 1 : yabai -m window --display 1 + ${mod2} + cmd - 2 : yabai -m window --display 2 + ${mod2} + cmd - 3 : yabai -m window --display 3 + + # Fullscreen ${mod2} - f : yabai -m window --toggle zoom-fullscreen + ${mod2} + shift - f : yabai -m window --toggle native-fullscreen + + # Mirror layout + ${mod2} - m : yabai -m space --mirror y-axis + + # Misc. ${mod2} - b : yabai -m space --balance - ${mod3} - space : yabai -m window --toggle float --grid 4:4:1:1:2:2 + ${mod2} - space : yabai -m window --toggle float --grid 4:4:1:1:2:2 + ${mod2} - return : yabai -m window --toggle split + + # Launch terminal + cmd - return : open -n -a ${pkgs.alacritty}/Applications/Alacritty.app ''; }; + + services.sketchybar = { + enable = true; + package = pkgs.unstable.sketchybar; + # The config is handled outside of nix, and is placed in ~/.config/sketchybar + }; + + fonts.fonts = [ + sketchybar-app-font + ]; }