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:
parent
1761d20fa4
commit
08571d7fff
2 changed files with 16 additions and 27 deletions
|
@ -3,6 +3,9 @@ use std null_device
|
||||||
|
|
||||||
source ~/.config/nushell/zoxide.nu
|
source ~/.config/nushell/zoxide.nu
|
||||||
|
|
||||||
|
$env.CARAPACE_BRIDGES = "inshellisense,zsh,fish,bash"
|
||||||
|
source ~/.config/nushell/carapace.nu
|
||||||
|
|
||||||
# Retrieve the output of the last command.
|
# Retrieve the output of the last command.
|
||||||
def _ []: nothing -> any {
|
def _ []: nothing -> any {
|
||||||
$env.last?
|
$env.last?
|
||||||
|
@ -54,29 +57,6 @@ $env.config.completions.case_sensitive = false
|
||||||
$env.config.completions.quick = true
|
$env.config.completions.quick = true
|
||||||
$env.config.completions.partial = true
|
$env.config.completions.partial = true
|
||||||
$env.config.completions.use_ls_colors = 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
|
$env.config.use_kitty_protocol = true
|
||||||
|
|
||||||
|
@ -303,6 +283,7 @@ let menus = [
|
||||||
layout: ide
|
layout: ide
|
||||||
border: false
|
border: false
|
||||||
correct_cursor_pos: true
|
correct_cursor_pos: true
|
||||||
|
max_completion_height: 25
|
||||||
}
|
}
|
||||||
style: {
|
style: {
|
||||||
text: white
|
text: white
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{ config, lib, pkgs, ... }: let
|
{ 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 {
|
in {
|
||||||
environment = optionalAttrs config.isLinux {
|
environment = optionalAttrs config.isLinux {
|
||||||
sessionVariables.SHELLS = getExe pkgs.nushell;
|
sessionVariables.SHELLS = getExe pkgs.nushell;
|
||||||
|
@ -8,6 +8,7 @@ in {
|
||||||
|
|
||||||
shellAliases = {
|
shellAliases = {
|
||||||
la = "ls --all";
|
la = "ls --all";
|
||||||
|
ll = "ls --long";
|
||||||
lla = "ls --long --all";
|
lla = "ls --long --all";
|
||||||
sl = "ls";
|
sl = "ls";
|
||||||
|
|
||||||
|
@ -22,8 +23,12 @@ in {
|
||||||
|
|
||||||
systemPackages = attrValues {
|
systemPackages = attrValues {
|
||||||
inherit (pkgs)
|
inherit (pkgs)
|
||||||
fish # For completions.
|
carapace # For completions.
|
||||||
zoxide # For completions and better cd.
|
fish # For completions.
|
||||||
|
zsh # For completions.
|
||||||
|
inshellisense # For completions.
|
||||||
|
|
||||||
|
zoxide # For better cd.
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -32,6 +37,10 @@ in {
|
||||||
homeConfig = homeArgs.config;
|
homeConfig = homeArgs.config;
|
||||||
in {
|
in {
|
||||||
xdg.configFile = {
|
xdg.configFile = {
|
||||||
|
"nushell/carapace.nu".source = pkgs.runCommand "carapace.nu" {} ''
|
||||||
|
${getExe pkgs.carapace} _carapace nushell > $out
|
||||||
|
'';
|
||||||
|
|
||||||
"nushell/zoxide.nu".source = pkgs.runCommand "zoxide.nu" {} ''
|
"nushell/zoxide.nu".source = pkgs.runCommand "zoxide.nu" {} ''
|
||||||
${getExe pkgs.zoxide} init nushell --cmd cd > $out
|
${getExe pkgs.zoxide} init nushell --cmd cd > $out
|
||||||
'';
|
'';
|
||||||
|
@ -74,7 +83,6 @@ in {
|
||||||
|
|
||||||
shellAliases = removeAttrs config.environment.shellAliases [ "ls" "l" ] // {
|
shellAliases = removeAttrs config.environment.shellAliases [ "ls" "l" ] // {
|
||||||
cdtmp = "cd (mktemp --directory)";
|
cdtmp = "cd (mktemp --directory)";
|
||||||
ll = "ls --long";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
})];
|
})];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue