fork/helix
git clone https://git.julia.blue/fork/helix
e22bbf54
25.07
1# You can move it here ~/.config/elvish/lib/hx.elv 2# Or add `eval (slurp < ~/$REPOS/helix/contrib/completion/hx.elv)` 3# Be sure to replace `$REPOS` with something that makes sense for you! 4 5### Renders a pretty completion candidate 6var candidate = { | _stem _desc | 7 edit:complex-candidate $_stem &display=(styled $_stem bold)(styled " "$_desc dim) 8} 9 10### These commands will invalidate further input (i.e. not react to them) 11var skips = [ "--tutor" "--help" "--version" "-V" "--health" ] 12 13### Grammar commands 14var grammar = [ "--grammar" "-g" ] 15 16### Config commands 17var config = [ "--config" "-c" ] 18 19### Set an arg-completer for the `hx` binary 20set edit:completion:arg-completer[hx] = {|@args| 21 var n = (count $args) 22 if (>= $n 3) { 23 # Stop completions if passed arg will take precedence 24 # and invalidate further input 25 if (has-value $skips $args[-2]) { 26 return 27 } 28 # If the previous arg == --grammar, then only suggest: 29 if (has-value $grammar $args[-2]) { 30 $candidate "fetch" "Fetch the tree-sitter grammars" 31 $candidate "build" "Build the tree-sitter grammars" 32 return 33 } 34 # When we have --config, we need a file 35 if (has-values $config $args[-2]) { 36 edit:complete-filename $args[-1] | each { |v| put $v[stem] } 37 return 38 } 39 # When we have --log, we need a file 40 if (has-values "log" $args[-2]) { 41 edit:complete-filename $args[-1] | each { |v| put $v[stem] } 42 return 43 } 44 } 45 edit:complete-filename $args[-1] | each { |v| put $v[stem]} 46 $candidate "--help" "(Prints help information)" 47 $candidate "--version" "(Prints version information)" 48 $candidate "--tutor" "(Loads the tutorial)" 49 $candidate "--health" "(Checks for errors in editor setup)" 50 $candidate "--grammar" "(Fetch or build the tree-sitter grammars)" 51 $candidate "--vsplit" "(Splits all given files vertically)" 52 $candidate "--hsplit" "(Splits all given files horizontally)" 53 $candidate "--config" "(Specifies a file to use for configuration)" 54 $candidate "--log" "(Specifies a file to write log data into)" 55}