diff --git a/.gitmodules b/.gitmodules index c1366da14..740ca3ea2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,3 @@ [submodule "zsh/plugins/zsh-autosuggestions"] path = zsh/plugins/zsh-autosuggestions url = https://github.com/zsh-users/zsh-autosuggestions.git -[submodule "zsh/plugins/oh-my-zsh"] - path = zsh/plugins/oh-my-zsh - url = https://github.com/robbyrussell/oh-my-zsh.git diff --git a/README.md b/README.md index 456391482..241d023e4 100644 --- a/README.md +++ b/README.md @@ -1,97 +1,9 @@ # Awesome Dotfiles -Simple, but extensive customization of ZSH, TMUX, and Vim. +A snapshot of my current configuration. -[![VideoWalkthrough](https://img.youtube.com/vi/UgDz_9i2nwc/0.jpg)](https://www.youtube.com/watch?v=UgDz_9i2nwc) - -## Setup Options - -There are 3 ways in which you can use this, depending on how much you think you'll be customizing. - -One of the key features is that this implementation stays in sync across all your machines. So depending on how much you'd like to customize your configuration, you have a few options: - -- Little Customization: Just clone this repo and jump to [Installation](#installation). -- Mild Customization: [Fork]() this repo, and clone your own fork. Keep an eye on this repo for bugfixes and other improvements that you'd like to incorporate into your fork. Then jump to [Installation](#installation). -- Most Customization: Building your own dotfiles from scratch! Read through these docs, watch the video above, star this repo, and create your own dotfiles! You can add this repository as a [git module](https://git-scm.com/book/en/v2/Git-Tools-Submodules) and source the parts you like. - -If you're unsure, just read the docs, watch the video, clone this repository, and jump to [Installation](#installation). - -## Installation - -Once the repo is cloned, execute the deploy script: - -```shell -./deploy -``` - -This script guides you through the following: - -1. Checks to see if you have zsh, tmux, and vim installed. -2. Installs them using your default package manager if you don't have some of them installed. -3. Checks to see if your default shell is zsh. -4. Sets zsh to your default shell. -5. Backs up your old configuration files. - -Pretty convenient for configuring new servers. - -## **Summary of Changes** - -## Basic runtime operations - -All default dotfiles (`.zshrc`, `.vimrc`, etc) source something within the dotfiles repository. This helps separate changes that are synced across all your machines with system-specific changes. +You can see an older snapshot in video form here: -Upon launching a new shell, the first thing that's evaluated is `zshrc_manager.sh`. This script first launches tmux. Then once zsh logs in, within tmux, it updates the dotfiles repository, and sources the changes. - -## [Zsh](https://en.wikipedia.org/wiki/Z_shell) - -- `cd` has been reassigned to `cd` and `ls`. Every time you navigate to a new directory, it will display the content of that directory. -- `v` has been aliased too: `vim -p`. This lets you open multiple files in vim as tabs. - -### Prompt - -The prompt takes on the form: - -```shell -[plugin, plugin, ...]: -``` - -Each plugin is sensitive to where you are and what you're doing, they reveal themselves when it's contextually relevant. Plugins include: - -- `PWD plugin`: always present, tells you where you are. Always the first plugin. -- `Status code plugin`: appears anytime a program returns with a non-zero status code. Tells you what status code the program completed with. -- `Git plugin`: appears when you're in a git repository. Tells you what branch you're on, and how many files have been changed since the last commit. -- `Sudo plugin`: tells you when you can sudo without a password. Or when you're logged in as root. -- `Time plugin`: appears when a program took more than 1s to execute. Tells you how long it took to execute. -- `PID plugin`: appears when you background a task. Tells you what the PID of the task is. - -### Keybindings - -| Key Stroke | What It Does | -| ---------- | ------------------------------------------------------------------------------------------| -| Ctrl-H | Goes to the root of a git project, runs `cd $(git rev-parse --show-toplevel || echo ".")` | -| Ctrl-K | Runs `cd ..` | -| Ctrl-G | Runs `git add -A; git commit -v && git push` | -| Ctrl-V | Runs `fc`. Takes last command and puts it in a vim buffer. | -| Ctrl-S | Adds `sudo` to the beginning of the buffer. | -| Ctrl-L | Runs `ls`. | -| Ctrl-O | Equivalent to hitting `Enter`. | -| Ctrl-P | Equivalent to pressing `Up Arrow`. | - -### Plugins - -- [zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions): Searches your history while you type and provides suggestions. -- [zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting/tree/ad522a091429ba180c930f84b2a023b40de4dbcc): Provides fish style syntax highlighting for zsh. -- [ohmyzsh](https://github.com/robbyrussell/oh-my-zsh/tree/291e96dcd034750fbe7473482508c08833b168e3): Borrowed things like tab completion, fixing ls, tmux's vi-mode plugin. -- [vimode-zsh](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/vi-mode) allows you to hit `esc` and navigate the current buffer using vim movement keys. - -## [Vim]() - -- Leader key has been remapped to `,` - -## [Tmux](https://en.wikipedia.org/wiki/Tmux) +[![VideoWalkthrough](https://img.youtube.com/vi/UgDz_9i2nwc/0.jpg)](https://www.youtube.com/watch?v=UgDz_9i2nwc) -- Ctrl-B has been remapped to the backtick character (`). If you want to type the actual backtick character (`) itself, just hit the key twice. -- `%` has been remapped to `v`. -- Use vim movement keys for moving between panes. -- Copy buffer is copied to xclip. -- Status bar tells you date, time, user, and hostname. Especially useful with nested ssh sessions. +The date on the video should serve as a reasonable indication for the commit you may be looking for. diff --git a/aerospace/aerospace.toml b/aerospace/aerospace.toml new file mode 100644 index 000000000..0dbcedf7a --- /dev/null +++ b/aerospace/aerospace.toml @@ -0,0 +1,212 @@ +# Place a copy of this config to ~/.aerospace.toml +# After that, you can edit ~/.aerospace.toml to your liking + +# You can use it to add commands that run after login to macOS user session. +# 'start-at-login' needs to be 'true' for 'after-login-command' to work +# Available commands: https://nikitabobko.github.io/AeroSpace/commands +after-login-command = [] + +# You can use it to add commands that run after AeroSpace startup. +# 'after-startup-command' is run after 'after-login-command' +# Available commands : https://nikitabobko.github.io/AeroSpace/commands +after-startup-command = [] + +# Start AeroSpace at login +start-at-login = false + +# Normalizations. See: https://nikitabobko.github.io/AeroSpace/guide#normalization +enable-normalization-flatten-containers = true +enable-normalization-opposite-orientation-for-nested-containers = true + +# See: https://nikitabobko.github.io/AeroSpace/guide#layouts +# The 'accordion-padding' specifies the size of accordion padding +# You can set 0 to disable the padding feature +accordion-padding = 30 + +# Possible values: tiles|accordion +default-root-container-layout = 'tiles' + +# Possible values: horizontal|vertical|auto +# 'auto' means: wide monitor (anything wider than high) gets horizontal orientation, +# tall monitor (anything higher than wide) gets vertical orientation +default-root-container-orientation = 'auto' + +# Mouse follows focus when focused monitor changes +# Drop it from your config, if you don't like this behavior +# See https://nikitabobko.github.io/AeroSpace/guide#on-focus-changed-callbacks +# See https://nikitabobko.github.io/AeroSpace/commands#move-mouse +# Fallback value (if you omit the key): on-focused-monitor-changed = [] +on-focused-monitor-changed = ['move-mouse monitor-lazy-center'] + +# You can effectively turn off macOS "Hide application" (cmd-h) feature by toggling this flag +# Useful if you don't use this macOS feature, but accidentally hit cmd-h or cmd-alt-h key +# Also see: https://nikitabobko.github.io/AeroSpace/goodies#disable-hide-app +automatically-unhide-macos-hidden-apps = false + +# Possible values: (qwerty|dvorak|colemak) +# See https://nikitabobko.github.io/AeroSpace/guide#key-mapping +[key-mapping] + preset = 'qwerty' + +# Gaps between windows (inner-*) and between monitor edges (outer-*). +# Possible values: +# - Constant: gaps.outer.top = 8 +# - Per monitor: gaps.outer.top = [{ monitor.main = 16 }, { monitor."some-pattern" = 32 }, 24] +# In this example, 24 is a default value when there is no match. +# Monitor pattern is the same as for 'workspace-to-monitor-force-assignment'. +# See: +# https://nikitabobko.github.io/AeroSpace/guide#assign-workspaces-to-monitors +[gaps] + inner.horizontal = 0 + inner.vertical = 0 + outer.left = 0 + outer.bottom = 0 + outer.top = 0 + outer.right = 0 + +# 'main' binding mode declaration +# See: https://nikitabobko.github.io/AeroSpace/guide#binding-modes +# 'main' binding mode must be always presented +# Fallback value (if you omit the key): mode.main.binding = {} +[mode.main.binding] + + # All possible keys: + # - Letters. a, b, c, ..., z + # - Numbers. 0, 1, 2, ..., 9 + # - Keypad numbers. keypad0, keypad1, keypad2, ..., keypad9 + # - F-keys. f1, f2, ..., f20 + # - Special keys. minus, equal, period, comma, slash, backslash, quote, semicolon, + # backtick, leftSquareBracket, rightSquareBracket, space, enter, esc, + # backspace, tab, pageUp, pageDown, home, end, forwardDelete, + # sectionSign (ISO keyboards only, european keyboards only) + # - Keypad special. keypadClear, keypadDecimalMark, keypadDivide, keypadEnter, keypadEqual, + # keypadMinus, keypadMultiply, keypadPlus + # - Arrows. left, down, up, right + + # All possible modifiers: cmd, alt, ctrl, shift + + # All possible commands: https://nikitabobko.github.io/AeroSpace/commands + + # See: https://nikitabobko.github.io/AeroSpace/commands#exec-and-forget + # You can uncomment the following lines to open up terminal with alt + enter shortcut + # (like in i3) + # alt-enter = '''exec-and-forget osascript -e ' + # tell application "Terminal" + # do script + # activate + # end tell' + # ''' + + # See: https://nikitabobko.github.io/AeroSpace/commands#layout + alt-slash = 'layout tiles horizontal vertical' + alt-comma = 'layout accordion horizontal vertical' + + # See: https://nikitabobko.github.io/AeroSpace/commands#focus + alt-h = 'focus left' + alt-j = 'focus down' + alt-k = 'focus up' + alt-l = 'focus right' + + # See: https://nikitabobko.github.io/AeroSpace/commands#move + alt-shift-h = 'move left' + alt-shift-j = 'move down' + alt-shift-k = 'move up' + alt-shift-l = 'move right' + + # See: https://nikitabobko.github.io/AeroSpace/commands#resize + alt-minus = 'resize smart -50' + alt-equal = 'resize smart +50' + + # See: https://nikitabobko.github.io/AeroSpace/commands#workspace + alt-1 = 'workspace 1' + alt-2 = 'workspace 2' + alt-3 = 'workspace 3' + alt-4 = 'workspace 4' + alt-5 = 'workspace 5' + alt-6 = 'workspace 6' + alt-7 = 'workspace 7' + alt-8 = 'workspace 8' + alt-9 = 'workspace 9' + alt-a = 'workspace A' # In your config, you can drop workspace bindings that you don't need + alt-b = 'workspace B' + alt-c = 'workspace C' + alt-d = 'workspace D' + alt-e = 'workspace E' + alt-f = 'workspace F' + alt-g = 'workspace G' + alt-i = 'workspace I' + alt-m = 'workspace M' + alt-n = 'workspace N' + alt-o = 'workspace O' + alt-p = 'workspace P' + alt-q = 'workspace Q' + alt-r = 'workspace R' + alt-s = 'workspace S' + alt-t = 'workspace T' + alt-u = 'workspace U' + alt-v = 'workspace V' + alt-w = 'workspace W' + alt-x = 'workspace X' + alt-y = 'workspace Y' + alt-z = 'workspace Z' + + # See: https://nikitabobko.github.io/AeroSpace/commands#move-node-to-workspace + alt-shift-1 = 'move-node-to-workspace 1' + alt-shift-2 = 'move-node-to-workspace 2' + alt-shift-3 = 'move-node-to-workspace 3' + alt-shift-4 = 'move-node-to-workspace 4' + alt-shift-5 = 'move-node-to-workspace 5' + alt-shift-6 = 'move-node-to-workspace 6' + alt-shift-7 = 'move-node-to-workspace 7' + alt-shift-8 = 'move-node-to-workspace 8' + alt-shift-9 = 'move-node-to-workspace 9' + alt-shift-a = 'move-node-to-workspace A' + alt-shift-b = 'move-node-to-workspace B' + alt-shift-c = 'move-node-to-workspace C' + alt-shift-d = 'move-node-to-workspace D' + alt-shift-e = 'move-node-to-workspace E' + alt-shift-f = 'move-node-to-workspace F' + alt-shift-g = 'move-node-to-workspace G' + alt-shift-i = 'move-node-to-workspace I' + alt-shift-m = 'move-node-to-workspace M' + alt-shift-n = 'move-node-to-workspace N' + alt-shift-o = 'move-node-to-workspace O' + alt-shift-p = 'move-node-to-workspace P' + alt-shift-q = 'move-node-to-workspace Q' + alt-shift-r = 'move-node-to-workspace R' + alt-shift-s = 'move-node-to-workspace S' + alt-shift-t = 'move-node-to-workspace T' + alt-shift-u = 'move-node-to-workspace U' + alt-shift-v = 'move-node-to-workspace V' + alt-shift-w = 'move-node-to-workspace W' + alt-shift-x = 'move-node-to-workspace X' + alt-shift-y = 'move-node-to-workspace Y' + alt-shift-z = 'move-node-to-workspace Z' + + # See: https://nikitabobko.github.io/AeroSpace/commands#workspace-back-and-forth + alt-tab = 'workspace-back-and-forth' + # See: https://nikitabobko.github.io/AeroSpace/commands#move-workspace-to-monitor + alt-shift-tab = 'move-workspace-to-monitor --wrap-around next' + + # See: https://nikitabobko.github.io/AeroSpace/commands#mode + alt-shift-semicolon = 'mode service' + +# 'service' binding mode declaration. +# See: https://nikitabobko.github.io/AeroSpace/guide#binding-modes +[mode.service.binding] + esc = ['reload-config', 'mode main'] + r = ['flatten-workspace-tree', 'mode main'] # reset layout + f = ['layout floating tiling', 'mode main'] # Toggle between floating and tiling layout + backspace = ['close-all-windows-but-current', 'mode main'] + + # sticky is not yet supported https://github.com/nikitabobko/AeroSpace/issues/2 + #s = ['layout sticky tiling', 'mode main'] + + alt-shift-h = ['join-with left', 'mode main'] + alt-shift-j = ['join-with down', 'mode main'] + alt-shift-k = ['join-with up', 'mode main'] + alt-shift-l = ['join-with right', 'mode main'] + + down = 'volume down' + up = 'volume up' + shift-down = ['volume set 0', 'mode main'] diff --git a/alacritty/alacritty.yml b/alacritty/alacritty.yml deleted file mode 100644 index 435ebdb9c..000000000 --- a/alacritty/alacritty.yml +++ /dev/null @@ -1,29 +0,0 @@ -draw_bold_text_with_bright_colors: false - -colors: - primary: - background: '0x2D2A2E' - foreground: '0xFCFCFA' - - normal: - black: '0x403E41' - red: '0xFF6188' - green: '0xA9DC76' - yellow: '0xFFD866' - blue: '0xFC9867' - magenta: '0xAB9DF2' - cyan: '0x78DCE8' - white: '0xFCFCFA' - - bright: - black: '0x727072' - red: '0xFF6188' - green: '0xA9DC76' - yellow: '0xFFD866' - blue: '0xFC9867' - magenta: '0xAB9DF2' - cyan: '0x78DCE8' - white: '0xFCFCFA' - -key_bindings: -- { key: N, mods: Command, action: SpawnNewInstance } diff --git a/deploy b/deploy deleted file mode 100755 index 13e48d429..000000000 --- a/deploy +++ /dev/null @@ -1,101 +0,0 @@ -prompt_install() { - echo -n "$1 is not installed. Would you like to install it? (y/n) " >&2 - old_stty_cfg=$(stty -g) - stty raw -echo - answer=$( while ! head -c 1 | grep -i '[ny]' ;do true ;done ) - stty $old_stty_cfg && echo - if echo "$answer" | grep -iq "^y" ;then - # This could def use community support - if [ -x "$(command -v apt-get)" ]; then - sudo apt-get install $1 -y - - elif [ -x "$(command -v brew)" ]; then - brew install $1 - - elif [ -x "$(command -v pkg)" ]; then - sudo pkg install $1 - - elif [ -x "$(command -v pacman)" ]; then - sudo pacman -S $1 - - else - echo "I'm not sure what your package manager is! Please install $1 on your own and run this deploy script again. Tests for package managers are in the deploy script you just ran starting at line 13. Feel free to make a pull request at https://github.com/parth/dotfiles :)" - fi - fi -} - -check_for_software() { - echo "Checking to see if $1 is installed" - if ! [ -x "$(command -v $1)" ]; then - prompt_install $1 - else - echo "$1 is installed." - fi -} - -check_default_shell() { - if [ -z "${SHELL##*zsh*}" ] ;then - echo "Default shell is zsh." - else - echo -n "Default shell is not zsh. Do you want to chsh -s \$(which zsh)? (y/n)" - old_stty_cfg=$(stty -g) - stty raw -echo - answer=$( while ! head -c 1 | grep -i '[ny]' ;do true ;done ) - stty $old_stty_cfg && echo - if echo "$answer" | grep -iq "^y" ;then - chsh -s $(which zsh) - else - echo "Warning: Your configuration won't work properly. If you exec zsh, it'll exec tmux which will exec your default shell which isn't zsh." - fi - fi -} - -echo "We're going to do the following:" -echo "1. Grab dependencies" -echo "2. Check to make sure you have zsh, vim, and tmux installed" -echo "3. We'll help you install them if you don't" -echo "4. We're going to check to see if your default shell is zsh" -echo "5. We'll try to change it if it's not" - -echo "Let's get started? (y/n)" -old_stty_cfg=$(stty -g) -stty raw -echo -answer=$( while ! head -c 1 | grep -i '[ny]' ;do true ;done ) -stty $old_stty_cfg -if echo "$answer" | grep -iq "^y" ;then - echo -else - echo "Quitting, nothing was changed." - exit 0 -fi - -git submodule update --init --recursive -check_for_software zsh -echo -check_for_software vim -echo -check_for_software tmux -echo - -check_default_shell - -echo -echo -n "Would you like to backup your current dotfiles? (y/n) " -old_stty_cfg=$(stty -g) -stty raw -echo -answer=$( while ! head -c 1 | grep -i '[ny]' ;do true ;done ) -stty $old_stty_cfg -if echo "$answer" | grep -iq "^y" ;then - mv ~/.zshrc ~/.zshrc.old - mv ~/.tmux.conf ~/.tmux.conf.old - mv ~/.vimrc ~/.vimrc.old -else - echo -e "\nNot backing up old dotfiles." -fi - -printf "source '$HOME/dotfiles/zsh/zshrc_manager.sh'" > ~/.zshrc -printf "so $HOME/dotfiles/vim/vimrc.vim" > ~/.vimrc -printf "source-file $HOME/dotfiles/tmux/tmux.conf" > ~/.tmux.conf - -echo -echo "Please log out and log back in for default shell to be initialized." diff --git a/env-vars.env b/env-vars.env new file mode 100644 index 000000000..dfdb49692 --- /dev/null +++ b/env-vars.env @@ -0,0 +1,5 @@ +# Set default text editor to vim +export VISUAL=vim + +# Utils +export PATH=$PATH:$HOME/dotfiles/utils diff --git a/nix/apply-macbook.sh b/nix/apply-macbook.sh new file mode 100755 index 000000000..7455632cf --- /dev/null +++ b/nix/apply-macbook.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +sudo darwin-rebuild switch --impure --flake .#default diff --git a/nix/apply.sh b/nix/apply.sh new file mode 100755 index 000000000..f2ff38b8f --- /dev/null +++ b/nix/apply.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ $# -eq 0 ] + then + echo "supply file as argument" + exit 1 +fi + +sudo rm -rf /etc/nixos/configuration.nix && sudo cp $HOME/dotfiles/nix/$1 /etc/nixos/configuration.nix && sudo nixos-rebuild switch diff --git a/nix/common/fish.nix b/nix/common/fish.nix new file mode 100644 index 000000000..2f07e4ad4 --- /dev/null +++ b/nix/common/fish.nix @@ -0,0 +1,12 @@ +{ ... }: +{ + programs.fish = { + enable = true; + interactiveShellInit = '' + fish_vi_key_bindings + set -gx PATH $HOME/.cargo/bin $PATH + set -gx EDITOR nvim + set -gx VISUAL nvim + ''; + }; +} diff --git a/nix/common/git.nix b/nix/common/git.nix new file mode 100644 index 000000000..7a73e67db --- /dev/null +++ b/nix/common/git.nix @@ -0,0 +1,11 @@ +{ ... }: +{ + programs.git = { + enable = true; + userName = "parth"; + userEmail = "parth@mehrotra.me"; + extraConfig = { + push.default = "current"; + }; + }; +} diff --git a/nix/common/gui.nix b/nix/common/gui.nix new file mode 100644 index 000000000..8be653dbf --- /dev/null +++ b/nix/common/gui.nix @@ -0,0 +1,71 @@ +{ pkgs, lib, ... }: { + + + # from: https://wiki.nixos.org/wiki/Sway + environment.systemPackages = with pkgs; [ + grim + slurp + wl-clipboard + mako + wdisplays + ]; + services.gnome.gnome-keyring.enable = true; + programs.sway = { + enable = true; + wrapperFeatures.gtk = true; + }; + xdg.portal = { + enable = true; + wlr.enable = true; + extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; + }; + # end sway + + services.printing.enable = true; + services.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + + fonts.packages = [ ] ++ builtins.filter lib.attrsets.isDerivation (builtins.attrValues pkgs.nerd-fonts); + + users.users.parth.packages = with pkgs; [ + zed-editor + _1password-gui + google-chrome + discord + spotify + wezterm + lockbook-desktop + nautilus + vlc + ]; + + programs.obs-studio = { + enable = true; + plugins = with pkgs.obs-studio-plugins; [ + obs-vaapi #optional AMD hardware acceleration + ]; + }; + + programs._1password-gui.enable = true; + programs.chromium = { + enable = true; + extraOpts = { + "PasswordManagerEnabled" = false; + }; + }; + + systemd.services."getty@tty1".enable = false; + systemd.services."autovt@tty1".enable = false; + + programs.virt-manager.enable = true; + users.groups.libvirtd.members = [ "parth" ]; + virtualisation.libvirtd.enable = true; + virtualisation.spiceUSBRedirection.enable = true; + +} diff --git a/nix/common/headless.nix b/nix/common/headless.nix new file mode 100644 index 000000000..f70f5bbe4 --- /dev/null +++ b/nix/common/headless.nix @@ -0,0 +1,79 @@ +{ pkgs, ... }: + +let + home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/release-25.05.tar.gz"; +in +{ + imports = + [ + # Include the results of the hardware scan. + # ./hardware-configuration.nix + "/etc/nixos/hardware-configuration.nix" + "/home/parth/dotfiles/nix/common/fish.nix" + (import "${home-manager}/nixos") + ]; + + networking.networkmanager.enable = true; + + time.timeZone = "America/New_York"; + i18n.defaultLocale = "en_US.UTF-8"; + i18n.extraLocaleSettings = { + LC_ADDRESS = "en_US.UTF-8"; + LC_IDENTIFICATION = "en_US.UTF-8"; + LC_MEASUREMENT = "en_US.UTF-8"; + LC_MONETARY = "en_US.UTF-8"; + LC_NAME = "en_US.UTF-8"; + LC_NUMERIC = "en_US.UTF-8"; + LC_PAPER = "en_US.UTF-8"; + LC_TELEPHONE = "en_US.UTF-8"; + LC_TIME = "en_US.UTF-8"; + }; + + users.defaultUserShell = pkgs.fish; + + home-manager.users.parth = { + /* The home.stateVersion option does not have a default and must be set */ + home.stateVersion = "18.09"; + /* Here goes the rest of your home-manager config, e.g. home.packages = [ pkgs.foo ]; */ + + imports = [ + "/home/parth/dotfiles/nix/common/nvim.nix" + "/home/parth/dotfiles/nix/common/git.nix" + "/home/parth/dotfiles/nix/common/xdg.nix" + ]; + }; + + users.users.parth = { + isNormalUser = true; + description = "parth"; + extraGroups = [ "networkmanager" "wheel" ]; + packages = with pkgs; [ + fzf + ripgrep + clang + samba + rust-analyzer + rustup + nixpkgs-fmt + google-cloud-sdk + lockbook + ]; + }; + + environment.variables = { EDITOR = "nvim"; VISUAL = "nvim"; }; + nixpkgs.config.allowUnfree = true; + system.stateVersion = "24.05"; + + fileSystems."/truenas" = { + device = "//192.168.12.2/parth-dataset"; + fsType = "cifs"; + options = [ + "credentials=/etc/nixos/smb-secrets" + "uid=1000" + "gid=100" + "vers=3.0" + "x-systemd.automount" + "noauto" + ]; + }; +} diff --git a/nix/common/nvim.nix b/nix/common/nvim.nix new file mode 100644 index 000000000..37dd5018e --- /dev/null +++ b/nix/common/nvim.nix @@ -0,0 +1,29 @@ +{ pkgs, ... }: +{ + programs.neovim = { + enable = true; + plugins = with pkgs.vimPlugins; [ + nvim-web-devicons + telescope-nvim + nvim-cmp + cmp-nvim-lsp + vim-illuminate + lualine-nvim + + nvim-tree-lua + nvim-lspconfig + luasnip + vim-sleuth + nvim-treesitter + nvim-treesitter.withAllGrammars + gitsigns-nvim + fidget-nvim + ]; + + extraPackages = with pkgs; [ + lua-language-server + nil + nixd + ]; + }; +} diff --git a/nix/common/xdg.nix b/nix/common/xdg.nix new file mode 100644 index 000000000..70b52cc9d --- /dev/null +++ b/nix/common/xdg.nix @@ -0,0 +1,27 @@ +{ config, ... }: +{ + xdg.configFile = { + "nvim" = { + source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/dotfiles/nvim"; + recursive = true; + }; + + "aerospace" = { + source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/dotfiles/aerospace"; + recursive = true; + }; + + "wezterm" = { + source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/dotfiles/wezterm"; + recursive = true; + }; + "sway" = { + source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/dotfiles/sway"; + recursive = true; + }; + }; + + home.sessionPath = [ + "$HOME/.cargo/bin" + ]; +} diff --git a/nix/flake.lock b/nix/flake.lock new file mode 100644 index 000000000..1d0b17881 --- /dev/null +++ b/nix/flake.lock @@ -0,0 +1,106 @@ +{ + "nodes": { + "brew-src": { + "flake": false, + "locked": { + "lastModified": 1756059815, + "narHash": "sha256-UALOxoXoFIHbwKzcqbqCAqw5cC0MJEehLaWSet5vxfE=", + "owner": "Homebrew", + "repo": "brew", + "rev": "02947ea4edbdef5fcce9ee57fa289547f4d096c9", + "type": "github" + }, + "original": { + "owner": "Homebrew", + "ref": "4.6.7", + "repo": "brew", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1757997814, + "narHash": "sha256-F+1aoG+3NH4jDDEmhnDUReISyq6kQBBuktTUqCUWSiw=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "5820376beb804de9acf07debaaff1ac84728b708", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1757430124, + "narHash": "sha256-MhDltfXesGH8VkGv3hmJ1QEKl1ChTIj9wmGAFfWj/Wk=", + "owner": "nix-darwin", + "repo": "nix-darwin", + "rev": "830b3f0b50045cf0bcfd4dab65fad05bf882e196", + "type": "github" + }, + "original": { + "owner": "nix-darwin", + "ref": "master", + "repo": "nix-darwin", + "type": "github" + } + }, + "nix-homebrew": { + "inputs": { + "brew-src": "brew-src" + }, + "locked": { + "lastModified": 1756398546, + "narHash": "sha256-n4GVDLhKu65XFraJuCzap2AaZji4xhPaZMTJ8aQdD3s=", + "owner": "zhaofengli-wip", + "repo": "nix-homebrew", + "rev": "3aa475996cb3bc1ecefa88c99c466e6f0bc17431", + "type": "github" + }, + "original": { + "owner": "zhaofengli-wip", + "repo": "nix-homebrew", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1757967192, + "narHash": "sha256-/aA9A/OBmnuOMgwfzdsXRusqzUpd8rQnQY8jtrHK+To=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0d7c15863b251a7a50265e57c1dca1a7add2e291", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nix-darwin": "nix-darwin", + "nix-homebrew": "nix-homebrew", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nix/flake.nix b/nix/flake.nix new file mode 100644 index 000000000..b33103c85 --- /dev/null +++ b/nix/flake.nix @@ -0,0 +1,144 @@ +{ + description = "Example nix-darwin system flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nix-darwin.url = "github:nix-darwin/nix-darwin/master"; + nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew"; + }; + + outputs = + inputs@{ self + , nix-darwin + , nixpkgs + , home-manager + , nix-homebrew + , + }: + let + configuration = + { pkgs, ... }: + { + nixpkgs.config.allowUnfree = true; + nix.settings.experimental-features = "nix-command flakes"; + homebrew.enable = true; + + # Set Git commit hash for darwin-version. + system.configurationRevision = self.rev or self.dirtyRev or null; + + environment.systemPackages = with pkgs; [ + ffmpeg_6 + + fzf + ripgrep + + lua-language-server + zola + nixpkgs-fmt + nixd + rust-analyzer + rustup + lockbook + # listing clang here makes the macOS clang act strange + ]; + + fonts.packages = with pkgs; [ + nerd-fonts.jetbrains-mono + ]; + + + # Used for backwards compatibility, please read the changelog before changing. + # $ darwin-rebuild changelog + system.stateVersion = 6; + + system.defaults.dock.autohide = true; + + # The platform the configuration will be used on. + nixpkgs.hostPlatform = "aarch64-darwin"; + + + imports = [ + ./common/fish.nix + ]; + + users.knownUsers = [ "parth" ]; + users.users.parth.uid = 501; + system.primaryUser = "parth"; + + users.users.parth = { + home = "/Users/parth"; + shell = pkgs.fish; + }; + + system.keyboard = { + enableKeyMapping = true; + remapCapsLockToEscape = true; + }; + }; + in + { + # Build darwin flake using: + # $ darwin-rebuild build --flake .#simple + darwinConfigurations.default = nix-darwin.lib.darwinSystem { + modules = [ + configuration + + nix-homebrew.darwinModules.nix-homebrew + { + nix-homebrew = { + enable = true; + user = "parth"; + }; + + homebrew = { + enable = true; + + masApps = { + "XCode" = 497799835; + "Lockbook" = 1526775001; + "Lightroom" = 1451544217; + }; + + casks = [ + "zed" + "gimp" + "wezterm" + "google-chrome" + "nikitabobko/tap/aerospace" + "insta360-studio" + "adobe-creative-cloud" + "discord" + "1password" + "spotify" + "chatgpt" + "makemkv" + "musescore" + ]; + }; + } + + + home-manager.darwinModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.backupFileExtension = "backup"; + home-manager.useUserPackages = true; + home-manager.users.parth = { ... }: { + home.stateVersion = "24.05"; + + imports = [ + ./common/nvim.nix + ./common/git.nix + ./common/xdg.nix + ]; + }; + } + ]; + + }; + }; +} +# https://github.com/dustinlyons/nixos-config/blob/8a14e1f0da074b3f9060e8c822164d922bfeec29/modules/darwin/home-manager.nix#L74 diff --git a/nix/laptop.nix b/nix/laptop.nix new file mode 100644 index 000000000..3a1ec9bf9 --- /dev/null +++ b/nix/laptop.nix @@ -0,0 +1,11 @@ +{ + imports = [ + "/home/parth/dotfiles/nix/common/headless.nix" + "/home/parth/dotfiles/nix/common/gui.nix" + ]; + + networking.hostName = "parth-laptop-nix"; + + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; +} diff --git a/nix/server.nix b/nix/server.nix new file mode 100644 index 000000000..84c815cc7 --- /dev/null +++ b/nix/server.nix @@ -0,0 +1,67 @@ +{ pkgs, ... }: { + imports = [ + "/home/parth/dotfiles/nix/common/headless.nix" + ]; + + networking.hostName = "parth-server-nix"; + + # Bootloader. + boot.loader.grub = { + enable = true; + device = "/dev/nvme1n1"; + useOSProber = true; + }; + + services.openssh = { + enable = true; + settings = { + PermitRootLogin = "yes"; + PasswordAuthentication = false; + }; + }; + + systemd.services."getty@tty1".enable = false; + + services.github-runners.lockbook = { + enable = true; + name = "lockbook ci"; + user = "parth"; + extraLabels = [ "ci" ]; + tokenFile = "/home/parth/token"; + url = "https://github.com/lockbook/lockbook"; + extraPackages = with pkgs; [ + rustup + gcc + psmisc + libxkbcommon + ]; + serviceOverrides = { + ProtectSystem = "no"; + ProtectHome = "no"; + PrivateTmp = false; + PrivateDevices = false; + }; + extraEnvironment = { + NIX_PATH = "/nix/var/nix/profiles/per-user/root/channels/nixos"; + LIBRARY_PATH = "${pkgs.libxkbcommon}/lib"; + }; + }; + + users.users.parth = { + openssh.authorizedKeys.keys = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDMjLtM4DKvdCdgajSHcEwFsG2DSdgJ4I4IB4t53YhW8j9iwzmh4wSGQ/lpEiXenfByoeDT6m5idVqMVzTaQScMxKoo+CMcu3gQhj1lK+QKbdCGtXZe6fI8KAJklJxLL11FB8dh3C7LNqI7IQJQD6b2YBqnT1sNlXloNu/ZtOvrt4nOBNrubAipXnTBJDp77ZJfLEv+mlG7cgLWBpTlHTIL5iFfr4sm3hQwqK393FGamVFm6IefEdI8kYXtTHo1WX35XCAgblGjyAk/ic6Xp1va/l6NQRvdYJVaCeI93xWQQ0xuOj7WoicVF6sKrg5HRMYR/YLFLUonSkZeNEXkkgWSpQdwIiYllz4DqFtMnZ6iZKpg4ZmVXFikG2eifCub48YQL31mwGzmpDMfdHjP92CyjgOsJtG23uyEX6RA+3XLrkoSowFql2FwKGV+bQ5ymfzIIwdS8FSZootgDP+KVFG1CJhffcHdQ8TosBqjqZ/NkNhvee1jwbCO/uR4Qv5yxL0=" + ]; + }; + + users.users.adam = { + isNormalUser = true; + home = "/home/adam"; + description = "Adam's account"; + extraGroups = [ "wheel" "networkmanager" ]; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBLMux74pTJaMlfX/sqBnggtRjwoIMgp2Glg6puQZxgC aew31gcmuy@gmail.com" + ]; + }; +} + + diff --git a/nix/workstation.nix b/nix/workstation.nix new file mode 100644 index 000000000..c789c7f60 --- /dev/null +++ b/nix/workstation.nix @@ -0,0 +1,24 @@ +{ config, pkgs, ... }: +{ + networking.hostName = "parth-workstation-nix"; + + services.xserver.videoDrivers = [ "amdgpu" ]; + + # Load nvidia driver for Xorg and Wayland + hardware.graphics = { + enable = true; + enable32Bit = true; + extraPackages = with pkgs; [ + rocmPackages.clr.icd + ]; + }; + + imports = [ + "/home/parth/dotfiles/nix/common/headless.nix" + "/home/parth/dotfiles/nix/common/gui.nix" + ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; +} diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 000000000..791758dec --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,16 @@ +vim.g.mapleader = ' '; + +require("keyboard") +require("config") + +require('auto-dark-mode').setup { + set_dark_mode = function() + require('dark_theme').colorscheme() + require('packages') + end, + set_light_mode = function() + require('light_theme').colorscheme() + require('packages') + end, +} + diff --git a/nvim/lua/auto-dark-mode/health.lua b/nvim/lua/auto-dark-mode/health.lua new file mode 100644 index 000000000..66a231847 --- /dev/null +++ b/nvim/lua/auto-dark-mode/health.lua @@ -0,0 +1,102 @@ +local M = {} + +local uv = vim.uv or vim.loop + +local adm = require("auto-dark-mode") +local interval = require("auto-dark-mode.interval") + +M.benchmark = function(iterations) + local result = { + avg = 0, + max = 0, + min = math.huge, + all_results = {}, + stdout = nil, + stderr = nil, + parsed = nil, + } + + for _ = 1, iterations do + local _start = uv.hrtime() + -- parsing the response is measured, but actually syncing the vim theme isn't performed + local function callback(_stdout, _stderr) + result.stdout = _stdout + result.stderr = _stderr + result.parsed = interval.parse_callback(_stdout, _stderr) + vim.schedule_wrap(function() + vim.print(result) + end) + end + + local success, _ = pcall(interval.poll_dark_mode, callback) + -- bail early if polling fails + if not success then + break + end + local _end = uv.hrtime() + + table.insert(result.all_results, (_end - _start) / 1e6) + end + + local sum = 0 + for _, v in pairs(result.all_results) do + result.max = result.max > v and result.max or v + result.min = result.min < v and result.min or v + sum = sum + v + end + result.avg = sum / iterations + + return result +end + +-- support for neovim < 0.9.0 +local H = vim.health +local health = {} +health.start = H.start or H.report_start +health.ok = H.ok or H.report_ok +health.info = H.info or H.report_info +health.error = H.error or H.report_error + +M.check = function() + health.start("auto-dark-mode.nvim") + + if adm.state.setup_correct then + health.ok("Setup is correct") + else + health.error("Setup is incorrect") + end + + health.info(string.format("Detected operating system: %s", adm.state.system)) + health.info(string.format("Using query command: `%s`", table.concat(adm.state.query_command, " "))) + + interval.poll_dark_mode(function(stdout, stderr) + vim.schedule(function() + health.info(string.format("Query response:\nstdout: %s\nstderr: %s\n", stdout, stderr)) + end) + end) + + local benchmark = M.benchmark(30) + health.info( + string.format("Benchmark: %.2fms avg / %.2fms min / %.2fms max", benchmark.avg, benchmark.min, benchmark.max) + ) + + local update_interval = adm.options.update_interval + local ratio = update_interval / benchmark.avg + local msg = { + info = string.format("Update interval (%dms) is %.2fx the average query time", update_interval, ratio), + error = string.format( + "Update interval (%dms) seems too short compared to current benchmarks, consider increasing it", + update_interval + ), + } + + if ratio > 30 then + health.ok(msg.info) + elseif ratio > 5 then + health.warn(msg.info) + else + health.error(msg.error) + end +end + +return M diff --git a/nvim/lua/auto-dark-mode/init.lua b/nvim/lua/auto-dark-mode/init.lua new file mode 100644 index 000000000..0c0184f1d --- /dev/null +++ b/nvim/lua/auto-dark-mode/init.lua @@ -0,0 +1,179 @@ +local M = {} + +local uv = vim.uv or vim.loop + +---@type AutoDarkModeOptions +local default_options = { + fallback = "dark", + + set_dark_mode = function() + vim.api.nvim_set_option_value("background", "dark", {}) + end, + + set_light_mode = function() + vim.api.nvim_set_option_value("background", "light", {}) + end, + + update_interval = 3000, +} + +---@param options AutoDarkModeOptions +local function validate_options(options) + local version = vim.version() + + if (version.major == 0 and version.minor >= 11) or version.major > 0 then + vim.validate("fallback", options.fallback, function(opt) + return vim.tbl_contains({ "dark", "light" }, opt) + end, "`fallback` to be either 'light' or 'dark'") + vim.validate("set_dark_mode", options.set_dark_mode, "function") + vim.validate("set_light_mode", options.set_light_mode, "function") + vim.validate("update_interval", options.update_interval, "number") + else + vim.validate({ + fallback = { + options.fallback, + function(opt) + return vim.tbl_contains({ "dark", "light" }, opt) + end, + "`fallback` to be either 'light' or 'dark'", + }, + set_dark_mode = { options.set_dark_mode, "function" }, + set_light_mode = { options.set_light_mode, "function" }, + update_interval = { options.update_interval, "number" }, + }) + end + + M.state.setup_correct = true +end + +---@class AutoDarkModeState +M.state = { + ---@type boolean + setup_correct = false, + ---@type DetectedOS + system = nil, + ---@type table + query_command = {}, +} + +---@return nil +M.init = function() + local os_uname = uv.os_uname() + + if string.match(os_uname.release, "WSL") then + M.state.system = "WSL" + elseif string.match(os_uname.release, "orbstack") then + M.state.system = "OrbStack" + else + M.state.system = os_uname.sysname + end + + if M.state.system == "Darwin" or M.state.system == "OrbStack" then + local query_command = { "defaults", "read", "-g", "AppleInterfaceStyle" } + if M.state.system == "OrbStack" then + query_command = vim.list_extend({ "mac" }, query_command) + end + M.state.query_command = query_command + elseif M.state.system == "Linux" then + if vim.fn.executable("dbus-send") == 0 then + error( + "auto-dark-mode.nvim: `dbus-send` is not available. The Linux implementation of auto-dark-mode.nvim relies on `dbus-send` being on the `$PATH`." + ) + end + + M.state.query_command = { + "dbus-send", + "--session", + "--print-reply=literal", + "--reply-timeout=1000", + "--dest=org.freedesktop.portal.Desktop", + "/org/freedesktop/portal/desktop", + "org.freedesktop.portal.Settings.Read", + "string:org.freedesktop.appearance", + "string:color-scheme", + } + elseif M.state.system == "Windows_NT" or M.state.system == "WSL" then + local reg = "reg.exe" + + -- gracefully handle a bunch of WSL specific errors + if M.state.system == "WSL" then + -- automount not being enabled + if not uv.fs_stat("/mnt/c/Windows") then + error( + "auto-dark-mode.nvim: Your WSL configuration doesn't enable `automount`. Please see https://learn.microsoft.com/en-us/windows/wsl/wsl-config#automount-settings." + ) + end + + -- binfmt not being provided for windows executables + if + not ( + uv.fs_stat("/proc/sys/fs/binfmt_misc/WSLInterop") + or uv.fs_stat("/proc/sys/fs/binfmt_misc/WSLInterop-late") + ) + then + error( + "auto-dark-mode.nvim: Your WSL configuration doesn't enable `interop`. Please see https://learn.microsoft.com/en-us/windows/wsl/wsl-config#interop-settings." + ) + end + + -- `appendWindowsPath` being set to false + if vim.fn.executable("reg.exe") == 0 then + local hardcoded_path = "/mnt/c/Windows/system32/reg.exe" + if uv.fs_stat(hardcoded_path) then + reg = hardcoded_path + else + error( + "auto-dark-mode.nvim: `reg.exe` cannot be found. To support syncing with the host system, this plugin relies on `reg.exe` being on the `$PATH`." + ) + end + end + end + + M.state.query_command = { + reg, + "Query", + "HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", + "/v", + "AppsUseLightTheme", + } + else + return + end + + -- when on a supported unix system, and the userid is root + if (M.state.system == "Darwin" or M.state.system == "Linux") and uv.getuid() == 0 then + local sudo_user = vim.env.SUDO_USER + + if not sudo_user then + error( + "auto-dark-mode.nvim: Running as `root`, but `$SUDO_USER` is not set. Please open an issue to add support for your setup." + ) + end + + local prefixed_cmd = { "sudo", "--user", sudo_user } + vim.list_extend(prefixed_cmd, M.state.query_command) + + M.state.query_command = prefixed_cmd + end + + local interval = require("auto-dark-mode.interval") + + interval.start(M.options, M.state) + + -- expose the previous `require("auto-dark-mode").disable()` function + M.disable = interval.stop_timer +end + +---@param options? AutoDarkModeOptions +---@return nil +M.setup = function(options) + if not options then + options = {} + end + M.options = vim.tbl_deep_extend("keep", options or {}, default_options) + validate_options(M.options) + + M.init() +end + +return M diff --git a/nvim/lua/auto-dark-mode/interval.lua b/nvim/lua/auto-dark-mode/interval.lua new file mode 100644 index 000000000..887e37548 --- /dev/null +++ b/nvim/lua/auto-dark-mode/interval.lua @@ -0,0 +1,157 @@ +local M = { + ---@type uv_timer_t + timer = nil, + ---@type number + timer_id = nil, + ---@type Appearance? + current_appearance = nil, +} + +local uv = vim.uv or vim.loop + +-- Parses the query response for each system, returning the current appearance, +-- or `nil` if it can't be resolved. +---@param stdout string +---@param stderr string +---@return Appearance? +local function parse_query_response(stdout, stderr) + if M.state.system == "Linux" then + if stderr ~= "" then + return nil; + end + + -- https://github.com/flatpak/xdg-desktop-portal/blob/c0f0eb103effdcf3701a1bf53f12fe953fbf0b75/data/org.freedesktop.impl.portal.Settings.xml#L32-L46 + -- 0: no preference + -- 1: dark + -- 2: light + if string.match(stdout, "uint32 1") ~= nil then + return "dark" + elseif string.match(stdout, "uint32 [02]") ~= nil then + return "light" + else + return M.options.fallback + end + elseif M.state.system == "Darwin" or M.state.system == "OrbStack" then + return stdout == "Dark\n" and "dark" or "light" + elseif M.state.system == "Windows_NT" or M.state.system == "WSL" then + -- AppsUseLightTheme REG_DWORD 0x0 : dark + -- AppsUseLightTheme REG_DWORD 0x1 : light + return string.match(stdout, "0x1") and "light" or "dark" + end + + return nil +end + +-- Executes the `set_dark_mode` and `set_light_mode` hooks when needed, +-- otherwise it's a no-op. +---@param appearance Appearance +---@return nil +local function sync_theme(appearance) + if appearance == M.current_appearance then + return + end + + M.current_appearance = appearance + if M.current_appearance == "dark" then + if vim.system then + vim.schedule(M.options.set_dark_mode) + else + M.options.set_dark_mode() + end + elseif M.current_appearance == "light" then + if vim.system then + vim.schedule(M.options.set_light_mode) + else + M.options.set_light_mode() + end + end +end + +-- Uses a subprocess to query the system for the current dark mode setting. +-- The callback is called with the plaintext stdout response of the query. +---@param callback? fun(stdout: string, stderr: string): nil +---@return nil +M.poll_dark_mode = function(callback) + -- if no callback is provided, use a no-op + if callback == nil then + callback = function() end + end + + if vim.system then + vim.system(M.state.query_command, { text = true }, function(data) + callback(data.stdout, data.stderr) + end) + else + -- Legacy implementation using `vim.fn.jobstart` instead of `vim.system`, + -- for use in neovim <0.10.0 + local stdout = "" + local stderr = "" + + vim.fn.jobstart(M.state.query_command, { + stderr_buffered = true, + stdout_buffered = true, + on_stderr = function(_, data, _) + stderr = table.concat(data, " ") + end, + on_stdout = function(_, data, _) + stdout = table.concat(data, " ") + end, + on_exit = function(_, _, _) + callback(stdout, stderr) + end, + }) + end +end + +---@param stdout string +---@param stderr string +---@return nil +M.parse_callback = function(stdout, stderr) + local appearance = parse_query_response(stdout, stderr) + + if appearance ~= nil then + sync_theme(appearance) + end +end + +local timer_callback = function() + M.poll_dark_mode(M.parse_callback) +end + +---@return nil +M.start_timer = function() + ---@type number + local interval = M.options.update_interval + + -- needs to check for `vim.system` because the poll function depends on it + if uv and vim.system then + M.timer = uv.new_timer() + M.timer:start(interval, interval, timer_callback) + else + M.timer_id = vim.fn.timer_start(interval, timer_callback, { ["repeat"] = -1 }) + end +end + +---@return nil +M.stop_timer = function() + if uv.timer_stop then + uv.timer_stop(M.timer) + else + vim.fn.timer_stop(M.timer_id) + end +end + +---@param options AutoDarkModeOptions +---@param state AutoDarkModeState +---@return nil +M.start = function(options, state) + M.options = options + M.state = state + + -- act as if the timer has finished once to instantly sync on startup + timer_callback() + + M.start_timer() +end + +return M diff --git a/nvim/lua/auto-dark-mode/types.lua b/nvim/lua/auto-dark-mode/types.lua new file mode 100644 index 000000000..ac67c8ceb --- /dev/null +++ b/nvim/lua/auto-dark-mode/types.lua @@ -0,0 +1,21 @@ +---@meta + +---@alias Appearance "light" | "dark" +---@alias DetectedOS "Linux" | "Darwin" | "Windows_NT" | "WSL" | "OrbStack" + +---@class AutoDarkModeOptions +-- Optional. Fallback theme to use if the system theme can't be detected. +-- Useful for linux and environments without a desktop manager. +---@field fallback? Appearance +-- Optional. The default runs: +-- ```lua +-- vim.api.nvim_set_option_value('background', 'dark', {}) +-- ``` +---@field set_dark_mode? fun(): nil +-- Optional. The default runs: +-- ```lua +-- vim.api.nvim_set_option_value('background', 'light', {}) +-- ``` +---@field set_light_mode? fun(): nil +-- Optional. Specifies the `update_interval` milliseconds a theme check will be performed. +---@field update_interval? number diff --git a/nvim/lua/config.lua b/nvim/lua/config.lua new file mode 100644 index 000000000..340c97f97 --- /dev/null +++ b/nvim/lua/config.lua @@ -0,0 +1,18 @@ +vim.opt.nu = true + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.smartindent = true + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" +vim.opt.undofile = true + +vim.opt.hlsearch = true +vim.opt.incsearch = true + +vim.opt.cursorline = true +vim.api.nvim_set_hl(0, 'CursorLine', { underline = true }) diff --git a/nvim/lua/dark_theme.lua b/nvim/lua/dark_theme.lua new file mode 100644 index 000000000..8dd055748 --- /dev/null +++ b/nvim/lua/dark_theme.lua @@ -0,0 +1,236 @@ +local M = {}; + +-- lua/colors/premonition_dark.lua +-- Mnemonic Dark Premonition – Neovim colorscheme (starter) +-- Palette derived from your JSON theme. + +local p = { + bg = "#080808", + fg = "#FFFFFF", + fg_muted = "#D0D0D0", + comment = "#808080", + border = "#505050", + + -- Accents + cyan = "#6EECF7", + cyan_bright = "#9EF2FA", + green = "#67E4B6", + green_bright = "#93ECCB", + yellow = "#FFDB70", + yellow_bright = "#FFE699", + red = "#FF6680", + red_bright = "#FF99AA", + blue = "#66B2FF", + blue_bright = "#80BFFF", + magenta = "#AC8CD9", + magenta_bright= "#BA9FDF", + + -- UI surfaces + ui = "#1A1A1A", -- status/tab/toolbars + panel = "#00000000", -- transparent-ish; we’ll blend to ui + active_line = "#242424", -- approx of #A0A0A020 over bg + selection = "#2A2A2A", -- comfy visual selection + search_bg = "#16454A", -- readable take on #13DAEC40 + gutter_bg = "#00000000", -- transparent in your theme + + -- Diagnostics backgrounds from your JSON (softened) + info_bg = "#26322D", + hint_bg = "#003366", + error_bg = "#660011", + warn_bg = "#806000", +} + +local function set(name, val) vim.api.nvim_set_hl(0, name, val) end + +local function setup_terminal() + -- Map terminal ANSI to your palette + vim.g.terminal_color_0 = p.border -- black + vim.g.terminal_color_8 = p.fg_muted -- bright black (gray) + + vim.g.terminal_color_1 = p.red + vim.g.terminal_color_9 = p.red_bright + + vim.g.terminal_color_2 = p.green + vim.g.terminal_color_10 = p.green_bright + + vim.g.terminal_color_3 = p.yellow + vim.g.terminal_color_11 = p.yellow_bright + + vim.g.terminal_color_4 = p.blue + vim.g.terminal_color_12 = p.blue_bright + + vim.g.terminal_color_5 = p.magenta + vim.g.terminal_color_13 = p.magenta_bright + + vim.g.terminal_color_6 = p.cyan + vim.g.terminal_color_14 = p.cyan_bright + + vim.g.terminal_color_7 = p.fg_muted + vim.g.terminal_color_15 = p.fg +end + +function M.colorscheme() + vim.cmd("highlight clear") + if vim.fn.exists("syntax_on") == 1 then vim.cmd("syntax reset") end + + vim.o.background = "dark" + vim.g.colors_name = "premonition_dark" + setup_terminal() + + --------------------------------------------------------------------------- + -- Core editor + --------------------------------------------------------------------------- + set("Normal", { fg = p.fg, bg = p.bg }) + set("NormalNC", { fg = p.fg_muted, bg = p.bg }) + set("SignColumn", { bg = p.bg }) + set("LineNr", { fg = p.fg_muted, bg = p.bg }) + set("CursorLineNr", { fg = p.cyan, bg = p.active_line, bold = true }) + set("CursorLine", { bg = p.active_line }) + set("CursorColumn", { bg = p.active_line }) + set("ColorColumn", { bg = p.active_line }) + set("VertSplit", { fg = p.border, bg = p.bg }) + set("WinSeparator", { fg = p.border, bg = p.bg }) + + set("Folded", { fg = p.fg_muted, bg = p.active_line }) + set("FoldColumn", { fg = p.fg_muted, bg = p.bg }) + + set("Visual", { bg = p.selection }) + set("Search", { fg = p.bg, bg = p.search_bg }) + set("IncSearch", { fg = p.bg, bg = p.cyan }) + set("MatchParen", { fg = p.yellow, bold = true }) + + set("Pmenu", { fg = p.fg, bg = p.ui }) + set("PmenuSel", { fg = p.bg, bg = p.cyan }) + set("PmenuSbar", { bg = p.active_line }) + set("PmenuThumb", { bg = p.border }) + + set("StatusLine", { fg = p.fg, bg = p.ui }) + set("StatusLineNC", { fg = p.fg_muted, bg = p.ui }) + set("TabLine", { fg = p.fg_muted, bg = p.ui }) + set("TabLineSel", { fg = p.fg, bg = p.active_line, bold = true }) + set("TabLineFill", { bg = p.ui }) + + set("Whitespace", { fg = p.border }) + set("NonText", { fg = p.border }) + set("SpecialKey", { fg = p.border }) + + --------------------------------------------------------------------------- + -- Syntax (Vim groups) + --------------------------------------------------------------------------- + set("Comment", { fg = p.comment, italic = true }) + set("Identifier", { fg = p.fg }) + set("Function", { fg = p.green, bold = true }) + set("Statement", { fg = p.magenta }) -- e.g. if/for/return + set("Keyword", { fg = p.magenta, italic = true }) + set("Conditional", { fg = p.magenta }) + set("Repeat", { fg = p.magenta }) + set("Operator", { fg = p.comment }) + set("Type", { fg = p.blue }) + set("StorageClass", { fg = p.blue }) + set("Structure", { fg = p.blue }) + set("Constant", { fg = p.cyan }) + set("Boolean", { fg = p.cyan }) + set("Number", { fg = p.cyan }) + set("String", { fg = p.cyan }) + set("Character", { fg = p.cyan }) + set("Special", { fg = p.green }) + set("Delimiter", { fg = p.comment }) + + --------------------------------------------------------------------------- + -- Diagnostics (LSP) + --------------------------------------------------------------------------- + set("Error", { fg = p.red }) + set("Todo", { fg = p.yellow, bold = true }) + set("ErrorMsg", { fg = p.red, bg = p.error_bg, bold = true }) + set("WarningMsg", { fg = p.yellow, bg = p.warn_bg }) + set("MoreMsg", { fg = p.green }) + set("Question", { fg = p.green }) + + set("DiagnosticError", { fg = p.red }) + set("DiagnosticWarn", { fg = p.yellow }) + set("DiagnosticInfo", { fg = p.fg_muted }) + set("DiagnosticHint", { fg = p.fg_muted }) + set("DiagnosticOk", { fg = p.green }) + + set("DiagnosticUnderlineError", { sp = p.red, undercurl = true }) + set("DiagnosticUnderlineWarn", { sp = p.yellow, undercurl = true }) + set("DiagnosticUnderlineInfo", { sp = p.blue, undercurl = true }) + set("DiagnosticUnderlineHint", { sp = p.magenta, undercurl = true }) + + set("DiagnosticVirtualTextError", { fg = p.red, bg = p.error_bg }) + set("DiagnosticVirtualTextWarn", { fg = p.yellow, bg = p.warn_bg }) + set("DiagnosticVirtualTextInfo", { fg = p.fg_muted, bg = p.info_bg }) + set("DiagnosticVirtualTextHint", { fg = p.fg_muted, bg = p.hint_bg }) + + --------------------------------------------------------------------------- + -- Diff / Git + --------------------------------------------------------------------------- + set("DiffAdd", { bg = "#1f2b26", fg = p.green }) -- soft green bg + set("DiffChange", { bg = "#2b2b1f", fg = p.yellow }) + set("DiffDelete", { bg = "#2b1f23", fg = p.red }) + set("DiffText", { bg = "#354134", bold = true }) + + set("GitSignsAdd", { fg = p.green }) + set("GitSignsChange", { fg = p.yellow }) + set("GitSignsDelete", { fg = p.red }) + + --------------------------------------------------------------------------- + -- Treesitter (link to Vim groups to keep it lean) + --------------------------------------------------------------------------- + local links = { + -- Basics + ["@comment"] = "Comment", + ["@punctuation"] = "Delimiter", + ["@operator"] = "Operator", + ["@keyword"] = "Keyword", + ["@conditional"] = "Conditional", + ["@repeat"] = "Repeat", + + ["@type"] = "Type", + ["@type.builtin"] = "Type", + ["@type.definition"] = "Type", + ["@storageclass"] = "StorageClass", + + ["@string"] = "String", + ["@string.escape"] = "Special", + ["@string.regex"] = "Special", + ["@character"] = "Character", + ["@boolean"] = "Boolean", + ["@number"] = "Number", + ["@constant"] = "Constant", + + ["@variable"] = "Identifier", + ["@variable.builtin"] = "Identifier", + ["@constant.builtin"] = "Constant", + + ["@function"] = "Function", + ["@function.builtin"] = "Function", + ["@method"] = "Function", + ["@constructor"] = "Function", + ["@parameter"] = "Identifier", + ["@field"] = "Identifier", + ["@property"] = "Identifier", + ["@attribute"] = "Identifier", + + -- Diagnostics / misc + ["@text.literal"] = "String", + ["@tag"] = "Type", + } + for from, to in pairs(links) do set(from, { link = to }) end + + --------------------------------------------------------------------------- + -- Plugin niceties (Telescope minimal) + --------------------------------------------------------------------------- + set("TelescopeNormal", { fg = p.fg, bg = p.ui }) + set("TelescopeBorder", { fg = p.border, bg = p.ui }) + set("TelescopeSelection", { bg = p.selection }) + set("TelescopeMatching", { fg = p.cyan, bold = true }) + + -- Make current line stand out just a bit + set("Cursor", { reverse = true }) + set("VisualNOS", { bg = p.selection }) +end + +M.setup = M.colorscheme +return M + diff --git a/nvim/lua/keyboard.lua b/nvim/lua/keyboard.lua new file mode 100644 index 000000000..0831c2105 --- /dev/null +++ b/nvim/lua/keyboard.lua @@ -0,0 +1,84 @@ +vim.keymap.set("n", "", vim.cmd.wall) +vim.keymap.set("i", "", ":w") +vim.keymap.set("n", "w", vim.cmd.wq) +vim.keymap.set("n", "", vim.cmd.q) + +local builtin = require('telescope.builtin') +vim.keymap.set('n', 't', builtin.find_files, {}) +vim.keymap.set('n', 'T', builtin.git_files, {}) +vim.keymap.set('n', 'l', builtin.buffers, {}) +vim.keymap.set('n', 'g', builtin.grep_string, {}) +vim.keymap.set('n', 'lg', builtin.live_grep, {}) +vim.keymap.set('n', 'o', builtin.oldfiles, {}) +vim.keymap.set("n", "ff", ":NvimTreeFindFile") +vim.keymap.set("n", "", "") +vim.keymap.set("n", "", "") +vim.keymap.set("n", "", "") +vim.keymap.set("n", "", "") +vim.keymap.set("n", "/", vim.cmd.nohlsearch) +vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {}) + +vim.keymap.set("i", "", vim.cmd.BlameToggle) +vim.keymap.set("n", "", vim.cmd.BlameToggle) + +-- LSP keybindings +vim.api.nvim_create_autocmd('LspAttach', { + desc = 'LSP actions', + callback = function(event) + local opts = { buffer = event.buf } + + vim.keymap.set('n', 'K', 'lua vim.lsp.buf.hover()', opts) + vim.keymap.set('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + vim.keymap.set('n', 'fr', builtin.lsp_references, opts) + vim.keymap.set('n', 'ws', builtin.lsp_workspace_symbols, opts) + vim.keymap.set('n', 'ds', builtin.lsp_document_symbols, opts) + vim.keymap.set('n', 'rn', 'lua vim.lsp.buf.rename()', opts) + vim.keymap.set('n', 'fmt', 'lua vim.lsp.buf.format()', opts) + vim.keymap.set('i', '', 'lua vim.lsp.buf.signature_help()', opts) + vim.keymap.set('n', 'vd', 'lua vim.diagnostic.open_float()', opts) + vim.keymap.set('n', 'nd', 'lua vim.diagnostic.goto_next()', opts) + vim.keymap.set('n', 'pd', 'lua vim.diagnostic.goto_prev()', opts) + vim.keymap.set('n', ' ', 'lua vim.lsp.buf.code_action()', opts) + vim.keymap.set('n', 'nr', function() require('illuminate').goto_next_reference(wrap) end, opts) + vim.keymap.set('n', 'pr', function() require('illuminate').goto_prev_reference(wrap) end, opts) + end +}) + + + +-- Completion related keybindings +local cmp = require('cmp') +cmp.setup({ + sources = { + { name = 'nvim_lsp' }, + }, + mapping = { + [''] = cmp.mapping.confirm({ select = false }), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.select_prev_item({ behavior = 'select' }), + [''] = cmp.mapping.select_next_item({ behavior = 'select' }), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping(function() + if cmp.visible() then + cmp.select_prev_item({ behavior = 'insert' }) + else + cmp.complete() + end + end), + [''] = cmp.mapping(function() + if cmp.visible() then + cmp.select_next_item({ behavior = 'insert' }) + else + cmp.complete() + end + end), + }, + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, +}) + + +-- blame diff --git a/nvim/lua/light_theme.lua b/nvim/lua/light_theme.lua new file mode 100644 index 000000000..e3040f094 --- /dev/null +++ b/nvim/lua/light_theme.lua @@ -0,0 +1,237 @@ +-- lua/colors/premonition_light.lua +-- Mnemonic Light Innovation – Neovim colorscheme (starter) +-- Palette mapped from your JSON. + +local M = {} + +local p = { + -- Core + bg = "#FFFFFF", + fg = "#1A1A1A", + fg_muted = "#505050", + comment = "#808080", + border = "#D0D0D0", + + -- Accents (from JSON) + blue = "#207FDF", + blue_bright = "#66B2FF", + magenta = "#7855AA", + magenta_bright= "#AC8CD9", + green = "#00B371", + green_bright = "#2DD296", + yellow = "#E6AC00", + yellow_bright = "#FFBF00", + red = "#DF2040", + red_bright = "#FF6680", + cyan = "#0FAEBD", + cyan_bright = "#13DAEC", + -- syntax cyan in your block uses 00BBCC; keep both: + cyan_syntax = "#00BBCC", + + -- UI + ui = "#FFFFFF", -- status/tab/toolbars + tabbar = "#F0F0F0", + active_line = "#F6F6F6", -- approx of #A0A0A010 over white + selection = "#EEF6FF", -- gentle selection for light bg + search_bg = "#DCEFF8", -- readable take on #13DAEC40 + + -- Diagnostics backgrounds + error_bg = "#F5DCE0", + warn_bg = "#FDF5D9", + hint_bg = "#DCEAFB", + info_bg = "#E3F5EE", +} + +local function set(name, val) vim.api.nvim_set_hl(0, name, val) end + +local function setup_terminal() + -- Terminal ANSI (from your "terminal.ansi.*") + vim.g.terminal_color_0 = "#1A1A1A" -- black + vim.g.terminal_color_8 = "#808080" -- bright black + + vim.g.terminal_color_1 = p.red + vim.g.terminal_color_9 = p.red_bright + + vim.g.terminal_color_2 = p.green + vim.g.terminal_color_10 = p.green_bright + + vim.g.terminal_color_3 = p.yellow + vim.g.terminal_color_11 = p.yellow_bright + + vim.g.terminal_color_4 = p.blue + vim.g.terminal_color_12 = p.blue_bright + + vim.g.terminal_color_5 = p.magenta + vim.g.terminal_color_13 = p.magenta_bright + + vim.g.terminal_color_6 = p.cyan + vim.g.terminal_color_14 = p.cyan_bright + + vim.g.terminal_color_7 = "#D0D0D0" -- white + vim.g.terminal_color_15 = "#1A1A1A" -- bright white (your JSON maps this dark) +end + +function M.colorscheme() + vim.cmd("highlight clear") + if vim.fn.exists("syntax_on") == 1 then vim.cmd("syntax reset") end + + vim.o.background = "light" + vim.g.colors_name = "premonition_light" + setup_terminal() + + --------------------------------------------------------------------------- + -- Core UI + --------------------------------------------------------------------------- + set("Normal", { fg = p.fg, bg = p.bg }) + set("NormalNC", { fg = p.fg_muted, bg = p.bg }) + set("SignColumn", { bg = p.bg }) + set("LineNr", { fg = p.fg_muted, bg = p.bg }) + set("CursorLineNr", { fg = p.blue, bg = p.active_line, bold = true }) + set("CursorLine", { bg = p.active_line }) + set("CursorColumn", { bg = p.active_line }) + set("ColorColumn", { bg = p.active_line }) + set("VertSplit", { fg = p.border, bg = p.bg }) + set("WinSeparator", { fg = p.border, bg = p.bg }) + + set("Folded", { fg = p.fg_muted, bg = p.active_line }) + set("FoldColumn", { fg = p.fg_muted, bg = p.bg }) + + set("Visual", { bg = p.selection }) + set("Search", { fg = p.fg, bg = p.search_bg }) + set("IncSearch", { fg = p.bg, bg = p.cyan_bright, bold = true }) + set("MatchParen", { fg = p.yellow_bright, bold = true }) + + set("Pmenu", { fg = p.fg, bg = p.ui, blend = 0 }) + set("PmenuSel", { fg = p.bg, bg = p.blue }) + set("PmenuSbar", { bg = p.active_line }) + set("PmenuThumb", { bg = p.border }) + + set("StatusLine", { fg = p.fg, bg = p.ui }) + set("StatusLineNC", { fg = p.fg_muted, bg = p.ui }) + set("TabLine", { fg = p.fg_muted, bg = p.tabbar }) + set("TabLineSel", { fg = p.fg, bg = p.ui, bold = true }) + set("TabLineFill", { bg = p.tabbar }) + + set("Whitespace", { fg = p.border }) + set("NonText", { fg = p.border }) + set("SpecialKey", { fg = p.border }) + + --------------------------------------------------------------------------- + -- Syntax (Vim groups) + --------------------------------------------------------------------------- + set("Comment", { fg = p.comment, italic = true }) + set("Identifier", { fg = p.fg }) + set("Function", { fg = p.green, bold = true }) + set("Statement", { fg = p.magenta }) -- if/for/return + set("Keyword", { fg = p.magenta, italic = true }) + set("Conditional", { fg = p.magenta }) + set("Repeat", { fg = p.magenta }) + set("Operator", { fg = p.comment }) + set("Type", { fg = p.blue }) + set("StorageClass", { fg = p.blue }) + set("Structure", { fg = p.blue }) + set("Constant", { fg = p.cyan_syntax }) + set("Boolean", { fg = p.cyan_syntax }) + set("Number", { fg = p.cyan_syntax }) + set("String", { fg = p.cyan_syntax }) + set("Character", { fg = p.cyan_syntax }) + set("Special", { fg = p.green }) + set("Delimiter", { fg = p.comment }) + + --------------------------------------------------------------------------- + -- Diagnostics (LSP) + --------------------------------------------------------------------------- + set("Error", { fg = p.red }) + set("Todo", { fg = p.yellow_bright, bold = true }) + set("ErrorMsg", { fg = p.red, bg = p.error_bg, bold = true }) + set("WarningMsg", { fg = p.yellow_bright, bg = p.warn_bg }) + set("MoreMsg", { fg = p.green }) + set("Question", { fg = p.green }) + + set("DiagnosticError", { fg = p.red }) + set("DiagnosticWarn", { fg = p.yellow_bright }) + set("DiagnosticInfo", { fg = p.fg_muted }) + set("DiagnosticHint", { fg = p.fg_muted }) + set("DiagnosticOk", { fg = p.green }) + + set("DiagnosticUnderlineError", { sp = p.red, undercurl = true }) + set("DiagnosticUnderlineWarn", { sp = p.yellow_bright, undercurl = true }) + set("DiagnosticUnderlineInfo", { sp = p.blue, undercurl = true }) + set("DiagnosticUnderlineHint", { sp = p.magenta, undercurl = true }) + + set("DiagnosticVirtualTextError", { fg = p.red, bg = p.error_bg }) + set("DiagnosticVirtualTextWarn", { fg = p.yellow_bright, bg = p.warn_bg }) + set("DiagnosticVirtualTextInfo", { fg = p.fg_muted, bg = p.info_bg }) + set("DiagnosticVirtualTextHint", { fg = p.fg_muted, bg = p.hint_bg }) + + --------------------------------------------------------------------------- + -- Diff / Git + --------------------------------------------------------------------------- + set("DiffAdd", { bg = "#E9F6F0", fg = p.green }) + set("DiffChange", { bg = "#F6F1E5", fg = p.yellow }) + set("DiffDelete", { bg = "#F6E9EC", fg = p.red }) + set("DiffText", { bg = "#E3EFE7", bold = true }) + + set("GitSignsAdd", { fg = p.green }) + set("GitSignsChange", { fg = p.yellow }) + set("GitSignsDelete", { fg = p.red }) + + --------------------------------------------------------------------------- + -- Treesitter (link to Vim groups) + --------------------------------------------------------------------------- + local links = { + ["@comment"] = "Comment", + ["@punctuation"] = "Delimiter", + ["@operator"] = "Operator", + ["@keyword"] = "Keyword", + ["@conditional"] = "Conditional", + ["@repeat"] = "Repeat", + + ["@type"] = "Type", + ["@type.builtin"] = "Type", + ["@type.definition"] = "Type", + ["@storageclass"] = "StorageClass", + + ["@string"] = "String", + ["@string.escape"] = "Special", + ["@string.regex"] = "Special", + ["@character"] = "Character", + ["@boolean"] = "Boolean", + ["@number"] = "Number", + ["@constant"] = "Constant", + + ["@variable"] = "Identifier", + ["@variable.builtin"] = "Identifier", + ["@constant.builtin"] = "Constant", + + ["@function"] = "Function", + ["@function.builtin"] = "Function", + ["@method"] = "Function", + ["@constructor"] = "Function", + ["@parameter"] = "Identifier", + ["@field"] = "Identifier", + ["@property"] = "Identifier", + ["@attribute"] = "Identifier", + + ["@text.literal"] = "String", + ["@tag"] = "Type", + } + for from, to in pairs(links) do set(from, { link = to }) end + + --------------------------------------------------------------------------- + -- Telescope (minimal) + --------------------------------------------------------------------------- + set("TelescopeNormal", { fg = p.fg, bg = p.ui }) + set("TelescopeBorder", { fg = p.border, bg = p.ui }) + set("TelescopeSelection", { bg = p.selection }) + set("TelescopeMatching", { fg = p.blue, bold = true }) + + set("Cursor", { reverse = true }) + set("VisualNOS", { bg = p.selection }) + + +end + +M.setup = M.colorscheme +return M + diff --git a/nvim/lua/packages.lua b/nvim/lua/packages.lua new file mode 100644 index 000000000..1c3abc8b0 --- /dev/null +++ b/nvim/lua/packages.lua @@ -0,0 +1,167 @@ +-- illuminate +require("illuminate").configure {} +vim.api.nvim_set_hl(0, "IlluminatedWordText", { link = "CursorLine" }) +vim.api.nvim_set_hl(0, "IlluminatedWordRead", { link = "CursorLine" }) +vim.api.nvim_set_hl(0, "IlluminatedWordWrite", { link = "CursorLine" }) + +require("gitsigns").setup { + current_line_blame = true, +} + +-- for status line things +-- require('lsp-status').register_progress() +require('fidget').setup {} +require('lualine').setup { + options = { + icons_enabled = true, + theme = { + normal = { + a = { fg = "#000000", bg = "#66B2FF", gui = "bold" }, + b = { fg = "#FFFFFF", bg = "#242424" }, + c = { fg = "#FFFFFF", bg = "#1A1A1A" } + }, + insert = { a = { fg = "#1A1A1A", bg = "#FFDB70", gui = "bold" } }, + visual = { a = { fg = "#1A1A1A", bg = "#AC8CD9", gui = "bold" } }, + replace = { a = { fg = "#1A1A1A", bg = "#FF6680", gui = "bold" } }, + command = { a = { fg = "#1A1A1A", bg = "#6EECF7", gui = "bold" } }, + inactive = { + a = { fg = "#D0D0D0", bg = "#1A1A1A" }, + b = { fg = "#D0D0D0", bg = "#1A1A1A" }, + c = { fg = "#D0D0D0", bg = "#1A1A1A" } + }, + }, + component_separators = { left = '', right = '' }, + section_separators = { left = '', right = '' }, + disabled_filetypes = { + statusline = { 'NvimTree' }, + winbar = { 'NvimTree' }, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 100, + tabline = 100, + winbar = 100, + } + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch', { + 'diff', + symbols = { added = ' ', modified = ' ', removed = ' ' }, + diff_color = { + added = { fg = '#67E4B6' }, + modified = { fg = '#66B2FF' }, + removed = { fg = '#FF6680' }, + }, + color = { bg = '#2A2A2A', fg = '#FFFFFF' }, -- ← custom background here + } }, + lualine_c = {}, + lualine_x = { 'filetype' }, + -- lualine_y = { "require'lsp-status'.status()" }, + lualine_z = { 'location' } + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { 'filename' }, + lualine_x = { 'location' }, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = { + lualine_a = { + { + 'filename', + path = 3, -- 0: just filename, 1: relative, 2: absolute, 3: absolute + tilde (~) + symbols = { + modified = ' ●', + readonly = ' ', + unnamed = '[No Name]', + }, + }, + }, + lualine_z = { + { + 'diagnostics', + sources = { 'nvim_diagnostic' }, + sections = { 'error', 'warn', 'info', 'hint' }, + symbols = { error = ' ', warn = ' ', info = ' ', hint = ' ' }, + -- per-severity colors (foregrounds) + diagnostics_color = { + error = { fg = '#FF6680', bg = '#2A2A2A' }, -- red text on dark gray + warn = { fg = '#FFDB70', bg = '#2A2A2A' }, -- yellow + info = { fg = '#6EECF7', bg = '#2A2A2A' }, -- cyan + hint = { fg = '#D0D0D0', bg = '#2A2A2A' }, -- light gray + }, + color = { fg = '#FFFFFF', bg = '#2A2A2A' }, -- set both! + -- always_visible = true, -- uncomment to test even with 0 diags + }, + }, + }, + inactive_winbar = {}, + extensions = {} +} + +-- for tree things +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 +require("nvim-tree").setup({ + diagnostics = { + enable = true + } +}) + +local lspconfig = require("lspconfig") + +lspconfig.rust_analyzer.setup({ + settings = { + ["rust-analyzer"] = { + cargo = { + allFeatures = true, + }, + checkOnSave = { + command = "clippy", + }, + }, + }, +}) + +lspconfig.lua_ls.setup { + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using + -- (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { + 'vim', + 'require' + }, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { + enable = false, + }, + }, + }, +} +lspconfig.nixd.setup { + settings = { + nixd = { + formatting = { + command = { "nixpkgs-fmt" } + } + } + } +} +lspconfig.nil_ls.setup {} diff --git a/nvim/todo.md b/nvim/todo.md new file mode 100644 index 000000000..efa3bab7c --- /dev/null +++ b/nvim/todo.md @@ -0,0 +1,12 @@ ++ run actions (codelens) ++ still some disatisfactory hanging lsp behaviors ++ flow for hitting cargo clippy and jumping through all the problems ++ restore the file progress (there are no scrollbars) ++ use clippy instead of cargo check (it's a rust config -- checkOnSave) ++ show full path, so when you gd inside a crate you know where you are ++ rust lsp function accept add () ++ tree goto next diagnostic same way as lsp ++ find current file in tree (cntrl 1 or something) ++ dark mode light mode syntax highlighting is still kinda busted + +read about nvim rust extensions: https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/lsp-extensions.md diff --git a/sway/config b/sway/config new file mode 100644 index 000000000..9588415f6 --- /dev/null +++ b/sway/config @@ -0,0 +1,241 @@ +input "type:keyboard" xkb_options caps:escape + +# todo: Use Mod1 for Alt. +set $mod Mod4 + +gaps inner 10 + +set $left h +set $down j +set $up k +set $right l + +bindsym $mod+Return exec wezterm +bindsym $mod+backslash exec google-chrome-stable +bindsym $mod+Space exec wmenu-run +bindsym $mod+d exec discord +bindsym $mod+shift+t exec wezterm start bash -c 'lockbook edit todo.md && lockbook sync && read -p "enter to cont"' +bindsym $mod+o exec lockbook-desktop + +set $A 'LG Electronics LG ULTRAGEAR 301NTZNBU797' +set $B 'California Institute of Technology HDMI demoset-1' +set $C 'LG Electronics LG HDR 4K 111NTMX7X891' + +output $A mode 3840x2160 position 3335,1420 +output $B mode 1920x1200 position 4038,3580 +output $C mode 3840x2160 position 1175,407 transform 90 + +bindsym $mod+shift+control+q exec swaylock -f -F -c 000000 --ring-color FFDB70 --inside-color FFDB70 --inside-wrong-color FF6680 --inside-ver-color AC8CD9 --key-hl-color 66B2FF + +# exec swayidle -w \ +# timeout 300 'swaylock -f -c 000000' \ +# timeout 600 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \ +# before-sleep 'swaylock -f -c 000000' + +# Kill focused window +bindsym $mod+Shift+q kill +bindsym $mod+shift+control+4 exec grim -g "$(slurp)" - | wl-copy + +# Drag floating windows by holding down $mod and left mouse button. +# Resize them with right mouse button + $mod. +# Despite the name, also works for non-floating windows. +# Change normal to inverse to use left mouse button for resizing and right +# mouse button for dragging. +floating_modifier $mod normal + +# Reload the configuration file +bindsym $mod+Shift+c reload + +# Exit sway (logs you out of your Wayland session) +bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -B 'Yes, exit sway' 'swaymsg exit' + +# Move your focus around +bindsym $mod+$left focus left +bindsym $mod+$down focus down +bindsym $mod+$up focus up +bindsym $mod+$right focus right +# Or use $mod+[up|down|left|right] +bindsym $mod+Left focus left +bindsym $mod+Down focus down +bindsym $mod+Up focus up +bindsym $mod+Right focus right + +# Move the focused window with the same, but add Shift +bindsym $mod+Shift+$left move left +bindsym $mod+Shift+$down move down +bindsym $mod+Shift+$up move up +bindsym $mod+Shift+$right move right +# Ditto, with arrow keys +bindsym $mod+Shift+Left move left +bindsym $mod+Shift+Down move down +bindsym $mod+Shift+Up move up +bindsym $mod+Shift+Right move right +# +# Workspaces: +# + +# Switch to workspace +bindsym $mod+1 workspace number 1 +bindsym $mod+2 workspace number 2 +bindsym $mod+3 workspace number 3 +bindsym $mod+4 workspace number 4 +bindsym $mod+5 workspace number 5 +bindsym $mod+6 workspace number 6 +bindsym $mod+7 workspace number 7 +bindsym $mod+8 workspace number 8 +bindsym $mod+9 workspace number 9 +bindsym $mod+0 workspace number 10 +# Move focused container to workspace +bindsym $mod+Shift+1 move container to workspace number 1 +bindsym $mod+Shift+2 move container to workspace number 2 +bindsym $mod+Shift+3 move container to workspace number 3 +bindsym $mod+Shift+4 move container to workspace number 4 +bindsym $mod+Shift+5 move container to workspace number 5 +bindsym $mod+Shift+6 move container to workspace number 6 +bindsym $mod+Shift+7 move container to workspace number 7 +bindsym $mod+Shift+8 move container to workspace number 8 +bindsym $mod+Shift+9 move container to workspace number 9 +bindsym $mod+Shift+0 move container to workspace number 10 + +# You can "split" the current object of your focus with +# $mod+b or $mod+v, for horizontal and vertical splits +# respectively. +bindsym $mod+b splith +bindsym $mod+v splitv + +# Switch the current container between different layout styles +bindsym $mod+s layout stacking +bindsym $mod+w layout tabbed +bindsym $mod+e layout toggle split + +# Make the current focus fullscreen +bindsym $mod+f fullscreen + +# Toggle the current focus between tiling and floating mode +bindsym $mod+Shift+space floating toggle + +# Swap focus between the tiling area and the floating area +bindsym $mod+t focus mode_toggle + +# Move focus to the parent container +bindsym $mod+a focus parent +# +# Scratchpad: +# + # Sway has a "scratchpad", which is a bag of holding for windows. + # You can send windows there and get them back later. + + # Move the currently focused window to the scratchpad + bindsym $mod+Shift+minus move scratchpad + + # Show the next scratchpad window or hide the focused scratchpad window. + # If there are multiple scratchpad windows, this command cycles through them. + bindsym $mod+minus scratchpad show +# +# Resizing containers: +# +mode "resize" { + # left will shrink the containers width + # right will grow the containers width + # up will shrink the containers height + # down will grow the containers height + bindsym $left resize shrink width 10px + bindsym $down resize grow height 10px + bindsym $up resize shrink height 10px + bindsym $right resize grow width 10px + + # Ditto, with arrow keys + bindsym Left resize shrink width 10px + bindsym Down resize grow height 10px + bindsym Up resize shrink height 10px + bindsym Right resize grow width 10px + + # Return to default mode + bindsym Return mode "default" + bindsym Escape mode "default" +} +bindsym $mod+r mode "resize" +# +# Utilities: +# + # Special keys to adjust volume via PulseAudio + bindsym --locked XF86AudioMute exec pactl set-sink-mute \@DEFAULT_SINK@ toggle + bindsym --locked XF86AudioLowerVolume exec pactl set-sink-volume \@DEFAULT_SINK@ -5% + bindsym --locked XF86AudioRaiseVolume exec pactl set-sink-volume \@DEFAULT_SINK@ +5% + bindsym --locked XF86AudioMicMute exec pactl set-source-mute \@DEFAULT_SOURCE@ toggle + # Special keys to adjust brightness via brightnessctl + bindsym --locked XF86MonBrightnessDown exec brightnessctl set 5%- + bindsym --locked XF86MonBrightnessUp exec brightnessctl set 5%+ + # Special key to take a screenshot with grim + bindsym Print exec grim + +# +# Status Bar: +# +# Read `man 5 sway-bar` for more information about this section. + +set $grey #808080 +set $red #FF6680 +set $green #67E4B6 +set $yellow #FFDB70 +set $blue #66B2FF +set $magenta #AC8CD9 +set $cyan #6EECF7 +set $white #F0F0F0 + +bar { + position top + + # When the status_command prints a new line to stdout, swaybar updates. + # The default just shows the current date and time. + status_command while date +'%Y-%m-%d %X '; do sleep 1; done + + colors { + statusline #ffffff + background #000000 + +# border background text + focused_workspace $yellow $yellow #000000 + active_workspace $yellow #000000 $yellow + inactive_workspace #000000 #000000 $yellow + urgent_workspace $red $red #000000 + binding_mode $magenta $magenta #000000 + } +} + +# default_border pixel 2 +# default_floating_border pixel 2 +default_border normal +default_floating_border normal +titlebar_padding 6 8 + +# === Palette === +exec_always swaybg -c '#000000' + +set $grey #808080 +set $red #FF6680 +set $green #67E4B6 +set $yellow #FFDB70 +set $blue #66B2FF +set $magenta #AC8CD9 +set $cyan #6EECF7 +set $white #F0F0F0 + +# set $black #505050 +# set $red #DF2040 +# set $green #2DD296 +# set $yellow #FFBF00 +# set $blue #207FDF +# set $magenta #7855AA +# set $cyan #13DAEC +# set $white #D0D0D0 + +# client. +client.focused $yellow $yellow #000000 $yellow $yellow +client.focused_inactive $grey #000000 $yellow $grey $grey +client.unfocused $grey #000000 #ffffff $grey $grey +client.urgent $red $red #000000 $red $red + +client.background $black + +include /etc/sway/config.d/* diff --git a/tmux/tmux-keybindings.conf b/tmux/tmux-keybindings.conf deleted file mode 100644 index 72ff8db38..000000000 --- a/tmux/tmux-keybindings.conf +++ /dev/null @@ -1,30 +0,0 @@ -# Prefix -unbind C-b -set -g prefix ` -bind ` send-prefix - -# New window -unbind '"' -unbind % -bind '"' split-window -c "#{pane_current_path}" -bind v split-window -h -c "#{pane_current_path}" -bind c new-window -c "#{pane_current_path}" - -# Easy Config Reloads -bind r source-file ~/.tmux.conf - -# Direction -bind h select-pane -L -bind j select-pane -D -bind k select-pane -U -bind l select-pane -R - -# Vim selection: -unbind [ -bind Escape copy-mode -unbind p -bind p paste-buffer -bind-key -Tcopy-mode-vi 'v' send -X begin-selection -bind-key -Tcopy-mode-vi 'y' send -X copy-pipe "~/dotfiles/utils/copy" - -setw -g mode-keys vi diff --git a/tmux/tmux.conf b/tmux/tmux.conf deleted file mode 100644 index 28a41ec68..000000000 --- a/tmux/tmux.conf +++ /dev/null @@ -1,30 +0,0 @@ -set -g default-terminal "screen-256color" -source-file ~/dotfiles/tmux/tmux-keybindings.conf -set -g focus-events on - -# Enable mouse mode (tmux 2.1 and above) -set -g mouse on - -# Quiet -set-option -g visual-activity off -set-option -g visual-bell off -set-option -g visual-silence off -set-window-option -g monitor-activity off -set-option -g bell-action none - -# Panes -set -g pane-border-style fg=black,bright -set -g pane-active-border-style fg=yellow -set -g base-index 1 - -# Statusbarset -g status-style bg=black -set -g status-style bg=yellow -set -g status-left '' -set -g status-right '#[fg=black,bg=yellow] #(whoami)@#H ' -set -g status-right-length 70 -setw -g window-status-current-format '#[fg=yellow,bg=black] #I #W #F ' -setw -g window-status-format '#[fg=black,bg=yellow][#I #W #F]' -set -g window-status-separator '' -set-option -g history-limit 250000 - -set-option -g renumber-windows on diff --git a/utils/copy b/utils/copy old mode 100755 new mode 100644 index dfdf61fa2..6c8a4c1f2 --- a/utils/copy +++ b/utils/copy @@ -1,3 +1,4 @@ +#!/bin/zsh if [[ $OSTYPE == darwin* ]]; then pbcopy elif [[ $OSTYPE == cygwin* ]]; then @@ -6,7 +7,7 @@ else if (( $+commands[xclip] )); then xclip -in -selection clipboard elif (( $+commands[xsel] )); then - xsel --clipboard --input + xsel --clipboard --input else print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2 return 1 diff --git a/utils/fix-ssh.sh b/utils/fix-ssh.sh new file mode 100755 index 000000000..9da230246 --- /dev/null +++ b/utils/fix-ssh.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +chmod 700 $HOME/.ssh +chmod 644 $HOME/.ssh/id_rsa.pub +chmod 600 $HOME/.ssh/id_rsa diff --git a/vim/sleuth.vim b/vim/sleuth.vim deleted file mode 100644 index e5f635500..000000000 --- a/vim/sleuth.vim +++ /dev/null @@ -1,206 +0,0 @@ -" sleuth.vim - Heuristically set buffer options -" Maintainer: Tim Pope -" Version: 1.1 -" GetLatestVimScripts: 4375 1 :AutoInstall: sleuth.vim - -if exists("g:loaded_sleuth") || v:version < 700 || &cp - finish -endif -let g:loaded_sleuth = 1 - -function! s:guess(lines) abort - let options = {} - let heuristics = {'spaces': 0, 'hard': 0, 'soft': 0} - let ccomment = 0 - let podcomment = 0 - let triplequote = 0 - let backtick = 0 - let xmlcomment = 0 - let softtab = repeat(' ', 8) - - for line in a:lines - if !len(line) || line =~# '^\s*$' - continue - endif - - if line =~# '^\s*/\*' - let ccomment = 1 - endif - if ccomment - if line =~# '\*/' - let ccomment = 0 - endif - continue - endif - - if line =~# '^=\w' - let podcomment = 1 - endif - if podcomment - if line =~# '^=\%(end\|cut\)\>' - let podcomment = 0 - endif - continue - endif - - if triplequote - if line =~# '^[^"]*"""[^"]*$' - let triplequote = 0 - endif - continue - elseif line =~# '^[^"]*"""[^"]*$' - let triplequote = 1 - endif - - if backtick - if line =~# '^[^`]*`[^`]*$' - let backtick = 0 - endif - continue - elseif line =~# '^[^`]*`[^`]*$' - let backtick = 1 - endif - - if line =~# '^\s*<\!--' - let xmlcomment = 1 - endif - if xmlcomment - if line =~# '-->' - let xmlcomment = 0 - endif - continue - endif - - if line =~# '^\t' - let heuristics.hard += 1 - elseif line =~# '^' . softtab - let heuristics.soft += 1 - endif - if line =~# '^ ' - let heuristics.spaces += 1 - endif - let indent = len(matchstr(substitute(line, '\t', softtab, 'g'), '^ *')) - if indent > 1 && (indent < 4 || indent % 2 == 0) && - \ get(options, 'shiftwidth', 99) > indent - let options.shiftwidth = indent - endif - endfor - - if heuristics.hard && !heuristics.spaces - return {'expandtab': 0, 'shiftwidth': &tabstop} - elseif heuristics.soft != heuristics.hard - let options.expandtab = heuristics.soft > heuristics.hard - if heuristics.hard - let options.tabstop = 8 - endif - endif - - return options -endfunction - -function! s:patterns_for(type) abort - if a:type ==# '' - return [] - endif - if !exists('s:patterns') - redir => capture - silent autocmd BufRead - redir END - let patterns = { - \ 'c': ['*.c'], - \ 'html': ['*.html'], - \ 'sh': ['*.sh'], - \ 'vim': ['vimrc', '.vimrc', '_vimrc'], - \ } - let setfpattern = '\s\+\%(setf\%[iletype]\s\+\|set\%[local]\s\+\%(ft\|filetype\)=\|call SetFileTypeSH(["'']\%(ba\|k\)\=\%(sh\)\@=\)' - for line in split(capture, "\n") - let match = matchlist(line, '^\s*\(\S\+\)\='.setfpattern.'\(\w\+\)') - if !empty(match) - call extend(patterns, {match[2]: []}, 'keep') - call extend(patterns[match[2]], [match[1] ==# '' ? last : match[1]]) - endif - let last = matchstr(line, '\S.*') - endfor - let s:patterns = patterns - endif - return copy(get(s:patterns, a:type, [])) -endfunction - -function! s:apply_if_ready(options) abort - if !has_key(a:options, 'expandtab') || !has_key(a:options, 'shiftwidth') - return 0 - else - for [option, value] in items(a:options) - call setbufvar('', '&'.option, value) - endfor - return 1 - endif -endfunction - -function! s:detect() abort - if &buftype ==# 'help' - return - endif - - let options = s:guess(getline(1, 1024)) - if s:apply_if_ready(options) - return - endif - let c = get(b:, 'sleuth_neighbor_limit', get(g:, 'sleuth_neighbor_limit', 20)) - let patterns = c > 0 ? s:patterns_for(&filetype) : [] - call filter(patterns, 'v:val !~# "/"') - let dir = expand('%:p:h') - while isdirectory(dir) && dir !=# fnamemodify(dir, ':h') && c > 0 - for pattern in patterns - for neighbor in split(glob(dir.'/'.pattern), "\n")[0:7] - if neighbor !=# expand('%:p') && filereadable(neighbor) - call extend(options, s:guess(readfile(neighbor, '', 256)), 'keep') - let c -= 1 - endif - if s:apply_if_ready(options) - let b:sleuth_culprit = neighbor - return - endif - if c <= 0 - break - endif - endfor - if c <= 0 - break - endif - endfor - let dir = fnamemodify(dir, ':h') - endwhile - if has_key(options, 'shiftwidth') - return s:apply_if_ready(extend({'expandtab': 1}, options)) - endif -endfunction - -setglobal smarttab - -if !exists('g:did_indent_on') - filetype indent on -endif - -function! SleuthIndicator() abort - let sw = &shiftwidth ? &shiftwidth : &tabstop - if &expandtab - return 'sw='.sw - elseif &tabstop == sw - return 'ts='.&tabstop - else - return 'sw='.sw.',ts='.&tabstop - endif -endfunction - -augroup sleuth - autocmd! - autocmd FileType * - \ if get(b:, 'sleuth_automatic', get(g:, 'sleuth_automatic', 1)) - \ | call s:detect() | endif - autocmd User Flags call Hoist('buffer', 5, 'SleuthIndicator') -augroup END - -command! -bar -bang Sleuth call s:detect() - -" vim:set et sw=2: diff --git a/vim/vimrc.vim b/vim/vimrc.vim deleted file mode 100644 index 5029c7472..000000000 --- a/vim/vimrc.vim +++ /dev/null @@ -1,95 +0,0 @@ -" General Vim settings - syntax on - let mapleader="," - set autoindent - set tabstop=4 - set shiftwidth=4 - set dir=/tmp/ - set relativenumber - set number - - autocmd Filetype html setlocal sw=2 expandtab - autocmd Filetype javascript setlocal sw=4 expandtab - - set hlsearch - nnoremap :nohl:echo "Search Cleared" - nnoremap :set norelativenumber:set nonumber:echo "Line numbers turned off." - nnoremap :set relativenumber:set number:echo "Line numbers turned on." - - nnoremap n nzzzv - nnoremap N Nzzzv - - nnoremap H 0 - nnoremap L $ - nnoremap J G - nnoremap K gg - - map % - - set backspace=indent,eol,start - - nnoremap za - nnoremap z zMzvzz - - nnoremap vv 0v$ - - set listchars=tab:\|\ - nnoremap :set list! - set pastetoggle= - set mouse=a - set incsearch - -" Language Specific - " Tabs - so ~/dotfiles/vim/sleuth.vim - - " Typescript - autocmd BufNewFile,BufRead *.ts set syntax=javascript - autocmd BufNewFile,BufRead *.tsx set syntax=javascript - - " Markup - inoremap < I<A>yypa/O - - -" File and Window Management - inoremap w :w - nnoremap w :w - - inoremap q :q - nnoremap q :q - - inoremap x :x - nnoremap x :x - - nnoremap e :Ex - nnoremap t :tabnew:Ex - nnoremap v :vsplit:w:Ex - nnoremap s :split:w:Ex - -" Return to the same line you left off at - augroup line_return - au! - au BufReadPost * - \ if line("'\"") > 0 && line("'\"") <= line("$") | - \ execute 'normal! g`"zvzz' | - \ endif - augroup END - -" Auto load - " Triger `autoread` when files changes on disk - " https://unix.stackexchange.com/questions/149209/refresh-changed-content-of-file-opened-in-vim/383044#383044 - " https://vi.stackexchange.com/questions/13692/prevent-focusgained-autocmd-running-in-command-line-editing-mode - autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif - set autoread - " Notification after file change - " https://vi.stackexchange.com/questions/13091/autocmd-event-for-autoread - autocmd FileChangedShellPost * - \ echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None - -" Future stuff - "Swap line - "Insert blank below and above - -" Fix for: https://github.com/fatih/vim-go/issues/1509 - -filetype plugin indent on diff --git a/wezterm/wezterm.lua b/wezterm/wezterm.lua new file mode 100644 index 000000000..f88ded085 --- /dev/null +++ b/wezterm/wezterm.lua @@ -0,0 +1,73 @@ +local wezterm = require 'wezterm' + +local config = wezterm.config_builder() + +config.enable_tab_bar = false + +config.window_padding = { + left = 20, + right = 20, + top = 20, + bottom = 20, +} +config.macos_window_background_blur = 100 +config.win32_system_backdrop = 'Acrylic' + +-- presently broken on linux as my system has no real way to set dark / light mode +print(wezterm.gui.get_appearance()) + +if wezterm.gui.get_appearance():find 'Dark' then + config.colors = { + ansi = { + '#505050', -- black + '#FF6680', -- red + '#67E4B6', -- green + '#FFDB70', -- yellow + '#66B2FF', -- blue + '#AC8CD9', -- magenta + '#6EECF7', -- cyan + '#D0D0D0', -- white + }, + brights = { + '#D0D0D0', -- brblack + '#FF99AA', -- brred + '#93ECCB', -- brgreen + '#FFE699', -- bryellow + '#80BFFF', -- brblue + '#BA9FDF', -- brmagenta + '#9EF2FA', -- brcyan + '#FFFFFF', -- brwhite + }, + + foreground = '#FFFFFF', + background = '#080808', + } +else + config.colors = { + ansi = { + '#1A1A1A', -- black + '#DF2040', -- red + '#00B371', -- green + '#CC9900', -- yellow + '#207FDF', -- blue + '#7855AA', -- magenta + '#0FAEBD', -- cyan + '#D0D0D0', -- white + }, + brights = { + '#808080', -- brblack + '#FF6680', -- brred + '#2DD296', -- brgreen + '#FFBF00', -- bryellow + '#66B2FF', -- brblue + '#AC8CD9', -- brmagenta + '#13DAEC', -- brcyan + '#1A1A1A', -- brwhite + }, + + foreground = '#000000', + background = '#FFFFFF', + } +end + +return config diff --git a/zsh/keybindings.sh b/zsh/keybindings.sh deleted file mode 100644 index 55617d785..000000000 --- a/zsh/keybindings.sh +++ /dev/null @@ -1,55 +0,0 @@ -# up - function up_widget() { - BUFFER="cd .." - zle accept-line - } - zle -N up_widget - bindkey "^k" up_widget - -# git - function git_prepare() { - if [ -n "$BUFFER" ]; - then - BUFFER="git add -A && git commit -m \"$BUFFER\" && git push" - fi - - if [ -z "$BUFFER" ]; - then - BUFFER="git add -A && git commit -v && git push" - fi - - zle accept-line - } - zle -N git_prepare - bindkey "^g" git_prepare - -# Edit and rerun - function edit_and_run() { - BUFFER="fc" - zle accept-line - } - zle -N edit_and_run - bindkey "^v" edit_and_run - -# Enter - function enter_line() { - zle accept-line - } - zle -N enter_line - bindkey "^o" enter_line - -# Sudo - function add_sudo() { - BUFFER="sudo "$BUFFER - zle end-of-line - } - zle -N add_sudo - bindkey "^s" add_sudo - - # Home - Navigates to the current root workspace - function git_root() { - BUFFER="cd $(git rev-parse --show-toplevel || echo ".")" - zle accept-line - } - zle -N git_root - bindkey "^h" git_root diff --git a/zsh/plugins/fixls.zsh b/zsh/plugins/fixls.zsh deleted file mode 100644 index 4dc8e9345..000000000 --- a/zsh/plugins/fixls.zsh +++ /dev/null @@ -1,45 +0,0 @@ -# https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/theme-and-appearance.zsh - -# ls colors -autoload -U colors && colors - -# Enable ls colors -export LSCOLORS="Gxfxcxdxbxegedabagacad" - -# TODO organise this chaotic logic - -if [[ "$DISABLE_LS_COLORS" != "true" ]]; then - # Find the option for using colors in ls, depending on the version - if [[ "$OSTYPE" == netbsd* ]]; then - # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); - # otherwise, leave ls as is, because NetBSD's ls doesn't support -G - gls --color -d . &>/dev/null && alias ls='gls --color=tty' - elif [[ "$OSTYPE" == openbsd* ]]; then - # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base, - # with color and multibyte support) are available from ports. "colorls" - # will be installed on purpose and can't be pulled in by installing - # coreutils, so prefer it to "gls". - gls --color -d . &>/dev/null && alias ls='gls --color=tty' - colorls -G -d . &>/dev/null && alias ls='colorls -G' - elif [[ "$OSTYPE" == darwin* ]]; then - # this is a good alias, it works by default just using $LSCOLORS - ls -G . &>/dev/null && alias ls='ls -G' - - # only use coreutils ls if there is a dircolors customization present ($LS_COLORS or .dircolors file) - # otherwise, gls will use the default color scheme which is ugly af - [[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] && gls --color -d . &>/dev/null && alias ls='gls --color=tty' - else - # For GNU ls, we use the default ls color theme. They can later be overwritten by themes. - if [[ -z "$LS_COLORS" ]]; then - (( $+commands[dircolors] )) && eval "$(dircolors -b)" - fi - - ls --color -d . &>/dev/null && alias ls='ls --color=tty' || { ls -G . &>/dev/null && alias ls='ls -G' } - - # Take advantage of $LS_COLORS for completion as well. - zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" - fi -fi - -setopt auto_cd -setopt multios diff --git a/zsh/plugins/oh-my-zsh b/zsh/plugins/oh-my-zsh deleted file mode 160000 index 291e96dcd..000000000 --- a/zsh/plugins/oh-my-zsh +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 291e96dcd034750fbe7473482508c08833b168e3 diff --git a/zsh/plugins/vi-mode.plugin.zsh b/zsh/plugins/vi-mode.plugin.zsh deleted file mode 100644 index 82a2f3040..000000000 --- a/zsh/plugins/vi-mode.plugin.zsh +++ /dev/null @@ -1,50 +0,0 @@ -# Updates editor information when the keymap changes. -function zle-keymap-select() { - zle reset-prompt - zle -R -} - -# Ensure that the prompt is redrawn when the terminal size changes. -TRAPWINCH() { - zle && zle -R -} - -zle -N zle-keymap-select -zle -N edit-command-line - - -bindkey -v - -# allow v to edit the command line (standard behaviour) -autoload -Uz edit-command-line -bindkey -M vicmd 'v' edit-command-line - -# allow ctrl-p, ctrl-n for navigate history (standard behaviour) -bindkey '^P' up-history -bindkey '^N' down-history - -# allow ctrl-h, ctrl-w, ctrl-? for char and word deletion (standard behaviour) -bindkey '^?' backward-delete-char -bindkey '^h' backward-delete-char -bindkey '^w' backward-kill-word - -# allow ctrl-r to perform backward search in history -bindkey '^r' history-incremental-search-backward - -# allow ctrl-a and ctrl-e to move to beginning/end of line -bindkey '^a' beginning-of-line -bindkey '^e' end-of-line - -# if mode indicator wasn't setup by theme, define default -if [[ "$MODE_INDICATOR" == "" ]]; then - MODE_INDICATOR="%{$fg_bold[red]%}<%{$fg[red]%}<<%{$reset_color%}" -fi - -function vi_mode_prompt_info() { - echo "${${KEYMAP/vicmd/$MODE_INDICATOR}/(main|viins)/}" -} - -# define right prompt, if it wasn't defined by a theme -if [[ "$RPS1" == "" && "$RPROMPT" == "" ]]; then - RPS1='$(vi_mode_prompt_info)' -fi diff --git a/zsh/plugins/zsh-autosuggestions b/zsh/plugins/zsh-autosuggestions deleted file mode 160000 index fedc22e9b..000000000 --- a/zsh/plugins/zsh-autosuggestions +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fedc22e9bbd046867860e772d7d6787f5dae9d4c diff --git a/zsh/plugins/zsh-syntax-highlighting b/zsh/plugins/zsh-syntax-highlighting deleted file mode 160000 index ad522a091..000000000 --- a/zsh/plugins/zsh-syntax-highlighting +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ad522a091429ba180c930f84b2a023b40de4dbcc diff --git a/zsh/prompt.sh b/zsh/prompt.sh deleted file mode 100644 index 32791bc2a..000000000 --- a/zsh/prompt.sh +++ /dev/null @@ -1,63 +0,0 @@ -# Reference for colors: http://stackoverflow.com/questions/689765/how-can-i-change-the-color-of-my-prompt-in-zsh-different-from-normal-text - -autoload -U colors && colors - -setopt PROMPT_SUBST - -set_prompt() { - - # [ - PS1="[" - - # Path: http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/ - PS1+="%{$fg_bold[blue]%}${PWD/#$HOME/~}%{$reset_color%}" - - # Status Code - PS1+='%(?.., %{$fg[red]%}%?%{$reset_color%})' - - # Git - if git rev-parse --is-inside-work-tree 2> /dev/null | grep -q 'true' ; then - PS1+=', ' - PS1+="%{$fg[magenta]%}$(git rev-parse --abbrev-ref HEAD 2> /dev/null)%{$reset_color%}" - STATUS=$(git status --short | wc -l) - if [ $STATUS -gt 0 ]; then - PS1+="%{$fg[green]%}+$(echo $STATUS | awk '{$1=$1};1')%{$reset_color%}" - fi - fi - - - # Timer: http://stackoverflow.com/questions/2704635/is-there-a-way-to-find-the-running-time-of-the-last-executed-command-in-the-shel - if [[ $_elapsed[-1] -ne 0 ]]; then - PS1+=', ' - PS1+="%{$fg[yellow]%}$_elapsed[-1]s%{$reset_color%}" - fi - - # PID - if [[ $! -ne 0 ]]; then - PS1+=', ' - PS1+="%{$fg[yellow]%}PID:$!%{$reset_color%}" - fi - - # Sudo: https://superuser.com/questions/195781/sudo-is-there-a-command-to-check-if-i-have-sudo-and-or-how-much-time-is-left - CAN_I_RUN_SUDO=$(sudo -n uptime 2>&1|grep "load"|wc -l) - if [ ${CAN_I_RUN_SUDO} -gt 0 ] - then - PS1+=', ' - PS1+="%{$fg_bold[red]%}SUDO%{$reset_color%}" - fi - - # ] - PS1+="]: " -} - -precmd_functions+=set_prompt - -preexec () { - (( ${#_elapsed[@]} > 1000 )) && _elapsed=(${_elapsed[@]: -1000}) - _start=$SECONDS -} - -precmd () { - (( _start >= 0 )) && _elapsed+=($(( SECONDS-_start ))) - _start=-1 -} diff --git a/zsh/zshrc.sh b/zsh/zshrc.sh deleted file mode 100644 index 048936380..000000000 --- a/zsh/zshrc.sh +++ /dev/null @@ -1,82 +0,0 @@ -# Vars - HISTFILE=~/.zsh_history - SAVEHIST=1000 - setopt inc_append_history # To save every command before it is executed - setopt share_history # setopt inc_append_history - - git config --global push.default current - -# Aliases - alias v="vim -p" - mkdir -p /tmp/log - - # This is currently causing problems (fails when you run it anywhere that isn't a git project's root directory) - # alias vs="v `git status --porcelain | sed -ne 's/^ M //p'`" - -# Settings - export VISUAL=vim - -source ~/dotfiles/zsh/plugins/fixls.zsh - -#Functions - # Loop a command and show the output in vim - loop() { - echo ":cq to quit\n" > /tmp/log/output - fc -ln -1 > /tmp/log/program - while true; do - cat /tmp/log/program >> /tmp/log/output ; - $(cat /tmp/log/program) |& tee -a /tmp/log/output ; - echo '\n' >> /tmp/log/output - vim + /tmp/log/output || break; - rm -rf /tmp/log/output - done; - } - -# Custom cd -chpwd() ls - -# For vim mappings: - stty -ixon - -# Completions -# These are all the plugin options available: https://github.com/robbyrussell/oh-my-zsh/tree/291e96dcd034750fbe7473482508c08833b168e3/plugins -# -# Edit the array below, or relocate it to ~/.zshrc before anything is sourced -# For help create an issue at github.com/parth/dotfiles - -autoload -U compinit - -plugins=( - docker -) - -for plugin ($plugins); do - fpath=(~/dotfiles/zsh/plugins/oh-my-zsh/plugins/$plugin $fpath) -done - -compinit - -source ~/dotfiles/zsh/plugins/oh-my-zsh/lib/history.zsh -source ~/dotfiles/zsh/plugins/oh-my-zsh/lib/key-bindings.zsh -source ~/dotfiles/zsh/plugins/oh-my-zsh/lib/completion.zsh -source ~/dotfiles/zsh/plugins/vi-mode.plugin.zsh -source ~/dotfiles/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh -source ~/dotfiles/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh -source ~/dotfiles/zsh/keybindings.sh - -# Fix for arrow-key searching -# start typing + [Up-Arrow] - fuzzy find history forward -if [[ "${terminfo[kcuu1]}" != "" ]]; then - autoload -U up-line-or-beginning-search - zle -N up-line-or-beginning-search - bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search -fi -# start typing + [Down-Arrow] - fuzzy find history backward -if [[ "${terminfo[kcud1]}" != "" ]]; then - autoload -U down-line-or-beginning-search - zle -N down-line-or-beginning-search - bindkey "${terminfo[kcud1]}" down-line-or-beginning-search -fi - -source ~/dotfiles/zsh/prompt.sh -export PATH=$PATH:$HOME/dotfiles/utils diff --git a/zsh/zshrc_manager.sh b/zsh/zshrc_manager.sh deleted file mode 100644 index 6d34075a7..000000000 --- a/zsh/zshrc_manager.sh +++ /dev/null @@ -1,27 +0,0 @@ -time_out () { perl -e 'alarm shift; exec @ARGV' "$@"; } - -# Run tmux if exists -if command -v tmux>/dev/null; then - if [ "$DISABLE_TMUX" = "true" ]; then - echo "DISABLE_TMUX=true" - else - [ -z $TMUX ] && exec tmux - fi -else - echo "tmux not installed. Run ./deploy to configure dependencies" -fi - -echo "Checking for updates." -({cd ~/dotfiles && git fetch -q} &> /dev/null) - -if [ $({cd ~/dotfiles} &> /dev/null && git rev-list HEAD...origin/master | wc -l) = 0 ] -then - echo "Already up to date." -else - echo "Updates Detected:" - ({cd ~/dotfiles} &> /dev/null && git log ..@{u} --pretty=format:%Cred%aN:%Creset\ %s\ %Cgreen%cd) - echo "Setting up..." - ({cd ~/dotfiles} &> /dev/null && git pull -q && git submodule update --init --recursive) -fi - -source ~/dotfiles/zsh/zshrc.sh