From bf200e93e6d9163d637fb184581d6c2be8719f6d Mon Sep 17 00:00:00 2001 From: Gabe Venberg Date: Sun, 24 Mar 2024 17:39:49 -0500 Subject: [PATCH] non-nixos configs. --- flake.lock | 306 ++++++ flake.nix | 57 ++ hosts/gabe-archlaptop.nix | 20 + hosts/non-nixos-server.nix | 20 + justfile | 18 + terminal/git.nix | 57 ++ terminal/home.nix | 82 ++ terminal/nushell/config.nu | 900 ++++++++++++++++++ terminal/nushell/env.nu | 118 +++ terminal/nushell/nushell.nix | 34 + terminal/nushell/scripts/cargo-completions.nu | 586 ++++++++++++ terminal/nushell/scripts/git-completions.nu | 493 ++++++++++ terminal/nushell/scripts/just-completions.nu | 44 + terminal/nushell/scripts/make-completions.nu | 65 ++ .../nushell/scripts/ultimate_extractor.nu | 27 + terminal/nvim/cmp/cmp.nix | 70 ++ terminal/nvim/gitsigns.nix | 25 + terminal/nvim/keybinds.nix | 97 ++ terminal/nvim/lsp/lsp.nix | 245 +++++ terminal/nvim/lsp/rust-tools.nix | 16 + terminal/nvim/lualine.nix | 77 ++ terminal/nvim/nvim-tree.nix | 31 + terminal/nvim/nvim.nix | 34 + terminal/nvim/options.nix | 70 ++ terminal/nvim/simpleplugins.nix | 21 + terminal/nvim/spell/en.utf-8.add | 52 + terminal/nvim/telescope.nix | 116 +++ terminal/nvim/toggleterm.nix | 32 + terminal/nvim/treesitter/arial.nix | 28 + .../nvim/treesitter/rainbow-delimiters.nix | 25 + terminal/nvim/treesitter/treesitter.nix | 39 + terminal/nvim/which-key.nix | 15 + terminal/starship.nix | 109 +++ terminal/voice.nix | 30 + terminal/zellij/config.kdl | 352 +++++++ terminal/zellij/zellij.nix | 10 + terminal/zsh.nix | 40 + 37 files changed, 4361 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hosts/gabe-archlaptop.nix create mode 100644 hosts/non-nixos-server.nix create mode 100644 justfile create mode 100644 terminal/git.nix create mode 100644 terminal/home.nix create mode 100644 terminal/nushell/config.nu create mode 100644 terminal/nushell/env.nu create mode 100644 terminal/nushell/nushell.nix create mode 100644 terminal/nushell/scripts/cargo-completions.nu create mode 100644 terminal/nushell/scripts/git-completions.nu create mode 100644 terminal/nushell/scripts/just-completions.nu create mode 100644 terminal/nushell/scripts/make-completions.nu create mode 100644 terminal/nushell/scripts/ultimate_extractor.nu create mode 100644 terminal/nvim/cmp/cmp.nix create mode 100644 terminal/nvim/gitsigns.nix create mode 100644 terminal/nvim/keybinds.nix create mode 100644 terminal/nvim/lsp/lsp.nix create mode 100644 terminal/nvim/lsp/rust-tools.nix create mode 100644 terminal/nvim/lualine.nix create mode 100644 terminal/nvim/nvim-tree.nix create mode 100644 terminal/nvim/nvim.nix create mode 100644 terminal/nvim/options.nix create mode 100644 terminal/nvim/simpleplugins.nix create mode 100644 terminal/nvim/spell/en.utf-8.add create mode 100644 terminal/nvim/telescope.nix create mode 100644 terminal/nvim/toggleterm.nix create mode 100644 terminal/nvim/treesitter/arial.nix create mode 100644 terminal/nvim/treesitter/rainbow-delimiters.nix create mode 100644 terminal/nvim/treesitter/treesitter.nix create mode 100644 terminal/nvim/which-key.nix create mode 100644 terminal/starship.nix create mode 100644 terminal/voice.nix create mode 100644 terminal/zellij/config.kdl create mode 100644 terminal/zellij/zellij.nix create mode 100644 terminal/zsh.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7af0878 --- /dev/null +++ b/flake.lock @@ -0,0 +1,306 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1711099426, + "narHash": "sha256-HzpgM/wc3aqpnHJJ2oDqPBkNsqWbW0WfWUO8lKu8nGk=", + "owner": "numtide", + "repo": "devshell", + "rev": "2d45b54ca4a183f2fdcf4b19c895b64fbf620ee8", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-compat": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709336216, + "narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "nixvim", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1711133180, + "narHash": "sha256-WJOahf+6115+GMl3wUfURu8fszuNeJLv9qAWFQl3Vmo=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "1c2c5e4cabba4c43504ef0f8cc3f3dfa284e2dbb", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "home-manager_2": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1711133180, + "narHash": "sha256-WJOahf+6115+GMl3wUfURu8fszuNeJLv9qAWFQl3Vmo=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "1c2c5e4cabba4c43504ef0f8cc3f3dfa284e2dbb", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1710717205, + "narHash": "sha256-Wf3gHh5uV6W1TV/A8X8QJf99a5ypDSugY4sNtdJDe0A=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "bcc8afd06e237df060c85bad6af7128e05fd61a3", + "type": "github" + }, + "original": { + "owner": "lnl7", + "repo": "nix-darwin", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1711163522, + "narHash": "sha256-YN/Ciidm+A0fmJPWlHBGvVkcarYWSC+s3NTPk/P+q3c=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "44d0940ea560dee511026a53f0e2e2cde489b4d4", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixvim": { + "inputs": { + "devshell": "devshell", + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "home-manager": "home-manager_2", + "nix-darwin": "nix-darwin", + "nixpkgs": [ + "nixpkgs" + ], + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1711284540, + "narHash": "sha256-DTzi4ujZoxM3ZXStCwD6Lph3FdGtkBlvfYsDCRITjfA=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "e7a3461fefd983ae3443e9aa849e9d1566ab47e4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_2", + "gitignore": "gitignore", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ], + "nixpkgs-stable": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1710923068, + "narHash": "sha256-6hOpUiuxuwpXXc/xfJsBUJeqqgGI+JMJuLo45aG3cKc=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "e611897ddfdde3ed3eaac4758635d7177ff78673", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs", + "nixvim": "nixvim" + } + }, + "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" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..cdfb1b1 --- /dev/null +++ b/flake.nix @@ -0,0 +1,57 @@ +{ + description = "Nix config for both home-manager and nixos"; + + inputs = { + # Nixpkgs + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + + # Home manager + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + nixvim = { + url = "github:nix-community/nixvim"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + # Shameless plug: looking for a way to nixify your themes and make + # everything match nicely? Try nix-colors! + # nix-colors.url = "github:misterio77/nix-colors"; + }; + + outputs = { + self, + nixpkgs, + home-manager, + nixvim, + ... + } @ inputs: let + inherit (self) outputs; + in { + formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra; + # NixOS configuration entrypoint + # Available through 'nixos-rebuild --flake .#your-hostname' + # nixosConfigurations = { + # archlaptop = nixpkgs.lib.nixosSystem { + # specialArgs = {inherit inputs outputs;}; + # # > Our main nixos configuration file < + # modules = [./nixos/configuration.nix]; + # }; + # }; + + # Standalone home-manager configuration entrypoint + # Available through 'home-manager --flake .#your-username@your-hostname' + homeConfigurations = { + "gabe@archlaptop" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance + extraSpecialArgs = {inherit inputs outputs;}; + # > Our main home-manager configuration file < + modules = [ + ./hosts/gabe-archlaptop.nix + nixvim.homeManagerModules.nixvim + ]; + }; + }; + }; +} diff --git a/hosts/gabe-archlaptop.nix b/hosts/gabe-archlaptop.nix new file mode 100644 index 0000000..12f5633 --- /dev/null +++ b/hosts/gabe-archlaptop.nix @@ -0,0 +1,20 @@ +{ + config, + pkgs, + lib, + ... +}: { + # Home Manager needs a bit of information about you and the paths it should + # manage. + # machine specific options + host.enable-speech = true; + host.nvim.enable-lsp = true; + host.nvim.enable-treesitter = true; + + targets.genericLinux.enable = true; + home.username = "gabe"; + home.homeDirectory = "/home/gabe"; + imports = [ + ../terminal/home.nix + ]; +} diff --git a/hosts/non-nixos-server.nix b/hosts/non-nixos-server.nix new file mode 100644 index 0000000..58fb1c9 --- /dev/null +++ b/hosts/non-nixos-server.nix @@ -0,0 +1,20 @@ +{ + config, + pkgs, + lib, + ... +}: { + # Home Manager needs a bit of information about you and the paths it should + # manage. + # machine specific options + host.enable-speech = false; + host.nvim.enable-lsp = false; + host.nvim.enable-treesitter = true; + + targets.genericLinux.enable = true; + home.username = "gabe"; + home.homeDirectory = "/home/gabe"; + imports = [ + ../terminal/home.nix + ]; +} diff --git a/justfile b/justfile new file mode 100644 index 0000000..a45e80b --- /dev/null +++ b/justfile @@ -0,0 +1,18 @@ +default: + just --list + +home-manager target: + home-manager --flake .#{{target}} switch + +check-home-manager target: + home-manager build --no-out-link --flake .#{{target}} + +bootstrap-home-manager target: + nix run --extra-experimental-features "nix-command flakes" --no-write-lock-file github:nix-community/home-manager/ -- --extra-experimental-features "nix-command flakes" --flake .#{{target}} switch + +format: + nix fmt + +home-gc: + home-manager expire-generations -7days + nix store gc diff --git a/terminal/git.nix b/terminal/git.nix new file mode 100644 index 0000000..62cf1b2 --- /dev/null +++ b/terminal/git.nix @@ -0,0 +1,57 @@ +{ + config, + pgks, + ... +}: { + programs.git = { + enable = true; + aliases = { + hist = "log --graph --date-order --date=short --pretty=format:'%C(auto)%h%d %C(reset)%s %C(bold blue)%ce %C(reset)%C(green)%cr (%cd)'"; + graph = "log --graph --topo-order --all --pretty=format:'%C(auto)%h %C(cyan)%an %C(blue)%ar %C(auto)%d %s'"; + recent = "branch --sort=-committerdate --format='%(committerdate:relative)%09%(refname:short)'"; + }; + delta.enable = true; + # difftastic.enable=true; + # difftastic.background="dark"; + userEmail = "gabevenberg@gmail.com"; + userName = "Gabe Venberg"; + extraConfig = { + init = { + defaultBranch = "main"; + }; + push = { + autoSetupRemote = true; + default = "current"; + }; + pull = { + ff = true; + }; + merge = { + conflictstyle = "zdiff3"; + }; + rebase = { + autosquash = true; + }; + help = { + autocorrect = "prompt"; + }; + branch = { + sort = "-committerdate"; + }; + status = { + submodulesummary = true; + }; + }; + includes = [ + { + condition = "gitdir:~/work/"; + contents = { + user = { + email = "venberggabe@johndeere.com"; + }; + }; + } + ]; + }; + programs.lazygit.enable = true; +} diff --git a/terminal/home.nix b/terminal/home.nix new file mode 100644 index 0000000..6cedf98 --- /dev/null +++ b/terminal/home.nix @@ -0,0 +1,82 @@ +{ + config, + pkgs, + lib, + ... +}: { + home.stateVersion = "23.11"; # Please read the comment before changing. + + home.packages = with pkgs; [ + sshfs + just + fd + sd + scc + tre-command + diskonaut + hyperfine + curl + ]; + + # Home Manager is pretty good at managing dotfiles. The primary way to manage + # plain files is through 'home.file'. + home.file = { + }; + + home.sessionVariables = { + EDITOR = "nvim"; + VISUAL = "nvim"; + PIPENV_VENV_IN_PROJECT = 1; + POETRY_VIRTUALENVS_IN_PROJECT = 1; + }; + + home.sessionPath = [ + "$HOME/.nix-profile/bin/" + "$HOME/.local/bin/" + "$HOME/.cargo/bin/" + "/opt/" + ]; + + home.shellAliases = { + # doc2pdf = "loffice --convert-to-pdf --headless *.docx"; + sshmnt = "sshfs -o idmap=user,compression=no,reconnect,follow_symlinks,dir_cache=yes,ServerAliveInterval=15"; + }; + + imports = [ + ./nushell/nushell.nix + ./zsh.nix + ./git.nix + ./starship.nix + ./nvim/nvim.nix + ./voice.nix + ]; + + programs = { + yazi.enable = true; + zoxide.enable = true; + fzf.enable = true; + ripgrep.enable = true; + bat.enable = true; + tealdeer.enable = true; + btop.enable = true; + direnv = { + enable = true; + nix-direnv.enable = true; + }; + }; + + services.ssh-agent.enable = true; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + + # enable flakes + nix = + lib.mkIf config.targets.genericLinux.enable + { + package = pkgs.nix; + settings.experimental-features = ["nix-command" "flakes"]; + settings.max-jobs = "auto"; + gc.automatic = true; + }; +} diff --git a/terminal/nushell/config.nu b/terminal/nushell/config.nu new file mode 100644 index 0000000..f828cab --- /dev/null +++ b/terminal/nushell/config.nu @@ -0,0 +1,900 @@ +# Nushell Config File +# +# version = "0.91.0" + +# For more information on defining custom themes, see +# https://www.nushell.sh/book/coloring_and_theming.html +# And here is the theme collection +# https://github.com/nushell/nu_scripts/tree/main/themes +let dark_theme = { + # color for nushell primitives + separator: white + leading_trailing_space_bg: { attr: n } # no fg, no bg, attr none effectively turns this off + header: green_bold + empty: blue + # Closures can be used to choose colors for specific values. + # The value (in this case, a bool) is piped into the closure. + # eg) {|| if $in { 'light_cyan' } else { 'light_gray' } } + bool: light_cyan + int: white + filesize: cyan + duration: white + date: purple + range: white + float: white + string: white + nothing: white + binary: white + cell-path: white + row_index: green_bold + record: white + list: white + block: white + hints: dark_gray + search_result: {bg: red fg: white} + shape_and: purple_bold + shape_binary: purple_bold + shape_block: blue_bold + shape_bool: light_cyan + shape_closure: green_bold + shape_custom: green + shape_datetime: cyan_bold + shape_directory: cyan + shape_external: cyan + shape_externalarg: green_bold + shape_external_resolved: light_yellow_bold + shape_filepath: cyan + shape_flag: blue_bold + shape_float: purple_bold + # shapes are used to change the cli syntax highlighting + shape_garbage: { fg: white bg: red attr: b} + shape_globpattern: cyan_bold + shape_int: purple_bold + shape_internalcall: cyan_bold + shape_keyword: cyan_bold + shape_list: cyan_bold + shape_literal: blue + shape_match_pattern: green + shape_matching_brackets: { attr: u } + shape_nothing: light_cyan + shape_operator: yellow + shape_or: purple_bold + shape_pipe: purple_bold + shape_range: yellow_bold + shape_record: cyan_bold + shape_redirection: purple_bold + shape_signature: green_bold + shape_string: green + shape_string_interpolation: cyan_bold + shape_table: blue_bold + shape_variable: purple + shape_vardecl: purple +} + +let light_theme = { + # color for nushell primitives + separator: dark_gray + leading_trailing_space_bg: { attr: n } # no fg, no bg, attr none effectively turns this off + header: green_bold + empty: blue + # Closures can be used to choose colors for specific values. + # The value (in this case, a bool) is piped into the closure. + # eg) {|| if $in { 'dark_cyan' } else { 'dark_gray' } } + bool: dark_cyan + int: dark_gray + filesize: cyan_bold + duration: dark_gray + date: purple + range: dark_gray + float: dark_gray + string: dark_gray + nothing: dark_gray + binary: dark_gray + cell-path: dark_gray + row_index: green_bold + record: dark_gray + list: dark_gray + block: dark_gray + hints: dark_gray + search_result: {fg: white bg: red} + shape_and: purple_bold + shape_binary: purple_bold + shape_block: blue_bold + shape_bool: light_cyan + shape_closure: green_bold + shape_custom: green + shape_datetime: cyan_bold + shape_directory: cyan + shape_external: cyan + shape_externalarg: green_bold + shape_external_resolved: light_purple_bold + shape_filepath: cyan + shape_flag: blue_bold + shape_float: purple_bold + # shapes are used to change the cli syntax highlighting + shape_garbage: { fg: white bg: red attr: b} + shape_globpattern: cyan_bold + shape_int: purple_bold + shape_internalcall: cyan_bold + shape_keyword: cyan_bold + shape_list: cyan_bold + shape_literal: blue + shape_match_pattern: green + shape_matching_brackets: { attr: u } + shape_nothing: light_cyan + shape_operator: yellow + shape_or: purple_bold + shape_pipe: purple_bold + shape_range: yellow_bold + shape_record: cyan_bold + shape_redirection: purple_bold + shape_signature: green_bold + shape_string: green + shape_string_interpolation: cyan_bold + shape_table: blue_bold + shape_variable: purple + shape_vardecl: purple +} + +# let fish_completer = {|spans| +# fish --command $'complete "--do-complete=($spans | str join " ")"' +# | $"value(char tab)description(char newline)" + $in +# | from tsv --flexible --no-infer +# } +# +# let carapace_completer = {|spans: list| +# carapace $spans.0 nushell ...$spans +# | from json +# | if ($in | default [] | where value =~ '^-.*ERR$' | is-empty) { $in } else { null } +# } +# +# let zoxide_completer = {|spans| +# $spans | skip 1 | zoxide query -l $in | lines | where {|x| $x != $env.PWD} +# } +# +# # This completer will use carapace by default +let external_completer = null +# The default config record. This is where much of your global configuration is setup. +$env.config = { + show_banner: true # true or false to enable or disable the welcome banner at startup + + ls: { + use_ls_colors: true # use the LS_COLORS environment variable to colorize output + clickable_links: true # enable or disable clickable links. Your terminal has to support links. + } + + rm: { + always_trash: false # always act as if -t was given. Can be overridden with -p + } + + table: { + mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other + index_mode: always # "always" show indexes, "never" show indexes, "auto" = show indexes when a table has "index" column + show_empty: true # show 'empty list' and 'empty record' placeholders for command output + padding: { left: 1, right: 1 } # a left right padding of each column in a table + trim: { + methodology: wrapping # wrapping or truncating + wrapping_try_keep_words: true # A strategy used by the 'wrapping' methodology + truncating_suffix: "..." # A suffix used by the 'truncating' methodology + } + header_on_separator: false # show header text on separator/border line + # abbreviated_row_count: 10 # limit data rows from top and bottom after reaching a set point + } + + error_style: "fancy" # "fancy" or "plain" for screen reader-friendly error messages + + # datetime_format determines what a datetime rendered in the shell would look like. + # Behavior without this configuration point will be to "humanize" the datetime display, + # showing something like "a day ago." + datetime_format: { + # normal: '%a, %d %b %Y %H:%M:%S %z' # shows up in displays of variables or other datetime's outside of tables + # table: '%m/%d/%y %I:%M:%S%p' # generally shows up in tabular outputs such as ls. commenting this out will change it to the default human readable datetime format + } + + explore: { + status_bar_background: {fg: "#1D1F21", bg: "#C4C9C6"}, + command_bar_text: {fg: "#C4C9C6"}, + highlight: {fg: "black", bg: "yellow"}, + status: { + error: {fg: "white", bg: "red"}, + warn: {} + info: {} + }, + table: { + split_line: {fg: "#404040"}, + selected_cell: {bg: light_blue}, + selected_row: {}, + selected_column: {}, + }, + } + + history: { + max_size: 100_000 # Session has to be reloaded for this to take effect + sync_on_enter: true # Enable to share history between multiple sessions, else you have to close the session to write history to file + file_format: "sqlite" # "sqlite" or "plaintext" + isolation: false # only available with sqlite file_format. true enables history isolation, false disables it. true will allow the history to be isolated to the current session using up/down arrows. false will allow the history to be shared across all sessions. + } + + completions: { + case_sensitive: false # set to true to enable case-sensitive completions + quick: true # set this to false to prevent auto-selecting completions when only one remains + partial: true # set this to false to prevent partial filling of the prompt + algorithm: "fuzzy" # prefix or fuzzy + external: { + enable: true # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up may be very slow + max_results: 100 # setting it lower can improve completion performance at the cost of omitting some options + completer: $external_completer # check 'carapace_completer' above as an example + } + } + + filesize: { + metric: true # true => KB, MB, GB (ISO standard), false => KiB, MiB, GiB (Windows standard) + format: "auto" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, auto + } + + cursor_shape: { + emacs: line # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (line is the default) + vi_insert: line # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (block is the default) + vi_normal: blink_block # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (underscore is the default) + } + + color_config: $dark_theme # if you want a more interesting theme, you can replace the empty record with `$dark_theme`, `$light_theme` or another custom record + use_grid_icons: true + footer_mode: "25" # always, never, number_of_rows, auto + float_precision: 2 # the precision for displaying floats in tables + buffer_editor: "" # command that will be used to edit the current line buffer with ctrl+o, if unset fallback to $env.EDITOR and $env.VISUAL + use_ansi_coloring: true + bracketed_paste: true # enable bracketed paste, currently useless on windows + edit_mode: vi # emacs, vi + shell_integration: true # enables terminal shell integration. Off by default, as some terminals have issues with this. + render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt. + # enables keyboard enhancement protocol implemented by kitty console, only if your terminal support this. + # Zellij does not modify the term var, so we have to special-case it. + use_kitty_protocol: ($env.TERM == 'xterm-kitty' and $env.ZELLIJ? == null) + highlight_resolved_externals: true # true enables highlighting of external commands in the repl resolved by which. + + plugins: {} # Per-plugin configuration. See https://www.nushell.sh/contributor-book/plugins.html#configuration. + + hooks: { + pre_prompt: [{ null }] # run before the prompt is shown + pre_execution: [{ null }] # run before the repl input is run + env_change: { + PWD: [{|before, after| null }] # run if the PWD environment is different since the last repl input + } + display_output: "if (term size).columns >= 100 { table -e } else { table }" # run to display the output of a pipeline + command_not_found: { null } # return an error message when a command is not found + } + + menus: [ + # Configuration for default nushell menus + # Note the lack of source parameter + { + name: completion_menu + only_buffer_difference: false + marker: "| " + type: { + layout: columnar + columns: 4 + col_width: 20 # Optional value. If missing all the screen width is used to calculate column width + col_padding: 2 + } + style: { + text: green + selected_text: {attr: r} + description_text: yellow + match_text: {attr: u} + selected_match_text: {attr: ur} + } + } + { + name: ide_completion_menu + only_buffer_difference: false + marker: "| " + type: { + layout: ide + min_completion_width: 0, + max_completion_width: 50, + # max_completion_height: 10, # will be limited by the available lines in the terminal + padding: 0, + border: true, + cursor_offset: 0, + description_mode: "prefer_right" + min_description_width: 0 + max_description_width: 50 + max_description_height: 10 + description_offset: 1 + # If true, the cursor pos will be corrected, so the suggestions match up with the typed text + # + # C:\> str + # str join + # str trim + # str split + correct_cursor_pos: false + } + style: { + text: green + selected_text: {attr: r} + description_text: yellow + match_text: {attr: u} + selected_match_text: {attr: ur} + } + } + { + name: history_menu + only_buffer_difference: true + marker: "? " + type: { + layout: list + page_size: 10 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + } + { + name: help_menu + only_buffer_difference: true + marker: "? " + type: { + layout: description + columns: 4 + col_width: 20 # Optional value. If missing all the screen width is used to calculate column width + col_padding: 2 + selection_rows: 4 + description_rows: 10 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + } + ] + + keybindings: [ + { + name: completion_menu + modifier: none + keycode: tab + mode: [emacs vi_normal vi_insert] + event: { + until: [ + { send: menu name: completion_menu } + { send: menunext } + { edit: complete } + ] + } + } + { + name: ide_completion_menu + modifier: control + keycode: char_n + mode: [emacs vi_normal vi_insert] + event: { + until: [ + { send: menu name: ide_completion_menu } + { send: menunext } + { edit: complete } + ] + } + } + { + name: history_menu + modifier: control + keycode: char_r + mode: [emacs, vi_insert, vi_normal] + event: { send: menu name: history_menu } + } + { + name: help_menu + modifier: none + keycode: f1 + mode: [emacs, vi_insert, vi_normal] + event: { send: menu name: help_menu } + } + { + name: completion_previous_menu + modifier: shift + keycode: backtab + mode: [emacs, vi_normal, vi_insert] + event: { send: menuprevious } + } + { + name: next_page_menu + modifier: control + keycode: char_x + mode: emacs + event: { send: menupagenext } + } + { + name: undo_or_previous_page_menu + modifier: control + keycode: char_z + mode: emacs + event: { + until: [ + { send: menupageprevious } + { edit: undo } + ] + } + } + { + name: escape + modifier: none + keycode: escape + mode: [emacs, vi_normal, vi_insert] + event: { send: esc } # NOTE: does not appear to work + } + { + name: cancel_command + modifier: control + keycode: char_c + mode: [emacs, vi_normal, vi_insert] + event: { send: ctrlc } + } + { + name: quit_shell + modifier: control + keycode: char_d + mode: [emacs, vi_normal, vi_insert] + event: { send: ctrld } + } + { + name: clear_screen + modifier: control + keycode: char_l + mode: [emacs, vi_normal, vi_insert] + event: { send: clearscreen } + } + { + name: search_history + modifier: control + keycode: char_q + mode: [emacs, vi_normal, vi_insert] + event: { send: searchhistory } + } + { + name: open_command_editor + modifier: control + keycode: char_o + mode: [emacs, vi_normal, vi_insert] + event: { send: openeditor } + } + { + name: move_up + modifier: none + keycode: up + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: menuup} + {send: up} + ] + } + } + { + name: move_down + modifier: none + keycode: down + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: menudown} + {send: down} + ] + } + } + { + name: move_left + modifier: none + keycode: left + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: menuleft} + {send: left} + ] + } + } + { + name: move_right_or_take_history_hint + modifier: none + keycode: right + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: historyhintcomplete} + {send: menuright} + {send: right} + ] + } + } + { + name: move_one_word_left + modifier: control + keycode: left + mode: [emacs, vi_normal, vi_insert] + event: {edit: movewordleft} + } + { + name: move_one_word_right_or_take_history_hint + modifier: control + keycode: right + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: historyhintwordcomplete} + {edit: movewordright} + ] + } + } + { + name: move_to_line_start + modifier: none + keycode: home + mode: [emacs, vi_normal, vi_insert] + event: {edit: movetolinestart} + } + { + name: move_to_line_start + modifier: control + keycode: char_a + mode: [emacs, vi_normal, vi_insert] + event: {edit: movetolinestart} + } + { + name: move_to_line_end_or_take_history_hint + modifier: none + keycode: end + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: historyhintcomplete} + {edit: movetolineend} + ] + } + } + { + name: move_to_line_end_or_take_history_hint + modifier: control + keycode: char_e + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: historyhintcomplete} + {edit: movetolineend} + ] + } + } + { + name: move_to_line_start + modifier: control + keycode: home + mode: [emacs, vi_normal, vi_insert] + event: {edit: movetolinestart} + } + { + name: move_to_line_end + modifier: control + keycode: end + mode: [emacs, vi_normal, vi_insert] + event: {edit: movetolineend} + } + { + name: move_up + modifier: control + keycode: char_p + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: menuup} + {send: up} + ] + } + } + { + name: move_down + modifier: control + keycode: char_t + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: menudown} + {send: down} + ] + } + } + { + name: delete_one_character_backward + modifier: none + keycode: backspace + mode: [emacs, vi_insert] + event: {edit: backspace} + } + { + name: delete_one_word_backward + modifier: control + keycode: backspace + mode: [emacs, vi_insert] + event: {edit: backspaceword} + } + { + name: delete_one_character_forward + modifier: none + keycode: delete + mode: [emacs, vi_insert] + event: {edit: delete} + } + { + name: delete_one_character_forward + modifier: control + keycode: delete + mode: [emacs, vi_insert] + event: {edit: delete} + } + { + name: delete_one_character_forward + modifier: control + keycode: char_h + mode: [emacs, vi_insert] + event: {edit: backspace} + } + { + name: delete_one_word_backward + modifier: control + keycode: char_w + mode: [emacs, vi_insert] + event: {edit: backspaceword} + } + { + name: move_left + modifier: none + keycode: backspace + mode: vi_normal + event: {edit: moveleft} + } + { + name: newline_or_run_command + modifier: none + keycode: enter + mode: emacs + event: {send: enter} + } + { + name: move_left + modifier: control + keycode: char_b + mode: emacs + event: { + until: [ + {send: menuleft} + {send: left} + ] + } + } + { + name: move_right_or_take_history_hint + modifier: control + keycode: char_f + mode: emacs + event: { + until: [ + {send: historyhintcomplete} + {send: menuright} + {send: right} + ] + } + } + { + name: redo_change + modifier: control + keycode: char_g + mode: emacs + event: {edit: redo} + } + { + name: undo_change + modifier: control + keycode: char_z + mode: emacs + event: {edit: undo} + } + { + name: paste_before + modifier: control + keycode: char_y + mode: emacs + event: {edit: pastecutbufferbefore} + } + { + name: cut_word_left + modifier: control + keycode: char_w + mode: emacs + event: {edit: cutwordleft} + } + { + name: cut_line_to_end + modifier: control + keycode: char_k + mode: emacs + event: {edit: cuttoend} + } + { + name: cut_line_from_start + modifier: control + keycode: char_u + mode: emacs + event: {edit: cutfromstart} + } + { + name: swap_graphemes + modifier: control + keycode: char_t + mode: emacs + event: {edit: swapgraphemes} + } + { + name: move_one_word_left + modifier: alt + keycode: left + mode: emacs + event: {edit: movewordleft} + } + { + name: move_one_word_right_or_take_history_hint + modifier: alt + keycode: right + mode: emacs + event: { + until: [ + {send: historyhintwordcomplete} + {edit: movewordright} + ] + } + } + { + name: move_one_word_left + modifier: alt + keycode: char_b + mode: emacs + event: {edit: movewordleft} + } + { + name: move_one_word_right_or_take_history_hint + modifier: alt + keycode: char_f + mode: emacs + event: { + until: [ + {send: historyhintwordcomplete} + {edit: movewordright} + ] + } + } + { + name: delete_one_word_forward + modifier: alt + keycode: delete + mode: emacs + event: {edit: deleteword} + } + { + name: delete_one_word_backward + modifier: alt + keycode: backspace + mode: emacs + event: {edit: backspaceword} + } + { + name: delete_one_word_backward + modifier: alt + keycode: char_m + mode: emacs + event: {edit: backspaceword} + } + { + name: cut_word_to_right + modifier: alt + keycode: char_d + mode: emacs + event: {edit: cutwordright} + } + { + name: upper_case_word + modifier: alt + keycode: char_u + mode: emacs + event: {edit: uppercaseword} + } + { + name: lower_case_word + modifier: alt + keycode: char_l + mode: emacs + event: {edit: lowercaseword} + } + { + name: capitalize_char + modifier: alt + keycode: char_c + mode: emacs + event: {edit: capitalizechar} + } + { + name: copy_selection + modifier: control_shift + keycode: char_c + mode: emacs + event: { edit: copyselection } + } + { + name: cut_selection + modifier: control_shift + keycode: char_x + mode: emacs + event: { edit: cutselection } + } + { + name: select_all + modifier: control_shift + keycode: char_a + mode: emacs + event: { edit: selectall } + } + { + name: paste + modifier: control_shift + keycode: char_v + mode: emacs + event: { edit: pastecutbufferbefore } + } + ] +} + +alias please = sudo (history | last | get command) +alias la = ls -a +alias ll = ls -l +alias lla = ls -la +alias pyactivate = overlay use ./.venv/bin/activate +alias tmux = tmux -u +# converts all .doc and .docx files in the local directory to pdfs using libreoffice +alias doc2pdf = loffice --convert-to pdf --headless *.docx +#common options for sshfs +alias sshmnt = sshfs -o idmap=user,compression=no,reconnect,follow_symlinks,dir_cache=yes,ServerAliveInterval=15 + +# display a slideshow of all pics in a directory, recursively +def slideshow [delay: int = 10] { + feh --full-screen --randomize --auto-zoom --recursive --slideshow-delay $delay +} + +#look up something on cheat.sh +def cheat [query: string] { + curl $"cheat.sh/($query)" +} +#look up the weather +def wttr [ + location?: string + --format (-f): string +] { + http get $"https://wttr.in/($location)?format=($format)" +} + +# parses git log into a nushell table. +def --wrapped git-log [...rest] { + git log --pretty=%h»¦«%H»¦«%s»¦«%aN»¦«%aE»¦«%aD ...$rest | lines | split column "»¦«" commit full-commit subject name email date | upsert date {|d| $d.date | into datetime} +} + +# lists all the authors and how many commits they made in a histogram +def git-authors [] { + git-log --all | select name date | histogram name +} + +# source the conditional config file that contains +# all the definitions, aliases, and env vars we want to set conditionally. +const conditional_config = ($nu.temp-path | path join 'conditional-config.nu') +# open $conditional_config | print +source $conditional_config +rm $conditional_config diff --git a/terminal/nushell/env.nu b/terminal/nushell/env.nu new file mode 100644 index 0000000..b786819 --- /dev/null +++ b/terminal/nushell/env.nu @@ -0,0 +1,118 @@ +# Nushell Environment Config File +# +# version = "0.91.0" + +def create_left_prompt [] { + let dir = match (do --ignore-shell-errors { $env.PWD | path relative-to $nu.home-path }) { + null => $env.PWD + '' => '~' + $relative_pwd => ([~ $relative_pwd] | path join) + } + + let path_color = (if (is-admin) { ansi red_bold } else { ansi green_bold }) + let separator_color = (if (is-admin) { ansi light_red_bold } else { ansi light_green_bold }) + let path_segment = $"($path_color)($dir)" + + $path_segment | str replace --all (char path_sep) $"($separator_color)(char path_sep)($path_color)" +} + +def create_right_prompt [] { + # create a right prompt in magenta with green separators and am/pm underlined + let time_segment = ([ + (ansi reset) + (ansi magenta) + (date now | format date '%x %X') # try to respect user's locale + ] | str join | str replace --regex --all "([/:])" $"(ansi green)${1}(ansi magenta)" | + str replace --regex --all "([AP]M)" $"(ansi magenta_underline)${1}") + + let last_exit_code = if ($env.LAST_EXIT_CODE != 0) {([ + (ansi rb) + ($env.LAST_EXIT_CODE) + ] | str join) + } else { "" } + + ([$last_exit_code, (char space), $time_segment] | str join) +} + +# Use nushell functions to define your right and left prompt +$env.PROMPT_COMMAND = {|| create_left_prompt } +# FIXME: This default is not implemented in rust code as of 2023-09-08. +$env.PROMPT_COMMAND_RIGHT = {|| create_right_prompt } + +# The prompt indicators are environmental variables that represent +# the state of the prompt +$env.PROMPT_INDICATOR = {|| "> " } +$env.PROMPT_INDICATOR_VI_INSERT = {|| "> " } +$env.PROMPT_INDICATOR_VI_NORMAL = {|| ": " } +$env.PROMPT_MULTILINE_INDICATOR = {|| "::: " } + +# If you want previously entered commands to have a different prompt from the usual one, +# you can uncomment one or more of the following lines. +# This can be useful if you have a 2-line prompt and it's taking up a lot of space +# because every command entered takes up 2 lines instead of 1. You can then uncomment +# the line below so that previously entered commands show with a single `🚀`. +# $env.TRANSIENT_PROMPT_COMMAND = {||""} +# $env.TRANSIENT_PROMPT_INDICATOR = {|| "" } +# $env.TRANSIENT_PROMPT_INDICATOR_VI_INSERT = {|| "" } +# $env.TRANSIENT_PROMPT_INDICATOR_VI_NORMAL = {|| "" } +# $env.TRANSIENT_PROMPT_MULTILINE_INDICATOR = {|| "" } +# $env.TRANSIENT_PROMPT_COMMAND_RIGHT = {|| "" } + +# Specifies how environment variables are: +# - converted from a string to a value on Nushell startup (from_string) +# - converted from a value back to a string when running external commands (to_string) +# Note: The conversions happen *after* config.nu is loaded +$env.ENV_CONVERSIONS = { + "PATH": { + from_string: { |s| $s | split row (char esep) | path expand --no-symlink } + to_string: { |v| $v | path expand --no-symlink | str join (char esep) } + } + "Path": { + from_string: { |s| $s | split row (char esep) | path expand --no-symlink } + to_string: { |v| $v | path expand --no-symlink | str join (char esep) } + } +} + +# Directories to search for scripts when calling source or use +# The default for this is $nu.default-config-dir/scripts +$env.NU_LIB_DIRS = [ + ($nu.default-config-dir | path join 'scripts') # add /scripts +] + +# Directories to search for plugin binaries when calling register +# The default for this is $nu.default-config-dir/plugins +$env.NU_PLUGIN_DIRS = [ + ($nu.default-config-dir | path join 'plugins') # add /plugins +] + +def is-installed [ app: string ] { + ((which $app | length) > 0) +} + +const conditional_config = ($nu.temp-path | path join 'conditional-config.nu') +'# This file is an ugly hack to conditionally source files and define aliases/custom commands. +' | save --force $conditional_config + +# To add entries to PATH (on Windows you might use Path), you can use the following pattern: +# $env.PATH = ($env.PATH | split row (char esep) | prepend '/some/path') +# $env.PATH = ($env.PATH | split row (char esep) | append ($nu.home-path | path join ".local/bin/")) +# $env.PATH = ($env.PATH | split row (char esep) | append ($nu.home-path | path join ".cargo/bin/")) +# $env.PATH = ($env.PATH | split row (char esep) | append ($nu.home-path | path join "opt")) +# An alternate way to add entries to $env.PATH is to use the custom command `path add` +# which is built into the nushell stdlib: +use std "path add" +$env.PATH = ($env.PATH | split row (char esep)) +path add ($env.HOME | path join ".cargo " "bin") +path add ($env.HOME | path join ".local" "bin") +path add ($env.HOME | path join ".nix-profile" "bin") +path add ('/opt') +$env.PATH = ($env.PATH | uniq) + +$env.EDITOR = nvim +$env.VISUAL = nvim +$env.PIPENV_VENV_IN_PROJECT = 1 +$env.POETRY_VIRTUALENVS_IN_PROJECT = 1 +$env.SSH_AUTH_SOCK = $"($env.XDG_RUNTIME_DIR)/ssh-agent" + +ls (($nu.default-config-dir | path join ('scripts/**/*.nu')) | into glob) | +each { |it| $"source ($it.name)\n" | save --append $conditional_config} | ignore diff --git a/terminal/nushell/nushell.nix b/terminal/nushell/nushell.nix new file mode 100644 index 0000000..e3b6d7b --- /dev/null +++ b/terminal/nushell/nushell.nix @@ -0,0 +1,34 @@ +{ + config, + pkgs, + ... +}: { + #sessionVariables, sessionPath and shellAliases are not applied to nushell. + programs.nushell = { + enable = true; + configFile.source = ./config.nu; + envFile.source = ./env.nu; + }; + + home.file = { + ".config/nushell/scripts".source = ./scripts; + }; + + programs.yazi.enableNushellIntegration = true; + programs.zoxide.enableNushellIntegration = true; + programs.starship.enableNushellIntegration = true; + programs.carapace = { + enable = true; + enableNushellIntegration = true; + }; + programs.direnv.enableNushellIntegration = true; + + services.pueue = { + enable = true; + settings = { + daemon = { + default_parallel_tasks = 5; + }; + }; + }; +} diff --git a/terminal/nushell/scripts/cargo-completions.nu b/terminal/nushell/scripts/cargo-completions.nu new file mode 100644 index 0000000..9678030 --- /dev/null +++ b/terminal/nushell/scripts/cargo-completions.nu @@ -0,0 +1,586 @@ +## Written by lukexor, Improved by @Dan-Gamin + +def "nu-complete cargo targets" [type: string] { + ^cargo metadata --format-version=1 --offline --no-deps | from json | get packages.targets | flatten | where ($type in $it.kind) | get name +} +def "nu-complete cargo bins" [] { nu-complete cargo targets bin } +def "nu-complete cargo examples" [] { nu-complete cargo targets example } + +def "nu-complete cargo packages" [] { + let metadata = (^cargo metadata --format-version=1 --offline --no-deps) + if $metadata == '' { + [] + } else { + $metadata | from json | get workspace_members | split column ' ' | get column1 + } +} + +def "nu-complete cargo color" [] { + ['auto', 'always', 'never'] +} + +def "nu-complete cargo profiles" [] { + open Cargo.toml | get profile | transpose | get column0 +} + +def "nu-complete cargo features" [] { + open Cargo.toml | get features | transpose | get column0 +} + +# `cargo --list` is slow, `open` is faster. +# TODO: Add caching. +def "nu-complete cargo subcommands" [] { + ^cargo --list | lines | skip 1 | str join "\n" | from ssv --noheaders | get column1 +} +def "nu-complete cargo vcs" [] { + [ + 'git', + 'hg', + 'pijul', + 'fossil', + 'none' + ] +} + +#*> Core <*# + +# Disabled due to messing with undefined cargo-subcommands + +# # Rust's package manager +# export extern "cargo" [ +# --version(-V) # Print version info and exit +# --list # List installed commands +# --explain: number # Run `rustc --explain CODE` +# --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output +# --quiet(-q) # Do not print cargo log messages +# --color: string@"nu-complete cargo color" # Control when colored output is used +# --frozen # Require Cargo.lock and cache are up to date +# --locked # Require Cargo.lock is up to date +# --offline # Run without accessing the network +# --config: string # Override a configuration value +# -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details +# -h, --help # Print help information +# ...args: any +# ] + +#*> Common Commands (Sorted by order shown by running the `cargo` command) <*# + +# Compile the current package +export extern "cargo build" [ + --package(-p): string@"nu-complete cargo packages" # Build only the specified packages + --workspace # Build all members in the workspace + --exclude: string@"nu-complete cargo packages" # Exclude the specified packages + --lib # Build the package's library + --bin: string@"nu-complete cargo bins" # Build the specified binary + --bins # Build all binary targets + --example: string@"nu-complete cargo examples" # Build the specified example + --examples # Build all example targets + --test: string # Build the specified integration test + --tests # Build all targets in test mode that have the test = true manifest flag set + --bench: string # Build the specified benchmark + --benches # Build all targets in benchmark mode that have the bench = true manifest flag set + --all-targets # Build all targets + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features of all selected packages + --no-default-features # Do not activate the default feature of the selected packages + --target: string # Build for the given architecture. + --release(-r) # Build optimized artifacts with the release profile + --profile: string@"nu-complete cargo profiles" # Build with the given profile + --ignore-rust-version # Ignore `rust-version` specification in packages + --timings: string # Output information how long each compilation takes + --target-dir: path # Directory for all generated artifacts and intermediate files + --out-dir: path # Copy final artifacts to this directory + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --message-format: string # The output format for diagnostic messages + --build-plan # Outputs a series of JSON messages to stdout that indicate the commands to run the build + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information + --jobs(-j): number # Number of parallel jobs to run + --future-incompat-report # Displays a future-incompat report for any future-incompatible warnings +] + +# Check the current package +export extern "cargo check" [ + --package(-p): string@"nu-complete cargo packages" #Check only the specified packages + --workspace # Check all members in the workspace + --all # Alias for --workspace (deprecated) + --exclude: string@"nu-complete cargo packages" # Exclude the specified packages + --lib # Check the package's library + --bin: string@"nu-complete cargo bins" # Check the specified binary + --example: string@"nu-complete cargo examples" # Check the specified example + --examples # Check all example targets + --test: string # Check the specified integration test + --tests # Check all targets in test mode that have the test = true manifest flag set + --bench: string # Check the specified benchmark + --benches # Check all targets in benchmark mode that have the bench = true manifest flag set + --all-targets # Check all targets + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features + --no-default-features # Do not activate the `default` feature + --target: string # Check for the given architecture + --release(-r) # Check optimized artifacts with the release profile + --profile: string@"nu-complete cargo profiles" # Check with the given profile + --ignore-rust-version # Ignore `rust-version` specification in packages + --timings: string # Output information how long each compilation takes + --target-dir: path # Directory for all generated artifacts and intermediate files + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --message-format: string # The output format for diagnostic messages + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information + --jobs(-j): number # Number of parallel jobs to run + --keep-going # Build as many crates in the dependency graph as possible + --future-incompat-report # Displays a future-incompat report for any future-incompatible warnings +] + +# Remove the target directory +export extern "cargo clean" [ + --package(-p): string@"nu-complete cargo packages" # Clean only the specified packages + --doc # Remove only the doc directory in the target directory + --release # Remove all artifacts in the release directory + --profile # Remove all artifacts in the directory with the given profile name + --target-dir: path # Directory for all generated artifacts and intermediate files + --target: string # Clean for the given architecture + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --message-format: string # The output format for diagnostic messages + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information +] + +# Build a package's documentation +export extern "cargo doc" [ + --open # Open the docs in a browser after building them + --no-deps # Do not build documentation for dependencie + --document-private-items # Include non-public items in the documentation + --package(-p): string@"nu-complete cargo packages" # Document only the specified packages + --workspace # Document all members in the workspace + --exclude: string@"nu-complete cargo packages" # Exclude the specified packages + --lib: string # Document the package's library + --bin: string@"nu-complete cargo bins" # Document the specified binary + --bins # Document all binary targets + --example: string@"nu-complete cargo examples" # Document the specified example + --examples # Document all example targets + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features of all selected packages + --no-default-features # Do not activate the default feature of the selected packages + --target: string # Document for the given architecture + --release(-r) # Document optimized artifacts with the release profile + --profile: string@"nu-complete cargo profiles" # Document with the given profile + --ignore-rust-version # Ignore `rust-version` specification in packages + --timings: string # Output information how long each compilation takes + --target-dir: path # Directory for all generated artifacts and intermediate files + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --message-format: string # The output format for diagnostic messages + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information + --jobs(-j): number # Number of parallel jobs to run + --keep-going # Build as many crates in the dependency graph as possible +] + +# Create a new cargo package +export extern "cargo new" [ + path: path # The directory that will contain the project + --bin # Create a package with a binary target (src/main.rs) (default) + --lib # Create a package with a library target (src/lib.rs) + --edition: number # Specify the Rust edition to use (default: 2021) + --name: string # Set the package name. Defaults to the directory name. + --vcs: string@"nu-complete cargo vcs" # Initialize a new VCS repository for the given version control system + --registry: string # Name of the registry to use + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information +] + +# Create a new cargo package in an existing directory +export extern "cargo init" [ + path: path # The directory that will contain the project + --bin # Create a package with a binary target (src/main.rs) (default) + --lib # Create a package with a library target (src/lib.rs) + --edition: number # Specify the Rust edition to use (default: 2021) + --name: string # Set the package name. Defaults to the directory name. + --vcs: string@"nu-complete cargo vcs" # Initialize a new VCS repository for the given version control system + --registry: string # Name of the registry to use + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information +] + +# Run the current cargo package +export extern "cargo run" [ + ...args: any # Arguments to be passed to your program + --bin: string@"nu-complete cargo bins" # Name of the bin target to run + --example: string@"nu-complete cargo examples" # Name of the example target to run + --quiet(-q) # Do not print cargo log messages + --package(-p): string@"nu-complete cargo packages" # Package with the target to run + --jobs(-j): number # Number of parallel jobs, defaults to # of CPUs + --release # Build artifacts in release mode, with optimizations + --profile: string@"nu-complete cargo profiles" # Build artifacts with the specified profile + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features + --no-default-features # Do not activate the `default` feature + --target: string # Build for the target triple + --target-dir: path # Directory for all generated artifacts + --manifest-path: path # Path to Cargo.toml + --message-format: string # Error format + --unit-graph # Output build graph in JSON (unstable) + --ignore-rust-version # Ignore `rust-version` specification in packages + --verbose(-v) # Use verbose output (-vv very verbose/build.rs output) + --color: string@"nu-complete cargo color" # Control when colored output is used + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + --config: string # Override a configuration value (unstable) + -Z: string # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + --help(-h) # Prints help information +] + +# Run the tests +export extern "cargo test" [ + test_arg_separator?: string + ...args: any # Arguments to be passed to the tests + --no-run # Compile, but don't run tests + --no-fail-fast # Run all tests regardless of failure + --package(-p): string@"nu-complete cargo packages" # Test only the specified packages + --workspace # Test all members in the workspace + --exclude: string@"nu-complete cargo packages" # Exclude the specified packages + --lib # Test the package's library + --bin: string@"nu-complete cargo bins" # Test only the specified binary + --bins # Test all binaries + --example: string@"nu-complete cargo examples" # Test only the specified example + --examples # Test all examples + --test: string # Test the specified integration test + --tests # Test all targets in test mode that have the test = true manifest flag set + --bench: string # Test the specified benchmark + --benches # Test all targets in benchmark mode that have the bench = true manifest flag set + --all-targets # Test all targets + --doc # Test ONLY the library's documentation + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features of all selected packages + --no-default-features # Do not activate the default feature of the selected packages + --target: string # Test for the given architecture + --release(-r) # Test optimized artifacts with the release profile + --profile: string@"nu-complete cargo profiles" # Test with the given profile + --ignore-rust-version # Ignore `rust-version` specification in packages + --timings: string # Output information how long each compilation takes + --target-dir: path # Directory for all generated artifacts and intermediate files + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --message-format: string # The output format for diagnostic messages + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + --help(-h) # Prints help information + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + --jobs(-j): number # Number of parallel jobs to run + --keep-going # Build as many crates in the dependency graph as possible + --future-incompat-report # Displays a future-incompat report for any future-incompatible warnings +] + +# Execute benchmarks of a package +export extern "cargo bench" [ + bench_option_seperator?: string + ...options: any # Options to be passed to the benchmarks + --no-run # Compile, but don't run benchmarks + --no-fail-fast # Run all benchmarks regardless of failure + --package(-p): string@"nu-complete cargo packages" # Benchmark only the specified packages + --workspace # Benchmark all members in the workspace + --exclude: string@"nu-complete cargo packages" # Exclude the specified packages + --lib # Benchmark the package's library + --bin: string@"nu-complete cargo bins" # Benchmark only the specified binary + --bins # Benchmark all binary targets + --example: string@"nu-complete cargo examples" # Benchmark only the specified example + --examples # Benchmark all example targets + --test: string # Benchmark the specified integration test + --tests # Benchmark all targets in test mode that have the test = true + --bench: string # Benchmark the specified benchmark + --benches # Benchmark all targets in benchmark mode that have the bench = true manifest flag set + --all-targets # Benchmark all targets + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features of all selected packages + --no-default-features # Do not activate the default feature of the selected packages + --target: string # Benchmark for the given architecture + --profile: string@"nu-complete cargo profiles" # Build artifacts with the specified profile + --ignore-rust-version # Ignore `rust-version` specification in packages + --timings: string # Output information how long each compilation takes + --target-dir: path # Directory for all generated artifacts and intermediate files + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --message-format: string # The output format for diagnostic messages + --build-plan # Outputs a series of JSON messages to stdout that indicate the commands to run the build + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information + --jobs(-j): number # Number of parallel jobs to run + --keep-going # Build as many crates in the dependency graph as possible +] + +# Update dependencies listed in Cargo.lock +export extern "cargo update" [ + --package(-p): string@"nu-complete cargo packages" # Update only the specified packages + --aggressive # Dependencies of the specified packages are forced to update as well + --precise: any # Allows you to specify a specific version number to set the package to + --workspace(-w) # Attempt to update only packages defined in the workspace + --dry-run # Displays what would be updated but doesn't write the lockfile + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + --help(-h) # Prints help information + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details +] + +# Search packages in crates.io +export extern "cargo search" [ + query: string # The thing to search + --limit: number # Limit the number of results. (default: 10, max: 100) + --index: string # The URL of the registry index to use + --registry: string # Name of the registry to use + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --help(-h) # Prints help information + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details +] + +# Package and upload a package to the registry +export extern "cargo publish" [ + --dry-run # Perform all checks without uploading + --token: any # API token to use when authenticating + --no-verify # Don't verify the contents by building them + --allow-dirty # Allow working directories with uncommitted VCS changes to be packaged + --index: string # The URL of the registry index to use + --registry: string # Name of the registry to publish to + --package(-p): string@"nu-complete cargo packages" # The package to publish + --target: string # Publish for the given architecture + --target-dir: path # Directory for all generated artifacts and intermediate files + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features of all selected packages + --no-default-features # Do not activate the default feature of the selected packages + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + --help(-h) # Prints help information + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + --jobs(-j): number # Number of parallel jobs to run + --keep-going # Build as many crates in the dependency graph as possible +] + +# Build and install a Rust binary +export extern "cargo install" [ + crate?: string # The crate to install + --version: string # Specify a version to install + --vers: string # Specify a version to install + --git: string # Git URL to install the specified crate from + --branch: string # Branch to use when installing from git + --tag: string # Tag to use when installing from git + --rev: string # Specific commit to use when installing from git + --path: path # Filesystem path to local crate to install + --list # List all installed packages and their versions + --force(-f) # Force overwriting existing crates or binaries + --no-track # Don't keep track of this package + --bin: string@"nu-complete cargo bins" # Install only the specified binary + --bins # Install all binaries + --example: string@"nu-complete cargo examples" # Install only the specified example + --examples # Install all examples + --root: path # Directory to install packages into + --registry: string # Name of the registry to use + --index: string # The URL of the registry index to use + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features of all selected packages + --no-default-features # Do not activate the default feature of the selected packages + --target: string # Install for the given architecture + --target-dir: path # Directory for all generated artifacts and intermediate files + --debug # Build with the dev profile instead the release profile + --profile: string@"nu-complete cargo profiles" # Build artifacts with the specified profile + --timings: string # Output information how long each compilation takes + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + --jobs(-j): number # Number of parallel jobs to run + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --message-format: string # The output format for diagnostic messages + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information +] + +# Remove a Rust binary +export extern "cargo uninstall" [ + package?: string@"nu-complete cargo packages" # Package to uninstall + --package(-p): string@"nu-complete cargo packages" # Package to uninstall + --bin: string@"nu-complete cargo bins" # Only uninstall the binary name + --root: path # Directory to uninstall packages from + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information +] + +#*> Other Commands <*# + +# Output the resolved dependencies of a package in machine-readable format +export extern "cargo metadata" [ + --no-deps # Output information only about the workspace members and don't fetch dependencies + --format-version: number # Specify the version of the output format to use. Currently 1 is the only possible value + --filter-platform: string # This filters the resolve output to only include dependencies for the iven target triple + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features of all selected packages + --no-default-features # Do not activate the default feature of the selected packages + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + --help(-h) # Prints help information + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details +] + +# Get the help of the given cargo subcommand +export extern "cargo help" [ + subcommand: string@"nu-complete cargo subcommands" + --color: string@"nu-complete cargo color" # Control when colored output is used + --config: string # Override a configuration value + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details +] + +# A bunch of lints to catch common mistakes and improve your Rust code +export extern "cargo clippy" [ + --no-deps # Run Clippy only on the given crate, without linting the dependencies + --fix # Automatically apply lint suggestions. This flag implies `--no-deps + --version(-V) # Prints version information + --help(-h) # Prints help information + --warn(-W) # Set lint warnings + --allow(-A) # Set lint allowed + --deny(-D) # Set lint denied + --forbid(-F) # Set lint forbidden + --package(-p): string@"nu-complete cargo packages" #Check only the specified packages + --workspace # Check all members in the workspace + --all # Alias for --workspace (deprecated) + --exclude: string@"nu-complete cargo packages" # Exclude the specified packages + --lib # Check the package's library + --bin: string@"nu-complete cargo bins" # Check the specified binary + --example: string@"nu-complete cargo examples" # Check the specified example + --examples # Check all example targets + --test: string # Check the specified integration test + --tests # Check all targets in test mode that have the test = true manifest flag set + --bench: string # Check the specified benchmark + --benches # Check all targets in benchmark mode that have the bench = true manifest flag set + --all-targets # Check all targets + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features + --no-default-features # Do not activate the `default` feature + --target: string # Check for the given architecture + --release(-r) # Check optimized artifacts with the release profile + --profile: string@"nu-complete cargo profiles" # Check with the given profile + --ignore-rust-version # Ignore `rust-version` specification in packages + --timings: string # Output information how long each compilation takes + --target-dir: path # Directory for all generated artifacts and intermediate files + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --message-format: string # The output format for diagnostic messages + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information + --jobs(-j): number # Number of parallel jobs to run + --keep-going # Build as many crates in the dependency graph as possible + --future-incompat-report # Displays a future-incompat report for any future-incompatible warnings + -Z: any +] + +# Parameters from cargo update +export extern "cargo install-update" [ + --all(-a) # Update all packages + --allow-no-update(-i) # Allow for fresh-installing packages + --downdate(-d) # Downdate packages to match latest unyanked registry version + --force(-f) # Update all packages regardless if they need updating + --git(-g) # Also update git packages + --help(-h) # Prints help information + --list(-l) # Don't update packages, only list and check if they need an update (all packages by default) + --quiet(-q) # No output printed to stdout + --version(-V) # Prints version information + --cargo-dir(-c) # The cargo home directory. Default: $CARGO_HOME or $HOME/.cargo + --filter(-s) # Specify a filter a package must match to be considered + --install-cargo(-r) # Specify an alternative cargo to run for installations + --temp-dir(-t) # The temporary directory. Default: $TEMP/cargo-update +] + +# Parameters from cargo add +export extern "cargo add" [ + --no-default-features # Disable the default features + --default-features # Re-enable the default features + --features(-F) # Space or comma separated list of features to activate + --optional # Mark the dependency as optional + --verbose(-v) # Use verbose output (-vv very verbose/build.rs output) + --no-optional # Mark the dependency as required + --color: string@"nu-complete cargo color" # Coloring: auto, always, never + --rename # Rename the dependency + --locked # Require Cargo.lock is up to date + --package(-p) # Package to modify + --offline # Run without accessing the network + --quiet(-q) # Do not print cargo log messages + --config # Override a configuration value + --dry-run # Don't actually write the manifest + --help(-h) # Print help information + --path # Filesystem path to local crate to add + --git # Git repository location + --branch # Git branch to download the crate from + --tag # Git tag to download the crate from + --rev # Git reference to download the crate from + --registry # Package registry for this dependency + --dev # Add as development dependency + --build # Add as build dependency + --target # Add as dependency to the given target platform + ...args +] diff --git a/terminal/nushell/scripts/git-completions.nu b/terminal/nushell/scripts/git-completions.nu new file mode 100644 index 0000000..d884a4b --- /dev/null +++ b/terminal/nushell/scripts/git-completions.nu @@ -0,0 +1,493 @@ + +def "nu-complete git available upstream" [] { + ^git branch -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 | lines | each { |line| $line | str replace '* ' "" | str trim } +} + +# Yield remote branches like `origin/main`, `upstream/feature-a` +def "nu-complete git remote branches with prefix" [] { + ^git branch -r | lines | parse -r '^\*?(\s*|\s*\S* -> )(?P\S*$)' | get branch | uniq +} + +# Yield remote branches *without* prefix which do not have a local counterpart. +# E.g. `upstream/feature-a` as `feature-a` to checkout and track in one command +# with `git checkout` or `git switch`. +def "nu-complete git remote branches nonlocal without prefix" [] { +# Get regex to strip remotes prefixes. It will look like `(origin|upstream)` +# for the two remotes `origin` and `upstream`. + let remotes_regex = (["(", ((nu-complete git remotes | each {|r| [$r, '/'] | str join}) | str join "|"), ")"] | str join) + let local_branches = (nu-complete git local branches) + ^git branch -r | lines | parse -r (['^[\* ]+', $remotes_regex, '?(?P\S+)'] | flatten | str join) | get branch | uniq | where {|branch| $branch != "HEAD"} | where {|branch| $branch not-in $local_branches } +} + +def "nu-complete git switch" [] { + (nu-complete git local branches) + | parse "{value}" + | insert description "local branch" + | append (nu-complete git remote branches nonlocal without prefix + | parse "{value}" + | insert description "remote branch") +} + +def "nu-complete git checkout" [] { + (nu-complete git local branches) + | parse "{value}" + | insert description "local branch" + | append (nu-complete git remote branches nonlocal without prefix + | parse "{value}" + | insert description "remote branch") + | append (nu-complete git remote branches with prefix + | parse "{value}" + | insert description "remote branch") + | append (nu-complete git commits all) + | append (nu-complete git files | where description != "Untracked" | select value) +} + +# 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 | 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 switchable 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 switchable 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 +} + +# 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 +] + +# 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 dowloaded 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 # rebase current branch on top of upstream after fetching +] + +# 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 detatched 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 +] + +# 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 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) # specify the commit message rather than opening an editor + --no-edit # don't edit the commit message (useful with --amend) +] + +# 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) # 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 +] diff --git a/terminal/nushell/scripts/just-completions.nu b/terminal/nushell/scripts/just-completions.nu new file mode 100644 index 0000000..a3168ff --- /dev/null +++ b/terminal/nushell/scripts/just-completions.nu @@ -0,0 +1,44 @@ +def "nu-complete just recipes" [] { + ^just --unsorted --dump --dump-format json + | from json + | get recipes + | transpose k v + | each {|x| + { + value: $x.k, + description: ( $x.v.parameters + | each {|y| + if ($y.default|is-empty) { + $y.name + } else { + $'($y.name)="($y.default)"' + } + } + | str join ' ' + ) + } + } +} + +def "nu-complete just args" [context: string, offset: int] { + let r = ($context | split row ' ') + ^just -u --dump --dump-format json + | from json + | get recipes + | get ($r.1) + | get body + | each {|x| {description: ($x | get 0) }} + | prepend '' + +} + +export def just [ + recipes?: string@"nu-complete just recipes" + ...args: any@"nu-complete just args" +] { + if ($recipes | is-empty) { + ^just + } else { + ^just $recipes ...$args + } +} diff --git a/terminal/nushell/scripts/make-completions.nu b/terminal/nushell/scripts/make-completions.nu new file mode 100644 index 0000000..80fe259 --- /dev/null +++ b/terminal/nushell/scripts/make-completions.nu @@ -0,0 +1,65 @@ +def "nu-complete make" [] { + ls + | find --ignore-case makefile + | open $in.0.name + | lines + | find ':' + | where ($it | str starts-with '.') == false + | split column ' ' + | get column1 + | find ':' + | str replace ':' '' +} + +def "nu-complete make jobs" [] { + seq 1 (sys | get cpu | length) +} + +def "nu-complete make files" [] { + ls **/* | where type == file | get name +} + +def "nu-complete make dirs" [] { + ls **/* | where type == dir | get name +} + +export extern "make" [ + command?: string@"nu-complete make" + --always-make(-B) # Unconditionally make all targets. + --directory(-C): string@"nu-complete make dirs" # Change to DIRECTORY before doing anything. + --debug(-d) # Print various types of debugging information. + --environment-overrides(-e) # Environment variables override makefiles. + --eval(-E): string # Evaluate STRING as a makefile statement. + --file(-f) # Read FILE as a makefile. + --help(-h) # Print this message and exit. + --ignore-errors(-i) # Ignore errors from recipes. + --include-dir(-I): string@"nu-complete make dirs" # Search DIRECTORY for included makefiles. + --jobs(-j): int@"nu-complete make jobs" # Allow N jobs at once; infinite jobs with no arg. + --keep-going(-k) # Keep going when some targets can't be made. + --load-average(-l): int@"nu-complete make jobs" # Don't start multiple jobs unless load is below N. + --check-symlink-times(-L) # Use the latest mtime between symlinks and target. + --just-print(-n) # Don't actually run any recipe; just print them. + --dry-run + --recon + --assume-old: string@"nu-complete make files" # Consider FILE to be very old and don't remake it. + --old-file(-o): string@"nu-complete make files" + --output-sync(-O) # Synchronize output of parallel jobs by TYPE. + --print-data-base(-p) # Print make's internal database. + --question(-q) # Run no recipe; exit status says if up to date. + --no-builtin-rules(-r) # Disable the built-in implicit rules. + --no-builtin-variables(-R) # Disable the built-in variable settings. + --silent(-s) # Don't echo recipes. + --quiet + --no-silent # Echo recipes (disable --silent mode). + --stop(-S) # Turns off -k. + --no-keep-going + --touch(-t) # Touch targets instead of remaking them. + --trace # Print tracing information. + --version(-v) # Print the version number of make and exit. + --print-directory(-w) # Print the current directory. + --no-print-directory # Turn off -w, even if it was turned on implicitly. + --what-if(-W): string@"nu-complete make files" # Consider FILE to be infinitely new. + --new-file: string@"nu-complete make files" + --assume-new: string@"nu-complete make files" + --warn-undefined-variables # Warn when an undefined variable is referenced. +] diff --git a/terminal/nushell/scripts/ultimate_extractor.nu b/terminal/nushell/scripts/ultimate_extractor.nu new file mode 100644 index 0000000..7197309 --- /dev/null +++ b/terminal/nushell/scripts/ultimate_extractor.nu @@ -0,0 +1,27 @@ +# Function to extract archives with different extensions. +export def extract [name:string] { + let handlers = [ + [extension command]; + ['tar\.bz2|tbz|tbz2' 'tar xvjf'] + ['tar\.gz|tgz' 'tar xvzf'] + ['tar\.xz|txz' 'tar xvf'] + ['tar\.Z' 'tar xvZf'] + ['bz2' 'bunzip2'] + ['deb' 'ar x'] + ['gz' 'gunzip'] + ['pkg' 'pkgutil --expand'] + ['rar' 'unrar x'] + ['tar' 'tar xvf'] + ['xz' 'xz --decompress'] + ['zip|war|jar|nupkg' 'unzip'] + ['Z' 'uncompress'] + ['7z' '7za x'] + ] + let maybe_handler = ($handlers | where $name =~ $'\.(($it.extension))$') + if ($maybe_handler | is-empty) { + error make { msg: "unsupported file extension" } + } else { + let handler = ($maybe_handler | first) + nu -c ($handler.command + ' ' + $"'($name)'") + } +} diff --git a/terminal/nvim/cmp/cmp.nix b/terminal/nvim/cmp/cmp.nix new file mode 100644 index 0000000..01136d9 --- /dev/null +++ b/terminal/nvim/cmp/cmp.nix @@ -0,0 +1,70 @@ +{ + config, + pkgs, + lib, + ... +}: { + options = { + host.nvim.enable-completions = + (lib.mkEnableOption "basic completion in nvim") + // { + default = config.nvim.enable-treesitter || config.nvim.enable-lsp; + }; + }; + config = + lib.mkIf config.host.nvim.enable-completions + { + programs.nixvim = { + plugins.luasnip.enable = true; + plugins.friendly-snippets.enable = true; + plugins.cmp = { + enable = true; + autoEnableSources = true; + settings = { + sources = [ + {name = "luasnip";} + {name = "treesitter";} + {name = "path";} + {name = "emoji";} + {name = "buffer";} + {name = "latex_symbols";} + {name = "digraphs";} + {name = "spell";} + ]; + snippet = { + expand = "function(args) require('luasnip').lsp_expand(args.body) end"; + }; + mapping = { + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.close()"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.confirm({ select = false })"; + "" = '' + function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") + else + fallback() + end + end + ''; + "" = '' + function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") + else + fallback() + end + end + ''; + }; + }; + }; + }; + }; +} diff --git a/terminal/nvim/gitsigns.nix b/terminal/nvim/gitsigns.nix new file mode 100644 index 0000000..3f24cd6 --- /dev/null +++ b/terminal/nvim/gitsigns.nix @@ -0,0 +1,25 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + plugins.gitsigns = { + enable = true; + }; + plugins.which-key.registrations = { + "g" = "+git"; + }; + keymaps = [ + { + action = ":Gitsigns toggle_current_line_blame"; + key = "gb"; + mode = "n"; + options = { + silent = true; + desc = "toggle git blame"; + }; + } + ]; + }; +} diff --git a/terminal/nvim/keybinds.nix b/terminal/nvim/keybinds.nix new file mode 100644 index 0000000..f10067e --- /dev/null +++ b/terminal/nvim/keybinds.nix @@ -0,0 +1,97 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + globals = { + mapleader = ";"; + }; + plugins.which-key.registrations = { + "c" = "+check"; + }; + keymaps = [ + { + action = ":setlocal spell!"; + key = "cs"; + mode = "n"; + options = { + silent = true; + desc = "toggle spell check"; + }; + } + { + action = ":bnext"; + key = "gf"; + mode = "n"; + options = { + silent = true; + desc = "next buffer"; + }; + } + { + action = ":bprevious"; + key = "gF"; + mode = "n"; + options = { + silent = true; + desc = "prev buffer"; + }; + } + { + action = "h"; + key = ""; + mode = "n"; + options = { + silent = true; + desc = "move to right split"; + }; + } + { + action = "j"; + key = ""; + mode = "n"; + options = { + silent = true; + desc = "move to below split"; + }; + } + { + action = "k"; + key = ""; + mode = "n"; + options = { + silent = true; + desc = "move to above split"; + }; + } + { + action = "l"; + key = ""; + mode = "n"; + options = { + silent = true; + desc = "move to left split"; + }; + } + { + action = "za"; + key = ""; + mode = "n"; + options = { + silent = true; + desc = "toggle fold"; + }; + } + { + action = ":nohls"; + key = "h"; + mode = "n"; + options = { + silent = true; + desc = "clear highlighting"; + }; + } + ]; + }; +} diff --git a/terminal/nvim/lsp/lsp.nix b/terminal/nvim/lsp/lsp.nix new file mode 100644 index 0000000..29e8c0e --- /dev/null +++ b/terminal/nvim/lsp/lsp.nix @@ -0,0 +1,245 @@ +{ + config, + pkgs, + lib, + ... +}: { + options = { + host.nvim.enable-lsp = lib.mkEnableOption "nvim lsp"; + }; + + config = + lib.mkIf config.host.nvim.enable-lsp + { + host.nvim.enable-completions = true; + programs.nixvim = { + plugins.lsp = { + enable = true; + servers = { + bashls.enable = true; + clangd.enable = true; + lua-ls.enable = true; + nil_ls.enable = true; + nil_ls.settings.formatting.command = ["alejandra"]; + nushell.enable = true; + pyright.enable = true; + ruff-lsp.enable = true; + rust-analyzer = { + enable = true; + installCargo = true; + installRustc = true; + }; + texlab.enable = true; + typst-lsp.enable = true; + taplo.enable = true; + yamlls.enable = true; + marksman.enable = true; + jsonls.enable = true; + hls.enable = true; + }; + }; + plugins.cmp.settings.sources = [ + {name = "nvim_lsp";} + ]; + plugins.which-key.registrations = { + "l" = "+lsp"; + }; + keymaps = [ + { + action = "vim.lsp.buf.declaration"; + key = "lc"; + lua = true; + mode = "n"; + options = { + silent = true; + desc = "declaration"; + }; + } + { + action = "vim.lsp.buf.definition"; + key = "ld"; + lua = true; + mode = "n"; + options = { + silent = true; + desc = "definition"; + }; + } + { + action = "vim.lsp.buf.hover"; + key = "lh"; + lua = true; + mode = "n"; + options = { + silent = true; + desc = "hover"; + }; + } + { + action = "vim.lsp.buf.implementation"; + key = "li"; + lua = true; + mode = "n"; + options = { + silent = true; + desc = "implementation"; + }; + } + { + action = "vim.lsp.buf.signature_help"; + key = "ls"; + lua = true; + mode = "n"; + options = { + silent = true; + desc = "signature_help"; + }; + } + { + action = "vim.lsp.buf.add_workspace_folder"; + key = "lwa"; + lua = true; + mode = "n"; + options = { + silent = true; + desc = "add folder"; + }; + } + { + action = "vim.lsp.buf.remove_workspace_folder"; + key = "lwr"; + lua = true; + mode = "n"; + options = { + silent = true; + desc = "remove folder"; + }; + } + { + action = "vim.lsp.buf.list_workspace_folders"; + key = "lw"; + lua = true; + mode = "n"; + options = { + silent = true; + desc = "workspace"; + }; + } + { + action = "vim.lsp.buf.rename"; + key = "lr"; + lua = true; + mode = "n"; + options = { + silent = true; + desc = "rename"; + }; + } + { + action = "vim.lsp.buf.code_action"; + key = "la"; + lua = true; + mode = "n"; + options = { + silent = true; + desc = "code action"; + }; + } + { + action = "vim.lsp.buf.references"; + key = "le"; + lua = true; + mode = "n"; + options = { + silent = true; + desc = "list references"; + }; + } + { + action = "function() vim.lsp.buf.format{async=true} end"; + key = "lm"; + lua = true; + mode = "n"; + options = { + silent = true; + desc = "format buffer"; + }; + } + { + action = "vim.diagnostic.open_float"; + key = "lo"; + lua = true; + mode = "n"; + options = { + silent = true; + desc = "open float"; + }; + } + { + action = "vim.diagnostic.goto_next"; + key = "]d"; + lua = true; + mode = "n"; + options = { + silent = true; + desc = "next diagnostic"; + }; + } + { + action = "vim.diagnostic.goto_prev"; + key = "[d"; + lua = true; + mode = "n"; + options = { + silent = true; + desc = "prev diagnostic"; + }; + } + ]; + }; + home.file = { + ".clangd".text = '' + # keeps clangd from choking when it sees a compiler flag for a different + # compiler. (sutch as when acting as an lsp for a project that uses GCC.) + CompileFlags: + Add: -Wno-unknown-warning-option + Remove: [-m*, -f*] + ''; + ".clang-format".text = '' + --- + #this syncronizes with settings used by neovims treesitters so that the lsp formatting and treesitter formatting do not fight eatch other. + PointerAlignment: Left + ColumnLimit: 80 + IndentWidth: 4 + TabWidth: 4 + UseCRLF: false + UseTab: Never + AlignAfterOpenBracket: BlockIndent + AlwaysBreakBeforeMultilineStrings: true + BreakBeforeBraces: Attach + AlignOperands: Align + BreakBeforeBinaryOperators: NonAssignment + ... + ''; + "work/.clang-format".text = '' + --- + #this syncronizes with settings used by neovims treesitters so that the lsp formatting and treesitter formatting do not fight eatch other. + PointerAlignment: Left + ColumnLimit: 80 + IndentWidth: 4 + TabWidth: 4 + UseCRLF: false + UseTab: Never + AlignAfterOpenBracket: BlockIndent + AlwaysBreakBeforeMultilineStrings: true + BreakBeforeBraces: Allman + BreakBeforeBinaryOperators: None + ... + ''; + }; + home.packages = with pkgs; [ + alejandra + ]; + }; + imports = [./rust-tools.nix]; +} diff --git a/terminal/nvim/lsp/rust-tools.nix b/terminal/nvim/lsp/rust-tools.nix new file mode 100644 index 0000000..ed00790 --- /dev/null +++ b/terminal/nvim/lsp/rust-tools.nix @@ -0,0 +1,16 @@ +{ + config, + pkgs, + lib, + ... +}: { + config = + lib.mkIf config.host.nvim.enable-lsp + { + programs.nixvim = { + plugins.rust-tools = { + enable = true; + }; + }; + }; +} diff --git a/terminal/nvim/lualine.nix b/terminal/nvim/lualine.nix new file mode 100644 index 0000000..0a9eea1 --- /dev/null +++ b/terminal/nvim/lualine.nix @@ -0,0 +1,77 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + plugins.lualine = { + enable = true; + alwaysDivideMiddle = true; + iconsEnabled = true; + sections = { + lualine_a = [ + {name = "mode";} + ]; + lualine_b = [ + {name = "branch";} + {name = "diff";} + {name = "diagnostics";} + ]; + lualine_c = [ + { + name = "filename"; + extraConfig = {path = 1;}; + } + ]; + lualine_x = [ + {name = "encoding";} + {name = "fileformat";} + {name = "filetype";} + ]; + lualine_y = [ + {name = "progress";} + ]; + lualine_z = [ + {name = "location";} + ]; + }; + + inactiveSections = { + lualine_a = []; + lualine_b = []; + lualine_c = [{name = "filename";}]; + lualine_x = [{name = "filetype";}]; + lualine_y = []; + lualine_z = []; + }; + + tabline = { + lualine_a = [ + { + name = "buffers"; + extraConfig = {mode = 4;}; + } + ]; + lualine_b = []; + lualine_c = []; + lualine_x = []; + lualine_y = []; + lualine_z = [ + { + name = "tabs"; + extraConfig = {mode = 2;}; + } + ]; + }; + + winbar = { + lualine_a = []; + lualine_b = []; + lualine_c = []; + lualine_x = []; + lualine_y = []; + lualine_z = []; + }; + }; + }; +} diff --git a/terminal/nvim/nvim-tree.nix b/terminal/nvim/nvim-tree.nix new file mode 100644 index 0000000..16c60aa --- /dev/null +++ b/terminal/nvim/nvim-tree.nix @@ -0,0 +1,31 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + plugins.nvim-tree = { + enable = true; + disableNetrw = true; + hijackCursor = true; + hijackNetrw = true; + hijackUnnamedBufferWhenOpening = true; + actions = { + useSystemClipboard = true; + changeDir.enable = true; + }; + filesystemWatchers.enable = true; + }; + keymaps = [ + { + action = ":NvimTreeToggle"; + key = "t"; + mode = "n"; + options = { + silent = true; + desc = "toggle file browser"; + }; + } + ]; + }; +} diff --git a/terminal/nvim/nvim.nix b/terminal/nvim/nvim.nix new file mode 100644 index 0000000..750c7aa --- /dev/null +++ b/terminal/nvim/nvim.nix @@ -0,0 +1,34 @@ +{ + configs, + pkgs, + helpers, + lib, + ... +}: { + programs.nixvim = { + enable = true; + viAlias = true; + vimAlias = true; + + colorschemes.base16 = { + colorscheme = "gruvbox-dark-medium"; + enable = true; + }; + + clipboard.providers.xsel.enable = true; + }; + imports = [ + ./keybinds.nix + ./options.nix + ./simpleplugins.nix + ./lualine.nix + ./nvim-tree.nix + ./toggleterm.nix + ./gitsigns.nix + ./which-key.nix + ./telescope.nix + ./treesitter/treesitter.nix + ./cmp/cmp.nix + ./lsp/lsp.nix + ]; +} diff --git a/terminal/nvim/options.nix b/terminal/nvim/options.nix new file mode 100644 index 0000000..3ac7717 --- /dev/null +++ b/terminal/nvim/options.nix @@ -0,0 +1,70 @@ +{ + configs, + pkgs, + lib, + ... +}: { + programs.nixvim = { + options = { + mouse = "a"; + lazyredraw = true; + termguicolors = true; + autoread = true; + swapfile = false; + history = 500; + formatoptions = "rojq"; + # dont hard wrap + textwidth = 0; + wrapmargin = 0; + breakindent = true; + # highlight after col + colorcolumn = "80,100,120"; + # add ruler to side of screen + number = true; + numberwidth = 3; + #display cursor cordinates + ruler = true; + #always leave 5 cells between cursor and side of window + scrolloff = 5; + # better command line completion + wildmenu = true; + # ignore case if all lowercase + ignorecase = true; + smartcase = true; + # show unfinished keycombos in statusbar + showcmd = true; + # regex stuff + magic = true; + # always show statusline + laststatus = 2; + # tab stuff + tabstop = 4; + shiftwidth = 0; + autoindent = true; + smartindent = true; + smarttab = true; + # for true tabs, change to false + expandtab = true; + softtabstop = -1; + # highlight search results as you type + hlsearch = true; + incsearch = true; + # folding stuff + foldlevelstart = 5; + foldmethod = lib.mkDefault "indent"; + foldcolumn = "auto:4"; + foldenable = true; + # display whitespace as other chars + list = true; + listchars = { + tab = ">-"; + eol = "↲"; + nbsp = "␣"; + trail = "•"; + extends = "⟩"; + precedes = "⟨"; + }; + showbreak = "↪"; + }; + }; +} diff --git a/terminal/nvim/simpleplugins.nix b/terminal/nvim/simpleplugins.nix new file mode 100644 index 0000000..7103301 --- /dev/null +++ b/terminal/nvim/simpleplugins.nix @@ -0,0 +1,21 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + plugins.comment-nvim.enable = true; + plugins.marks.enable = true; + plugins.surround.enable = true; + plugins.todo-comments.enable = true; + plugins.leap = { + enable = true; + addDefaultMappings = true; + }; + extraPlugins = with pkgs.vimPlugins; [ + vim-numbertoggle + dressing-nvim + ]; + extraConfigLua = ''require("dressing").setup({})''; + }; +} diff --git a/terminal/nvim/spell/en.utf-8.add b/terminal/nvim/spell/en.utf-8.add new file mode 100644 index 0000000..3827808 --- /dev/null +++ b/terminal/nvim/spell/en.utf-8.add @@ -0,0 +1,52 @@ +asciidoc +ASCIISite +asciidoctor +ASCIIsite +asciiDoc +nextcloud +filesystem +zsh +backend +Incrementals +incrementals +Ransomware +ransomware +hypervisor +offsite +FTL +superintelligent +homeworld +toolchain +Kata +ctl +NDSU +rebasing +posix +tmux +keybinds +dotfile +dotfiles +ctrl +sed +NGINX +timezones +Proxmox +Gabe +Venberg +Github +dotfiles +config +nvim +neovim +config +Syncthing +homelab +microcontrollers +nushell +datatypes +datetimes +filesizes +filetypes +datastructures +footguns +csv diff --git a/terminal/nvim/telescope.nix b/terminal/nvim/telescope.nix new file mode 100644 index 0000000..ffda359 --- /dev/null +++ b/terminal/nvim/telescope.nix @@ -0,0 +1,116 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + plugins.telescope = { + enable = true; + }; + plugins.which-key.registrations = { + "f" = "+telescope"; + "fg" = "+telescope git"; + }; + keymaps = [ + { + action = ":Telescope find_files"; + key = "ff"; + mode = "n"; + options = { + silent = true; + desc = "files"; + }; + } + { + action = ":Telescope live_grep"; + key = "fg"; + mode = "n"; + options = { + silent = true; + desc = "grep"; + }; + } + { + action = ":Telescope buffers"; + key = "fb"; + mode = "n"; + options = { + silent = true; + desc = "buffers"; + }; + } + { + action = ":Telescope marks"; + key = "fm"; + mode = "n"; + options = { + silent = true; + desc = "marks"; + }; + } + { + action = ":Telescope registers"; + key = "fr"; + mode = "n"; + options = { + silent = true; + desc = "registers"; + }; + } + { + action = ":Telescope keymaps"; + key = "fk"; + mode = "n"; + options = { + silent = true; + desc = "keymaps"; + }; + } + { + action = ":Telescope current_buffer_fuzzy_find"; + key = "fz"; + mode = "n"; + options = { + silent = true; + desc = "fuzzy find"; + }; + } + { + action = ":Telescope git_commits"; + key = "fgc"; + mode = "n"; + options = { + silent = true; + desc = "commits"; + }; + } + { + action = ":Telescope git_branches"; + key = "fgb"; + mode = "n"; + options = { + silent = true; + desc = "branches"; + }; + } + { + action = ":Telescope git_stash"; + key = "fgs"; + mode = "n"; + options = { + silent = true; + desc = "stash"; + }; + } + { + action = ":Telescope git_commits"; + key = "fgc"; + mode = "n"; + options = { + silent = true; + desc = "commits"; + }; + } + ]; + }; +} diff --git a/terminal/nvim/toggleterm.nix b/terminal/nvim/toggleterm.nix new file mode 100644 index 0000000..7f75e5e --- /dev/null +++ b/terminal/nvim/toggleterm.nix @@ -0,0 +1,32 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + plugins.toggleterm = { + enable = true; + direction = "horizontal"; + insertMappings = false; + }; + keymaps = [ + { + action = "function() Floatingterm:toggle() end"; + key = "s"; + lua = true; + mode = "n"; + options = { + silent = true; + desc = "toggle scratch terminal"; + }; + } + ]; + extraConfigLuaPre = '' + local Terminal = require('toggleterm.terminal').Terminal + Floatingterm = Terminal:new({ + hidden = true, + direction = "float" + }) + ''; + }; +} diff --git a/terminal/nvim/treesitter/arial.nix b/terminal/nvim/treesitter/arial.nix new file mode 100644 index 0000000..3f7cc00 --- /dev/null +++ b/terminal/nvim/treesitter/arial.nix @@ -0,0 +1,28 @@ +{ + config, + pkgs, + lib, + ... +}: { + config = + lib.mkIf config.host.nvim.enable-treesitter + { + programs.nixvim = { + keymaps = [ + { + action = ":AerialToggle!"; + key = "o"; + mode = "n"; + options = { + silent = true; + desc = "toggle outline"; + }; + } + ]; + extraPlugins = with pkgs.vimPlugins; [ + aerial-nvim + ]; + extraConfigLua = ''require("aerial").setup({})''; + }; + }; +} diff --git a/terminal/nvim/treesitter/rainbow-delimiters.nix b/terminal/nvim/treesitter/rainbow-delimiters.nix new file mode 100644 index 0000000..3b1ec38 --- /dev/null +++ b/terminal/nvim/treesitter/rainbow-delimiters.nix @@ -0,0 +1,25 @@ +{ + config, + pkgs, + lib, + ... +}: { + config = + lib.mkIf config.host.nvim.enable-treesitter + { + programs.nixvim = { + plugins.rainbow-delimiters = { + enable = true; + highlight = [ + "RainbowDelimiterYellow" + "RainbowDelimiterBlue" + "RainbowDelimiterOrange" + "RainbowDelimiterGreen" + "RainbowDelimiterViolet" + "RainbowDelimiterCyan" + # "RainbowDelimiterRed" + ]; + }; + }; + }; +} diff --git a/terminal/nvim/treesitter/treesitter.nix b/terminal/nvim/treesitter/treesitter.nix new file mode 100644 index 0000000..b585be8 --- /dev/null +++ b/terminal/nvim/treesitter/treesitter.nix @@ -0,0 +1,39 @@ +{ + config, + pkgs, + lib, + ... +}: { + options = { + host.nvim.enable-treesitter = lib.mkOption { + default = false; + type = lib.types.bool; + description = '' + enable nvim treesitter + ''; + }; + }; + config = + lib.mkIf config.host.nvim.enable-treesitter + { + host.nvim.enable-completions = true; + programs.nixvim = { + plugins.treesitter = { + enable = true; + folding = true; + indent = true; + nixvimInjections = true; + }; + plugins.treesitter-context.enable = true; + plugins.indent-blankline.enable = true; + extraPlugins = with pkgs.vimPlugins; [ + treesj + ]; + extraConfigLua = ''require("treesj").setup({})''; + }; + }; + imports = [ + ./rainbow-delimiters.nix + ./arial.nix + ]; +} diff --git a/terminal/nvim/which-key.nix b/terminal/nvim/which-key.nix new file mode 100644 index 0000000..e8886b8 --- /dev/null +++ b/terminal/nvim/which-key.nix @@ -0,0 +1,15 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + options = { + timeout = true; + timeoutlen = 300; + }; + plugins.which-key = { + enable = true; + }; + }; +} diff --git a/terminal/starship.nix b/terminal/starship.nix new file mode 100644 index 0000000..36e71e8 --- /dev/null +++ b/terminal/starship.nix @@ -0,0 +1,109 @@ +{ + config, + pkgs, + lib, + ... +}: { + programs.starship = { + enable = true; + settings = { + format = lib.concatStrings [ + "[](color_orange)" + "$shell" + "$username" + "[@](bg:color_orange)" + "$hostname" + "[ ](bg:color_orange)" + "[](bg:color_yellow fg:color_orange)" + "$directory" + "[](fg:color_yellow bg:color_aqua)" + "$git_branch" + "$git_status" + "[](fg:color_aqua bg:color_blue)" + "$git_metrics" + "[](fg:color_blue bg:color_bg3)" + "$git_commit" + "$fill" + "[](fg:color_bg1 bg:color_bg3)" + "$time" + "[ ](fg:color_bg1)" + "$line_break" + "$character" + ]; + add_newline = false; + palette = "gruvbox_dark"; + palettes.gruvbox_dark = { + color_fg0 = "#fbf1c7"; + color_bg1 = "#3c3836"; + color_bg3 = "#665c54"; + color_blue = "#458588"; + color_aqua = "#689d6a"; + color_green = "#98971a"; + color_orange = "#d65d0e"; + color_purple = "#b16286"; + color_red = "#cc241d"; + color_yellow = "#d79921"; + }; + hostname = { + ssh_only = false; + format = "[$ssh_symbol$hostname]($style)"; + style = "bg:color_orange"; + }; + shell = { + disabled = false; + bash_indicator = "$"; + fish_indicator = "<><"; + zsh_indicator = "%"; + nu_indicator = ">"; + format = "[$indicator ]($style)"; + style = "bg:color_orange"; + }; + fill = { + symbol = " "; + style = "bg:color_bg3"; + }; + username = { + show_always = true; + style_user = "bg:color_orange fg:color_fg0"; + style_root = "bg:color_orange fg:color_fg0"; + format = "[$user]($style)"; + }; + directory = { + style = "fg:color_fg0 bg:color_yellow"; + format = "[ $path ]($style)"; + fish_style_pwd_dir_length = 3; + truncation_length = 4; + truncation_symbol = "…/"; + }; + git_branch = { + symbol = ""; + style = "bg:color_aqua"; + format = "[[ $symbol $branch ](fg:color_fg0 bg:color_aqua)]($style)"; + }; + git_status = { + style = "bg:color_aqua"; + format = "[[($all_status$ahead_behind )](fg:color_fg0 bg:color_aqua)]($style)"; + }; + git_metrics = { + disabled = false; + added_style = "bg:color_blue fg:bold green"; + deleted_style = "bg:color_blue fg:bold red"; + format = "([ +$added ]($added_style))([-$deleted ]($deleted_style))"; + }; + git_commit = { + only_detached = false; + tag_disabled = false; + format = "[($hash$tag)]($style)"; + style = "bg:color_bg3"; + }; + time = { + disabled = false; + time_format = "%R"; + style = "bg:color_bg1"; + format = "[[  $time ](fg:color_fg0 bg:color_bg1)]($style)"; + }; + line_break.disabled = false; + character.disabled = false; + }; + }; +} diff --git a/terminal/voice.nix b/terminal/voice.nix new file mode 100644 index 0000000..add8366 --- /dev/null +++ b/terminal/voice.nix @@ -0,0 +1,30 @@ +{ + config, + pkgs, + lib, + ... +}: { + options = { + host.enable-speech = lib.mkOption { + default = false; + type = lib.types.bool; + description = '' + install a text to speech engine + ''; + }; + }; + + config = + lib.mkIf config.host.enable-speech + { + home.shellAliases = { + say = "espeak -p 10 -s 150 -a 200"; + }; + home.packages = with pkgs; [ + espeak + ]; + programs.nushell.extraConfig = '' + alias say = espeak -p 10 -s 150 -a 200 + ''; + }; +} diff --git a/terminal/zellij/config.kdl b/terminal/zellij/config.kdl new file mode 100644 index 0000000..2175a5d --- /dev/null +++ b/terminal/zellij/config.kdl @@ -0,0 +1,352 @@ +// If you'd like to override the default keybindings completely, be sure to change "keybinds" to "keybinds clear-defaults=true" +keybinds clear-defaults=true{ + normal { + // uncomment this and adjust key if using copy_on_select=false + // bind "Alt c" { Copy; } + } + locked { + bind "Alt g" { SwitchToMode "Normal"; } + } + resize { + bind "Alt r" { SwitchToMode "Normal"; } + bind "h" "Left" { Resize "Increase Left"; } + bind "j" "Down" { Resize "Increase Down"; } + bind "k" "Up" { Resize "Increase Up"; } + bind "l" "Right" { Resize "Increase Right"; } + bind "H" { Resize "Decrease Left"; } + bind "J" { Resize "Decrease Down"; } + bind "K" { Resize "Decrease Up"; } + bind "L" { Resize "Decrease Right"; } + bind "=" "+" { Resize "Increase"; } + bind "-" { Resize "Decrease"; } + } + pane { + bind "Alt p" { SwitchToMode "Normal"; } + bind "h" "Left" { MoveFocus "Left"; } + bind "l" "Right" { MoveFocus "Right"; } + bind "j" "Down" { MoveFocus "Down"; } + bind "k" "Up" { MoveFocus "Up"; } + bind "p" { SwitchFocus; } + bind "n" { NewPane; SwitchToMode "Normal"; } + bind "d" { NewPane "Down"; SwitchToMode "Normal"; } + bind "r" { NewPane "Right"; SwitchToMode "Normal"; } + bind "x" { CloseFocus; SwitchToMode "Normal"; } + bind "f" { ToggleFocusFullscreen; SwitchToMode "Normal"; } + bind "z" { TogglePaneFrames; SwitchToMode "Normal"; } + bind "w" { ToggleFloatingPanes; SwitchToMode "Normal"; } + bind "e" { TogglePaneEmbedOrFloating; SwitchToMode "Normal"; } + bind "c" { SwitchToMode "RenamePane"; PaneNameInput 0;} + } + move { + bind "Alt m" { SwitchToMode "Normal"; } + bind "n" "Tab" { MovePane; } + bind "p" { MovePaneBackwards; } + bind "h" "Left" { MovePane "Left"; } + bind "j" "Down" { MovePane "Down"; } + bind "k" "Up" { MovePane "Up"; } + bind "l" "Right" { MovePane "Right"; } + } + tab { + bind "Alt t" { SwitchToMode "Normal"; } + bind "r" { SwitchToMode "RenameTab"; TabNameInput 0; } + bind "h" "Left" "Up" "k" { GoToPreviousTab; } + bind "l" "Right" "Down" "j" { GoToNextTab; } + bind "n" { NewTab; SwitchToMode "Normal"; } + bind "x" { CloseTab; SwitchToMode "Normal"; } + bind "s" { ToggleActiveSyncTab; SwitchToMode "Normal"; } + bind "b" { BreakPane; SwitchToMode "Normal"; } + bind "]" { BreakPaneRight; SwitchToMode "Normal"; } + bind "[" { BreakPaneLeft; SwitchToMode "Normal"; } + bind "1" { GoToTab 1; SwitchToMode "Normal"; } + bind "2" { GoToTab 2; SwitchToMode "Normal"; } + bind "3" { GoToTab 3; SwitchToMode "Normal"; } + bind "4" { GoToTab 4; SwitchToMode "Normal"; } + bind "5" { GoToTab 5; SwitchToMode "Normal"; } + bind "6" { GoToTab 6; SwitchToMode "Normal"; } + bind "7" { GoToTab 7; SwitchToMode "Normal"; } + bind "8" { GoToTab 8; SwitchToMode "Normal"; } + bind "9" { GoToTab 9; SwitchToMode "Normal"; } + bind "Tab" { ToggleTab; } + } + scroll { + bind "Alt s" { SwitchToMode "Normal"; } + bind "e" { EditScrollback; SwitchToMode "Normal"; } + bind "s" { SwitchToMode "EnterSearch"; SearchInput 0; } + bind "Ctrl c" { ScrollToBottom; SwitchToMode "Normal"; } + bind "j" "Down" { ScrollDown; } + bind "k" "Up" { ScrollUp; } + bind "Ctrl f" "PageDown" "Right" "l" { PageScrollDown; } + bind "Ctrl b" "PageUp" "Left" "h" { PageScrollUp; } + bind "d" { HalfPageScrollDown; } + bind "u" { HalfPageScrollUp; } + // uncomment this and adjust key if using copy_on_select=false + // bind "Alt c" { Copy; } + } + search { + bind "Alt s" { SwitchToMode "Normal"; } + bind "Ctrl c" { ScrollToBottom; SwitchToMode "Normal"; } + bind "j" "Down" { ScrollDown; } + bind "k" "Up" { ScrollUp; } + bind "Ctrl f" "PageDown" "Right" "l" { PageScrollDown; } + bind "Ctrl b" "PageUp" "Left" "h" { PageScrollUp; } + bind "d" { HalfPageScrollDown; } + bind "u" { HalfPageScrollUp; } + bind "n" { Search "down"; } + bind "p" { Search "up"; } + bind "c" { SearchToggleOption "CaseSensitivity"; } + bind "w" { SearchToggleOption "Wrap"; } + bind "o" { SearchToggleOption "WholeWord"; } + } + entersearch { + bind "Ctrl c" "Esc" { SwitchToMode "Scroll"; } + bind "Enter" { SwitchToMode "Search"; } + } + renametab { + bind "Ctrl c" { SwitchToMode "Normal"; } + bind "Esc" { UndoRenameTab; SwitchToMode "Tab"; } + } + renamepane { + bind "Ctrl c" { SwitchToMode "Normal"; } + bind "Esc" { UndoRenamePane; SwitchToMode "Pane"; } + } + session { + bind "Alt o" { SwitchToMode "Normal"; } + bind "Alt s" { SwitchToMode "Scroll"; } + bind "d" { Detach; } + bind "w" { + LaunchOrFocusPlugin "zellij:session-manager" { + floating true + move_to_focused_tab true + }; + SwitchToMode "Normal" + } + } + tmux { + bind "[" { SwitchToMode "Scroll"; } + bind "Alt a" { Write 2; SwitchToMode "Normal"; } + bind "\"" { NewPane "Down"; SwitchToMode "Normal"; } + bind "%" { NewPane "Right"; SwitchToMode "Normal"; } + bind "z" { ToggleFocusFullscreen; SwitchToMode "Normal"; } + bind "c" { NewTab; SwitchToMode "Normal"; } + bind "," { SwitchToMode "RenameTab"; } + bind "p" { GoToPreviousTab; SwitchToMode "Normal"; } + bind "n" { GoToNextTab; SwitchToMode "Normal"; } + bind "Left" { MoveFocus "Left"; SwitchToMode "Normal"; } + bind "Right" { MoveFocus "Right"; SwitchToMode "Normal"; } + bind "Down" { MoveFocus "Down"; SwitchToMode "Normal"; } + bind "Up" { MoveFocus "Up"; SwitchToMode "Normal"; } + bind "h" { MoveFocus "Left"; SwitchToMode "Normal"; } + bind "l" { MoveFocus "Right"; SwitchToMode "Normal"; } + bind "j" { MoveFocus "Down"; SwitchToMode "Normal"; } + bind "k" { MoveFocus "Up"; SwitchToMode "Normal"; } + bind "o" { FocusNextPane; } + bind "d" { Detach; } + bind "Space" { NextSwapLayout; } + bind "x" { CloseFocus; SwitchToMode "Normal"; } + } + shared_except "locked" { + bind "Alt g" { SwitchToMode "Locked"; } + bind "Alt q" { Quit; } + bind "Alt n" { NewPane; } + bind "Alt h" "Alt Left" { MoveFocusOrTab "Left"; } + bind "Alt l" "Alt Right" { MoveFocusOrTab "Right"; } + bind "Alt j" "Alt Down" { MoveFocus "Down"; } + bind "Alt k" "Alt Up" { MoveFocus "Up"; } + bind "Alt =" "Alt +" { Resize "Increase"; } + bind "Alt -" { Resize "Decrease"; } + bind "Alt [" { PreviousSwapLayout; } + bind "Alt ]" { NextSwapLayout; } + } + shared_except "normal" "locked" { + bind "Enter" "Esc" { SwitchToMode "Normal"; } + } + shared_except "pane" "locked" { + bind "Alt p" { SwitchToMode "Pane"; } + } + shared_except "resize" "locked" { + bind "Alt r" { SwitchToMode "Resize"; } + } + shared_except "scroll" "locked" { + bind "Alt s" { SwitchToMode "Scroll"; } + } + shared_except "session" "locked" { + bind "Alt o" { SwitchToMode "Session"; } + } + shared_except "tab" "locked" { + bind "Alt t" { SwitchToMode "Tab"; } + } + shared_except "move" "locked" { + bind "Alt m" { SwitchToMode "Move"; } + } + shared_except "tmux" "locked" { + bind "Alt b" { SwitchToMode "Tmux"; } + } +} + +plugins { + tab-bar { path "tab-bar"; } + status-bar { path "status-bar"; } + strider { path "strider"; } + compact-bar { path "compact-bar"; } + session-manager { path "session-manager"; } +} + +// Choose what to do when zellij receives SIGTERM, SIGINT, SIGQUIT or SIGHUP +// eg. when terminal window with an active zellij session is closed +// Options: +// - detach (Default) +// - quit +// +// on_force_close "detach" + +// Send a request for a simplified ui (without arrow fonts) to plugins +// Options: +// - true +// - false (Default) +// +// simplified_ui false + +// Choose the path to the default shell that zellij will use for opening new panes +// Default: $SHELL +// +// default_shell "fish" + +// Choose the path to override cwd that zellij will use for opening new panes +// +// default_cwd "" + +// Toggle between having pane frames around the panes +// Options: +// - true (default) +// - false +// +// pane_frames true + +// Toggle between having Zellij lay out panes according to a predefined set of layouts whenever possible +// Options: +// - true (default) +// - false +// +// auto_layout true + +// Whether sessions should be serialized to the cache folder (including their tabs/panes, cwds and running commands) so that they can later be resurrected +// Options: +// - true (default) +// - false +// +// session_serialization false + +// Whether pane viewports are serialized along with the session, default is false +// Options: +// - true +// - false (default) +// serialize_pane_viewport true + +// Scrollback lines to serialize along with the pane viewport when serializing sessions, 0 +// defaults to the scrollback size. If this number is higher than the scrollback size, it will +// also default to the scrollback size. This does nothing if `serialize_pane_viewport` is not true. +// +// scrollback_lines_to_serialize 10000 + +// Define color themes for Zellij +// For more examples, see: https://github.com/zellij-org/zellij/tree/main/example/themes +// Once these themes are defined, one of them should to be selected in the "theme" section of this file +// +themes { + // example of how to set a theme in HEX format + gruvbox-dark { + fg "#D5C4A1" + bg "#282828" + black "#3C3836" + red "#CC241D" + green "#98971A" + yellow "#D79921" + blue "#3C8588" + magenta "#B16286" + cyan "#689D6A" + white "#FBF1C7" + orange "#D65D0E" + } +} + +// Choose the theme that is specified in the themes section. +// Default: default +// +theme "gruvbox-dark" + +// The name of the default layout to load on startup +// Default: "default" +// +// default_layout "compact" + +// Choose the mode that zellij uses when starting up. +// Default: normal +// +// default_mode "locked" + +// Toggle enabling the mouse mode. +// On certain configurations, or terminals this could +// potentially interfere with copying text. +// Options: +// - true (default) +// - false +// +// mouse_mode false + +// Configure the scroll back buffer size +// This is the number of lines zellij stores for each pane in the scroll back +// buffer. Excess number of lines are discarded in a FIFO fashion. +// Valid values: positive integers +// Default value: 10000 +// +// scroll_buffer_size 10000 + +// Provide a command to execute when copying text. The text will be piped to +// the stdin of the program to perform the copy. This can be used with +// terminal emulators which do not support the OSC 52 ANSI control sequence +// that will be used by default if this option is not set. +// Examples: +// +// copy_command "xclip -selection clipboard" // x11 +// copy_command "wl-copy" // wayland +// copy_command "pbcopy" // osx + +// Choose the destination for copied text +// Allows using the primary selection buffer (on x11/wayland) instead of the system clipboard. +// Does not apply when using copy_command. +// Options: +// - system (default) +// - primary +// +// copy_clipboard "primary" + +// Enable or disable automatic copy (and clear) of selection when releasing mouse +// Default: true +// +// copy_on_select false + +// Path to the default editor to use to edit pane scrollbuffer +// Default: $EDITOR or $VISUAL +// +// scrollback_editor "/usr/bin/vim" + +// When attaching to an existing session with other users, +// should the session be mirrored (true) +// or should each user have their own cursor (false) +// Default: false +// +// mirror_session true + +// The folder in which Zellij will look for layouts +// +// layout_dir "/path/to/my/layout_dir" + +// The folder in which Zellij will look for themes +// +// theme_dir "/path/to/my/theme_dir" + +// Enable or disable the rendering of styled and colored underlines (undercurl). +// May need to be disabled for certain unsupported terminals +// Default: true +// +// styled_underlines false diff --git a/terminal/zellij/zellij.nix b/terminal/zellij/zellij.nix new file mode 100644 index 0000000..fea7536 --- /dev/null +++ b/terminal/zellij/zellij.nix @@ -0,0 +1,10 @@ +{ + config, + pkgs, + ... +}: { + programs.zellij.enable = true; + home.file = { + ".config/zellij/config.kdl".source = ./config.kdl; + }; +} diff --git a/terminal/zsh.nix b/terminal/zsh.nix new file mode 100644 index 0000000..366a12d --- /dev/null +++ b/terminal/zsh.nix @@ -0,0 +1,40 @@ +{ + config, + pkgs, + ... +}: { + programs.starship.enableZshIntegration = true; + programs.fzf.enableZshIntegration = true; + programs.zoxide.enableZshIntegration = true; + programs.yazi.enableZshIntegration = true; + programs.carapace.enableZshIntegration = true; + programs.direnv.enableZshIntegration=true; + programs.zsh = { + enable = true; + enableCompletion = true; + autocd = true; + history = { + ignoreAllDups = true; + extended = true; + }; + shellAliases = { + ll = "ls -lh"; + la = "-lha"; + please = "sudo $(fc -ln -1)"; + slideshow = "feh --full-screen --randomize --auto-zoom --recursive --slideshow-delay"; + pyactivate = "source ./.venv/bin/activate"; + }; + syntaxHighlighting = { + enable = true; + highlighters = [ + "main" + "brackets" + "pattern" + "regexp" + "cursor" + "root" + "line" + ]; + }; + }; +}