1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-31 12:07:48 +00:00

Compare commits

...

4 commits

Author SHA1 Message Date
e3096645a8
nushell: fix jc completer 2025-07-18 22:57:40 +03:00
fd49444afe
nushell: make jc wrapper better 2025-07-18 22:33:45 +03:00
9da7ad1439
nushell: uncap ide suggestion width 2025-07-18 21:17:59 +03:00
a8cec1de3c
nushell: add jc 2025-07-18 21:06:53 +03:00
2 changed files with 71 additions and 2 deletions

View file

@ -24,6 +24,65 @@ def --env mcg [path: path]: nothing -> nothing {
jj git init --colocate
}
def --env "nu-complete jc" [] {
if $env.__NU_COMPLETE_JC? != null {
return $env.__NU_COMPLETE_JC
}
let options = try {
let options = ^jc --help
| collect
| parse "{_}Parsers:\n{_}\n\nOptions:\n{inherent}\n\nSlice:{_}"
| get 0
let parsers = ^jc --about
| from json
| get parsers
| select argument description
| rename value description
let inherent = $options.inherent
| lines
| parse " {short}, {long} {description}"
| update description { str trim }
| each {|record|
[[value, description];
[$record.short, $record.description],
[$record.long, $record.description]]
}
| flatten
$parsers ++ $inherent
} catch {
[]
}
$env.__NU_COMPLETE_JC = $options
$options
}
# Run `jc` (JSON Converter).
def --wrapped jc [...arguments: string@"nu-complete jc"]: [any -> table, any -> record, any -> string] {
let run = ^jc ...$arguments | complete
if $run.exit_code != 0 {
error make {
msg: "jc exection failed"
label: {
text: ($run.stderr | str replace "jc:" "" | str replace "Error -" "" | str trim)
span: (metadata $arguments).span
}
}
}
if "--help" in $arguments or "-h" in $arguments {
$run.stdout
} else {
$run.stdout | from json
}
}
# `nu-highlight` with default colors
#
# Custom themes can produce a lot more ansi color codes and make the output
@ -295,9 +354,18 @@ let menus = [
marker: $env.PROMPT_INDICATOR
type: {
layout: ide
border: false
correct_cursor_pos: true
min_completion_width: 0
max_completion_width: 150
max_completion_height: 25
padding: 0
border: false
cursor_offset: 0
description_mode: "prefer_right"
min_description_width: 0
max_description_width: 50
max_description_height: 10
description_offset: 1
correct_cursor_pos: true
}
style: {
text: white

View file

@ -14,6 +14,7 @@ in {
fastfetch
fd
hyperfine
jc
moreutils
openssl
p7zip