mirror of
https://github.com/youwen5/liminalOS.git
synced 2025-06-20 05:59:51 -07:00
fix: nushell completions
This commit is contained in:
parent
11a7673570
commit
775fc350f7
2 changed files with 55 additions and 39 deletions
|
@ -1,12 +1,13 @@
|
||||||
let fish_completer = {|spans|
|
let fish_completer = {|spans|
|
||||||
fish --command $'complete "--do-complete=($spans | str join " ")"'
|
fish --command $'complete --escape "--do-complete=($spans | str join " ")"'
|
||||||
| from tsv --flexible --noheaders --no-infer
|
| $"value(char tab)description(char newline)" + $in
|
||||||
| rename value description
|
| from tsv --flexible --no-infer
|
||||||
| update value {
|
| each {|i|
|
||||||
if ($in | path exists) {$'"($in | str replace "\"" "\\\"" )"'} else {$in}
|
if '\' in $i.value {
|
||||||
|
$i | merge {'value': $"\"($i.value | str replace -a '\' '')\""}
|
||||||
|
} else {$i}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# This completer will use fish by default
|
# This completer will use fish by default
|
||||||
let external_completer = {|spans|
|
let external_completer = {|spans|
|
||||||
let expanded_alias = scope aliases
|
let expanded_alias = scope aliases
|
||||||
|
@ -28,20 +29,3 @@ let external_completer = {|spans|
|
||||||
}
|
}
|
||||||
|
|
||||||
$env.config.completions.external.completer = $external_completer
|
$env.config.completions.external.completer = $external_completer
|
||||||
|
|
||||||
def "nu-complete zoxide path" [context: string] {
|
|
||||||
let parts = $context | split row " " | skip 1
|
|
||||||
{
|
|
||||||
options: {
|
|
||||||
sort: false
|
|
||||||
completion_algorithm: prefix
|
|
||||||
positional: false
|
|
||||||
case_sensitive: false
|
|
||||||
}
|
|
||||||
completions: (zoxide query --list --exclude $env.PWD -- ...$parts | lines)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def --env --wrapped z [...rest: string@"nu-complete zoxide path"] {
|
|
||||||
__zoxide_z ...$rest
|
|
||||||
}
|
|
||||||
|
|
|
@ -27,24 +27,55 @@ in
|
||||||
|
|
||||||
programs.bash.enable = true;
|
programs.bash.enable = true;
|
||||||
|
|
||||||
programs.nushell = {
|
programs.nushell =
|
||||||
enable = true;
|
let
|
||||||
configFile.source = ./config.nu;
|
zoxideInit = pkgs.stdenvNoCC.mkDerivation {
|
||||||
settings = {
|
inherit (pkgs.zoxide) version;
|
||||||
show_banner = false;
|
pname = "zoxide-init";
|
||||||
completions.external = {
|
nativeBuildInputs = [ pkgs.zoxide ];
|
||||||
enable = true;
|
phases = [ "installPhase" ];
|
||||||
max_results = 200;
|
installPhase = ''
|
||||||
|
zoxide init nushell >> $out
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
edit_mode = "vi";
|
in
|
||||||
cursor_shape = {
|
{
|
||||||
emacs = "line";
|
enable = true;
|
||||||
vi_insert = "line";
|
configFile.source = ./config.nu;
|
||||||
vi_normal = "block";
|
settings = {
|
||||||
|
show_banner = false;
|
||||||
|
completions.external = {
|
||||||
|
enable = true;
|
||||||
|
max_results = 200;
|
||||||
|
};
|
||||||
|
edit_mode = "vi";
|
||||||
|
cursor_shape = {
|
||||||
|
emacs = "line";
|
||||||
|
vi_insert = "line";
|
||||||
|
vi_normal = "block";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
extraConfig = lib.mkIf config.programs.zoxide.enable ''
|
||||||
|
source "${zoxideInit}"
|
||||||
|
def "nu-complete zoxide path" [context: string] {
|
||||||
|
let parts = $context | split row " " | skip 1
|
||||||
|
{
|
||||||
|
options: {
|
||||||
|
sort: false
|
||||||
|
completion_algorithm: prefix
|
||||||
|
positional: false
|
||||||
|
case_sensitive: false
|
||||||
|
}
|
||||||
|
completions: (zoxide query --list --exclude $env.PWD -- ...$parts | lines)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def --env --wrapped z [...rest: string@"nu-complete zoxide path"] {
|
||||||
|
__zoxide_z ...$rest
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
plugins = with pkgs.nushellPlugins; [ polars ];
|
||||||
};
|
};
|
||||||
plugins = with pkgs.nushellPlugins; [ polars ];
|
|
||||||
};
|
|
||||||
|
|
||||||
programs.fzf = {
|
programs.fzf = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
@ -89,7 +120,8 @@ in
|
||||||
enable = true;
|
enable = true;
|
||||||
# we have our own fish completion plugin for zoxide
|
# we have our own fish completion plugin for zoxide
|
||||||
enableFishIntegration = false;
|
enableFishIntegration = false;
|
||||||
enableNushellIntegration = true;
|
# we have our own nushell completion plugin for zoxide
|
||||||
|
enableNushellIntegration = false;
|
||||||
enableBashIntegration = true;
|
enableBashIntegration = true;
|
||||||
package =
|
package =
|
||||||
if
|
if
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue