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 #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. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -28,7 +28,7 @@
# Description # Description
# ----------- # -----------
# #
# Completion script for pygmentize. # Completion script for pygmentize 2.13.0 (https://github.com/pygments/pygments)
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Authors # Authors
@ -42,22 +42,29 @@ _pygmentize() {
local context state line local context state line
_arguments -s -S \ _arguments -s -S \
'-h[prints help]:' \ '(-g)-l[Specify the lexer to use]:LEXER:_pygmentize_get_lexers' \
'-V[prints the package version]:' \ '(-l)-g[Guess the lexer from the file contents]' \
'-L[lists lexers, formatters, styles or filters]:args:(lexers formatters styles filters):' \ '-F[Add a filter to the token stream]:STYLE:_pygmentize_get_filters' \
'-f[formatter]:FORMATTER:_get_formatters' \ '-f[Specify the formatter to use]:FORMATTER:_pygmentize_get_formatters' \
'-o[output file]:FILENAME:_gnu_generic' \ '-O[Give options to the lexer and formatter as a comma-separated list of key-value pairs]' \
'(-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:' \ '-P[Give a single option to the lexer and formatter]' \
'(-h -V -L -o -F -H -g -l -N)-S[style]:STYLE:_get_styles' \ '-o[output file]:FILENAME:_files' \
'-F[filter]:STYLE:_get_filters' \ '-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>]:' \ '-H[prints detailed help for the object <name> of type <type>]:' \
'(-g)-l[lexer]::LEXER:_get_lexers:' \ '-a[Formatter-specific additional argument for the -S mode]:' \
'(-l)-g[attempt to guess the lexer from the file contents]' \ '(* -)-V[prints the package version]' \
'*:args:_gnu_generic' '(* -)'{-h,--help}'[prints help]' \
'*:args:_files'
} }
_pygmentize_get_filters() {
_get_filters() {
local cache_policy local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then if [[ -z "$cache_policy" ]]; then
@ -74,9 +81,7 @@ _get_filters() {
_wanted pygmentize_filters expl 'pygmentize filters' compadd -a _pygmentize_filters _wanted pygmentize_filters expl 'pygmentize filters' compadd -a _pygmentize_filters
} }
_pygmentize_get_formatters() {
(( $+functions[_get_formatters] )) ||
_get_formatters() {
local cache_policy local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then if [[ -z "$cache_policy" ]]; then
@ -93,8 +98,7 @@ _get_formatters() {
_wanted pygmentize_formatter expl 'pygmentize formatters' compadd -a _pygmentize_formatter _wanted pygmentize_formatter expl 'pygmentize formatters' compadd -a _pygmentize_formatter
} }
_pygmentize_get_lexers() {
_get_lexers() {
local cache_policy local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then if [[ -z "$cache_policy" ]]; then
@ -111,8 +115,7 @@ _get_lexers() {
_wanted pygmentize_lexer expl 'pygmentize lexers' compadd -a _pygmentize_lexer _wanted pygmentize_lexer expl 'pygmentize lexers' compadd -a _pygmentize_lexer
} }
_pygmentize_get_styles() {
_get_styles() {
local cache_policy local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then if [[ -z "$cache_policy" ]]; then
@ -129,7 +132,6 @@ _get_styles() {
_wanted pygmentize_style expl 'pygmentize styles' compadd -a _pygmentize_style _wanted pygmentize_style expl 'pygmentize styles' compadd -a _pygmentize_style
} }
_pygmentize_caching_policy() { _pygmentize_caching_policy() {
local -a oldp local -a oldp
oldp=( "$1"(Nmh+24) ) # 24 hour oldp=( "$1"(Nmh+24) ) # 24 hour