Merge pull request #921 from zsh-users/update-pygmentize

Update pygmentize completion
This commit is contained in:
Shohei YOSHIDA 2022-11-16 23:08:33 +09:00 committed by GitHub
commit c39f496be3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 23 deletions

View File

@ -1,6 +1,6 @@
#compdef pygmentize
# ------------------------------------------------------------------------------
# Copyright (c) 2012 Github zsh-users - http://github.com/zsh-users
# Copyright (c) 2012 Github zsh-users - https://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -28,7 +28,7 @@
# Description
# -----------
#
# Completion script for pygmentize.
# Completion script for pygmentize 2.13.0 (https://github.com/pygments/pygments)
#
# ------------------------------------------------------------------------------
# Authors
@ -42,22 +42,29 @@ _pygmentize() {
local context state line
_arguments -s -S \
'-h[prints help]:' \
'-V[prints the package version]:' \
'-L[lists lexers, formatters, styles or filters]:args:(lexers formatters styles filters):' \
'-f[formatter]:FORMATTER:_get_formatters' \
'-o[output file]:FILENAME:_gnu_generic' \
'(-h -V -L -f -o -S -F -H -g -l)-N[guesses and prints out a lexer name based solely on given filename]:FILENAME:_files:' \
'(-h -V -L -o -F -H -g -l -N)-S[style]:STYLE:_get_styles' \
'-F[filter]:STYLE:_get_filters' \
'(-g)-l[Specify the lexer to use]:LEXER:_pygmentize_get_lexers' \
'(-l)-g[Guess the lexer from the file contents]' \
'-F[Add a filter to the token stream]:STYLE:_pygmentize_get_filters' \
'-f[Specify the formatter to use]:FORMATTER:_pygmentize_get_formatters' \
'-O[Give options to the lexer and formatter as a comma-separated list of key-value pairs]' \
'-P[Give a single option to the lexer and formatter]' \
'-o[output file]:FILENAME:_files' \
'-v[Print a detailed traceback on unhandled exceptions]' \
'-s[Process lines one at a time until EOF]' \
'-x[Allow custom lexers and formatters to be loaded from a .py file]' \
'--json[Output as JSON]' \
'(-L -o -F -H -g -l -N)-S[Print style definitions for STYLE for a formatter given with -f]:STYLE:_pygmentize_get_styles' \
'-L[lists lexers, formatters, styles or filters]:args:(lexers formatters styles filters)' \
'(-L -f -o -S -F -H -g -l)-N[guesses and prints out a lexer name based solely on given filename]:FILENAME:_files' \
'-C[Like -N, but print out a lexer name based solely on a given content from standard input]' \
'-H[prints detailed help for the object <name> of type <type>]:' \
'(-g)-l[lexer]::LEXER:_get_lexers:' \
'(-l)-g[attempt to guess the lexer from the file contents]' \
'*:args:_gnu_generic'
'-a[Formatter-specific additional argument for the -S mode]:' \
'(* -)-V[prints the package version]' \
'(* -)'{-h,--help}'[prints help]' \
'*:args:_files'
}
_get_filters() {
_pygmentize_get_filters() {
local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then
@ -74,9 +81,7 @@ _get_filters() {
_wanted pygmentize_filters expl 'pygmentize filters' compadd -a _pygmentize_filters
}
(( $+functions[_get_formatters] )) ||
_get_formatters() {
_pygmentize_get_formatters() {
local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then
@ -93,8 +98,7 @@ _get_formatters() {
_wanted pygmentize_formatter expl 'pygmentize formatters' compadd -a _pygmentize_formatter
}
_get_lexers() {
_pygmentize_get_lexers() {
local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then
@ -111,8 +115,7 @@ _get_lexers() {
_wanted pygmentize_lexer expl 'pygmentize lexers' compadd -a _pygmentize_lexer
}
_get_styles() {
_pygmentize_get_styles() {
local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then
@ -129,7 +132,6 @@ _get_styles() {
_wanted pygmentize_style expl 'pygmentize styles' compadd -a _pygmentize_style
}
_pygmentize_caching_policy() {
local -a oldp
oldp=( "$1"(Nmh+24) ) # 24 hour