1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-28 18:47:44 +00:00

nushell: make completions way better

This commit is contained in:
RGBCube 2025-07-17 01:00:03 +03:00
parent 1761d20fa4
commit 08571d7fff
Signed by: RGBCube
SSH key fingerprint: SHA256:CzqbPcfwt+GxFYNnFVCqoN5Itn4YFrshg1TrnACpA5M
2 changed files with 16 additions and 27 deletions

View file

@ -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<string>|
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

View file

@ -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";
};
};
})];