nushell: Set up external completion using fish
This commit is contained in:
@ -174,11 +174,22 @@ let light_theme = {
|
||||
shape_vardecl: purple
|
||||
}
|
||||
|
||||
# External completer example
|
||||
# let carapace_completer = {|spans|
|
||||
# carapace $spans.0 nushell $spans | from json
|
||||
# }
|
||||
# Use fish for external completion
|
||||
let fish_completer = {|spans|
|
||||
# if the current command is an alias, get it's expansion
|
||||
let expanded_alias = (scope aliases | where name == $spans.0 | get -i 0 | get -i expansion)
|
||||
|
||||
# overwrite
|
||||
let spans = (if $expanded_alias != null {
|
||||
# put the first word of the expanded alias first in the span
|
||||
$spans | skip 1 | prepend ($expanded_alias | split row " " | take 1)
|
||||
} else { $spans })
|
||||
|
||||
|
||||
fish --command $'complete "--do-complete=($spans | str join " ")"'
|
||||
| $"value(char tab)description(char newline)" + $in
|
||||
| from tsv --flexible --no-infer
|
||||
}
|
||||
|
||||
$env.config = {
|
||||
show_banner: false
|
||||
@ -259,7 +270,7 @@ $env.config = {
|
||||
external: {
|
||||
enable: true # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up may be very slow
|
||||
max_results: 100 # setting it lower can improve completion performance at the cost of omitting some options
|
||||
completer: null # check 'carapace_completer' above as an example
|
||||
completer: $fish_completer
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user