diff --git a/modules/common/nushell/config.nu b/modules/common/nushell/config.nu index 12e774b..9db9601 100644 --- a/modules/common/nushell/config.nu +++ b/modules/common/nushell/config.nu @@ -3,6 +3,9 @@ use std null_device source ~/.config/nushell/zoxide.nu +$env.CARAPACE_BRIDGES = "inshellisense,zsh,fish,bash" +source ~/.config/nushell/carapace.nu + # Retrieve the output of the last command. def _ []: nothing -> any { $env.last? @@ -54,29 +57,6 @@ $env.config.completions.case_sensitive = false $env.config.completions.quick = true $env.config.completions.partial = true $env.config.completions.use_ls_colors = true -$env.config.completions.external.enable = true -$env.config.completions.external.max_results = 100 -$env.config.completions.external.completer = {|tokens: list| - let expanded = scope aliases - | where name == $tokens.0 - | get --ignore-errors 0.expansion - - mut tokens = if $expanded != null and $tokens.0 != "cd" { - $expanded | split row " " | append ($tokens | skip 1) - } else { - $tokens - } - - $tokens.0 = $tokens.0 | str trim --left --char "^" - - let command = $tokens - | str join " " - | str replace --all (char single_quote) $"\\(char single_quote)" - - fish --command $"complete '--do-complete=($command)'" - | $"value(char tab)description(char newline)" + $in - | from tsv --flexible --no-infer -} $env.config.use_kitty_protocol = true @@ -303,6 +283,7 @@ let menus = [ layout: ide border: false correct_cursor_pos: true + max_completion_height: 25 } style: { text: white diff --git a/modules/common/nushell/default.nix b/modules/common/nushell/default.nix index a010db5..06cc79d 100644 --- a/modules/common/nushell/default.nix +++ b/modules/common/nushell/default.nix @@ -1,5 +1,5 @@ { config, lib, pkgs, ... }: let - inherit (lib) attrValues const disabled enabled getExe mapAttrs mkIf optionalAttrs readFile removeAttrs replaceString; + inherit (lib) attrValues const enabled getExe mapAttrs mkIf optionalAttrs readFile removeAttrs replaceString; in { environment = optionalAttrs config.isLinux { sessionVariables.SHELLS = getExe pkgs.nushell; @@ -8,6 +8,7 @@ in { shellAliases = { la = "ls --all"; + ll = "ls --long"; lla = "ls --long --all"; sl = "ls"; @@ -22,8 +23,12 @@ in { systemPackages = attrValues { inherit (pkgs) - fish # For completions. - zoxide # For completions and better cd. + carapace # For completions. + fish # For completions. + zsh # For completions. + inshellisense # For completions. + + zoxide # For better cd. ; }; }; @@ -32,6 +37,10 @@ in { homeConfig = homeArgs.config; in { xdg.configFile = { + "nushell/carapace.nu".source = pkgs.runCommand "carapace.nu" {} '' + ${getExe pkgs.carapace} _carapace nushell > $out + ''; + "nushell/zoxide.nu".source = pkgs.runCommand "zoxide.nu" {} '' ${getExe pkgs.zoxide} init nushell --cmd cd > $out ''; @@ -74,7 +83,6 @@ in { shellAliases = removeAttrs config.environment.shellAliases [ "ls" "l" ] // { cdtmp = "cd (mktemp --directory)"; - ll = "ls --long"; }; }; })];