Compare commits

..

1 Commits

Author SHA1 Message Date
F.B. 33e9c1fba0
Merge 5359bbf0e7 into 334c14d1b4 2026-08-09 18:56:09 +08:00
8 changed files with 54 additions and 263 deletions

View File

@ -84,8 +84,7 @@ _arguments \
_chromium_proxyurls () {
#TODO: semicolon separated urls not yet implemented
# mostly copied from _urls
local ipre scheme host user uhosts ret=1 expl glob suf
local -a match mbegin mend
local ipre scheme host user uhosts ret=1 expl match glob suf
local localhttp
zstyle -a ":completion:${curcontext}:urls" local localhttp
local localhttp_servername="$localhttp[1]"

View File

@ -166,69 +166,12 @@ _cmake_build_presets() {
(( $+functions[_cmake_json_field] )) ||
_cmake_json_field() {
local json="$1" key="$2"
local -a match mbegin mend
# Non-greedy match of: "key" <ws> : <ws> " value "
if [[ $json =~ "\"$key\"[[:space:]]*:[[:space:]]*\"([^\"]*)\"" ]]; then
print -r -- "$match[1]"
fi
}
# ----------------------
# _cmake_json_preset_block
#
# Slice out one preset object (by its "name") from a presets-array section
# (the text following the "buildPresets"/"configurePresets" key). Returns the
# object's text from its "name" entry up to the start of the next preset's
# "name" entry.
# ----------------------
(( $+functions[_cmake_json_preset_block] )) ||
_cmake_json_preset_block() {
local section="$1" name="$2"
local after="${section#*\"name\"[[:space:]]#:[[:space:]]#\"$name\"}"
[[ $after == "$section" ]] && return 1
print -r -- "${after%%\"name\"[[:space:]]#:*}"
}
# ----------------------
# _cmake_json_inherited_field
#
# Look up $field on preset $name inside array-section $section, following
# "inherits" (a string or an array of strings) when the preset itself
# doesn't set the field, depth-first with first-match-wins -- matching
# CMake's own resolution order. $4 is an internal "seen names" guard
# against cyclic (invalid) inherits.
# ----------------------
(( $+functions[_cmake_json_inherited_field] )) ||
_cmake_json_inherited_field() {
local section="$1" name="$2" field="$3" seen="$4"
[[ " $seen " == *" $name "* ]] && return 1
local block
block=$(_cmake_json_preset_block "$section" "$name") || return 1
local value
value=$(_cmake_json_field "$block" "$field")
if [[ -n $value ]]; then
print -r -- "$value"
return 0
fi
local parent
local -a match mbegin mend
if [[ $block =~ '"inherits"[[:space:]]*:[[:space:]]*\[([^]]*)\]' ]]; then
for parent in ${(s:,:)match[1]}; do
parent=${parent//[\"[:space:]]/}
[[ -z $parent ]] && continue
value=$(_cmake_json_inherited_field "$section" "$parent" "$field" "$seen $name") && \
{ print -r -- "$value"; return 0 }
done
elif [[ $block =~ '"inherits"[[:space:]]*:[[:space:]]*"([^"]*)"' ]]; then
_cmake_json_inherited_field "$section" "$match[1]" "$field" "$seen $name"
return
fi
return 1
}
# ----------------------
# _cmake_json_preset_dir
#
@ -237,9 +180,12 @@ _cmake_json_inherited_field() {
# $2 = build preset name
#
# Steps:
# a) Find the build preset's "configurePreset" (following "inherits" if needed).
# b) Find that configure preset's "binaryDir" (following "inherits" if needed).
# c) Expand the ${sourceDir}/${presetName} macros and strip a trailing slash.
# a) Slice out the build preset object (from its "name" entry up to the next "name" entry)
# and read its "configurePreset".
# b) Slice out that configure preset object the same way and read its "binaryDir".
# c) Expand the ${sourceDir} macro and strip a trailing slash.
# Inheritance ("inherits") is not resolved; the caller's glob fallback covers
# those uncommon setups.
# ----------------------
(( $+functions[_cmake_json_preset_dir] )) ||
_cmake_json_preset_dir() {
@ -247,23 +193,29 @@ _cmake_json_preset_dir() {
setopt extendedglob
local json="$1" name="$2"
# Restrict the "name" search to the right array so a configurePreset and
# a buildPreset sharing the same name (a common CMakePresets pattern)
# don't get confused for one another.
local build_section="${json#*\"buildPresets\"}"
local configure_section="${json#*\"configurePresets\"}"
# --- a) locate the build preset object, read its configurePreset ---
# Everything from `"name": "<name>"` onward:
local after="${json#*\"name\"[[:space:]]#:[[:space:]]#\"$name\"}"
[[ $after == "$json" ]] && return # name not found
# Trim at the start of the *next* preset object's name field, so we only
# look inside this preset.
local block="${after%%\"name\"[[:space:]]#:*}"
local configPreset
configPreset=$(_cmake_json_inherited_field "$build_section" "$name" configurePreset)
configPreset=$(_cmake_json_field "$block" configurePreset)
[[ -z $configPreset ]] && return
# --- b) locate that configure preset object, read its binaryDir ---
after="${json#*\"name\"[[:space:]]#:[[:space:]]#\"$configPreset\"}"
[[ $after == "$json" ]] && return
block="${after%%\"name\"[[:space:]]#:*}"
local bd
bd=$(_cmake_json_inherited_field "$configure_section" "$configPreset" binaryDir)
bd=$(_cmake_json_field "$block" binaryDir)
[[ -z $bd ]] && return
# --- c) expand macros ---
bd="${bd//\$\{sourceDir\}/$PWD}"
bd="${bd//\$\{presetName\}/$configPreset}"
bd="${bd%/}"
print -r -- "$bd"
}
@ -324,9 +276,6 @@ _cmake_preset_build_dir() {
_cmake_presets() {
local invoke=(${(Q)words})
invoke[$CURRENT]=()
# drop a dangling --preset/--preset=... so it doesn't swallow --list-presets as its value
invoke=(${invoke:#--preset})
invoke=(${invoke:#--preset=*})
# TODO: remove all arguments -* except -S
local list_presets=(${(f)"$(${invoke} --list-presets 2>/dev/null |
@ -339,36 +288,17 @@ _cmake_presets() {
# --------------
# _cmake_targets
# --------------
typeset -gA _cmake_targets_cache
(( $+functions[_cmake_targets] )) ||
_cmake_targets() {
local dir="$1"
local -a targets=()
local file mtime key
if [[ -f "${dir}/Makefile" && $+commands[make] ]]; then
file="${dir}/Makefile"
elif [[ -f "${dir}/build.ninja" && $+commands[ninja] ]]; then
file="${dir}/build.ninja"
fi
if [[ -n $file ]]; then
zmodload -F zsh/stat b:zstat 2>/dev/null
mtime=$(zstat +mtime "$file" 2>/dev/null)
key="${file:A}:${mtime}"
if (( $+_cmake_targets_cache[$key] )); then
targets=(${(f)_cmake_targets_cache[$key]})
else
if [[ $file == */Makefile ]]; then
# `make help` doesn't work for Makefiles in general, but for CMake generated Makefiles it does.
targets=(${(f)"$(make -f $file help 2>/dev/null | awk '/^\.\.\./ { print $2 }')"})
else
targets=(${(f)"$(make -f $dir/Makefile help 2>/dev/null | awk '/^\.\.\./ { print $2 }')"})
elif [[ -f "${dir}/build.ninja" && $+commands[ninja] ]]; then
# `ninja help` doesn't seem to be the list of targets we're interested in
targets=(${(f)"$(ninja -C $dir -t targets all 2>/dev/null | awk -F: '{print $1}' )"})
fi
_cmake_targets_cache[$key]="${(F)targets}"
fi
fi
_describe 'build targets' targets
}
@ -392,7 +322,12 @@ _cmake_on_build() {
'--preset[Specify a build preset]:preset:_cmake_build_presets'
'--list-presets[List available build presets]'
)
local -a undescribed_build_extras=(${build_extras%%\[*})
local -a undescribed_build_extras
local i=1
for be in $build_extras ; do
undescribed_build_extras[$i]=$(echo $be | sed "s/\[.*//")
(( i++ ))
done
local in_build=false
local dash_dash_position=-1
@ -411,9 +346,7 @@ _cmake_on_build() {
local out_of_build=false
for ((i = (($CURRENT - 1)); i > (($build_at + 1)); i--)); do
# don't check the word after --build (should be a directory)
# strip a possible "=value" suffix so --target=foo matches like --target
local _wi=${words[$i]%%=*}
if [[ ${undescribed_build_extras[(r)$_wi]} == $_wi ]]; then
if [[ ${undescribed_build_extras[(r)$words[$i]]} == $words[$i] ]]; then
continue
fi
@ -436,36 +369,20 @@ _cmake_on_build() {
"$cmake_build_options[@]" \
- build_cmds \
"$cmake_suggest_build[@]" && return 0
elif [[ "$difference" -eq 1 && $words[$CURRENT] == --preset=* ]] ; then
# --build --preset=<TAB> as the very first arg (joined form)
compset -P '*='
_cmake_build_presets && return 0
elif [[ "$difference" -eq 1 && $words[$CURRENT] == --target=* ]] ; then
# --build --target=<TAB> as the very first arg (joined form, implicit '.' dir)
compset -P '*='
_cmake_targets "." && return 0
elif [[ "$difference" -eq 1 ]] ; then
# completing first arg after --build: dir, --preset, or --list-presets
_alternative \
':current directory:(.)' \
'directory::_directories' \
'preset-flags:flag:((--preset\:"Specify a build preset" --list-presets\:"List available build presets"))' && return 0
elif [[ $words[(($CURRENT - 1))] == --preset || $words[$CURRENT] == --preset=* ]] ; then
# after --build --preset or --build --preset=, complete build presets
compset -P '*='
elif [[ $words[(($CURRENT - 1))] == --preset ]] ; then
# after --build --preset, complete build presets
_cmake_build_presets && return 0
elif [[ $words[(($CURRENT - 1))] == --target || $words[$CURRENT] == --target=* ]] ; then
# after --build <dir|--preset name> --target(=), suggest targets
compset -P '*='
elif [[ $words[(($CURRENT - 1))] == --target ]] ; then
# after --build <dir|--preset name> --target, suggest targets
local _tgt_first=$words[(($build_at + 1))]
local _preset_name=
if [[ $_tgt_first == --preset=* ]]; then
_preset_name=${_tgt_first#--preset=}
elif [[ $_tgt_first == --preset ]]; then
_preset_name=$words[(($build_at + 2))]
fi
if [[ -n $_preset_name ]]; then
local _tgt_dir=$(_cmake_preset_build_dir "$_preset_name")
if [[ $_tgt_first == --preset ]]; then
local _tgt_dir=$(_cmake_preset_build_dir "$words[(($build_at + 2))]")
[[ -n "$_tgt_dir" ]] && _cmake_targets "$_tgt_dir"
elif [[ $_tgt_first != --* ]]; then
_cmake_targets "$_tgt_first"
@ -495,7 +412,12 @@ _cmake_on_install() {
'--strip[Strip before installing.]'
)
local -a undescribed_build_extras=(${build_extras%%\[*})
local -a undescribed_build_extras
local i=1
for be in $build_extras ; do
undescribed_build_extras[$i]=$(echo $be | sed "s/\[.*//")
(( i++ ))
done
local in_build=false
local dash_dash_position=-1
@ -513,9 +435,7 @@ _cmake_on_install() {
local out_of_build=false
for ((i = (($CURRENT - 1)); i > (($build_at + 1)); i--)); do
# don't check the word after --install (should be a directory)
# strip a possible "=value" suffix so --prefix=foo matches like --prefix
local _wi=${words[$i]%%=*}
if [[ ${undescribed_build_extras[(r)$_wi]} == $_wi ]] ; then continue ; fi
if [[ ${undescribed_build_extras[(r)$words[$i]]} == $words[$i] ]] ; then continue ; fi
if [[ $words[(($i - 1))] == --prefix ]]; then continue ; fi
if [[ $words[(($i - 1))] == --config ]]; then continue ; fi
if [[ $words[(($i - 1))] == --component ]]; then continue ; fi
@ -614,15 +534,6 @@ _cmake_define_property_names() {
local alternatives=(
'common-property-names:common property name:_cmake_define_common_property_names -qS='
)
# --find-package (cmake's legacy pkg-config-like mode) requires
# -DNAME=, -DLANGUAGE=, -DCOMPILER_ID= and -DMODE= to be set, see
# Modules/CMakeFindPackageMode.cmake. Suggest them whenever
# --find-package is present on the command line.
if (( ${words[(I)--find-package]} )); then
alternatives+=('find-package-property-names:find-package property name:_cmake_find_package_property_names -qS=')
fi
local -A cmake_langs
zstyle -a ":completion:${curcontext}:" languages cmake_langs
[[ $#cmake_langs -eq 0 ]] && cmake_langs=('C' 'C' 'CXX' 'C++')
@ -658,21 +569,6 @@ _cmake_define_lang_property_names() {
_describe -t "${cmake_lang//:/-}-property-names" "${cmake_lang_desc} property name" properties $@[0,-3] && return 0
}
# ------------------------------------
# _cmake_find_package_property_names
# ------------------------------------
(( $+functions[_cmake_find_package_property_names] )) ||
_cmake_find_package_property_names() {
local -a properties=(
'NAME:Name of the package to search for, e.g. JPEG'
'LANGUAGE:Language context for the search (C, CXX or Fortran)'
'COMPILER_ID:Compiler identification to use, e.g. GNU'
'MODE:Search mode (EXIST, COMPILE or LINK)'
)
_describe -t 'find-package-property-names' 'find-package property name' properties "$@"
}
# -----------------------------------
# _cmake_define_common_property_names
# -----------------------------------
@ -734,19 +630,6 @@ _cmake_define_property_values() {
(CMAKE_UNITY_BUILD)
_wanted booleans expl 'boolean' _cmake_booleans && ret=0
;;
(NAME)
_message -e package-name 'package name to search for, e.g. JPEG' && ret=0
;;
(LANGUAGE)
_wanted languages expl 'language' _values 'language' 'C' 'CXX' 'Fortran' && ret=0
;;
(COMPILER_ID)
_wanted compiler-ids expl 'compiler id' _values 'compiler id' \
'GNU' 'Clang' 'AppleClang' 'MSVC' 'Intel' 'IntelLLVM' 'PGI' 'XL' 'Cray' 'Fujitsu' 'SunPro' 'HP' 'Compaq' 'Borland' 'Watcom' && ret=0
;;
(MODE)
_wanted modes expl 'find-package mode' _values 'mode' 'EXIST' 'COMPILE' 'LINK' && ret=0
;;
(CMAKE_INSTALL_PREFIX)
_files -/ && ret=0
;;

View File

@ -24,7 +24,7 @@
# Description
# -----------
#
# Completion script for dart 3.13.0 (https://dart.dev/)
# Completion script for dart 3.12.0 (https://dart.dev/)
#
# ------------------------------------------------------------------------------
# Authors
@ -60,26 +60,6 @@ _dart() {
'1: :_dart_subcommands' \
&& ret=0
;;
(install)
_arguments \
'(- *)'{-h,--help}'[Print this usage information]' \
'--overwrite[Overwrite executables from other packages with the same name]' \
'*:package' \
&& ret=0
;;
(installed)
_arguments \
'(- *)'{-h,--help}'[Print this usage information]' \
'(-a --all)'{-a,--all}'[Also list packages which are currently not active]'
'*:package' \
&& ret=0
;;
(uninstall)
_arguments \
'(- *)'{-h,--help}'[Print this usage information]' \
'*:package' \
&& ret=0
;;
(analyze)
_arguments \
'(- *)'{-h,--help}'[Print this usage information]' \
@ -89,9 +69,6 @@ _dart() {
'*: :_files -/' \
&& ret=0
;;
(build)
_dart_build && ret=0
;;
(compile)
_dart_compile && ret=0
;;
@ -211,47 +188,6 @@ _dart() {
return ret
}
(( $+functions[_dart_build] )) ||
_dart_build() {
local ret=1
local -a commands=(
'cli:Build a Dart application with a command line interface (CLI)'
)
_arguments -C \
'(- *)'{-h,--help}'[Show help and usage information]' \
'1: :(($commands))' \
'*:: :->subcmd' && ret=0
case $state in
(subcmd)
local -a options=(
'(- *)'{-h,--help}'[Show help and usage information]'
)
case $words[1] in
(cli)
_arguments \
'(- *)'{-h,--help}'[Show help and usage information]' \
'(-o --output)'{-o,--output=}'[Write the output to <output>/bundle/]:output:_files -/' \
'(-t --target)'{-t,--target=}'[Main entry-point file of the command-line application]:file:_files' \
'(-p --packages)'{-p,--packages=}'[Get package locations from the specified file]:file:_files' \
'--verbosity=[Set the verbosity level of the compilation]:level:(error warning info all)' \
'--depfile=[Path to an output file in Ninja depfile format containing compilation dependencies]:path:_files' \
'--target-sanitizer[Build with a specific target sanitizer]:sanitizer:(none asan msan tsan)' \
'--target-os[Compile to a specific target operating system]:os:(android fuchsia ios linux macos windows)' \
'--target-arch[Compile to a specific target architecture]:arch:(arm arm64 ia32 risv32 riscv64 x64)' \
'--root-package=[Package for which hooks are run are outside the packages in packages argument]:name' \
'*: :_files' \
&& ret=0
;;
esac
;;
esac
return ret
}
(( $+functions[_dart_compile] )) ||
_dart_compile() {
local ret=1
@ -602,13 +538,6 @@ _dart_pub_cache() {
'(-f --force)'{-f,--force}'[Do not ask for confirmation]'
)
;;
(gc)
opts+=(
'(-f --force)'{-f,--force}'[Prune cache without confirmation]'
'--collect-recent[Also delete recent files]'
'--dry-run[Print list of files that would be deleted]'
)
;;
esac
_arguments "$opts[@]" && ret=0
@ -624,7 +553,6 @@ _dart_pub_cache_subcommands() {
"add:Install a package"
"clean:Clears the global PUB_CACHE"
"repair:Reinstall cached packages"
'gc:Prune unused packages from the system cache'
)
_describe -t commands 'command' commands "$@"
}
@ -777,25 +705,17 @@ _dart_test_reporter() {
(( $+functions[_dart_subcommands] )) ||
_dart_subcommands() {
local -a commands=(
# global
"install:Install or upgrade a Dart CLI tool for global use"
"installed:List globally installed Dart CLI tools"
"uninstall:Remove aglobally instaled Dart CLI tool"
# project
"build:Build a Dart application including code assets"
"analyze:Analyze Dart code in a directory"
"compile:Compile Dart to various formats"
"create:Create a new Dart project"
"pub:Work with packages"
"run:Run a Dart program"
"test:Run tests for a project"
# source code
"analyze:Analyze Dart code in a directory"
"devtools:Open DevTools (optionally connecting to an existing application)"
"doc:Generate API documentation for Dart projects"
"fix:Apply automated fixes to Dart source code"
"format:Idiomatically format Dart source code"
# tools
"devtools:Open DevTools (optionally connecting to an existing application)"
"info:Show diagnostic information about the installed tooling"
"pub:Work with packages"
"run:Run a Dart program"
"test:Run tests for a project"
)
_describe -t commands 'command' commands "$@"
}

View File

@ -25,7 +25,7 @@
# Description
# -----------
#
# Completion script for the Flutter.io sdk's cli tool 3.47.0 (https://flutter.dev)
# Completion script for the Flutter.io sdk's cli tool 3.41.1 (https://flutter.dev)
#
# ------------------------------------------------------------------------------
# Authors
@ -150,13 +150,6 @@ _flutter() {
(build)
_flutter_build && ret=0
;;
(clean)
_arguments \
'(- *)'{-h,--help}'[Print this usage information]' \
'--scheme[When cleaning Xcode schemes, clean only the specified scheme]:scheme' \
'--include-example[Also clean the example directory]' \
&& ret=0
;;
(config)
_arguments \
'(- *)'{-h,--help}'[Print this usage information]' \

View File

@ -346,7 +346,6 @@ __git_flow_feature_list() {
__git_flow_remote() {
local expl gitdir remotes
local -a match mbegin mend
gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
__git_flow_command_successful || return

View File

@ -234,7 +234,7 @@ while (( $#state )); do
;;
query)
local -a accs keywords match mbegin mend
local -a accs keywords
keywords=(
'acct\::match account names'
'code\::match by transaction code'

View File

@ -43,7 +43,6 @@
_httpie_params() {
local ret=1 expl
local -a match mbegin mend
# or a url
if (( CURRENT <= NORMARG+1 )) && [[ $words[NORMARG] != *:* ]] ; then
@ -124,7 +123,6 @@ _httpie_urls() {
_httpie_printflags() {
local ret=1
local -a match mbegin mend
# not sure why this is necessary, but it will complete "-pH" style without it
[[ $IPREFIX == "-p" ]] && IPREFIX+=" "

View File

@ -28,7 +28,7 @@
# Description
# -----------
#
# Completion script for Node.js v26.7.0 (https://nodejs.org)
# Completion script for Node.js v26.5.0 (https://nodejs.org)
#
# ------------------------------------------------------------------------------
# Authors
@ -236,7 +236,6 @@ _node() {
'--test-coverage-exclude=[exclude files from coverage report that match this glob pattern]:pattern' \
'--test-coverage-functions=[the function coverage minimum threshold]:threshold' \
'--test-coverage-include=[include files from coverage report that match this glob pattern]:pattern' \
'--test-coverage-include-all[include source files that were never loaded in the coverage report]' \
'--test-coverage-lines=[the line coverage minimum threshold]:threshold' \
'--test-force-exit[force test runner to exit upon completion]' \
'--test-global-setup=[specify the path to the global setup file]:file:_files' \