From 72110796fad4fbda866fcef093632a2083141b3d Mon Sep 17 00:00:00 2001 From: RGBCube Date: Wed, 7 Feb 2024 08:53:21 +0300 Subject: [PATCH] Expand alises when calling fish completer --- BROKEN.md | 38 ---------------------------- modules/nix.nix | 10 +++----- modules/nushell/configuration.nix.nu | 14 ++++++++-- 3 files changed, 16 insertions(+), 46 deletions(-) diff --git a/BROKEN.md b/BROKEN.md index c4084a9..c5abbd0 100644 --- a/BROKEN.md +++ b/BROKEN.md @@ -9,41 +9,3 @@ - Nushell custom prompt title does not work, as it gets overriden by the shell integration in a split second. - -- Nix Super errors, saying it expected an attrset and got a - trunk when evaluating the non-outputs section. This should - work, as it is an advertised feature (And it does! Don't get - me wrong, it works if you don't use the builtins namespace) - but doesn't work completely. Max is working on a fix, so I've - put the soon-to-be attributes here, so I don't forget. - - ```nix - nixConfig = with builtins; mapAttrs (name: concatStringsSep " ") { - extra-substituters = [ - "https://nix-community.cachix.org/" - "https://hyprland.cachix.org/" - "https://cache.privatevoid.net/" - ]; - - extra-trusted-public-keys = [ - "nix-community.cachix.org:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - "hyprland.cachix.org:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" - "cache.privatevoid.net:SErQ8bvNWANeAvtsOESUwVYr2VJynfuc9JRwlzTTkVg=" - ]; - }; - - inputs = with builtins; mapAttrs (name: url: { - url = "git+https://${url}"; - } // (if elem name [ "nixSuper" "hyprland" "hyprpicker" ] then {} else { - inputs.nixpkgs.follows = "nixpkgs"; - })) { - nixSuper = "github.com/privatevoid-net/nix-super"; - nixpkgs = "github.com/NixOS/nixpkgs/tree/nixos-unstable"; - homeManager = "github.com/nix-community/home-manager"; - hyprland = "github.com/hyprwm/Hyprland"; - hyprpicker = "github.com/hyprwm/hyprpicker"; - fenix = "github.com/nix-community/fenix"; - tools = "github.com/RGBCube/FlakeTools"; - themes = "github.com/RGBCube/ThemeNix"; - }; - ``` diff --git a/modules/nix.nix b/modules/nix.nix index 6bb930e..bc207b2 100644 --- a/modules/nix.nix +++ b/modules/nix.nix @@ -15,12 +15,10 @@ systemConfiguration { package = upkgs.nixSuper; - registry = (lib.filterAttrs - (_: value: value != {}) - (builtins.mapAttrs - (_: value: lib.optionalAttrs (value ? sourceInfo) { - flake = value; - }) inputs)) // { default.flake = inputs.nixpkgs; }; + registry = (builtins.mapAttrs + (_: value: lib.mkIf (value ? sourceInfo) { + flake = value; + }) inputs) // { default.flake = inputs.nixpkgs; }; settings.experimental-features = [ "auto-allocate-uids" diff --git a/modules/nushell/configuration.nix.nu b/modules/nushell/configuration.nix.nu index 1e2d386..eba52cb 100644 --- a/modules/nushell/configuration.nix.nu +++ b/modules/nushell/configuration.nix.nu @@ -129,7 +129,7 @@ $env.config.history = { } $env.config.completions = { - algorithm: fuzzy + algorithm: prefix case_sensitive: false partial: true quick: true @@ -137,7 +137,17 @@ $env.config.completions = { enable: true max_results: 100 completer: {|tokens: list| - fish --command $'complete (char sq)--do-complete=($tokens | str join " ")(char sq)' + mut expanded = scope aliases | where name == $tokens.0 | get --ignore-errors expansion.0 + + mut expanded = if $expanded != null { + $expanded | split row " " | append ($tokens | skip 1) + } else { + $tokens + } + + $expanded.0 = ($expanded.0 | str trim --left --char "^") + + fish --command $'complete (char sq)--do-complete=($expanded | str join " ")(char sq)' | $"value(char tab)description(char newline)" + $in | from tsv --flexible --no-infer }