Fix pygmentize completion

The previous implementation didn't take into account that a lexer could
have multiple names and gave `cpp, c++` instead of `cpp` and `c++` when
completing `pygmentize -l c`.
This commit is contained in:
Clément Martinez 2016-12-02 15:33:04 +01:00 committed by Fabian Homborg
parent 885de80a0e
commit 0785260365

View file

@ -1,8 +1,12 @@
function __fish_print_pygmentize
set -l lines (pygmentize -L $argv[1] | string match -r '^(?:\* | ).*(?:)$' | string replace -r '\* (.*):$' '$1' | string replace -r '^(.*).$' '$1' | string trim)
set -l lines (pygmentize -L $argv[1] | string match -r '^(?:\* | ).*(?:)$' | string replace -r '\* (.*):$' '$1' | string replace -r '^(.*)\.$' '$1' | string trim)
while set -q lines[2]
printf '%s\t%s\n' $lines[1] $lines[2]
set -l names (string split ", " $lines[1])
for name in $names
printf '%s\t%s\n' $name $lines[2]
end
set -e lines[1]
set -e lines[1]
end