1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tools/vcomplete: add fish auto completion support (#6917)

This commit is contained in:
Larpon 2020-11-23 13:53:32 +01:00 committed by GitHub
parent 2f9b7fe0f7
commit c7ca1e7e13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,22 +9,25 @@
// auto-completion features. // auto-completion features.
// //
// # bash // # bash
// To install auto-completion for V in bash, simply add this code to your ~/.bashrc: // To install auto-completion for V in bash, simply add this code to your `~/.bashrc`:
// `source /dev/stdin <<<"$(v complete setup bash)"` // `source /dev/stdin <<<"$(v complete setup bash)"`
// On more recent versions of bash (>3.2) this should suffice: // On more recent versions of bash (>3.2) this should suffice:
// `source <(v complete setup bash)` // `source <(v complete setup bash)`
// //
// # fish // TODO // # fish
// For versions of fish <3.0.0, add the following to your `~/.config/fish/config.fish`
// `v complete setup fish | source`
// Later versions of fish source completions by default.
// //
// # zsh // # zsh
// To install auto-completion for V in zsh - please add the following to your ~/.zshrc: // To install auto-completion for V in zsh - please add the following to your `~/.zshrc`:
// ``` // ```
// autoload -Uz compinit // autoload -Uz compinit
// compinit // compinit
// # Completion for v // # Completion for v
// v complete setup zsh | source /dev/stdin // v complete setup zsh | source /dev/stdin
// ``` // ```
// # It's important is to make sure the call to v to load the zsh completions happens after the call to compinit // Please note that you should let v load the zsh completions after the call to compinit
// //
// # powershell //TODO // # powershell //TODO
// //
@ -224,7 +227,13 @@ _v_completions() {
complete -o nospace -F _v_completions v complete -o nospace -F _v_completions v
' } ' }
// 'fish' {} //TODO see https://github.com/kovidgoyal/kitty/blob/75a94bcd96f74be024eb0a28de87ca9e15c4c995/kitty/complete.py#L113 'fish' { setup = '
function __v_completions
# Send all words up to the one before the cursor
$vexe complete fish (commandline -cop)
end
complete -f -c v -a "(__v_completions)"
' }
'zsh' { setup = ' 'zsh' { setup = '
#compdef v #compdef v
_v() { _v() {
@ -254,7 +263,17 @@ compdef _v v
} }
println(lines.join('\n')) println(lines.join('\n'))
} }
// 'fish' {} //TODO 'fish' {
if sub_args.len <= 1 {
exit(0)
}
mut lines := []string{}
list := auto_complete_request(sub_args[1..])
for entry in list {
lines << '$entry'
}
println(lines.join('\n'))
}
'zsh' { 'zsh' {
if sub_args.len <= 1 { if sub_args.len <= 1 {
exit(0) exit(0)