-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add shell completion * Add shell completion to release
- Loading branch information
Showing
4 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
# Bash completion script for Helix editor | ||
|
||
_hx() { | ||
# $1 command name | ||
# $2 word being completed | ||
# $3 word preceding | ||
COMPREPLY=() | ||
|
||
case "$3" in | ||
-g | --grammar) | ||
COMPREPLY=($(compgen -W "fetch build" -- $2)) | ||
;; | ||
--health) | ||
local languages=$(hx --health |tail -n '+7' |awk '{print $1}' |sed 's/\x1b\[[0-9;]*m//g') | ||
COMPREPLY=($(compgen -W "$languages" -- $2)) | ||
;; | ||
*) | ||
COMPREPLY=($(compgen -fd -W "-h --help --tutor -V --version -v -vv -vvv --health -g --grammar" -- $2)) | ||
;; | ||
esac | ||
} && complete -F _hx hx | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env fish | ||
# Fish completion script for Helix editor | ||
|
||
set -l langs (hx --health |tail -n '+7' |awk '{print $1}' |sed 's/\x1b\[[0-9;]*m//g') | ||
|
||
complete -c hx -s h -l help -d "Prints help information" | ||
complete -c hx -l tutor -d "Loads the tutorial" | ||
complete -c hx -l health -x -a "$langs" -d "Checks for errors in editor setup" | ||
complete -c hx -s g -l grammar -x -a "fetch build" -d "Fetches or builds tree-sitter grammars" | ||
complete -c hx -s v -o vv -o vvv -d "Increases logging verbosity" | ||
complete -c hx -s V -l version -d "Prints version information" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#compdef _hx hx | ||
# Zsh completion script for Helix editor | ||
|
||
_hx() { | ||
_arguments -C \ | ||
"-h[Prints help information]" \ | ||
"--help[Prints help information]" \ | ||
"-v[Increase logging verbosity]" \ | ||
"-vv[Increase logging verbosity]" \ | ||
"-vvv[Increase logging verbosity]" \ | ||
"-V[Prints version information]" \ | ||
"--version[Prints version information]" \ | ||
"--tutor[Loads the tutorial]" \ | ||
"--health[Checks for errors in editor setup]:language:->health" \ | ||
"-g[Fetches or builds tree-sitter grammars]:action:->grammar" \ | ||
"--grammar[Fetches or builds tree-sitter grammars]:action:->grammar" \ | ||
"*:file:_files" | ||
|
||
case "$state" in | ||
health) | ||
local languages=($(hx --health |tail -n '+7' |awk '{print $1}' |sed 's/\x1b\[[0-9;]*m//g')) | ||
_values 'language' $languages | ||
;; | ||
grammar) | ||
_values 'action' fetch build | ||
;; | ||
esac | ||
} | ||
|