From b891aeeb46f63fdaba70ed34138c2948bcfeeb17 Mon Sep 17 00:00:00 2001 From: Elisiei Yehorov Date: Sun, 16 Nov 2025 01:03:19 +0100 Subject: [PATCH] ok --- Makefile | 77 ++ flake.lock | 243 +++++ flake.nix | 41 + home/home.nix | 37 + home/modules/hyprland/default.nix | 177 ++++ home/modules/ide/micro/default.nix | 5 + home/modules/ide/nvim/default.nix | 83 ++ home/modules/ide/nvim/keymaps.nix | 9 + home/modules/ide/nvim/lsp/fidget.nix | 110 ++ home/modules/ide/nvim/lsp/langs/c.nix | 18 + home/modules/ide/nvim/lsp/langs/default.nix | 5 + home/modules/ide/nvim/lsp/langs/go.nix | 23 + home/modules/ide/nvim/lsp/langs/lua.nix | 12 + home/modules/ide/nvim/lsp/langs/nix.nix | 13 + home/modules/ide/nvim/lsp/langs/odin.nix | 21 + home/modules/ide/nvim/lsp/langs/web.nix | 12 + home/modules/ide/nvim/lsp/lsp.nix | 78 ++ home/modules/ide/nvim/lsp/roslyn.nix | 17 + home/modules/ide/nvim/plugins/aerial.nix | 63 ++ home/modules/ide/nvim/plugins/autopairs.nix | 11 + home/modules/ide/nvim/plugins/blink.nix | 95 ++ home/modules/ide/nvim/plugins/dashboard.nix | 86 ++ home/modules/ide/nvim/plugins/hlchunk.nix | 46 + home/modules/ide/nvim/plugins/lualine.nix | 97 ++ home/modules/ide/nvim/plugins/neo-tree.nix | 120 +++ home/modules/ide/nvim/plugins/snacks.nix | 45 + home/modules/ide/nvim/plugins/toggleterm.nix | 33 + home/modules/ide/nvim/plugins/treesitter.nix | 32 + home/modules/ide/nvim/plugins/treesj.nix | 25 + .../modules/ide/nvim/plugins/web-devicons.nix | 10 + home/modules/ide/nvim/plugins/yanky.nix | 139 +++ home/modules/ide/nvim/themes.nix | 24 + home/modules/shell/bash/default.nix | 11 + home/modules/shell/direnv/default.nix | 7 + home/modules/shell/fish/config.fish | 8 + home/modules/shell/fish/default.nix | 27 + home/modules/shell/fish/themes/kanagawa.fish | 37 + home/modules/shell/nushell/config.nu | 103 ++ .../shell/nushell/config/aliases/git.nu | 246 +++++ .../shell/nushell/config/completions/git.nu | 985 ++++++++++++++++++ .../shell/nushell/config/completions/make.nu | 64 ++ .../nushell/config/hooks/did_you_mean.nu | 48 + .../shell/nushell/config/scripts/nufetch.nu | 120 +++ .../nushell/config/themes/tokyo-night.nu | 133 +++ home/modules/shell/nushell/default.nix | 12 + home/modules/terminal/foot/default.nix | 18 + .../modules/terminal/foot/themes/kanagawa.ini | 27 + .../terminal/foot/themes/tokyonight.ini | 25 + home/modules/terminal/st/default.nix | 27 + home/modules/user/dunst/default.nix | 39 + home/modules/user/git/default.nix | 27 + home/modules/user/obs/default.nix | 11 + home/modules/user/tofi/default.nix | 17 + home/modules/user/wofi/default.nix | 18 + home/modules/user/wofi/style.css | 35 + home/packages.nix | 14 + nixos/configuration.nix | 28 + nixos/hardware-configuration.nix | 41 + nixos/modules/audio.nix | 11 + nixos/modules/boot.nix | 35 + nixos/modules/fonts.nix | 18 + nixos/modules/gaming.nix | 13 + nixos/modules/localization.nix | 17 + nixos/modules/networking.nix | 30 + nixos/modules/programs.nix | 58 ++ nixos/modules/user.nix | 19 + nixos/modules/xserver.nix | 42 + 67 files changed, 4178 insertions(+) create mode 100644 Makefile create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 home/home.nix create mode 100644 home/modules/hyprland/default.nix create mode 100644 home/modules/ide/micro/default.nix create mode 100644 home/modules/ide/nvim/default.nix create mode 100644 home/modules/ide/nvim/keymaps.nix create mode 100644 home/modules/ide/nvim/lsp/fidget.nix create mode 100644 home/modules/ide/nvim/lsp/langs/c.nix create mode 100644 home/modules/ide/nvim/lsp/langs/default.nix create mode 100644 home/modules/ide/nvim/lsp/langs/go.nix create mode 100644 home/modules/ide/nvim/lsp/langs/lua.nix create mode 100644 home/modules/ide/nvim/lsp/langs/nix.nix create mode 100644 home/modules/ide/nvim/lsp/langs/odin.nix create mode 100644 home/modules/ide/nvim/lsp/langs/web.nix create mode 100644 home/modules/ide/nvim/lsp/lsp.nix create mode 100644 home/modules/ide/nvim/lsp/roslyn.nix create mode 100644 home/modules/ide/nvim/plugins/aerial.nix create mode 100644 home/modules/ide/nvim/plugins/autopairs.nix create mode 100644 home/modules/ide/nvim/plugins/blink.nix create mode 100644 home/modules/ide/nvim/plugins/dashboard.nix create mode 100644 home/modules/ide/nvim/plugins/hlchunk.nix create mode 100644 home/modules/ide/nvim/plugins/lualine.nix create mode 100644 home/modules/ide/nvim/plugins/neo-tree.nix create mode 100644 home/modules/ide/nvim/plugins/snacks.nix create mode 100644 home/modules/ide/nvim/plugins/toggleterm.nix create mode 100644 home/modules/ide/nvim/plugins/treesitter.nix create mode 100644 home/modules/ide/nvim/plugins/treesj.nix create mode 100644 home/modules/ide/nvim/plugins/web-devicons.nix create mode 100644 home/modules/ide/nvim/plugins/yanky.nix create mode 100644 home/modules/ide/nvim/themes.nix create mode 100644 home/modules/shell/bash/default.nix create mode 100644 home/modules/shell/direnv/default.nix create mode 100644 home/modules/shell/fish/config.fish create mode 100644 home/modules/shell/fish/default.nix create mode 100644 home/modules/shell/fish/themes/kanagawa.fish create mode 100644 home/modules/shell/nushell/config.nu create mode 100644 home/modules/shell/nushell/config/aliases/git.nu create mode 100644 home/modules/shell/nushell/config/completions/git.nu create mode 100644 home/modules/shell/nushell/config/completions/make.nu create mode 100644 home/modules/shell/nushell/config/hooks/did_you_mean.nu create mode 100644 home/modules/shell/nushell/config/scripts/nufetch.nu create mode 100644 home/modules/shell/nushell/config/themes/tokyo-night.nu create mode 100644 home/modules/shell/nushell/default.nix create mode 100644 home/modules/terminal/foot/default.nix create mode 100644 home/modules/terminal/foot/themes/kanagawa.ini create mode 100644 home/modules/terminal/foot/themes/tokyonight.ini create mode 100644 home/modules/terminal/st/default.nix create mode 100644 home/modules/user/dunst/default.nix create mode 100644 home/modules/user/git/default.nix create mode 100644 home/modules/user/obs/default.nix create mode 100644 home/modules/user/tofi/default.nix create mode 100644 home/modules/user/wofi/default.nix create mode 100644 home/modules/user/wofi/style.css create mode 100644 home/packages.nix create mode 100644 nixos/configuration.nix create mode 100644 nixos/hardware-configuration.nix create mode 100644 nixos/modules/audio.nix create mode 100644 nixos/modules/boot.nix create mode 100644 nixos/modules/fonts.nix create mode 100644 nixos/modules/gaming.nix create mode 100644 nixos/modules/localization.nix create mode 100644 nixos/modules/networking.nix create mode 100644 nixos/modules/programs.nix create mode 100644 nixos/modules/user.nix create mode 100644 nixos/modules/xserver.nix diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..48f10ba --- /dev/null +++ b/Makefile @@ -0,0 +1,77 @@ +############################################################################### +# 🛠️ NixOS & System Management Commands +# +# These commands help manage the system configuration using Nix flakes. +############################################################################### + +.PHONY: copy-config deploy home upgrade debug up upp test history repl clean gc-sudo gc gcboot + +# 🛑 Utility function: copy ~/nixos to /etc/nixos +copy-config: + sudo rm -rf /etc/nixos/* + sudo cp -r ~/nixos/* /etc/nixos/ + +# 🚀 Deploy the current system configuration and make it the default on boot. +# Usage: make deploy +deploy: copy-config + sudo nixos-rebuild switch --flake /etc/nixos + +# 🏡 Same as `deploy`, but with a custom flake target (e.g., for home-manager). +# Usage: make home +home: copy-config + sudo nixos-rebuild switch --flake /etc/nixos#nixos + +# ⬆️ Upgrade system packages and apply the latest flake changes. +# Usage: make upgrade +upgrade: copy-config + sudo nixos-rebuild switch --upgrade --flake /etc/nixos + +# 🐛 Like `deploy`, but with verbose logs and error traces for debugging. +# Usage: make debug +debug: copy-config + sudo nixos-rebuild switch --flake /etc/nixos --show-trace --verbose + +# 🌐 Update all flake inputs to their latest versions. +# Usage: make up +up: + nix flake update /etc/nixos + +# 🔍 Update a specific flake input (e.g., `make upp i=home-manager`) +# Usage: make upp i=home-manager +upp: + nix flake update ~/nixos/${i} + +# 🧪 Test the configuration without setting it as the default boot entry. +# Usage: make test +test: copy-config + sudo nixos-rebuild test --flake /etc/nixos + +# 🕓 Show system profile history. +# Usage: make history +history: + nix profile history --profile /nix/var/nix/profiles/system + +# 💻 Launch the Nix REPL with nixpkgs from the flake. +# Usage: make repl +repl: + nix repl -f flake:nixpkgs + +# 🧹 Clean up system profile history older than 1 day. +# Usage: make clean +clean: + sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than 1d + +# 🧼 Collect and delete old garbage as root. +# Usage: make gc-sudo +gc-sudo: + sudo nix-collect-garbage -d + +# 🧽 Same as above, but for the current user. +# Usage: make gc +gc: + nix-collect-garbage -d + +# 🥾 Boot into a specific configuration without switching immediately. +# Usage: make gcboot +gcboot: + sudo /run/current-system/bin/switch-to-configuration boot diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..4ac96b8 --- /dev/null +++ b/flake.lock @@ -0,0 +1,243 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1754487366, + "narHash": "sha256-pHYj8gUBapuUzKV/kN/tR3Zvqc7o6gdFB9XKXIp1SQ8=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "af66ad14b28a127c5c0f3bbb298218fc63528a18", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1754950654, + "narHash": "sha256-30f9MF+zIKLodQRuSLyY4OSDZSOy5O+/FslgPt/prbc=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "d19f3213e51469321835a9188adfa20391ff9371", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "ixx": { + "inputs": { + "flake-utils": [ + "nixvim", + "nuschtosSearch", + "flake-utils" + ], + "nixpkgs": [ + "nixvim", + "nuschtosSearch", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1748294338, + "narHash": "sha256-FVO01jdmUNArzBS7NmaktLdGA5qA3lUMJ4B7a05Iynw=", + "owner": "NuschtOS", + "repo": "ixx", + "rev": "cc5f390f7caf265461d4aab37e98d2292ebbdb85", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "ref": "v0.0.8", + "repo": "ixx", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1754882787, + "narHash": "sha256-Y2nY1s+ZS3vkVS72SsEa/zJe+j9JuwLbev4grzcHTA8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "59ca61e5a844a0c35cdc272bc671c5d9b6840741", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable-small", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1754725699, + "narHash": "sha256-iAcj9T/Y+3DBy2J0N+yF9XQQQ8IEb5swLFzs23CdP88=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "85dbfc7aaf52ecb755f87e577ddbe6dbbdbc1054", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixvim": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": [ + "nixpkgs" + ], + "nuschtosSearch": "nuschtosSearch", + "systems": "systems_2" + }, + "locked": { + "lastModified": 1754921951, + "narHash": "sha256-KY+/livAp6l3fI8SdNa+CLN/AA4Z038yL/pQL2PaW7g=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "7b53322d75a1c66f84fb145e4b5f0f411d9edc6b", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "nuschtosSearch": { + "inputs": { + "flake-utils": "flake-utils", + "ixx": "ixx", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1754301638, + "narHash": "sha256-aRgzcPDd2axHFOuMlPLuzmDptUM2JU8mUL3jfgbBeyc=", + "owner": "NuschtOS", + "repo": "search", + "rev": "a60091045273484c040a91f5c229ba298f8ecc27", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "repo": "search", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs", + "nixvim": "nixvim", + "spicetify-nix": "spicetify-nix" + } + }, + "spicetify-nix": { + "inputs": { + "nixpkgs": "nixpkgs_2", + "systems": "systems_3" + }, + "locked": { + "lastModified": 1754801101, + "narHash": "sha256-oxWjZ/SfhCvHFNePZcUu+LcE5j4xxuIt/yaoaSvMZk0=", + "owner": "Gerg-L", + "repo": "spicetify-nix", + "rev": "fcbfc21572518c68317df992929b28df9a1d8468", + "type": "github" + }, + "original": { + "owner": "Gerg-L", + "repo": "spicetify-nix", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..384c955 --- /dev/null +++ b/flake.nix @@ -0,0 +1,41 @@ +{ + description = "Modular and minimalist NixOS configuration"; + + inputs = { + # Nixos + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable-small"; + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + + # Spotify + spicetify-nix.url = "github:Gerg-L/spicetify-nix"; + + # Nvim + nixvim = { + url = "github:nix-community/nixvim"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + inputs@{ nixpkgs, home-manager, ... }: + { + nixosConfigurations = { + nixos = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; }; + modules = [ + ./nixos/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.elisiei = import ./home/home.nix; + home-manager.backupFileExtension = "hm-backup"; + home-manager.extraSpecialArgs = { inherit inputs; }; + } + ]; + }; + }; + }; +} diff --git a/home/home.nix b/home/home.nix new file mode 100644 index 0000000..cec255f --- /dev/null +++ b/home/home.nix @@ -0,0 +1,37 @@ +{ + imports = [ + ./packages.nix + + # hyprland + ./modules/hyprland/default.nix + + # editors + ./modules/ide/nvim/default.nix + # ./modules/ide/micro/default.nix + + # terminal stuff + ./modules/terminal/foot/default.nix + + # shell stuff + ./modules/shell/bash/default.nix + # ./modules/shell/nushell/default.nix + ./modules/shell/direnv/default.nix + ./modules/shell/fish/default.nix + + # user stuff + # ./modules/user/wofi/default.nix # deprecated, i use tofi now. + ./modules/user/tofi/default.nix + ./modules/user/dunst/default.nix + ./modules/user/git/default.nix + # ./modules/user/obs/default.nix + ]; + + home.username = "elisiei"; + home.homeDirectory = "/home/elisiei"; + home.stateVersion = "25.05"; + + # workaround + nixpkgs.config.allowUnfreePredicate = _: true; + + programs.home-manager.enable = true; +} diff --git a/home/modules/hyprland/default.nix b/home/modules/hyprland/default.nix new file mode 100644 index 0000000..87e35e5 --- /dev/null +++ b/home/modules/hyprland/default.nix @@ -0,0 +1,177 @@ +{ pkgs, ... }: +let + wallpaperScript = pkgs.writeShellScriptBin "random-wallpaper" '' + pkill swaybg 2>/dev/null || true + WALP=$(find "$HOME/wallpapers" -type f \( -iname "*.jpg" -o -iname "*.png" \) | shuf -n 1) + [ -n "$WALP" ] && ${pkgs.swaybg}/bin/swaybg -i "$WALP" --mode fill + ''; + startupScript = pkgs.writeShellScriptBin "start" '' + ${wallpaperScript}/bin/random-wallpaper + ''; +in +{ + home.packages = [ wallpaperScript ]; + + wayland.windowManager.hyprland = { + enable = true; + xwayland.enable = true; + settings = { + monitor = [ + ",1920x1080,auto,1,bitdepth,8" + ",preferred,auto,1,mirror,eDP-1,bitdepth,8" + ]; + + xwayland = { + force_zero_scaling = "true"; + }; + + exec-once = [ "${startupScript}/bin/start" ]; + + "$term" = "foot"; + "$browser" = "librewolf"; + "$menu" = "exec $(tofi-drun)"; + + env = [ + "XCURSOR_THEME,macOS" + "XCURSOR_SIZE,24" + ]; + + general = { + gaps_in = "0"; + gaps_out = "0"; + border_size = "0"; + "col.active_border" = "rgba(0,0,0,0)"; + "col.inactive_border" = "rgba(0,0,0,0)"; + resize_on_border = "false"; + allow_tearing = "false"; + layout = "dwindle"; + }; + + debug = { + disable_logs = false; + }; + + decoration = { + rounding = "0"; + active_opacity = "1"; + inactive_opacity = "0.95"; + shadow.enabled = false; + blur = { + enabled = false; + xray = false; + special = true; + new_optimizations = true; + size = 10; + passes = 3; + brightness = 0.9; + noise = 2.0e-2; + contrast = 1.1; + popups = true; + popups_ignorealpha = 0.5; + + vibrancy = 0.2; + vibrancy_darkness = 0.1; + }; + }; + + animations = { + enabled = false; + animations = { + bezier = [ + "easeOutQuint, 0.23, 1, 0.32, 1" + "easeInOutCubic, 0.65, 0.05, 0.36, 1" + "linear, 0, 0, 1, 1" + "almostLinear, 0.5, 0.5, 0.75, 1.0" + "quick, 0.15, 0, 0.1, 1" + ]; + animation = [ + "global, 1, 10, default" + "border, 1, 5.39, easeOutQuint" + "windows, 1, 4.79, easeOutQuint" + "windowsIn, 1, 4.1, easeOutQuint, popin 87%" + "windowsOut, 1, 1.49, linear, popin 87%" + "fadeIn, 1, 1.73, almostLinear" + "fadeOut, 1, 1.46, almostLinear" + "fade, 1, 3.03, quick" + "layers, 1, 3.81, easeOutQuint" + "layersIn, 1, 4, easeOutQuint, fade" + "layersOut, 1, 1.5, linear, fade" + "fadeLayersIn, 1, 1.79, almostLinear" + "fadeLayersOut, 1, 1.39, almostLinear" + "workspaces, 1, 1.94, almostLinear, fade" + "workspacesIn, 1, 1.21, almostLinear, fade" + "workspacesOut, 1, 1.94, almostLinear, fade" + "zoomFactor, 1, 7, quick" + ]; + }; + }; + + misc = { + force_default_wallpaper = "0"; + disable_hyprland_logo = "true"; + middle_click_paste = "false"; + vfr = "true"; + }; + + gestures.workspace_swipe = "false"; + + device = { + name = "epic-mouse-v1"; + sensitivity = "-0.5"; + }; + + "$mainMod" = "SUPER"; + + bind = [ + "$mainMod SHIFT, PRINT, exec, ~/bin/grimblast copy screen" # whole screen + "$mainMod, PRINT, exec, ~/bin/grimblast copy area" # selection + "$mainMod, SPACE, exec, $menu" + "$mainMod, W, exec, random-wallpaper" + "$mainMod, S, pin" + "$mainMod, T, exec, $term" + "$mainMod, Z, exec, $browser" + # "$mainMod, K, exec, st" # CHANGE THIS SDBHFDSFSFHJ + "$mainMod, Q, killactive" + "$mainMod SHIFT, M, exit" + "$mainMod, V, togglefloating" + "$mainMod, left, movefocus, l" + "$mainMod, right, movefocus, r" + "$mainMod, up, movefocus, u" + "$mainMod, down, movefocus, d" + "$mainMod, 1, workspace, 1" + "$mainMod, 2, workspace, 2" + "$mainMod, 3, workspace, 3" + "$mainMod, 4, workspace, 4" + "$mainMod, 5, workspace, 5" + "$mainMod, 6, workspace, 6" + "$mainMod, 7, workspace, 7" + "$mainMod, 8, workspace, 8" + "$mainMod, 9, workspace, 9" + "$mainMod, 0, workspace, 10" + "$mainMod SHIFT, 1, movetoworkspace, 1" + "$mainMod SHIFT, 2, movetoworkspace, 2" + "$mainMod SHIFT, 3, movetoworkspace, 3" + "$mainMod SHIFT, 4, movetoworkspace, 4" + "$mainMod SHIFT, 5, movetoworkspace, 5" + "$mainMod SHIFT, 6, movetoworkspace, 6" + "$mainMod SHIFT, 7, movetoworkspace, 7" + "$mainMod SHIFT, 8, movetoworkspace, 8" + "$mainMod SHIFT, 9, movetoworkspace, 9" + "$mainMod SHIFT, 0, movetoworkspace, 10" + ]; + + input = { + kb_layout = "es,ru"; + kb_options = "grp:alt_space_toggle"; + numlock_by_default = true; + }; + + bindm = [ + "$mainMod, mouse:272, movewindow" # left click + "$mainMod, mouse:273, resizewindow" # right click + ]; + + windowrulev2 = "suppressevent maximize, class:.*"; + }; + }; +} diff --git a/home/modules/ide/micro/default.nix b/home/modules/ide/micro/default.nix new file mode 100644 index 0000000..6b0990a --- /dev/null +++ b/home/modules/ide/micro/default.nix @@ -0,0 +1,5 @@ +{ + programs.micro = { + enable = true; + }; +} diff --git a/home/modules/ide/nvim/default.nix b/home/modules/ide/nvim/default.nix new file mode 100644 index 0000000..4f461ff --- /dev/null +++ b/home/modules/ide/nvim/default.nix @@ -0,0 +1,83 @@ +{ pkgs, inputs, ... }: + +# my most preciated config, well documented if you want to use it. +# inspired by https://github.com/xhuyz/nixvim + +{ + imports = [ inputs.nixvim.homeModules.nixvim ]; + + programs.nixvim = { + enable = true; + + imports = [ + # plugins + # ./plugins/aerial.nix + ./plugins/autopairs.nix + ./plugins/blink.nix + ./plugins/dashboard.nix + ./plugins/hlchunk.nix + ./plugins/lualine.nix + ./plugins/neo-tree.nix + ./plugins/snacks.nix + ./plugins/toggleterm.nix + ./plugins/treesitter.nix + ./plugins/treesj.nix + ./plugins/web-devicons.nix + ./plugins/yanky.nix + + # lsp + ./lsp/fidget.nix + ./lsp/lsp.nix + ./lsp/roslyn.nix + + # keymaps + ./keymaps.nix + + # themes + ./themes.nix + ]; + + globals.mapleader = " "; + + opts = { + number = true; + relativenumber = false; + colorcolumn = "80"; + shiftwidth = 2; + tabstop = 2; + wrap = false; + swapfile = false; # undotree + backup = false; # undotree + undofile = true; + hlsearch = false; + incsearch = true; + termguicolors = true; + scrolloff = 8; + signcolumn = "no"; + updatetime = 50; + foldlevelstart = 99; + }; + + clipboard = { + register = "unnamedplus"; + }; + + extraPackages = with pkgs; [ + # formatters + stylua + nixfmt-rfc-style + + # linters + golangci-lint + shellcheck + ]; + + extraConfigLua = '' + vim.diagnostic.config({ virtual_lines = true }) + vim.diagnostic.config({ virtual_text = true }) + vim.o.undofile = true + vim.o.undodir = vim.fn.expand("~/.local/state/nvim/undo") + vim.diagnostic.config({ signs = false }) + ''; + }; +} diff --git a/home/modules/ide/nvim/keymaps.nix b/home/modules/ide/nvim/keymaps.nix new file mode 100644 index 0000000..e3ad111 --- /dev/null +++ b/home/modules/ide/nvim/keymaps.nix @@ -0,0 +1,9 @@ +{ + keymaps = [ + { + key = "qq"; + mode = [ "n" ]; + action = "qa"; + } + ]; +} diff --git a/home/modules/ide/nvim/lsp/fidget.nix b/home/modules/ide/nvim/lsp/fidget.nix new file mode 100644 index 0000000..f8924c4 --- /dev/null +++ b/home/modules/ide/nvim/lsp/fidget.nix @@ -0,0 +1,110 @@ +{ + plugins.fidget = { + enable = true; + settings = { + logger = { + level = "warn"; # "off", "error", "warn", "info", "debug", "trace" + float_precision = 1.0e-2; # Limit the number of decimals displayed for floats + }; + progress = { + poll_rate = 0; # How and when to poll for progress messages + suppress_on_insert = true; # Suppress new messages while in insert mode + ignore_done_already = false; # Ignore new tasks that are already complete + ignore_empty_message = false; # Ignore new tasks that don't contain a message + clear_on_detach = + # Clear notification group when LSP server detaches + '' + function(client_id) + local client = vim.lsp.get_client_by_id(client_id) + return client and client.name or nil + end + ''; + notification_group = + # How to get a progress message's notification group key + '' + function(msg) return msg.lsp_client.name end + ''; + ignore = [ ]; # List of LSP servers to ignore + lsp = { + progress_ringbuf_size = 0; # Configure the nvim's LSP progress ring buffer size + }; + display = { + render_limit = 16; # How many LSP messages to show at once + done_ttl = 3; # How long a message should persist after completion + done_icon = "✔"; # Icon shown when all LSP progress tasks are complete + done_style = "Constant"; # Highlight group for completed LSP tasks + progress_ttl = 10; # How long a message should persist when in progress + progress_icon = { + pattern = "dots"; + period = 1; + }; # Icon shown when LSP progress tasks are in progress + progress_style = "WarningMsg"; # Highlight group for in-progress LSP tasks + group_style = "Title"; # Highlight group for group name (LSP server name) + icon_style = "Question"; # Highlight group for group icons + priority = 30; # Ordering priority for LSP notification group + skip_history = true; # Whether progress notifications should be omitted from history + format_message = '' + require ("fidget.progress.display").default_format_message + ''; # How to format a progress message + format_annote = '' + function (msg) return msg.title end + ''; # How to format a progress annotation + format_group_name = '' + function (group) return tostring (group) end + ''; # How to format a progress notification group's name + overrides = { + rust_analyzer = { + name = "rust-analyzer"; + }; + }; # Override options from the default notification config + }; + }; + notification = { + poll_rate = 10; # How frequently to update and render notifications + filter = "info"; # "off", "error", "warn", "info", "debug", "trace" + history_size = 128; # Number of removed messages to retain in history + override_vim_notify = true; + redirect = { + __raw = '' + function(msg, level, opts) + if opts and opts.on_open then + return require("fidget.integration.nvim-notify").delegate(msg, level, opts) + end + end + ''; + }; + configs = { + default = { + name = "Notifications"; + icon = "󰏪"; + group = "Notifications"; + annote = true; + debug = false; + debug_rate = 0.25; + }; + }; + + window = { + normal_hl = "Comment"; + winblend = 0; + border = "none"; # none, single, double, rounded, solid, shadow + zindex = 45; + max_width = 0; + max_height = 0; + x_padding = 1; + y_padding = 0; + align = "bottom"; + relative = "editor"; + }; + view = { + stack_upwards = true; # Display notification items from bottom to top + icon_separator = " "; # Separator between group name and icon + group_separator = "---"; # Separator between notification groups + group_separator_hl = + # Highlight group used for group separator + "Comment"; + }; + }; + }; + }; +} diff --git a/home/modules/ide/nvim/lsp/langs/c.nix b/home/modules/ide/nvim/lsp/langs/c.nix new file mode 100644 index 0000000..7829578 --- /dev/null +++ b/home/modules/ide/nvim/lsp/langs/c.nix @@ -0,0 +1,18 @@ +{ lib, pkgs, ... }: +{ + plugins = { + lsp.servers = { + clangd.enable = true; + cmake.enable = true; + }; + + conform-nvim.settings = { + formatters_by_ft = { + c = [ "clang_format" ]; + cpp = [ "clang_format" ]; + cmake = [ "cmake-format" ]; + }; + formatters.cmake-format.command = lib.getExe pkgs.cmake-format; + }; + }; +} diff --git a/home/modules/ide/nvim/lsp/langs/default.nix b/home/modules/ide/nvim/lsp/langs/default.nix new file mode 100644 index 0000000..37ea051 --- /dev/null +++ b/home/modules/ide/nvim/lsp/langs/default.nix @@ -0,0 +1,5 @@ +{ + imports = + with builtins; + map (fn: ./${fn}) (filter (fn: fn != "default.nix") (attrNames (readDir ./.))); +} diff --git a/home/modules/ide/nvim/lsp/langs/go.nix b/home/modules/ide/nvim/lsp/langs/go.nix new file mode 100644 index 0000000..1430f96 --- /dev/null +++ b/home/modules/ide/nvim/lsp/langs/go.nix @@ -0,0 +1,23 @@ +{ lib, pkgs, ... }: +{ + plugins = { + lsp.servers = { + gopls = { + enable = true; + filetypes = [ + "go" + ]; + }; + }; + conform-nvim.settings = { + formatters_by_ft = { + go = [ "gofmt" ]; + }; + formatters = { + gofmt = { + command = lib.getExe pkgs.go + " fmt"; + }; + }; + }; + }; +} diff --git a/home/modules/ide/nvim/lsp/langs/lua.nix b/home/modules/ide/nvim/lsp/langs/lua.nix new file mode 100644 index 0000000..1a5523d --- /dev/null +++ b/home/modules/ide/nvim/lsp/langs/lua.nix @@ -0,0 +1,12 @@ +{ + plugins = { + lsp.servers.lua_ls.enable = true; + conform-nvim.settings = { + formatters_by_ft.lua = [ "stylua" ]; + formatters.stylua = { + # if a command is string then it will execute the system's stylua binary + command = "stylua"; + }; + }; + }; +} diff --git a/home/modules/ide/nvim/lsp/langs/nix.nix b/home/modules/ide/nvim/lsp/langs/nix.nix new file mode 100644 index 0000000..e802d27 --- /dev/null +++ b/home/modules/ide/nvim/lsp/langs/nix.nix @@ -0,0 +1,13 @@ +{ + plugins = { + lsp.servers = { + nixd = { + enable = true; + cmd = [ "nixd" ]; + rootMarkers = [ + "require('lspconfig.util').root_pattern('.nixd.json', 'flake.nix', '.git')" + ]; + }; + }; + }; +} diff --git a/home/modules/ide/nvim/lsp/langs/odin.nix b/home/modules/ide/nvim/lsp/langs/odin.nix new file mode 100644 index 0000000..d90cd5f --- /dev/null +++ b/home/modules/ide/nvim/lsp/langs/odin.nix @@ -0,0 +1,21 @@ +{ + plugins = { + conform-nvim.settings = { + formatters = { + odinfmt = { + command = "odinfmt"; + args = [ "-stdin" ]; + stdin = true; + }; + }; + formatters_by_ft = { + odin = [ "odinfmt" ]; + }; + }; + lsp.servers = { + ols = { + enable = true; + }; + }; + }; +} diff --git a/home/modules/ide/nvim/lsp/langs/web.nix b/home/modules/ide/nvim/lsp/langs/web.nix new file mode 100644 index 0000000..f0d801e --- /dev/null +++ b/home/modules/ide/nvim/lsp/langs/web.nix @@ -0,0 +1,12 @@ +{ + plugins = { + ts-autotag.enable = false; + ts-comments.enable = false; + lsp.servers = { + html.enable = true; + cssls.enable = true; + svelte.enable = false; + ts_ls.enable = false; + }; + }; +} diff --git a/home/modules/ide/nvim/lsp/lsp.nix b/home/modules/ide/nvim/lsp/lsp.nix new file mode 100644 index 0000000..8b0be38 --- /dev/null +++ b/home/modules/ide/nvim/lsp/lsp.nix @@ -0,0 +1,78 @@ +{ + pkgs, + ... +}: +{ + imports = [ ./langs/default.nix ]; + plugins = { + lsp = { + enable = true; + inlayHints = true; + keymaps = { + silent = true; + lspBuf = { + gd = { + action = "definition"; + desc = "Goto Definition"; + }; + gr = { + action = "references"; + desc = "Goto References"; + }; + gD = { + action = "declaration"; + desc = "Goto Declaration"; + }; + gI = { + action = "implementation"; + desc = "Goto Implementation"; + }; + gT = { + action = "type_definition"; + desc = "Type Definition"; + }; + K = { + action = "hover"; + desc = "Hover"; + }; + "cw" = { + action = "workspace_symbol"; + desc = "Workspace Symbol"; + }; + "cr" = { + action = "rename"; + desc = "Rename"; + }; + }; + diagnostic = { + "cd" = { + action = "open_float"; + desc = "Line Diagnostics"; + }; + "[d" = { + action = "goto_next"; + desc = "Next Diagnostic"; + }; + "]d" = { + action = "goto_prev"; + desc = "Previous Diagnostic"; + }; + }; + }; + }; + lsp-lines.enable = true; + lsp-format.enable = true; + helm.enable = true; + }; + + extraPlugins = with pkgs.vimPlugins; [ + roslyn-nvim + ]; + extraPackages = with pkgs; [ + roslyn-ls + nixfmt-rfc-style + svelte-language-server + typescript-language-server + typescript + ]; +} diff --git a/home/modules/ide/nvim/lsp/roslyn.nix b/home/modules/ide/nvim/lsp/roslyn.nix new file mode 100644 index 0000000..f24888a --- /dev/null +++ b/home/modules/ide/nvim/lsp/roslyn.nix @@ -0,0 +1,17 @@ +{ lib, pkgs, ... }: +{ + lsp.servers.roslyn_ls = { + enable = true; + + settings = { + cmd = [ + "${lib.getExe' pkgs.roslyn-ls "Microsoft.CodeAnalysis.LanguageServer"}" + "--logLevel" + "Information" + "--extensionLogDirectory" + "fs.joinpath(uv.os_tmpdir() \"roslyn_ls/logs\")" + "--stdio" + ]; + }; + }; +} diff --git a/home/modules/ide/nvim/plugins/aerial.nix b/home/modules/ide/nvim/plugins/aerial.nix new file mode 100644 index 0000000..d6b51c8 --- /dev/null +++ b/home/modules/ide/nvim/plugins/aerial.nix @@ -0,0 +1,63 @@ +{ + plugins.aerial = { + enable = true; + autoLoad = true; + settings = { + attach_mode = "global"; + backends = [ + "treesitter" + "lsp" + "markdown" + "man" + ]; + disable_max_lines = 5000; + highlight_on_hover = true; + ignore = { + filetypes = [ + "gomod" + ]; + }; + keymaps = { + "<2-LeftMouse>" = "actions.jump"; + "" = "actions.down_and_scroll"; + "" = "actions.up_and_scroll"; + "" = "actions.jump_split"; + "" = "actions.jump_vsplit"; + "" = "actions.jump"; + "?" = "actions.show_help"; + H = "actions.tree_close_recursive"; + L = "actions.tree_open_recursive"; + O = "actions.tree_toggle_recursive"; + "[[" = "actions.prev_up"; + "]]" = "actions.next_up"; + "g?" = "actions.show_help"; + h = "actions.tree_close"; + l = "actions.tree_open"; + o = "actions.tree_toggle"; + p = "actions.scroll"; + q = "actions.close"; + zA = "actions.tree_toggle_recursive"; + zC = "actions.tree_close_recursive"; + zM = "actions.tree_close_all"; + zO = "actions.tree_open_recursive"; + zR = "actions.tree_open_all"; + zX = "actions.tree_sync_folds"; + za = "actions.tree_toggle"; + zc = "actions.tree_close"; + zm = "actions.tree_decrease_fold_level"; + zo = "actions.tree_open"; + zr = "actions.tree_increase_fold_level"; + zx = "actions.tree_sync_folds"; + "{" = "actions.prev"; + "}" = "actions.next"; + }; + }; + }; + keymaps = [ + { + key = "o"; + mode = [ "n" ]; + action = "AerialToggle"; + } + ]; +} diff --git a/home/modules/ide/nvim/plugins/autopairs.nix b/home/modules/ide/nvim/plugins/autopairs.nix new file mode 100644 index 0000000..2f3853e --- /dev/null +++ b/home/modules/ide/nvim/plugins/autopairs.nix @@ -0,0 +1,11 @@ +{ + plugins.nvim-autopairs = { + enable = true; + settings = { + disable_filetype = [ + "TelescopePrompt" + "vim" + ]; + }; + }; +} diff --git a/home/modules/ide/nvim/plugins/blink.nix b/home/modules/ide/nvim/plugins/blink.nix new file mode 100644 index 0000000..d26a8d4 --- /dev/null +++ b/home/modules/ide/nvim/plugins/blink.nix @@ -0,0 +1,95 @@ +{ + plugins = { + blink-cmp = { + enable = true; + setupLspCapabilities = true; + + settings = { + keymap.preset = "super-tab"; + signature.enabled = true; + + sources = { + default = [ + "lsp" + "buffer" + "path" + "snippets" + ]; + + providers = { + lsp.score_offset = 4; + }; + }; + + appearance = { + nerd_font_variant = "mono"; + kind_icons = { + Text = "󰉿"; + Method = ""; + Function = "󰊕"; + Constructor = "󰒓"; + Field = "󰜢"; + Variable = "󰆦"; + Property = "󰖷"; + Class = "󱡠"; + Interface = "󱡠"; + Struct = "󱡠"; + Module = "󰅩"; + Unit = "󰪚"; + Value = "󰦨"; + Enum = "󰦨"; + EnumMember = "󰦨"; + Keyword = "󰻾"; + Constant = "󰏿"; + Snippet = "󱄽"; + Color = "󰏘"; + File = "󰈔"; + Reference = "󰬲"; + Folder = "󰉋"; + Event = "󱐋"; + Operator = "󰪚"; + TypeParameter = "󰬛"; + Error = "󰏭"; + Warning = "󰏯"; + Information = "󰏮"; + Hint = "󰏭"; + }; + }; + + completion = { + menu = { + border = "none"; + draw = { + gap = 1; + treesitter = [ "lsp" ]; + columns = [ + { __unkeyed-1 = "label"; } + { + __unkeyed-1 = "kind_icon"; + __unkeyed-2 = "kind"; + gap = 1; + } + { __unkeyed-1 = "source_name"; } + ]; + }; + }; + + trigger.show_in_snippet = false; + + documentation = { + auto_show = true; + window.border = "single"; + }; + + accept.auto_brackets.enabled = false; + + performance = { + debounce_ms = 80; + throttle_ms = 50; + max_view_entries = 20; + }; + }; + }; + }; + }; +} diff --git a/home/modules/ide/nvim/plugins/dashboard.nix b/home/modules/ide/nvim/plugins/dashboard.nix new file mode 100644 index 0000000..f6430ad --- /dev/null +++ b/home/modules/ide/nvim/plugins/dashboard.nix @@ -0,0 +1,86 @@ +{ + plugins.dashboard = { + enable = true; + autoLoad = true; + + settings = { + theme = "doom"; + + config = { + header = [ + "" + "" + "" + "" + "" + "" + "" + "" + "" + " ⢀⣴⡾⠃⠄⠄⠄⠄⠄⠈⠺⠟⠛⠛⠛⠛⠻⢿⣿⣿⣿⣿⣶⣤⡀ " + " ⢀⣴⣿⡿⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣸⣿⣿⣿⣿⣿⣿⣿⣷ " + " ⣴⣿⡿⡟⡼⢹⣷⢲⡶⣖⣾⣶⢄⠄⠄⠄⠄⠄⢀⣼⣿⢿⣿⣿⣿⣿⣿⣿⣿ " + " ⣾⣿⡟⣾⡸⢠⡿⢳⡿⠍⣼⣿⢏⣿⣷⢄⡀⠄⢠⣾⢻⣿⣸⣿⣿⣿⣿⣿⣿⣿ " + " ⣡⣿⣿⡟⡼⡁⠁⣰⠂⡾⠉⢨⣿⠃⣿⡿⠍⣾⣟⢤⣿⢇⣿⢇⣿⣿⢿⣿⣿⣿⣿⣿ " + " ⣱⣿⣿⡟⡐⣰⣧⡷⣿⣴⣧⣤⣼⣯⢸⡿⠁⣰⠟⢀⣼⠏⣲⠏⢸⣿⡟⣿⣿⣿⣿⣿⣿ " + " ⣿⣿⡟⠁⠄⠟⣁⠄⢡⣿⣿⣿⣿⣿⣿⣦⣼⢟⢀⡼⠃⡹⠃⡀⢸⡿⢸⣿⣿⣿⣿⣿⡟ " + " ⣿⣿⠃⠄⢀⣾⠋⠓⢰⣿⣿⣿⣿⣿⣿⠿⣿⣿⣾⣅⢔⣕⡇⡇⡼⢁⣿⣿⣿⣿⣿⣿⢣ " + " ⣿⡟⠄⠄⣾⣇⠷⣢⣿⣿⣿⣿⣿⣿⣿⣭⣀⡈⠙⢿⣿⣿⡇⡧⢁⣾⣿⣿⣿⣿⣿⢏⣾ " + " ⣿⡇⠄⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⢻⠇⠄⠄⢿⣿⡇⢡⣾⣿⣿⣿⣿⣿⣏⣼⣿ " + " ⣿⣷⢰⣿⣿⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⢰⣧⣀⡄⢀⠘⡿⣰⣿⣿⣿⣿⣿⣿⠟⣼⣿⣿ " + " ⢹⣿⢸⣿⣿⠟⠻⢿⣿⣿⣿⣿⣿⣿⣿⣶⣭⣉⣤⣿⢈⣼⣿⣿⣿⣿⣿⣿⠏⣾⣹⣿⣿ " + " ⢸⠇⡜⣿⡟⠄⠄⠄⠈⠙⣿⣿⣿⣿⣿⣿⣿⣿⠟⣱⣻⣿⣿⣿⣿⣿⠟⠁⢳⠃⣿⣿⣿ " + " ⣰⡗⠹⣿⣄⠄⠄⠄⢀⣿⣿⣿⣿⣿⣿⠟⣅⣥⣿⣿⣿⣿⠿⠋ ⣾⡌⢠⣿⡿⠃ " + " ⠜⠋⢠⣷⢻⣿⣿⣶⣾⣿⣿⣿⣿⠿⣛⣥⣾⣿⠿⠟⠛⠉ " + "" + "" + "" + ]; + + center = [ + { + icon = " "; + desc = "find files"; + action = "lua Snacks.picker.files()"; + key = "f"; + } + { + icon = " "; + desc = "projects"; + action = "lua Snacks.picker.projects()"; + key = "p"; + } + { + icon = "󱁴 "; + desc = "grep"; + action = "lua Snacks.picker.grep()"; + key = "s"; + } + { + icon = " "; + desc = "todos"; + action = "lua Snacks.picker.todo_comments()"; + key = "t"; + } + { + icon = " "; + desc = "ragequit"; + action = "qa"; + key = "x"; + } + ]; + + footer = [ "~elisiei" ]; + }; + }; + }; + + extraConfigLua = '' + vim.api.nvim_create_autocmd("User", { + pattern = "DashboardReady", + callback = function() + vim.b.miniindentscope_disable = true + end, + }) + ''; +} diff --git a/home/modules/ide/nvim/plugins/hlchunk.nix b/home/modules/ide/nvim/plugins/hlchunk.nix new file mode 100644 index 0000000..2379458 --- /dev/null +++ b/home/modules/ide/nvim/plugins/hlchunk.nix @@ -0,0 +1,46 @@ +{ + plugins.hlchunk = { + enable = true; + autoLoad = true; + settings = { + blank = { + enable = false; + }; + chunk = { + chars = { + horizontal_line = "─"; + left_bottom = "╰"; + left_top = "╭"; + right_arrow = "─"; + vertical_line = "│"; + }; + enable = true; + exclude_filetypes = { + lazyterm = true; + neo-tree = true; + }; + style = { + fg = "#91bef0"; + }; + use_treesitter = true; + }; + indent = { + chars = [ + "│" + ]; + exclude_filetypes = { + lazyterm = true; + neo-tree = true; + }; + style = { + fg = "#45475a"; + }; + use_treesitter = false; + }; + line_num = { + style = "#91bef0"; + use_treesitter = true; + }; + }; + }; +} diff --git a/home/modules/ide/nvim/plugins/lualine.nix b/home/modules/ide/nvim/plugins/lualine.nix new file mode 100644 index 0000000..082aeea --- /dev/null +++ b/home/modules/ide/nvim/plugins/lualine.nix @@ -0,0 +1,97 @@ +{ + plugins.lualine = { + enable = true; + settings = { + options = { + globalstatus = true; + extensions = [ + "fzf" + "neo-tree" + ]; + disabledFiletypes = { + statusline = [ + "startup" + "alpha" + ]; + }; + theme = "kanagawa"; + }; + sections = { + lualine_a = [ + { + __unkeyed-1 = "mode"; + icon = ""; + } + ]; + lualine_b = [ + { + __unkeyed-1 = "branch"; + icon = ""; + } + { + __unkeyed-1 = "diff"; + symbols = { + added = " "; + modified = " "; + removed = " "; + }; + } + ]; + lualine_c = [ + { + __unkeyed-1 = "diagnostics"; + sources = [ "nvim_lsp" ]; + symbols = { + error = " "; + warn = " "; + info = " "; + hint = "󰝶 "; + }; + } + { + __unkeyed-1 = "navic"; + } + ]; + lualine_x = [ + { + __unkeyed-1 = "filetype"; + icon_only = true; + separator = ""; + padding = { + left = 1; + right = 0; + }; + } + { + __unkeyed-1 = "filename"; + path = 1; + } + { + __unkeyed-1.__raw = '' + function() + local icon = " " + local status = require("copilot.api").status.data + return icon .. (status.message or " ") + end, + + cond = function() + local ok, clients = pcall(vim.lsp.get_clients, { name = "copilot", bufnr = 0 }) + return ok and #clients > 0 + end, + ''; + } + ]; + lualine_y = [ + { + __unkeyed-1 = "progress"; + } + ]; + lualine_z = [ + { + __unkeyed-1 = "location"; + } + ]; + }; + }; + }; +} diff --git a/home/modules/ide/nvim/plugins/neo-tree.nix b/home/modules/ide/nvim/plugins/neo-tree.nix new file mode 100644 index 0000000..ca3c5b3 --- /dev/null +++ b/home/modules/ide/nvim/plugins/neo-tree.nix @@ -0,0 +1,120 @@ +{ + plugins.neo-tree = { + enable = true; + + sources = [ + "filesystem" + "buffers" + "git_status" + ]; + enableDiagnostics = true; + enableGitStatus = true; + enableModifiedMarkers = true; + enableRefreshOnWrite = true; + openFilesInLastWindow = true; + + extraOptions = { + open_files_do_not_replace_types = [ + "terminal" + "Trouble" + "trouble" + "qf" + "Outline" + ]; + + filesystem = { + bind_to_cwd = false; + follow_current_file = { + enabled = true; + }; + use_libuv_file_watcher = true; + }; + + window.mappings = { + "l" = "open"; + "h" = "close_node"; + "" = "none"; + + "Y" = { + __raw = '' + function(state) + local node = state.tree:get_node() + local path = node:get_id() + vim.fn.setreg("+", path, "c") + end + ''; + desc = "Copy Path to Clipboard"; + }; + + "O" = { + __raw = '' + function(state) + vim.ui.open(state.tree:get_node().path) + end + ''; + desc = "Open with System Application"; + }; + }; + + default_component_configs = { + indent = { + with_expanders = true; + expander_collapsed = ""; + expander_expanded = ""; + expander_highlight = "NeoTreeExpander"; + }; + git_status.symbols = { + unstaged = "󰄱"; + staged = "󰱒"; + }; + }; + }; + + eventHandlers = { + file_moved = '' + function(data) + require("snacks.rename").on_rename_file(data.source, data.destination) + end + ''; + file_renamed = '' + function(data) + require("snacks.rename").on_rename_file(data.source, data.destination) + end + ''; + }; + }; + + keymaps = [ + { + key = "fe"; + mode = [ "n" ]; + action = '' + lua require("neo-tree.command").execute({ toggle = true, dir = vim.fn.getcwd() }) + ''; + options.desc = "Explorer NeoTree (cwd)"; + } + { + key = "e"; + mode = [ "n" ]; + action = "fe"; + options.remap = true; + options.desc = "Explorer NeoTree (cwd)"; + } + { + key = "ge"; + mode = [ "n" ]; + action = '' + lua require("neo-tree.command").execute({ source = "git_status", toggle = true }) + ''; + options.desc = "Git Explorer"; + } + { + key = "be"; + mode = [ "n" ]; + action = '' + lua require("neo-tree.command").execute({ source = "buffers", toggle = true }) + ''; + options.desc = "Buffer Explorer"; + } + ]; +} diff --git a/home/modules/ide/nvim/plugins/snacks.nix b/home/modules/ide/nvim/plugins/snacks.nix new file mode 100644 index 0000000..3ed2cdf --- /dev/null +++ b/home/modules/ide/nvim/plugins/snacks.nix @@ -0,0 +1,45 @@ +{ + plugins.snacks = { + enable = true; + autoLoad = true; + }; + + keymaps = [ + { + key = "ff"; + mode = [ "n" ]; + action = "lua Snacks.picker.files()"; + options.desc = "Find files"; + } + { + key = "fb"; + mode = [ "n" ]; + action = "lua Snacks.picker.buffers()"; + options.desc = "Find buffers"; + } + { + key = "gl"; + mode = [ "n" ]; + action = "lua Snacks.picker.git_log()"; + options.desc = "Git log"; + } + { + key = "gs"; + mode = [ "n" ]; + action = "lua Snacks.picker.git_status()"; + options.desc = "Git status"; + } + { + key = "uC"; + mode = [ "n" ]; + action = "lua Snacks.picker.colorschemes()"; + options.desc = "Colorschemes"; + } + { + key = ":"; + mode = [ "n" ]; + action = "lua Snacks.picker.command_history()"; + options.desc = "Command history"; + } + ]; +} diff --git a/home/modules/ide/nvim/plugins/toggleterm.nix b/home/modules/ide/nvim/plugins/toggleterm.nix new file mode 100644 index 0000000..921a8ad --- /dev/null +++ b/home/modules/ide/nvim/plugins/toggleterm.nix @@ -0,0 +1,33 @@ +{ + plugins.toggleterm = { + enable = true; + settings = { + direction = "vertical"; + float_opts = { + border = "curved"; + height = 30; + width = 130; + }; + open_mapping = "[[]]"; + autochdir = true; + auto_scroll = true; + close_on_exit = true; + insert_mappings = true; + shell = "nu"; + }; + }; + keymaps = [ + { + key = ""; + mode = [ + "n" + "t" + ]; + action = "ToggleTerm"; + options = { + silent = true; + noremap = true; + }; + } + ]; +} diff --git a/home/modules/ide/nvim/plugins/treesitter.nix b/home/modules/ide/nvim/plugins/treesitter.nix new file mode 100644 index 0000000..75f4411 --- /dev/null +++ b/home/modules/ide/nvim/plugins/treesitter.nix @@ -0,0 +1,32 @@ +{ pkgs, ... }: +{ + plugins = { + treesitter = { + enable = true; + + settings = { + indent = { + enable = true; + }; + highlight = { + enable = true; + }; + }; + + nixvimInjections = true; + grammarPackages = pkgs.vimPlugins.nvim-treesitter.allGrammars; + }; + + treesitter-context = { + enable = false; + }; + + treesitter-textobjects = { + enable = true; + select = { + enable = true; + lookahead = true; + }; + }; + }; +} diff --git a/home/modules/ide/nvim/plugins/treesj.nix b/home/modules/ide/nvim/plugins/treesj.nix new file mode 100644 index 0000000..a3455f1 --- /dev/null +++ b/home/modules/ide/nvim/plugins/treesj.nix @@ -0,0 +1,25 @@ +{ + plugins.treesj = { + enable = true; + autoLoad = true; + }; + keymaps = [ + { + key = "m"; + mode = [ + "n" + ]; + action = "TSJToggle"; + } + { + key = "s"; + mode = [ "n" ]; + action = "TSJSplit"; + } + { + key = "j"; + mode = [ "n" ]; + action = "TSJJoin"; + } + ]; +} diff --git a/home/modules/ide/nvim/plugins/web-devicons.nix b/home/modules/ide/nvim/plugins/web-devicons.nix new file mode 100644 index 0000000..1b25f3a --- /dev/null +++ b/home/modules/ide/nvim/plugins/web-devicons.nix @@ -0,0 +1,10 @@ +{ + plugins.web-devicons = { + enable = true; + autoLoad = true; + settings = { + color_icons = true; + strict = true; + }; + }; +} diff --git a/home/modules/ide/nvim/plugins/yanky.nix b/home/modules/ide/nvim/plugins/yanky.nix new file mode 100644 index 0000000..76146b6 --- /dev/null +++ b/home/modules/ide/nvim/plugins/yanky.nix @@ -0,0 +1,139 @@ +{ config, lib, ... }: +{ + plugins = { + sqlite-lua.enable = true; + + yanky = { + enable = true; + + lazyLoad = { + settings = { + keys = lib.mkIf config.plugins.lz-n.enable [ + { + __unkeyed-1 = "fy"; + __unkeyed-2 = "Telescope yank_history"; + desc = "Paste from yanky history"; + } + { + __unkeyed-1 = "y"; + __unkeyed-2 = "(YankyYank)"; + mode = [ + "n" + "x" + ]; + desc = "Yank text"; + } + { + __unkeyed-1 = "p"; + __unkeyed-2 = "(YankyPutAfter)"; + mode = [ + "n" + "x" + ]; + desc = "Put yanked text after cursor"; + } + { + __unkeyed-1 = "P"; + __unkeyed-2 = "(YankyPutBefore)"; + mode = [ + "n" + "x" + ]; + desc = "Put yanked text before cursor"; + } + { + __unkeyed-1 = "gp"; + __unkeyed-2 = "(YankyGPutAfter)"; + mode = [ + "n" + "x" + ]; + desc = "Put yanked text after selection"; + } + { + __unkeyed-1 = "gP"; + __unkeyed-2 = "(YankyGPutBefore)"; + mode = [ + "n" + "x" + ]; + desc = "Put yanked text before selection"; + } + { + __unkeyed-1 = ""; + __unkeyed-2 = "(YankyPreviousEntry)"; + desc = "Select previous entry through yank history"; + } + { + __unkeyed-1 = ""; + __unkeyed-2 = "(YankyNextEntry)"; + desc = "Select next entry through yank history"; + } + { + __unkeyed-1 = "]p"; + __unkeyed-2 = "(YankyPutIndentAfterLinewise)"; + desc = "Put indented after cursor (linewise)"; + } + { + __unkeyed-1 = "[p"; + __unkeyed-2 = "(YankyPutIndentBeforeLinewise)"; + desc = "Put indented before cursor (linewise)"; + } + { + __unkeyed-1 = "]P"; + __unkeyed-2 = "(YankyPutIndentAfterLinewise)"; + desc = "Put indented after cursor (linewise)"; + } + { + __unkeyed-1 = "[P"; + __unkeyed-2 = "(YankyPutIndentBeforeLinewise)"; + desc = "Put indented before cursor (linewise)"; + } + { + __unkeyed-1 = ">p"; + __unkeyed-2 = "(YankyPutIndentAfterShiftRight)"; + desc = "Put and indent right"; + } + { + __unkeyed-1 = "%Creset' +export alias glods = git log --graph $'--pretty=%Cred%h%Creset -%C(char lp)auto(char rp)%d%Creset %s %Cgreen(char lp)%ad(char rp) %C(char lp)bold blue(char rp)<%an>%Creset' --date=short +export alias glog = git log --oneline --decorate --graph +export alias gloga = git log --oneline --decorate --graph --all +export alias glol = git log --graph $'--pretty=%Cred%h%Creset -%C(char lp)auto(char rp)%d%Creset %s %Cgreen(char lp)%ar(char rp) %C(char lp)bold blue(char rp)<%an>%Creset' +export alias glola = git log --graph $'--pretty=%Cred%h%Creset -%C(char lp)auto(char rp)%d%Creset %s %Cgreen(char lp)%ar(char rp) %C(char lp)bold blue(char rp)<%an>%Creset' --all +export alias glols = git log --graph $'--pretty=%Cred%h%Creset -%C(char lp)auto(char rp)%d%Creset %s %Cgreen(char lp)%ar(char rp) %C(char lp)bold blue(char rp)<%an>%Creset' --stat + +export alias gm = git merge +export alias gmtl = git mergetool --no-prompt +export alias gmtlvim = git mergetool --no-prompt --tool=vimdiff +export alias gma = git merge --abort +export def gmom [] { + let main = (git_main_branch) + git merge $"origin/($main)" +} + +export alias gp = git push +export alias gpd = git push --dry-run +export alias gpf = git push --force-with-lease +export alias gpf! = git push --force +export alias gpl = git pull +export def gpoat [] { + git push origin --all; git push origin --tags +} +export alias gpod = git push origin --delete +export alias gpodc = git push origin --delete (git_current_branch) +def "nu-complete git pull rebase" [] { + ["false","true","merges","interactive"] +} +export def gpr [rebase_type: string@"nu-complete git pull rebase"] { + git pull --rebase $rebase_type +} +export alias gpu = git push upstream +export alias gpv = git push --verbose + +export alias gr = git remote +export alias gpra = git pull --rebase --autostash +export alias gprav = git pull --rebase --autostash --verbose +export alias gprv = git pull --rebase --verbose +export alias gpsup = git push --set-upstream origin (git_current_branch) +export alias gra = git remote add +export alias grb = git rebase +export alias grba = git rebase --abort +export alias grbc = git rebase --continue +export alias grbd = git rebase develop +export alias grbi = git rebase --interactive +export alias grbm = git rebase (git_main_branch) +export alias grbo = git rebase --onto +export alias grbs = git rebase --skip +export alias grev = git revert +export alias grh = git reset +export alias grhh = git reset --hard +export alias groh = git reset $"origin/(git_current_branch)" --hard +export alias grm = git rm +export alias grmc = git rm --cached +export def grmv [remote: string, new_name: string] { + git remote rename $remote $new_name +} +export def grrm [remote: string] { + git remote remove $remote +} +export alias grs = git restore +export def grset [remote: string, url: string] { + git remote set-url $remote $url +} +export alias grss = git restore --source +export alias grst = git restore --staged +export alias grt = cd (git rev-parse --show-toplevel or echo .) +export alias gru = git reset -- +export alias grup = git remote update +export alias grv = git remote --verbose + +export alias gsb = git status --short --branch +export alias gsd = git svn dcommit +export alias gsh = git show +export alias gshs = git show -s +export alias gsi = git submodule init +export alias gsps = git show --pretty=short --show-signature +export alias gsr = git svn rebase +export alias gss = git status --short +export alias gst = git status + +export alias gsta = git stash push +export alias gstaa = git stash apply +export alias gstc = git stash clear +export alias gstd = git stash drop +export alias gstl = git stash list +export alias gstp = git stash pop +export alias gsts = git stash show --text +export alias gstu = gsta --include-untracked +export alias gstall = git stash --all +export alias gsu = git submodule update +export alias gsw = git switch +export alias gswc = git switch --create + +export alias gts = git tag --sign +export def gtv [] { + git tag | lines | sort +} +export alias glum = git pull upstream (git_main_branch) + +export alias gunignore = git update-index --no-assume-unchanged +export def gup [rebase_type: string@"nu-complete git pull rebase"] { + git pull --rebase $rebase_type +} +export alias gupv = git pull --rebase --verbose +export alias gupa = git pull --rebase --autostash +export alias gupav = git pull --rebase --autostash --verbose + +export alias gwch = git whatchanged -p --abbrev-commit --pretty=medium + +export alias gwt = git worktree +export def gwta [path: path, branch?: string] { + if $branch != null { + git worktree add $path $branch + } else { + git worktree add $path + } +} +export alias gwtls = git worktree list +export alias gwtmv = git worktree move +export def gwtm [worktree: string] { + git worktree remove $worktree +} + +export alias gam = git am +export alias gamc = git am --continue +export alias gams = git am --skip +export alias gama = git am --abort +export alias gamscp = git am --show-current-patch + diff --git a/home/modules/shell/nushell/config/completions/git.nu b/home/modules/shell/nushell/config/completions/git.nu new file mode 100644 index 0000000..e41b28e --- /dev/null +++ b/home/modules/shell/nushell/config/completions/git.nu @@ -0,0 +1,985 @@ +# nu-version: 0.102.0 + +module git-completion-utils { + export const GIT_SKIPABLE_FLAGS = ['-v', '--version', '-h', '--help', '-p', '--paginate', '-P', '--no-pager', '--no-replace-objects', '--bare'] + + # Helper function to append token if non-empty + def append-non-empty [token: string]: list -> list { + if ($token | is-empty) { $in } else { $in | append $token } + } + + # Split a string to list of args, taking quotes into account. + # Code is copied and modified from https://github.com/nushell/nushell/issues/14582#issuecomment-2542596272 + export def args-split []: string -> list { + # Define our states + const STATE_NORMAL = 0 + const STATE_IN_SINGLE_QUOTE = 1 + const STATE_IN_DOUBLE_QUOTE = 2 + const STATE_ESCAPE = 3 + const WHITESPACES = [" " "\t" "\n" "\r"] + + # Initialize variables + mut state = $STATE_NORMAL + mut current_token = "" + mut result: list = [] + mut prev_state = $STATE_NORMAL + + # Process each character + for char in ($in | split chars) { + if $state == $STATE_ESCAPE { + # Handle escaped character + $current_token = $current_token + $char + $state = $prev_state + } else if $char == '\' { + # Enter escape state + $prev_state = $state + $state = $STATE_ESCAPE + } else if $state == $STATE_NORMAL { + if $char == "'" { + $state = $STATE_IN_SINGLE_QUOTE + } else if $char == '"' { + $state = $STATE_IN_DOUBLE_QUOTE + } else if ($char in $WHITESPACES) { + # Whitespace in normal state means token boundary + $result = $result | append-non-empty $current_token + $current_token = "" + } else { + $current_token = $current_token + $char + } + } else if $state == $STATE_IN_SINGLE_QUOTE { + if $char == "'" { + $state = $STATE_NORMAL + } else { + $current_token = $current_token + $char + } + } else if $state == $STATE_IN_DOUBLE_QUOTE { + if $char == '"' { + $state = $STATE_NORMAL + } else { + $current_token = $current_token + $char + } + } + } + # Handle the last token + $result = $result | append-non-empty $current_token + # Return the result + $result + } + + # Get changed files which can be restored by `git checkout --` + export def get-changed-files []: nothing -> list { + ^git status -uno --porcelain=2 | lines + | where $it =~ '^1 [.MD]{2}' + | each { split row ' ' -n 9 | last } + } + + # Get files which can be retrieved from a branch/commit by `git checkout ` + export def get-checkoutable-files []: nothing -> list { + # Relevant statuses are .M", "MM", "MD", ".D", "UU" + ^git status -uno --porcelain=2 | lines + | where $it =~ '^1 ([.MD]{2}|UU)' + | each { split row ' ' -n 9 | last } + } + + export def get-all-git-local-refs []: nothing -> list> { + ^git for-each-ref --format '%(refname:lstrip=2)%09%(objectname:short)%09%(upstream:remotename)%(upstream:track)%09%(contents:subject)' refs/heads | lines | parse "{ref}\t{obj}\t{upstream}\t{subject}" + } + + export def get-all-git-remote-refs []: nothing -> list> { + ^git for-each-ref --format '%(refname:lstrip=2)%09%(objectname:short)%09%(contents:subject)' refs/remotes | lines | parse "{ref}\t{obj}\t{subject}" + } + + # Get local branches, remote branches which can be passed to `git merge` + export def get-mergable-sources []: nothing -> list> { + let local = get-all-git-local-refs | each {|x| {value: $x.ref description: $'Branch, Local, ($x.obj) ($x.subject), (if ($x.upstream | is-not-empty) { $x.upstream } else { "no upstream" } )'} } | insert style 'light_blue' + let remote = get-all-git-remote-refs | each {|x| {value: $x.ref description: $'Branch, Remote, ($x.obj) ($x.subject)'} } | insert style 'blue_italic' + $local | append $remote + } +} + +def "nu-complete git available upstream" [] { + ^git branch --no-color -a | lines | each { |line| $line | str replace '* ' "" | str trim } +} + +def "nu-complete git remotes" [] { + ^git remote | lines | each { |line| $line | str trim } +} + +def "nu-complete git log" [] { + ^git log --pretty=%h | lines | each { |line| $line | str trim } +} + +# Yield all existing commits in descending chronological order. +def "nu-complete git commits all" [] { + ^git rev-list --all --remotes --pretty=oneline | lines | parse "{value} {description}" +} + +# Yield commits of current branch only. This is useful for e.g. cut points in +# `git rebase`. +def "nu-complete git commits current branch" [] { + ^git log --pretty="%h %s" | lines | parse "{value} {description}" +} + +# Yield local branches like `main`, `feature/typo_fix` +def "nu-complete git local branches" [] { + ^git branch --no-color | lines | each { |line| $line | str replace '* ' "" | str replace '+ ' "" | str trim } +} + +# Yield remote branches like `origin/main`, `upstream/feature-a` +def "nu-complete git remote branches with prefix" [] { + ^git branch --no-color -r | lines | parse -r '^\*?(\s*|\s*\S* -> )(?P\S*$)' | get branch | uniq +} + +# Yield local and remote branch names which can be passed to `git merge` +def "nu-complete git mergable sources" [] { + use git-completion-utils * + let branches = get-mergable-sources + { + options: { + case_sensitive: false, + completion_algorithm: prefix, + sort: false, + }, + completions: $branches + } +} + +def "nu-complete git switch" [] { + use git-completion-utils * + let branches = get-mergable-sources + { + options: { + case_sensitive: false, + completion_algorithm: prefix, + sort: false, + }, + completions: $branches + } +} + +def "nu-complete git checkout" [context: string, position?:int] { + use git-completion-utils * + let preceding = $context | str substring ..$position + # See what user typed before, like 'git checkout a-branch a-path'. + # We exclude some flags from previous tokens, to detect if a branch name has been used as the first argument. + # FIXME: This method is still naive, though. + let prev_tokens = $preceding | str trim | args-split | where ($it not-in $GIT_SKIPABLE_FLAGS) + # In these scenarios, we suggest only file paths, not branch: + # - After '--' + # - First arg is a branch + # If before '--' is just 'git checkout' (or its alias), we suggest "dirty" files only (user is about to reset file). + if $prev_tokens.2? == '--' { + return (get-changed-files) + } + if '--' in $prev_tokens { + return (get-checkoutable-files) + } + # Already typed first argument. + if ($prev_tokens | length) > 2 and $preceding ends-with ' ' { + return (get-checkoutable-files) + } + # The first argument can be local branches, remote branches, files and commits + # Get local and remote branches + let branches = get-mergable-sources + let files = (get-checkoutable-files) | wrap value | insert description 'File' | insert style green + let commits = ^git rev-list -n 400 --remotes --oneline | lines | split column -n 2 ' ' value description | upsert description {|x| $'Commit, ($x.value) ($x.description)' } | insert style 'light_cyan_dimmed' + { + options: { + case_sensitive: false, + completion_algorithm: prefix, + sort: false, + }, + completions: [...$branches, ...$files, ...$commits] + } +} + +# Arguments to `git rebase --onto ` +def "nu-complete git rebase" [] { + (nu-complete git local branches) + | parse "{value}" + | insert description "local branch" + | append (nu-complete git remote branches with prefix + | parse "{value}" + | insert description "remote branch") + | append (nu-complete git commits all) +} + +def "nu-complete git stash-list" [] { + git stash list | lines | parse "{value}: {description}" +} + +def "nu-complete git tags" [] { + ^git tag --no-color | lines +} + +# See `man git-status` under "Short Format" +# This is incomplete, but should cover the most common cases. +const short_status_descriptions = { + ".D": "Deleted" + ".M": "Modified" + "!" : "Ignored" + "?" : "Untracked" + "AU": "Staged, not merged" + "MD": "Some modifications staged, file deleted in work tree" + "MM": "Some modifications staged, some modifications untracked" + "R.": "Renamed" + "UU": "Both modified (in merge conflict)" +} + +def "nu-complete git files" [] { + let relevant_statuses = ["?",".M", "MM", "MD", ".D", "UU"] + ^git status -uall --porcelain=2 + | lines + | each { |$it| + if $it starts-with "1 " { + $it | parse --regex "1 (?P\\S+) (?:\\S+\\s?){6} (?P\\S+)" + } else if $it starts-with "2 " { + $it | parse --regex "2 (?P\\S+) (?:\\S+\\s?){6} (?P\\S+)" + } else if $it starts-with "u " { + $it | parse --regex "u (?P\\S+) (?:\\S+\\s?){8} (?P\\S+)" + } else if $it starts-with "? " { + $it | parse --regex "(?P.{1}) (?P.+)" + } else { + { short_status: 'unknown', value: $it } + } + } + | flatten + | where $it.short_status in $relevant_statuses + | insert "description" { |e| $short_status_descriptions | get $e.short_status} +} + +def "nu-complete git built-in-refs" [] { + [HEAD FETCH_HEAD ORIG_HEAD] +} + +def "nu-complete git refs" [] { + nu-complete git local branches + | parse "{value}" + | insert description Branch + | append (nu-complete git tags | parse "{value}" | insert description Tag) + | append (nu-complete git built-in-refs) +} + +def "nu-complete git files-or-refs" [] { + nu-complete git local branches + | parse "{value}" + | insert description Branch + | append (nu-complete git files | where description == "Modified" | select value) + | append (nu-complete git tags | parse "{value}" | insert description Tag) + | append (nu-complete git built-in-refs) +} + +def "nu-complete git subcommands" [] { + ^git help -a | lines | where $it starts-with " " | parse -r '\s*(?P[^ ]+) \s*(?P\w.*)' +} + +def "nu-complete git add" [] { + nu-complete git files +} + +def "nu-complete git pull rebase" [] { + ["false","true","merges","interactive"] +} + +def "nu-complete git merge strategies" [] { + ['ort', 'octopus'] +} + +def "nu-complete git merge strategy options" [] { + ['ours', 'theirs'] +} + + +# Check out git branches and files +export extern "git checkout" [ + ...targets: string@"nu-complete git checkout" # name of the branch or files to checkout + --conflict: string # conflict style (merge or diff3) + --detach(-d) # detach HEAD at named commit + --force(-f) # force checkout (throw away local modifications) + --guess # second guess 'git checkout ' (default) + --ignore-other-worktrees # do not check if another worktree is holding the given ref + --ignore-skip-worktree-bits # do not limit pathspecs to sparse entries only + --merge(-m) # perform a 3-way merge with the new branch + --orphan: string # new unparented branch + --ours(-2) # checkout our version for unmerged files + --overlay # use overlay mode (default) + --overwrite-ignore # update ignored files (default) + --patch(-p) # select hunks interactively + --pathspec-from-file: string # read pathspec from file + --progress # force progress reporting + --quiet(-q) # suppress progress reporting + --recurse-submodules # control recursive updating of submodules + --theirs(-3) # checkout their version for unmerged files + --track(-t) # set upstream info for new branch + -b # create and checkout a new branch + -B: string # create/reset and checkout a branch + -l # create reflog for new branch +] + +export extern "git reset" [ + ...targets: string@"nu-complete git checkout" # name of commit, branch, or files to reset to + --hard # reset HEAD, index and working tree + --keep # reset HEAD but keep local changes + --merge # reset HEAD, index and working tree + --mixed # reset HEAD and index + --patch(-p) # select hunks interactively + --quiet(-q) # be quiet, only report errors + --soft # reset only HEAD + --pathspec-from-file: string # read pathspec from file + --pathspec-file-nul # with --pathspec-from-file, pathspec elements are separated with NUL character + --no-refresh # skip refreshing the index after reset + --recurse-submodules: string # control recursive updating of submodules + --no-recurse-submodules # don't recurse into submodules +] + +# Download objects and refs from another repository +export extern "git fetch" [ + repository?: string@"nu-complete git remotes" # name of the branch to fetch + --all # Fetch all remotes + --append(-a) # Append ref names and object names to .git/FETCH_HEAD + --atomic # Use an atomic transaction to update local refs. + --depth: int # Limit fetching to n commits from the tip + --deepen: int # Limit fetching to n commits from the current shallow boundary + --shallow-since: string # Deepen or shorten the history by date + --shallow-exclude: string # Deepen or shorten the history by branch/tag + --unshallow # Fetch all available history + --update-shallow # Update .git/shallow to accept new refs + --negotiation-tip: string # Specify which commit/glob to report while fetching + --negotiate-only # Do not fetch, only print common ancestors + --dry-run # Show what would be done + --write-fetch-head # Write fetched refs in FETCH_HEAD (default) + --no-write-fetch-head # Do not write FETCH_HEAD + --force(-f) # Always update the local branch + --keep(-k) # Keep downloaded pack + --multiple # Allow several arguments to be specified + --auto-maintenance # Run 'git maintenance run --auto' at the end (default) + --no-auto-maintenance # Don't run 'git maintenance' at the end + --auto-gc # Run 'git maintenance run --auto' at the end (default) + --no-auto-gc # Don't run 'git maintenance' at the end + --write-commit-graph # Write a commit-graph after fetching + --no-write-commit-graph # Don't write a commit-graph after fetching + --prefetch # Place all refs into the refs/prefetch/ namespace + --prune(-p) # Remove obsolete remote-tracking references + --prune-tags(-P) # Remove any local tags that do not exist on the remote + --no-tags(-n) # Disable automatic tag following + --refmap: string # Use this refspec to map the refs to remote-tracking branches + --tags(-t) # Fetch all tags + --recurse-submodules: string # Fetch new commits of populated submodules (yes/on-demand/no) + --jobs(-j): int # Number of parallel children + --no-recurse-submodules # Disable recursive fetching of submodules + --set-upstream # Add upstream (tracking) reference + --submodule-prefix: string # Prepend to paths printed in informative messages + --upload-pack: string # Non-default path for remote command + --quiet(-q) # Silence internally used git commands + --verbose(-v) # Be verbose + --progress # Report progress on stderr + --server-option(-o): string # Pass options for the server to handle + --show-forced-updates # Check if a branch is force-updated + --no-show-forced-updates # Don't check if a branch is force-updated + -4 # Use IPv4 addresses, ignore IPv6 addresses + -6 # Use IPv6 addresses, ignore IPv4 addresses +] + +# Push changes +export extern "git push" [ + remote?: string@"nu-complete git remotes", # the name of the remote + ...refs: string@"nu-complete git local branches" # the branch / refspec + --all # push all refs + --atomic # request atomic transaction on remote side + --delete(-d) # delete refs + --dry-run(-n) # dry run + --exec: string # receive pack program + --follow-tags # push missing but relevant tags + --force-with-lease # require old value of ref to be at this value + --force(-f) # force updates + --ipv4(-4) # use IPv4 addresses only + --ipv6(-6) # use IPv6 addresses only + --mirror # mirror all refs + --no-verify # bypass pre-push hook + --porcelain # machine-readable output + --progress # force progress reporting + --prune # prune locally removed refs + --push-option(-o): string # option to transmit + --quiet(-q) # be more quiet + --receive-pack: string # receive pack program + --recurse-submodules: string # control recursive pushing of submodules + --repo: string # repository + --set-upstream(-u) # set upstream for git pull/status + --signed: string # GPG sign the push + --tags # push tags (can't be used with --all or --mirror) + --thin # use thin pack + --verbose(-v) # be more verbose +] + +# Pull changes +export extern "git pull" [ + remote?: string@"nu-complete git remotes", # the name of the remote + ...refs: string@"nu-complete git local branches", # the branch / refspec + --rebase(-r): string@"nu-complete git pull rebase", # rebase current branch on top of upstream after fetching + --quiet(-q) # suppress output during transfer and merge + --verbose(-v) # be more verbose + --commit # perform the merge and commit the result + --no-commit # perform the merge but do not commit the result + --edit(-e) # edit the merge commit message + --no-edit # use the auto-generated merge commit message + --cleanup: string # specify how to clean up the merge commit message + --ff # fast-forward if possible + --no-ff # create a merge commit in all cases + --gpg-sign(-S) # GPG-sign the resulting merge commit + --no-gpg-sign # do not GPG-sign the resulting merge commit + --log: int # include log messages from merged commits + --no-log # do not include log messages from merged commits + --signoff # add Signed-off-by trailer + --no-signoff # do not add Signed-off-by trailer + --stat(-n) # show a diffstat at the end of the merge + --no-stat # do not show a diffstat at the end of the merge + --squash # produce working tree and index state as if a merge happened + --no-squash # perform the merge and commit the result + --verify # run pre-merge and commit-msg hooks + --no-verify # do not run pre-merge and commit-msg hooks + --strategy(-s): string # use the given merge strategy + --strategy-option(-X): string # pass merge strategy-specific option + --verify-signatures # verify the tip commit of the side branch being merged + --no-verify-signatures # do not verify the tip commit of the side branch being merged + --summary # show a summary of the merge + --no-summary # do not show a summary of the merge + --autostash # create a temporary stash entry before the operation + --no-autostash # do not create a temporary stash entry before the operation + --allow-unrelated-histories # allow merging histories without a common ancestor + --no-rebase # do not rebase the current branch on top of the upstream branch + --all # fetch all remotes + --append(-a) # append fetched refs to existing contents of FETCH_HEAD + --atomic # use an atomic transaction to update local refs + --depth: int # limit fetching to the specified number of commits + --deepen: int # deepen the history by the specified number of commits + --shallow-since: string # deepen or shorten the history since a specified date + --shallow-exclude: string # exclude commits reachable from a specified branch or tag + --unshallow # convert a shallow repository to a complete one + --update-shallow # update .git/shallow with new refs + --tags(-t) # fetch all tags from the remote + --jobs(-j): int # number of parallel children for fetching + --set-upstream # add upstream (tracking) reference + --upload-pack: string # specify non-default path for upload-pack on the remote + --progress # force progress status even if stderr is not a terminal + --server-option(-o): string # transmit the given string to the server +] + +# Switch between branches and commits +export extern "git switch" [ + switch?: string@"nu-complete git switch" # name of branch to switch to + --create(-c) # create a new branch + --detach(-d): string@"nu-complete git log" # switch to a commit in a detached state + --force-create(-C): string # forces creation of new branch, if it exists then the existing branch will be reset to starting point + --force(-f) # alias for --discard-changes + --guess # if there is no local branch which matches then name but there is a remote one then this is checked out + --ignore-other-worktrees # switch even if the ref is held by another worktree + --merge(-m) # attempts to merge changes when switching branches if there are local changes + --no-guess # do not attempt to match remote branch names + --no-progress # do not report progress + --no-recurse-submodules # do not update the contents of sub-modules + --no-track # do not set "upstream" configuration + --orphan: string # create a new orphaned branch + --progress # report progress status + --quiet(-q) # suppress feedback messages + --recurse-submodules # update the contents of sub-modules + --track(-t) # set "upstream" configuration +] + +# Apply the change introduced by an existing commit +export extern "git cherry-pick" [ + commit?: string@"nu-complete git commits all" # The commit ID to be cherry-picked + --edit(-e) # Edit the commit message prior to committing + --no-commit(-n) # Apply changes without making any commit + --signoff(-s) # Add Signed-off-by line to the commit message + --ff # Fast-forward if possible + --continue # Continue the operation in progress + --abort # Cancel the operation + --skip # Skip the current commit and continue with the rest of the sequence +] + +# Rebase the current branch +export extern "git rebase" [ + branch?: string@"nu-complete git rebase" # name of the branch to rebase onto + upstream?: string@"nu-complete git rebase" # upstream branch to compare against + --continue # restart rebasing process after editing/resolving a conflict + --abort # abort rebase and reset HEAD to original branch + --quit # abort rebase but do not reset HEAD + --interactive(-i) # rebase interactively with list of commits in editor + --onto?: string@"nu-complete git rebase" # starting point at which to create the new commits + --root # start rebase from root commit +] + +# Merge from a branch +export extern "git merge" [ + # For now, to make it simple, we only complete branches (not commits) and support single-parent case. + branch?: string@"nu-complete git mergable sources" # The source branch + --edit(-e) # Edit the commit message prior to committing + --no-edit # Do not edit commit message + --no-commit(-n) # Apply changes without making any commit + --signoff # Add Signed-off-by line to the commit message + --ff # Fast-forward if possible + --continue # Continue after resolving a conflict + --abort # Abort resolving conflict and go back to original state + --quit # Forget about the current merge in progress + --strategy(-s): string@"nu-complete git merge strategies" # Merge strategy + -X: string@"nu-complete git merge strategy options" # Option for merge strategy + --verbose(-v) + --help +] + +# List or change branches +export extern "git branch" [ + branch?: string@"nu-complete git local branches" # name of branch to operate on + --abbrev # use short commit hash prefixes + --edit-description # open editor to edit branch description + --merged # list reachable branches + --no-merged # list unreachable branches + --set-upstream-to: string@"nu-complete git available upstream" # set upstream for branch + --unset-upstream # remote upstream for branch + --all # list both remote and local branches + --copy # copy branch together with config and reflog + --format # specify format for listing branches + --move # rename branch + --points-at # list branches that point at an object + --show-current # print the name of the current branch + --verbose # show commit and upstream for each branch + --color # use color in output + --quiet # suppress messages except errors + --delete(-d) # delete branch + --list # list branches + --contains: string@"nu-complete git commits all" # show only branches that contain the specified commit + --no-contains # show only branches that don't contain specified commit + --track(-t) # when creating a branch, set upstream +] + +# List all variables set in config file, along with their values. +export extern "git config list" [ +] + +# Emits the value of the specified key. +export extern "git config get" [ +] + +# Set value for one or more config options. +export extern "git config set" [ +] + +# Unset value for one or more config options. +export extern "git config unset" [ +] + +# Rename the given section to a new name. +export extern "git config rename-section" [ +] + +# Remove the given section from the configuration file. +export extern "git config remove-section" [ +] + +# Opens an editor to modify the specified config file +export extern "git config edit" [ +] + +# List or change tracked repositories +export extern "git remote" [ + --verbose(-v) # Show URL for remotes +] + +# Add a new tracked repository +export extern "git remote add" [ +] + +# Rename a tracked repository +export extern "git remote rename" [ + remote: string@"nu-complete git remotes" # remote to rename + new_name: string # new name for remote +] + +# Remove a tracked repository +export extern "git remote remove" [ + remote: string@"nu-complete git remotes" # remote to remove +] + +# Get the URL for a tracked repository +export extern "git remote get-url" [ + remote: string@"nu-complete git remotes" # remote to get URL for +] + +# Set the URL for a tracked repository +export extern "git remote set-url" [ + remote: string@"nu-complete git remotes" # remote to set URL for + url: string # new URL for remote +] + +# Show changes between commits, working tree etc +export extern "git diff" [ + rev1_or_file?: string@"nu-complete git files-or-refs" + rev2?: string@"nu-complete git refs" + --cached # show staged changes + --name-only # only show names of changed files + --name-status # show changed files and kind of change + --no-color # disable color output +] + +# Commit changes +export extern "git commit" [ + --all(-a) # automatically stage all modified and deleted files + --amend # amend the previous commit rather than adding a new one + --message(-m): string # specify the commit message rather than opening an editor + --reuse-message(-C): string # reuse the message from a previous commit + --reedit-message(-c): string # reuse and edit message from a commit + --fixup: string # create a fixup/amend commit + --squash: string # squash commit for autosquash rebase + --reset-author # reset author information + --short # short-format output for dry-run + --branch # show branch info in short-format + --porcelain # porcelain-ready format for dry-run + --long # long-format output for dry-run + --null(-z) # use NUL instead of LF in output + --file(-F): string # read commit message from file + --author: string # override commit author + --date: string # override author date + --template(-t): string # use commit message template file + --signoff(-s) # add Signed-off-by trailer + --no-signoff # do not add Signed-off-by trailer + --trailer: string # add trailer to commit message + --no-verify(-n) # bypass pre-commit and commit-msg hooks + --verify # do not bypass pre-commit and commit-msg hooks + --allow-empty # allow commit with no changes + --allow-empty-message # allow commit with empty message + --cleanup: string # cleanup commit message + --edit(-e) # edit commit message + --no-edit # do not edit commit message + --include(-i) # include given paths in commit + --only(-o) # commit only specified paths + --pathspec-from-file: string # read pathspec from file + --pathspec-file-nul # use NUL character for pathspec file + --untracked-files(-u): string # show untracked files + --verbose(-v) # show diff in commit message template + --quiet(-q) # suppress commit summary + --dry-run # show paths to be committed without committing + --status # include git-status output in commit message + --no-status # do not include git-status output + --gpg-sign(-S) # GPG-sign commit + --no-gpg-sign # do not GPG-sign commit + ...pathspec: string # commit files matching pathspec +] + +# List commits +export extern "git log" [ + # Ideally we'd allow completion of revisions here, but that would make completion of filenames not work. + -U # show diffs + --follow # show history beyond renames (single file only) + --grep: string # show log entries matching supplied regular expression +] + +# Show or change the reflog +export extern "git reflog" [ +] + +# Stage files +export extern "git add" [ + ...file: string@"nu-complete git add" # file to add + --all(-A) # add all files + --dry-run(-n) # don't actually add the file(s), just show if they exist and/or will be ignored + --edit(-e) # open the diff vs. the index in an editor and let the user edit it + --force(-f) # allow adding otherwise ignored files + --interactive(-i) # add modified contents in the working tree interactively to the index + --patch(-p) # interactively choose hunks to stage + --verbose(-v) # be verbose +] + +# Delete file from the working tree and the index +export extern "git rm" [ + -r # recursive + --force(-f) # override the up-to-date check + --dry-run(-n) # Don't actually remove any file(s) + --cached # unstage and remove paths only from the index +] + +# Show the working tree status +export extern "git status" [ + --verbose(-v) # be verbose + --short(-s) # show status concisely + --branch(-b) # show branch information + --show-stash # show stash information +] + +# Stash changes for later +export extern "git stash push" [ + --patch(-p) # interactively choose hunks to stash +] + +# Unstash previously stashed changes +export extern "git stash pop" [ + stash?: string@"nu-complete git stash-list" # stash to pop + --index(-i) # try to reinstate not only the working tree's changes, but also the index's ones +] + +# List stashed changes +export extern "git stash list" [ +] + +# Show a stashed change +export extern "git stash show" [ + stash?: string@"nu-complete git stash-list" + -U # show diff +] + +# Drop a stashed change +export extern "git stash drop" [ + stash?: string@"nu-complete git stash-list" +] + +# Create a new git repository +export extern "git init" [ + --initial-branch(-b): string # initial branch name +] + +# List or manipulate tags +export extern "git tag" [ + --delete(-d): string@"nu-complete git tags" # delete a tag +] + +# Prune all unreachable objects +export extern "git prune" [ + --dry-run(-n) # dry run + --expire: string # expire objects older than + --progress # show progress + --verbose(-v) # report all removed objects +] + +# Start a binary search to find the commit that introduced a bug +export extern "git bisect start" [ + bad?: string # a commit that has the bug + good?: string # a commit that doesn't have the bug +] + +# Mark the current (or specified) revision as bad +export extern "git bisect bad" [ +] + +# Mark the current (or specified) revision as good +export extern "git bisect good" [ +] + +# Skip the current (or specified) revision +export extern "git bisect skip" [ +] + +# End bisection +export extern "git bisect reset" [ +] + +# Show help for a git subcommand +export extern "git help" [ + command?: string@"nu-complete git subcommands" # subcommand to show help for +] + +# git worktree +export extern "git worktree" [ + --help(-h) # display the help message for this command + ...args +] + +# create a new working tree +export extern "git worktree add" [ + path: path # directory to clone the branch + branch: string@"nu-complete git available upstream" # Branch to clone + --help(-h) # display the help message for this command + --force(-f) # checkout even if already checked out in other worktree + -b # create a new branch + -B # create or reset a branch + --detach(-d) # detach HEAD at named commit + --checkout # populate the new working tree + --lock # keep the new working tree locked + --reason # reason for locking + --quiet(-q) # suppress progress reporting + --track # set up tracking mode (see git-branch(1)) + --guess-remote # try to match the new branch name with a remote-tracking branch + ...args +] + +# list details of each worktree +export extern "git worktree list" [ + --help(-h) # display the help message for this command + --porcelain # machine-readable output + --verbose(-v) # show extended annotations and reasons, if available + --expire # add 'prunable' annotation to worktrees older than