diff --git a/.config/hypr/hyprland.conf b/.config/hypr/hyprland.conf index a681330..a960ab8 100644 --- a/.config/hypr/hyprland.conf +++ b/.config/hypr/hyprland.conf @@ -152,11 +152,6 @@ input { } } -# https://wiki.hyprland.org/Configuring/Variables/#gestures -gestures { - workspace_swipe = false -} - # Example per-device config # See https://wiki.hyprland.org/Configuring/Keywords/#per-device-input-configs for more device { diff --git a/.config/nvim/lua/lsp/servers/gopls.lua b/.config/nvim/lua/lsp/servers/gopls.lua index 955c189..017e5f8 100644 --- a/.config/nvim/lua/lsp/servers/gopls.lua +++ b/.config/nvim/lua/lsp/servers/gopls.lua @@ -3,7 +3,7 @@ local util = require("lspconfig.util") return { cmd = { "gopls" }, filetypes = { "go", "gomod", "gowork", "gotmpl" }, - root_dir = util.root_pattern("go.work", "go.mod", ".git"), + root_markers = { "go.work", "go.mod" }, settings = { gopls = { completeUnimported = true, diff --git a/.config/nvim/lua/lsp/servers/tsserver.lua b/.config/nvim/lua/lsp/servers/tsserver.lua index 1f07ec2..f36452f 100644 --- a/.config/nvim/lua/lsp/servers/tsserver.lua +++ b/.config/nvim/lua/lsp/servers/tsserver.lua @@ -33,6 +33,37 @@ local function get_typescript_server_path(root_dir) return global_ts end +local function get_tsserver_cmd(root_dir) + -- Check for local typescript-language-server in node_modules + local tsserver + + tsserver = root_dir .. '/node_modules/.bin/typescript-language-server' + if vim.loop.fs_stat(tsserver) then + return { tsserver, '--stdio' } + end + + -- Check for local typescript-language-server in node_modules + tsserver = root_dir .. '/node_modules/.bin/tsserver' + if vim.loop.fs_stat(tsserver) then + return { tsserver, '--stdio' } + end + + -- Check frontend/node_modules + tsserver = root_dir .. '/frontend/node_modules/.bin/typescript-language-server' + if vim.loop.fs_stat(tsserver) then + return { tsserver, '--stdio' } + end + + -- Check frontend/node_modules + tsserver = root_dir .. '/frontend/node_modules/.bin/tsserver' + if vim.loop.fs_stat(tsserver) then + return { tsserver, '--stdio' } + end + + -- Fallback to Mason + return { vim.fn.expand('~/.local/share/nvim/mason/bin/typescript-language-server'), '--stdio' } +end + local function organize_imports() local params = { command = "_typescript.organizeImports", @@ -66,12 +97,19 @@ return { description = "Organize Imports" } }, - on_new_config = function(new_config, new_root_dir) + before_init = function(initialize_params, config) + local root_dir = initialize_params.rootPath or initialize_params.rootUri + if root_dir and root_dir:match("^file://") then + root_dir = vim.uri_to_fname(root_dir) + end + + -- Update cmd + config.cmd = get_tsserver_cmd(root_dir) + + -- Update tsdk if get_typescript_server_path then - new_config.init_options.typescript = new_config.init_options.typescript or {} - new_config.init_options.typescript.tsdk = get_typescript_server_path(new_root_dir) - else - vim.notify("get_typescript_server_path is not defined", vim.log.levels.ERROR) + config.init_options.typescript = config.init_options.typescript or {} + config.init_options.typescript.tsdk = get_typescript_server_path(root_dir) end end, } diff --git a/.config/nvim/lua/plugins/dadbod.lua b/.config/nvim/lua/plugins/dadbod.lua index 72d6e39..b21a8e1 100644 --- a/.config/nvim/lua/plugins/dadbod.lua +++ b/.config/nvim/lua/plugins/dadbod.lua @@ -17,6 +17,7 @@ return { vim.g.dbs = { dev = 'mysql://jack:secret@localhost:33061/jack?protocol=tcp', + dev_prod_dump = 'mysql://root:secret@localhost:33061/jac_prod?protocol=tcp', } vim.api.nvim_create_user_command('DBUITab', function() diff --git a/.config/phpcs.xml b/.config/phpcs.xml index a2f70e6..3dc664d 100644 --- a/.config/phpcs.xml +++ b/.config/phpcs.xml @@ -28,6 +28,5 @@ - diff --git a/.config/zsh/.zsh/_git b/.config/zsh/.zsh/_git deleted file mode 100644 index e0fda27..0000000 --- a/.config/zsh/.zsh/_git +++ /dev/null @@ -1,293 +0,0 @@ -#compdef git gitk - -# zsh completion wrapper for git -# -# Copyright (c) 2012-2020 Felipe Contreras -# -# The recommended way to install this script is to make a copy of it as a -# file named '_git' inside any directory in your fpath. -# -# For example, create a directory '~/.zsh/', copy this file to '~/.zsh/_git', -# and then add the following to your ~/.zshrc file: -# -# fpath=(~/.zsh $fpath) -# -# You need git's bash completion script installed. By default bash-completion's -# location will be used (e.g. pkg-config --variable=completionsdir bash-completion). -# -# If your bash completion script is somewhere else, you can specify the -# location in your ~/.zshrc: -# -# zstyle ':completion:*:*:git:*' script ~/.git-completion.bash -# - -zstyle -T ':completion:*:*:git:*' tag-order && \ - zstyle ':completion:*:*:git:*' tag-order 'common-commands' - -zstyle -s ":completion:*:*:git:*" script script -if [ -z "$script" ]; then - local -a locations - local e bash_completion - - bash_completion=$(pkg-config --variable=completionsdir bash-completion 2>/dev/null) || - bash_completion='/usr/share/bash-completion/completions/' - - locations=( - "$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash - "$HOME/.local/share/bash-completion/completions/git" - "$bash_completion/git" - '/etc/bash_completion.d/git' # old debian - ) - for e in $locations; do - test -f $e && script="$e" && break - done -fi - -local old_complete="$functions[complete]" -functions[complete]=: -GIT_SOURCING_ZSH_COMPLETION=y . "$script" -functions[complete]="$old_complete" - -__gitcomp () -{ - emulate -L zsh - - local cur_="${3-$cur}" - - case "$cur_" in - --*=) - ;; - --no-*) - local c IFS=$' \t\n' - local -a array - for c in ${=1}; do - if [[ $c == "--" ]]; then - continue - fi - c="$c${4-}" - case $c in - --*=|*.) ;; - *) c="$c " ;; - esac - array+=("$c") - done - compset -P '*[=:]' - compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 - ;; - *) - local c IFS=$' \t\n' - local -a array - for c in ${=1}; do - if [[ $c == "--" ]]; then - c="--no-...${4-}" - array+=("$c ") - break - fi - c="$c${4-}" - case $c in - --*=|*.) ;; - *) c="$c " ;; - esac - array+=("$c") - done - compset -P '*[=:]' - compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 - ;; - esac -} - -__gitcomp_direct () -{ - emulate -L zsh - - compset -P '*[=:]' - compadd -Q -S '' -- ${(f)1} && _ret=0 -} - -__gitcomp_nl () -{ - emulate -L zsh - - compset -P '*[=:]' - compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0 -} - -__gitcomp_file () -{ - emulate -L zsh - - compadd -f -p "${2-}" -- ${(f)1} && _ret=0 -} - -__gitcomp_direct_append () -{ - __gitcomp_direct "$@" -} - -__gitcomp_nl_append () -{ - __gitcomp_nl "$@" -} - -__gitcomp_file_direct () -{ - __gitcomp_file "$1" "" -} - -_git_zsh () -{ - __gitcomp "v1.1" -} - -__git_complete_command () -{ - emulate -L zsh - - local command="$1" - local completion_func="_git_${command//-/_}" - if (( $+functions[$completion_func] )); then - emulate ksh -c $completion_func - return 0 - else - return 1 - fi -} - -__git_zsh_bash_func () -{ - emulate -L ksh - - local command=$1 - - __git_complete_command "$command" && return - - local expansion=$(__git_aliased_command "$command") - if [ -n "$expansion" ]; then - words[1]=$expansion - __git_complete_command "$expansion" - fi -} - -__git_zsh_cmd_common () -{ - local -a list - list=( - add:'add file contents to the index' - bisect:'find by binary search the change that introduced a bug' - branch:'list, create, or delete branches' - checkout:'checkout a branch or paths to the working tree' - clone:'clone a repository into a new directory' - commit:'record changes to the repository' - diff:'show changes between commits, commit and working tree, etc' - fetch:'download objects and refs from another repository' - grep:'print lines matching a pattern' - init:'create an empty Git repository or reinitialize an existing one' - log:'show commit logs' - merge:'join two or more development histories together' - mv:'move or rename a file, a directory, or a symlink' - pull:'fetch from and merge with another repository or a local branch' - push:'update remote refs along with associated objects' - rebase:'forward-port local commits to the updated upstream head' - reset:'reset current HEAD to the specified state' - restore:'restore working tree files' - rm:'remove files from the working tree and from the index' - show:'show various types of objects' - status:'show the working tree status' - switch:'switch branches' - tag:'create, list, delete or verify a tag object signed with GPG') - _describe -t common-commands 'common commands' list && _ret=0 -} - -__git_zsh_cmd_alias () -{ - local -a list - list=(${${(0)"$(git config -z --get-regexp '^alias\.*')"}#alias.}) - list=(${(f)"$(printf "%s:alias for '%s'\n" ${(f@)list})"}) - _describe -t alias-commands 'aliases' list && _ret=0 -} - -__git_zsh_cmd_all () -{ - local -a list - emulate ksh -c __git_compute_all_commands - list=( ${=__git_all_commands} ) - _describe -t all-commands 'all commands' list && _ret=0 -} - -__git_zsh_main () -{ - local curcontext="$curcontext" state state_descr line - typeset -A opt_args - local -a orig_words - - orig_words=( ${words[@]} ) - - _arguments -C \ - '(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \ - '(-p --paginate)--no-pager[do not pipe git output into a pager]' \ - '--git-dir=-[set the path to the repository]: :_directories' \ - '--bare[treat the repository as a bare repository]' \ - '(- :)--version[prints the git suite version]' \ - '--exec-path=-[path to where your core git programs are installed]:: :_directories' \ - '--html-path[print the path where git''s HTML documentation is installed]' \ - '--info-path[print the path where the Info files are installed]' \ - '--man-path[print the manpath (see `man(1)`) for the man pages]' \ - '--work-tree=-[set the path to the working tree]: :_directories' \ - '--namespace=-[set the git namespace]' \ - '--no-replace-objects[do not use replacement refs to replace git objects]' \ - '(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \ - '(-): :->command' \ - '(-)*:: :->arg' && return - - case $state in - (command) - _tags common-commands alias-commands all-commands - while _tags; do - _requested common-commands && __git_zsh_cmd_common - _requested alias-commands && __git_zsh_cmd_alias - _requested all-commands && __git_zsh_cmd_all - let _ret || break - done - ;; - (arg) - local command="${words[1]}" __git_dir - - if (( $+opt_args[--bare] )); then - __git_dir='.' - else - __git_dir=${opt_args[--git-dir]} - fi - - (( $+opt_args[--help] )) && command='help' - - words=( ${orig_words[@]} ) - - __git_zsh_bash_func $command - ;; - esac -} - -_git () -{ - local _ret=1 - local cur cword prev - - cur=${words[CURRENT]} - prev=${words[CURRENT-1]} - let cword=CURRENT-1 - - if (( $+functions[__${service}_zsh_main] )); then - __${service}_zsh_main - elif (( $+functions[__${service}_main] )); then - emulate ksh -c __${service}_main - elif (( $+functions[_${service}] )); then - emulate ksh -c _${service} - elif (( $+functions[_${service//-/_}] )); then - emulate ksh -c _${service//-/_} - fi - - let _ret && _default && _ret=0 - return _ret -} - -_git diff --git a/.config/zsh/.zsh/fsh/.fast-make-targets b/.config/zsh/.zsh/fsh/.fast-make-targets deleted file mode 100644 index e2cbd32..0000000 --- a/.config/zsh/.zsh/fsh/.fast-make-targets +++ /dev/null @@ -1,98 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Almost all code borrowed from Zshell's _make function -# -# Copyright (c) 2018 Sebastian Gniazdowski - -local -a TARGETS - -.make-expandVars() { - local open close var val front='' rest=$1 - - while [[ $rest == (#b)[^$]#($)* ]]; do - front=$front${rest[1,$mbegin[1]-1]} - rest=${rest[$mbegin[1],-1]} - - case $rest[2] in - ($) # '$$'. may not appear in target and variable's value - front=$front\$\$ - rest=${rest[3,-1]} - continue - ;; - (\() # Variable of the form $(foobar) - open='(' - close=')' - ;; - ({) # ${foobar} - open='{' - close='}' - ;; - ([[:alpha:]]) # $foobar. This is exactly $(f)oobar. - open='' - close='' - var=$rest[2] - ;; - (*) # bad parameter name - print -- $front$rest - return 1 - ;; - esac - - if [[ -n $open ]]; then - if [[ $rest == \$$open(#b)([[:alnum:]_]##)(#B)$close* ]]; then - var=$match - else # unmatched () or {}, or bad parameter name - print -- $front$rest - return 1 - fi - fi - - val='' - if [[ -n ${VAR_ARGS[(i)$var]} ]]; then - val=${VAR_ARGS[$var]} - else - if [[ -n $opt_args[(I)(-e|--environment-overrides)] ]]; then - if [[ $parameters[$var] == scalar-export* ]]; then - val=${(P)var} - elif [[ -n ${VARIABLES[(i)$var]} ]]; then - val=${VARIABLES[$var]} - fi - else - if [[ -n ${VARIABLES[(i)$var]} ]]; then - val=${VARIABLES[$var]} - elif [[ $parameters[$var] == scalar-export* ]]; then - val=${(P)var} - fi - fi - fi - rest=${rest//\$$open$var$close/$val} - done - - print -- ${front}${rest} -} - - -.make-parseMakefile () { - local input var val target dep TAB=$'\t' tmp IFS= - - while read input - do - case "$input " in - # TARGET: dependencies - # TARGET1 TARGET2 TARGET3: dependencies - ([[*?[:alnum:]$][^$TAB:=%]#:[^=]*) - target=$(.make-expandVars ${input%%:*}) - TARGETS+=( ${(z)target} ) - ;; - esac - done -} - -if [[ -z "${FAST_HIGHLIGHT[chroma-make-cache]}" || $(( EPOCHSECONDS - FAST_HIGHLIGHT[chroma-make-cache-born-at] )) -gt 7 ]]; then - .make-parseMakefile - FAST_HIGHLIGHT[chroma-make-cache-born-at]="$EPOCHSECONDS" - FAST_HIGHLIGHT[chroma-make-cache]="${(j:;:)TARGETS}" -fi - -reply2=( "${(s:;:)FAST_HIGHLIGHT[chroma-make-cache]}" ) - -# vim:ft=zsh:et diff --git a/.config/zsh/.zsh/fsh/.fast-read-ini-file b/.config/zsh/.zsh/fsh/.fast-read-ini-file deleted file mode 100644 index 2e57d10..0000000 --- a/.config/zsh/.zsh/fsh/.fast-read-ini-file +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) 2018 Sebastian Gniazdowski -# -# $1 - path to the ini file to parse -# $2 - name of output hash (INI by default) -# $3 - prefix for keys in the hash (can be empty) -# -# Writes to given hash under keys built in following way: ${3}
_field. -# Values are values from ini file. - -local __ini_file="$1" __out_hash="${2:-INI}" __key_prefix="$3" -local IFS='' __line __cur_section="void" __access_string -local -a match mbegin mend - -[[ ! -r "$__ini_file" ]] && { builtin print -r "fast-syntax-highlighting: an ini file is unreadable ($__ini_file)"; return 1; } - -while read -r -t 1 __line; do - if [[ "$__line" = [[:blank:]]#\;* ]]; then - continue - elif [[ "$__line" = (#b)[[:blank:]]#\[([^\]]##)\][[:blank:]]# ]]; then - __cur_section="${match[1]}" - elif [[ "$__line" = (#b)[[:blank:]]#([^[:blank:]=]##)[[:blank:]]#[=][[:blank:]]#(*) ]]; then - match[2]="${match[2]%"${match[2]##*[! $'\t']}"}" # remove trailing whitespace - __access_string="${__out_hash}[${__key_prefix}<$__cur_section>_${match[1]}]" - : "${(P)__access_string::=${match[2]}}" - fi -done < "$__ini_file" - -return 0 - -# vim:ft=zsh:sw=4:sts=4:et diff --git a/.config/zsh/.zsh/fsh/.fast-run-command b/.config/zsh/.zsh/fsh/.fast-run-command deleted file mode 100644 index e251bcc..0000000 --- a/.config/zsh/.zsh/fsh/.fast-run-command +++ /dev/null @@ -1,37 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# FAST_HIGHLIGHT hash serves as container for variables that -# prevents creating them in global scope. (P) flag is not used, -# output array is fixed (__lines_list). -# -# $1 - the command, e.g. "git remote"; 2>/dev/null redirection is -# added automatically -# $2 - FAST_HIGHLIGHT field name, e.g. "chroma-git-branches"; two -# additional fields will be used, $2-cache, $2-cache-born-at -# $3 - what to remove from beginning of the lines returned by the -# command -# $4 - cache validity time, default 5 (seconds) -# -# Output: array __lines_list, with output of the command ran - -# User should not forget to define this array, the below code -# will only ensure that it's array (can also define a global) -typeset -ga __lines_list -local -a __response - -if [[ -z "${FAST_HIGHLIGHT[$2-cache]}" || $(( EPOCHSECONDS - FAST_HIGHLIGHT[$2-cache-born-at] )) -gt ${4:-5} ]]; then - FAST_HIGHLIGHT[$2-cache-born-at]="$EPOCHSECONDS" - __response=( ${${(f)"$(command ${(Qz)1#+} 2>/dev/null)"}#${~3}} ) - [[ "$1" = "+"* ]] && __lines_list+=( "${__response[@]}" ) || __lines_list=( "${__response[@]}" ) - FAST_HIGHLIGHT[$2-cache]="${(j:;:)__response}" -else - # Quoted (s:;:) flag without @ will skip empty elements. It - # still produces array output, interesingly. All this is for - # the trailing ";" above, to skip last, empty element. - [[ "$1" = "+"* ]] && \ - __lines_list+=( "${(@s:;:)FAST_HIGHLIGHT[$2-cache]}" ) || \ - __lines_list=( "${(@s:;:)FAST_HIGHLIGHT[$2-cache]}" ) -fi - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/.fast-run-git-command b/.config/zsh/.zsh/fsh/.fast-run-git-command deleted file mode 100644 index 4a42b97..0000000 --- a/.config/zsh/.zsh/fsh/.fast-run-git-command +++ /dev/null @@ -1,60 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# It runs given command, which in general will be a git command, -# automatically looking at cache first (a field named *-cache, -# in FAST_HIGHLIGHT), which is valid for 5 seconds, and in case -# of outdated or not existing cache, runs the command, splitting -# on new-lines, first checking if PWD is inside git repository. -# -# FAST_HIGHLIGHT hash serves as container for variables that -# prevents creating them in global scope. (P) flag is not used, -# output array is fixed (__lines_list). -# -# $1 - the command, e.g. "git remote"; 2>/dev/null redirection is -# added automatically -# $2 - FAST_HIGHLIGHT field name, e.g. "chroma-git-branches"; two -# additional fields will be used, $2-cache, $2-cache-born-at -# $3 - what to remove from beginning of the lines returned by the -# command -# $4 - cache validity time, default 5 (seconds) -# -# Output: array __lines_list, with output of the (git) command ran - -# User should not forget to define this array, the below code -# will only ensure that it's array (can also define a global) -typeset -ga __lines_list -local -a __response - -if [[ $1 == --status ]] { - integer __status=1 - shift -} - -if [[ -z ${FAST_HIGHLIGHT[$2-cache]} || $(( EPOCHSECONDS - FAST_HIGHLIGHT[$2-cache-born-at] )) -gt ${4:-5} ]]; then - FAST_HIGHLIGHT[$2-cache-born-at]=$EPOCHSECONDS - if [[ "$(command git rev-parse --is-inside-work-tree 2>/dev/null)" = true ]]; then - __response=( ${${(f)"$(command ${(Qz)${1#+}} 2>/dev/null)"}#$3} ) - integer retval=$? - if (( __status )) { - __response=( $retval ) - __lines_list=( $retval ) - } else { - [[ "$1" = "+"* ]] && \ - __lines_list+=( "${__response[@]}" ) || \ - __lines_list=( "${__response[@]}" ) - } - else - __lines_list=() - fi - FAST_HIGHLIGHT[$2-cache]="${(j:;:)__response}" -else - # Quoted (s:;:) flag without @ will skip empty elements. It - # still produces array output, interesingly. All this is for - # the trailing ";" above, to skip last, empty element. - [[ "$1" = "+"* ]] && \ - __lines_list+=( "${(@s:;:)FAST_HIGHLIGHT[$2-cache]}" ) || \ - __lines_list=( "${(@s:;:)FAST_HIGHLIGHT[$2-cache]}" ) -fi - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/.fast-zts-read-all b/.config/zsh/.zsh/fsh/.fast-zts-read-all deleted file mode 100644 index 96c52ab..0000000 --- a/.config/zsh/.zsh/fsh/.fast-zts-read-all +++ /dev/null @@ -1,17 +0,0 @@ -# $1 - file-descriptor to be read from -# $2 - name of output variable (default: REPLY) - -local __in_fd=${1:-0} __out_var=${2:-REPLY} -local -a __tmp -integer __ret=1 __repeat=10 __tmp_size=0 - -while sysread -s 65535 -i "$__in_fd" '__tmp[__tmp_size + 1]'; do - (( ( __ret=$? ) == 0 )) && (( ++ __tmp_size )) - (( __ret == 5 )) && { __ret=0; (( --__repeat == 0 )) && break; } -done - -: ${(P)__out_var::="${(j::)__tmp}"} - -return __ret - -# vim: ft=zsh:et:sw=4:sts=4 diff --git a/.config/zsh/.zsh/fsh/.github/FUNDING.yml b/.config/zsh/.zsh/fsh/.github/FUNDING.yml deleted file mode 100644 index 56544b3..0000000 --- a/.config/zsh/.zsh/fsh/.github/FUNDING.yml +++ /dev/null @@ -1,5 +0,0 @@ -# These are supported funding model platforms - -github: psprint -patreon: psprint -ko_fi: psprint diff --git a/.config/zsh/.zsh/fsh/.gitignore b/.config/zsh/.zsh/fsh/.gitignore deleted file mode 100644 index a863220..0000000 --- a/.config/zsh/.zsh/fsh/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -current_theme.zsh -secondary_theme.zsh -theme_overlay.zsh -*.txt -test/out.parse -test/res -hold/* -*.zwc - -### Vim -# Swap -[._]*.s[a-v][a-z] -[._]*.sw[a-p] -[._]s[a-v][a-z] -[._]sw[a-p] - -# Session -Session.vim - -# Temporary -.netrwhist -*~ -# Auto-generated tag files -tags diff --git a/.config/zsh/.zsh/fsh/.travis.yml b/.config/zsh/.zsh/fsh/.travis.yml deleted file mode 100644 index 351b593..0000000 --- a/.config/zsh/.zsh/fsh/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -addons: - apt: - packages: - zsh -install: - - mkdir .bin - - curl -L https://github.com/zunit-zsh/zunit/releases/download/v0.8.2/zunit > .bin/zunit - - curl -L https://raw.githubusercontent.com/molovo/revolver/master/revolver > .bin/revolver - - curl -L https://raw.githubusercontent.com/molovo/color/master/color.zsh > .bin/color -before_script: - - chmod u+x .bin/{color,revolver,zunit} - - export PATH="$PWD/.bin:$PATH" -script: zunit diff --git a/.config/zsh/.zsh/fsh/.zunit.yml b/.config/zsh/.zsh/fsh/.zunit.yml deleted file mode 100644 index e4fd57f..0000000 --- a/.config/zsh/.zsh/fsh/.zunit.yml +++ /dev/null @@ -1,8 +0,0 @@ -tap: false -directories: - tests: tests - output: tests/_output - support: tests/_support -time_limit: 0 -fail_fast: false -allow_risky: false diff --git a/.config/zsh/.zsh/fsh/CHANGELOG.md b/.config/zsh/.zsh/fsh/CHANGELOG.md deleted file mode 100644 index b2a7665..0000000 --- a/.config/zsh/.zsh/fsh/CHANGELOG.md +++ /dev/null @@ -1,144 +0,0 @@ -# News On Updates in F-Sy-H - -**2018-08-09** - -Added ideal string highlighting – FSH now handles any legal quoting and combination of `"`,`'` and `\` when -highlighting program arguments. See the introduction for an example (item #14). - -**2018-08-02** - -Global aliases are now supported: - -![image](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/global-alias.png) - -**2018-08-01** - -Hint – how to customize styles when using Zplugin and turbo mode: - -```zsh -zplugin ice wait"1" atload"set_fast_theme" -zplugin light zdharma/fast-syntax-highlighting - -set_fast_theme() { - FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}paired-bracket]='bg=blue' - FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}bracket-level-1]='fg=red,bold' - FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}bracket-level-2]='fg=magenta,bold' - FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}bracket-level-3]='fg=cyan,bold' -} -``` - -If you have set theme before an update of styles (e.g. recent addition of bracket highlighting) -then please repeat `fast-theme {theme}` call to regenerate theme files. (**2018-08-09**: FSH -now has full user-theme support, refer to [appropriate section of README](#customization)). - -**2018-07-30** - -Ideal highlighting of brackets (pairing, etc.) – no quoting can disturb the result: - -![image](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/brackets.gif) - -`FAST_HIGHLIGHT[use_brackets]=1` to enable this feature (**2018-07-31**: not needed anymore, this highlighting is active by default). - -**2018-07-21** - -Chroma architecture now supports aliases. You can have `alias mygit="git commit"` and when `mygit` -will be invoked everything will work as expected (Git chroma will be ran). - -**2018-07-11** - -There were problems with Ctrl-C not working when using FSH. After many days I've found a fix -for this, it's pushed to master. - -Second, asynchronous path checking (useful on e.g. slow network drives, or when there are many files in directory) -is now optional. Set `FAST_HIGHLIGHT[use_async]=1` to enable it. This saves some users from Zshell crashes -– there's an unknown bug in Zsh. - -**2018-06-09** - -New chroma functions: `awk`, `make`, `perl`, `vim`. Checkout the [video](https://asciinema.org/a/186234), -it shows functionality of `awk` – compiling of code and NOT running it. Perl can do this too: -[video](https://asciinema.org/a/186098). - -**2018-06-06** - -FSH gained a new architecture – "chroma functions". They are similar to "completion functions", i.e. they -are defined **per-command**, but instead of completing that command, they colorize it. Two chroma exist, -for `Git` ([video](https://asciinema.org/a/185707), [video](https://asciinema.org/a/185811)) and for `grep` -([video](https://asciinema.org/a/185942)). Checkout -[example chroma](https://github.com/zdharma/fast-syntax-highlighting/blob/master/chroma/-example.ch) if you -would like to highlight a command. - -![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/git_chroma.png) - -**2018-06-01** - -Highlighting of command substitution (i.e. `$(...)`) with alternate theme – two themes at once! It was just white before: - -![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/cmdsubst.png) - -To select which theme to use for `$(...)` set the key `secondary=` in [theme ini file](https://github.com/zdharma/fast-syntax-highlighting/blob/master/themes/free.ini#L7). -All shipped themes have this key set (only the `default` theme doesn't use second theme). - -Also added correct highlighting of descriptor-variables passed to `exec`: - -![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/execfd.png) - -**2018-05-30** - -For-loop is highlighted, it has separate settings in [theme file](https://github.com/zdharma/fast-syntax-highlighting/blob/master/themes/free.ini). - -![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/for-loop.png) - -**2018-05-27** - -Added support for 256-color themes. There are six themes shipped with FSH. The command to -switch theme is `fast-theme {theme-name}`, it has a completion which lists available themes -and options. Checkout [asciinema recording](https://asciinema.org/a/183814) that presents -the themes. - -**2018-05-25** - -Hash holding paths that shouldn't be grepped (globbed) – blacklist for slow disks, mounts, etc.: - -```zsh -typeset -gA FAST_BLIST_PATTERNS -FAST_BLIST_PATTERNS[/mount/nfs1/*]=1 -FAST_BLIST_PATTERNS[/mount/disk2/*]=1 -``` - -**2018-05-23** - -Assign colorizing now spans to variables defined by `typeset`, `export`, `local`, etc.: - -![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/typeset.png) - -Also, `zcalc` has a separate math mode and specialized highlighting – no more light-red colors because of -treating `zcalc` like a regular command-line: - -![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/zcalc.png) - -**2018-05-22** - -Array assignments were still boring, so I throwed in bracked colorizing: - -![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/array-assign.png) - -**2018-05-22** - -Assignments are no more one-colour default-white. When used in assignment, highlighted are: - -- variables (outside strings), -- strings (double-quoted and single-quoted), -- math-mode (`val=$(( ... ))`). - -![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/assign.png) - -**2018-01-06** - -Math mode is highlighted – expressions `(( ... ))` and `$(( ... ))`. Empty variables are colorized as red. -There are 3 style names (fields of -[FAST_HIGHLIGHT_STYLES](https://github.com/zdharma/fast-syntax-highlighting/blob/master/fast-highlight#L34) -hash) for math-variable, number and empty variable (error): `mathvar`, `mathnum`, `matherr`. You can set -them (like the animation below shows) to change colors. - -![animation](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/math.gif) diff --git a/.config/zsh/.zsh/fsh/CHROMA_GUIDE.adoc b/.config/zsh/.zsh/fsh/CHROMA_GUIDE.adoc deleted file mode 100644 index 579f192..0000000 --- a/.config/zsh/.zsh/fsh/CHROMA_GUIDE.adoc +++ /dev/null @@ -1,166 +0,0 @@ -# Chroma Guide for F-Sy-H - -## Motivation - -Someone might want to create a detailed highlighting for a **specific program** -and this document helps achieving this. It explains how chroma functions – the -code behind such detailed highlighting – are constructed and used. - -## Keywords - -- `chroma` - a shorthand for `chroma function` – the thing that literally colorizes selected commands, like `git`, `grep`, etc. invocations, see `chroma function` below, -- `big loop` - main highlighting code, a loop over tokens and at least 2 large structular constructs (big `if` and `case`); - it is advanced, e.g. parses `case` statements, here-string, it basically constitutes 90% of the F-Sy-H project, -- `chroma function` - a plugin-function that is called when a specific command occurs (e.g. when user enters `git` at - command line) suppressing activity of `big loop` (i.e. no standard highlighting unless requested), -- `token` - result of splitting whole command line (i.e. `$BUFFER`, the Zle variable) into bits called tokens, which are - words in general, separated by spaces on the command line. - -## Overview Of Functioning - -1. Big loop is working – token by token processes command line, changes states (e.g. enters state "inside case - statement") and in the end decides on color of the token currently processed. - -2. Big loop occurs a command that has a chroma, e.g. `git`. - -3. Big loop enters "chroma" state, calls associated chroma function. - -4. Chroma takes care of "chroma" state, ensures it will be set also for next token. - -5. "chroma" state is active, so all following tokens are routed to the chroma (in general skipping big-loop, see next items), - -6. When processing of a single token is complete, the associated chroma returns 0 - (shell-truth) to request no further processing by the big loop. - -7. It can also return 1 so that single, current token will be passed into big-loop - for processing (to do a standard highlighting). - -## Chroma-Function Arguments - -- `$1` - 0 or 1, denoting if it's the first call to the chroma, or a following one, - -- `$2` - the current token, also accessible by `$\__arg` from the upper scope - - basically a private copy of `$__arg`; the token can be eg.: "grep", - -- `$3` - a private copy of `$_start_pos`, i.e. the position of the token in the - command line buffer, used to add region_highlight entry (see man), - because Zsh colorizes by *ranges* applied onto command line buffer (e.g. - `from-10 to-13 fg=red`), - -- `$4` - a private copy of `$_end_pos` from the upper scope; denotes where current token - ends (at which index in the string being the command line). - -So example invocation could look like this: - ----- -chroma/-example.ch 1 "grep" "$_start_pos" "$_end_pos" ----- - -Big-loop will be doing such calls for the user, after occurring a specific chroma-enabled command (like e.g. `awk`), and then until chroma will detect end of this chroma-enabled command (end of whole invocation, with arguments, etc.; in other words, when e.g. new line or `;`-character occurs, etc.). - -## Example Chroma-Function - -[source,zsh] ----- -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# Example chroma function. It colorizes first two arguments as `builtin' style, -# third and following arguments as `globbing' style. First two arguments may -# be "strings", they will be passed through to normal higlighter (by returning 1). -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# -# $2 - like above document says -# -# $3 - ... -# -# $4 - ... -# -# Other tips are: -# - $CURSOR holds cursor position -# - $BUFFER holds whole command line buffer -# - $LBUFFER holds command line buffer that is left from the cursor, i.e. it's a -# BUFFER substring 1 .. $CURSOR -# - $RBUFFER is the same as LBUFFER but holds part of BUFFER right to the cursor -# -# The function receives $BUFFER but via sequence of tokens, which are shell words, -# e.g. "a b c" is a shell word, while a b c are 3 shell words. -# -# FAST_HIGHLIGHT is a friendly hash array which allows to store strings without -# creating global parameters (variables). If you need hash, go ahead and use it, -# declaring first, under some distinct name like: typeset -gA CHROMA_EXPLE_DICT. -# Remember to reset the hash and others at __first_call == 1, so that you have -# a fresh state for new command. - -# Keep chroma-takever state meaning: until ;, handle highlighting via chroma. -# So the below 8192 assignment takes care that next token will be routed to chroma. -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style -integer __idx1 __idx2 - -(( __first_call )) && { - # Called for the first time - new command. - # FAST_HIGHLIGHT is used because it survives between calls, and - # allows to use a single global hash only, instead of multiple - # global string variables. - FAST_HIGHLIGHT[chroma-example-counter]=0 - - # Set style for region_highlight entry. It is used below in - # '[[ -n "$__style" ]] ...' line, which adds highlight entry, - # like "10 12 fg=green", through `reply' array. - # - # Could check if command `example' exists and set `unknown-token' - # style instead of `command' - __style=${FAST_THEME_NAME}command - -} || { - # Following call, i.e. not the first one - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if [[ "$__wrd" = -* ]]; then - # Detected option, add style for it. - [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ - __style=${FAST_THEME_NAME}single-hyphen-option - else - # Count non-option tokens - (( FAST_HIGHLIGHT[chroma-example-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-example-counter] )) - - # Colorize 1..2 as builtin, 3.. as glob - if (( FAST_HIGHLIGHT[chroma-example-counter] <= 2 )); then - if [[ "$__wrd" = \"* ]]; then - # Pass through, fsh main code will do the highlight! - return 1 - else - __style=${FAST_THEME_NAME}builtin - fi - else - __style=${FAST_THEME_NAME}globbing - fi - fi -} - -# Add region_highlight entry (via `reply' array). -# If 1 will be added to __start_pos, this will highlight "oken". -# If 1 will be subtracted from __end_pos, this will highlight "toke". -# $PREBUFFER is for specific situations when users does command \ -# i.e. when multi-line command using backslash is entered. -# -# This is a common place of adding such entry, but any above code can do -# it itself (and it does in other chromas) and skip setting __style to -# this way disable this code. -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through, do obligatory things ourselves. -# _start_pos=$_end_pos advainces pointers in command line buffer. -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 ----- - diff --git a/.config/zsh/.zsh/fsh/DONATIONS.md b/.config/zsh/.zsh/fsh/DONATIONS.md deleted file mode 100644 index fc22058..0000000 --- a/.config/zsh/.zsh/fsh/DONATIONS.md +++ /dev/null @@ -1,441 +0,0 @@ - - -**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* - -- [2018-08-14, received $30](#2018-08-14-received-30) -- [2018-08-03, received $8](#2018-08-03-received-8) -- [2018-08-02, received $3 from Patreon](#2018-08-02-received-3-from-patreon) -- [2018-07-31, received $7](#2018-07-31-received-7) -- [2018-07-28, received $2](#2018-07-28-received-2) -- [2018-07-25, received $3](#2018-07-25-received-3) -- [2018-07-20, received $3](#2018-07-20-received-3) -- [2018-06-17, received ~$155 (200 CAD)](#2018-06-17-received-155-200-cad) -- [2018-06-10, received $10](#2018-06-10-received-10) -- [2018-05-25, received $50](#2018-05-25-received-50) - - - -Below are reports about what is being done with donations, i.e. which commits -are created thanks to them, which new features are added, etc. From the money -I receive I buy myself coffee and organize the time to work on the requested -features, sometimes many days in a row. - -## 2018-08-14, received $30 - - * **Project**: **[Zplugin](https://github.com/zdharma/zplugin)** - * **Goal**: Create a binary Zsh module with one Zplugin optimization and optionally some - other features. - * **Status**: The job is done. - -Thanks to this donation I have finally started to code **[binary Zplugin module]( -https://github.com/zdharma/zplugin#quick-start-module-only)**, which is a big step onward -in evolution of Zplugin. I've implemented and published the module with 3 complete -features: 1) `load` optimization, 2) autocompilation of scripts, 3) profiling of script -load times. - -Commit list: -``` -2018-08-22 7b96fad doc: mod-install.sh -2018-08-22 ba1ba64 module: Update zpmod usage text -2018-08-22 b0d72e8 zplugin,*autoload: `module' command, manages new zdharma/zplugin module -2018-08-22 706bbb3 Update Zsh source files to latest -2018-08-20 b77426f module: source-study builds report with milliseconds without fractions -2018-08-20 c3cc09b module: Updated zpmod_usage, i.a. with `source-study' sub-command -2018-08-20 6190295 module: Go back to subcommand-interface to `zpmod'; simple option parser -2018-08-20 881005f module: Report on sourcing times is shown on `zpmod -S`. Done generation -2018-08-19 e5d046a module: Correct conditions on zwc file vs. script file (after stats) -2018-08-19 1282c21 module: Duration of sourcing a file is measured and stored into a hash -2018-08-18 e080153 module: Overload both `source' and `.' builtins -2018-08-18 580efb8 module: Invoke bin_zcompile with -U option (i.e. no alias expansion) -2018-08-18 b7d9836 module: Custom `source' ensures script is compiled, compiles if not -2018-08-18 1e75a47 module: Code cleanup, vim folding -2018-08-18 a4a02f3 module: Finally working `source'/`.' overload (used options translating) -2018-08-16 99bba56 module: zpmod_usage gained content -2018-08-16 04703cd module: Add the main builtin zpmod with report-append which is working -2018-08-16 cd6dc19 module: my_ztrdup_glen, zp_unmetafy_zalloc -2018-08-16 6d44e36 module: Cleanup, `source' overload after patron leoj3n restarted module -``` - -## 2018-08-03, received $8 - - * **Project**: **[zdharma/history-search-multi-word](https://github.com/zdharma/history-search-multi-word)** - * **Goal**: Allow calling `zle reset-prompt` (Zshell feature). - * **Status**: The job is done. - -A user wanted to be able to call `reset-prompt` Zshell widget without disturbing my project -`history-search-multi-word`. I've implemented the necessary changes to HSMW. - -Commit list: - -``` -2018-08-04 9745d3d hsmw: reset-prompt-protect zstyle – allow users to run zle reset-prompt -2018-08-04 ce48a53 hsmw: More typo-like lackings of % substitution -2018-08-04 7e2d79b hsmw: A somewhat typo, missing % substitution -``` - -## 2018-08-02, received $3 from Patreon - - * **Project**: **[zdharma/fast-syntax-highlighting](https://github.com/zdharma/fast-syntax-highlighting)** - * **Goal**: No goal set up. - * **Status**: Bug-fixing work. - -I did bug-fixing run on `fast-syntax-highlighting`, spotted many small and sometimes important things to -improve. Did one bigger thing – added global-aliases functionality. - -Commit list: - -``` -2018-08-02 1e854f5 -autoload.ch: Don't check existence for arguments that are variables -2018-08-02 14cdc5e *-string-*: Support highlighter cooperation in presence of $PREBUFFER -2018-08-02 2d8f0e4 *-highlight: Correctly highlight $VAR, $~VAR, ${+VAR}, etc. in strings -2018-08-02 e3032d9 *-highlight: ${#PREBUFFER} -> __PBUFLEN, equal performance -2018-08-02 f0a7121 *-highlight: Make case conditions and brackets highlighter compatible -2018-08-02 781f68e *-highlight: Recognize more case-item-end tokens -2018-08-02 206c122 *-highlight: Remove unused 4th __arg_type -2018-08-02 c6da477 *-string-*: Handle 'abc\' – no slash-quoting here. Full quoting support -2018-08-02 52e0176 *-string-*: Fix bug, third level was getting wrong style -2018-08-02 5edbfae -git.ch: Support "--message=..." syntax (commit) -2018-08-02 669d4b7 -git.ch: Handle "--" argument (stops options) -2018-08-02 4fae1f2 -make.ch: Handle make's -f option -2018-08-02 3fd32fe -make.ch: Handle make's -C option -2018-08-02 31751f5 -make.ch: Recognize options that obtain argument -2018-08-02 e480f18 -make.ch: Fix reply-var clash, gained consistency -2018-08-02 0e8bc1e Updated README.md -2018-08-02 eee0034 images: global-alias.png -2018-08-02 00b41ef *-highlight,themes,fast-theme: Support for global aliases #41 -``` - -## 2018-07-31, received $7 - - * **Project**: **[zdharma/fast-syntax-highlighting](https://github.com/zdharma/fast-syntax-highlighting)** - * **Goal**: Implement ideal brackets highlighting. - * **Status**: The job is done. - -When a source code is edited e.g. in `Notepad++` or some IDE, then most often brackets are somehow matched to -each other, so that the programmer can detect mistakes. `Fast-syntax-highlighting` too gained that feature. It -was done in such a way that FSH cannot make any mistake, colors will perfectly match brackets to each other. - -Commit list: - -``` -2018-07-31 2889860 *-highlight: Correct place to initialize $_FAST_COMPLEX_BRACKETS -2018-07-31 2bde2a9 Performance status -15/8/8 -2018-07-31 5078261 *-highlight,README: Brackets highlighter active by default -2018-07-31 2ee3073 *-highlight,*string-*: Brackets in [[..]], ((..)), etc. handled normally -2018-07-31 776b12d plugin.zsh: $_ZSH_HIGHLIGHT_MAIN_CACHE -> $_FAST_MAIN_CACHE -2018-07-30 2867712 plugin.zsh: Fix array parameter created without declaring #43 -2018-07-30 cbe5fc8 Updated README.md -2018-07-30 2bd3291 images: brackets.gif -2018-07-30 ef23a96 *-string-*: Bug-fix, correctly use theme styles -2018-07-30 9046f82 plugin.zsh: Attach the new brackets highlighter; F_H[use_brackets]=1 -2018-07-30 b33a5fd fast-theme: Support 4 new styles (for brackets) -2018-07-30 a03f004 themes: Add 4 new styles (brackets) -2018-07-30 2448cdc *-string-*: Additional highlight of bracket under cursor; more styles -2018-07-30 5e1795e *-string-*: Highlighter for brackets, handles all quotings; detached -``` - -## 2018-07-28, received $2 - - * **Project**: **[zdharma/fast-syntax-highlighting](https://github.com/zdharma/fast-syntax-highlighting)** - * **Goal**: Distinguish file and directory when highlighting - * **Status**: The job is done. - -A user requested that when `fast-syntax-highlighting` colorizes the command line it should use different -styles (e.g. colors) for token that's a *file* and that's a *directory*. It was a reasonable idea and I've -implemented it. - -Commit list: -``` -2018-07-28 7f48e04 themes: Extend all themes with new style `path-to-dir' -2018-07-28 c7c6a91 fast-theme: Support for new style `path-to-dir' -2018-07-28 264676c *-highlight: Differentiate path and to-dir path. New style: path-to-dir -``` - -## 2018-07-25, received $3 - - * **Project**: **[zdharma/zshelldoc](https://github.com/zdharma/zshelldoc)** - * **Goal**: Implement documenting of used environment variables. - * **Status**: The job is done. - -Zshelldoc generates code-documentation like Doxygen or Javadoc, etc. User requested a -new feature: the generated docs should enumerate environment variables used and/or -exported by every function. Everything went fine and this feature has been implemented. - -Commit list: - -``` -2018-07-26 f63ea25 Updated README.md -2018-07-26 3af0cf7 *detect: Get `var' from ${var:-...} and ${...:+${var}} and other subst -2018-07-25 2932510 *adoc: Better language in output document (about exported vars) #5 -2018-07-25 f858dd8 *adoc: Include (in the output document) data on env-vars used #5 -2018-07-25 80e3763 *adoc: Include data on exports (environment) in the output document #5 -2018-07-25 ca576e2 *detect: Detect which env-vars are used, store meta-data in data/ #5 -2018-07-25 f369dcc *detect: Function `find-variables' reported "$" as a variable, fixed #5 -2018-07-25 e243dab *detect: Function `find-variables' #5 -2018-07-25 5b34bb1 *transform: Detect exports done by function/script-body, store #5 -``` - -## 2018-07-20, received $3 - - * **Project**: **[zdharma/zshelldoc](https://github.com/zdharma/zshelldoc)** - * **Goal**: Implement stripping of leading `#` char from functions' descriptions. - * **Status**: The job is done. - -A user didn't like that functions' descriptions in the JavaDoc-like document (generated with Zshelldoc) all -contain a leading `#` character. I've added stripping of this character (it is there in the processed source -code) controlled by a new Zshelldoc option. - -Commit list: -``` -2018-07-20 172c220 zsd,*adoc,README: Option --scomm to strip "#" from function descriptions -``` - -## 2018-06-17, received ~$155 (200 CAD) - - * **Project**: **[zdharma/fast-syntax-highlighting](https://github.com/zdharma/fast-syntax-highlighting)** - * **Goal**: No goal set up. - * **Status**: Done intense research. - -I've created 2 new branches: `Hue-optimization` (33 commits) and `Tidbits-feature` (22 commits). Those were -branches with architectural changes and extraordinary features. The changes yielded to be too slow, and I had -to withdraw the merge. Below are fixing and optimizing commits (i.e. the valuable ones) that I've restored -from the two branches into master. - -Commit list: -``` -2018-07-21 dab6576 *-highlight: Merge-restore: remove old comments -2018-07-21 637521f *-highlight: Merge-restore: a threshold on # of zle .redisplay calls -2018-07-21 4163d4d *-highlight: Merge-restore: optimize four $__arg[1] = ... cases -2018-07-21 0f01195 *-highlight: Merge-restore: can remove one (Q) dequoting -2018-07-21 39a4ec6 *-highlight: Merge-restore: $v = A* is faster than $v[1] = A, tests: -2018-07-21 99d6b33 *-highlight: Merge-restore: optimize-out ${var:1} Bash syntax -2018-07-21 719c092 *-highlight: Merge-restore: allow $V/cmd, "$V/cmd, "$V/cmd", "${V}/cmd" -2018-07-21 026941d *-highlight: Merge-restore: stack pop in single instruction, not two -2018-07-21 3467e3d *-highlight: Merge-restore: more reasonable redirection-detecting code -2018-07-21 00d25ee *-highlight: Merge-restore: one active_command="$__arg" not needed (?) -2018-07-21 1daa6b3 *-highlight: Merge-restore: simplify ; and \n code short-paths -2018-07-21 55d65be *-highlight: Merge-restore: proc_buf advancement via patterns (not (i)) -2018-07-21 cc55546 *-highlight: Merge-restore: pattern matching to replace (i) flag -``` - -## 2018-06-10, received $10 - - * **Project**: **[zdharma/fast-syntax-highlighting](https://github.com/zdharma/fast-syntax-highlighting)** - * **Goal**: No goal set up. - * **Status**: Done intense experimenting. - -I was working on *chromas* – command-specific colorization. I've added `which` and -`printf` colorization, then added asynchronous path checking (needed on slow network -drives), then coded experimental `ZPath` feature for chromas, but it couldn't be optimized -so I had to resign of it. - -Commit list: -``` -2018-06-12 c4ed1c6 Optimization – the same idea as in previous patch, better method -2018-06-12 c36feef Optimization – a) don't index large buffer, b) with negative index -2018-06-12 2f03829 Performance status 2298 / 1850 -2018-06-12 14f5159 New working feature – ZPath. It requires optimization -2018-06-12 e027c40 -which.ch: One of commands can apparently return via stderr (#27) -2018-06-11 5b8004f New chroma `ruby', works like chroma `perl', checks syntax via -ce opts -2018-06-10 ca2e18b *-highlight: Async path checking has now 8-second cache -2018-06-10 e071469 *-highlight: Remove path-exists queue clearing -2018-06-10 5a6684c *-highlight: Support for asynchronous path checking -2018-06-10 1d7d6f5 New chroma: `printf', highlights special sequences like %s, %20s, etc. -2018-06-10 8f59868 -which.ch: Update main comment on purpose of this chroma -2018-06-10 5f4ece2 -which.ch: Added `whatis', it has only 1st line if output used -2018-06-10 e2d173e -which.ch: Uplift: handle `which' called on a function, /usr/bin/which -``` - -## 2018-05-25, received $50 - - * **Project**: **[zdharma/fast-syntax-highlighting](https://github.com/zdharma/fast-syntax-highlighting)** - * **Goal**: No goal set up. - * **Status**: New ideas and features. - -I was working from May, 25 to June, 9 and came up with key ideas and implemented them. First were *themes* -that were very special because they were using `INI` files instead of some Zsh-script format. Creating themes -for `fast-syntax-highlighting` is thus easy and fun. Then I came up with *chromas*, command-specific -highlighting, which redefine how syntax-highlighting for Zshell works – detailed highlighting for e.g. Git -became possible, the user is informed about e.g. a mistake even before running a command. Overall 178 commits -in 16 days. - -``` -2018-06-09 3f72e6c -git.ch: `revert' works almost like `checkout', attach `revert' there -2018-06-09 b892743 Updated CHROMA_GUIDE.adoc -2018-06-09 f05643d Revert "Revert "Updated CHROMA_GUIDE.md"" -2018-06-09 729bf7f Revert "Revert "CHROMA_GUIDE: Remove redundant comments, uplift"" -2018-06-09 48a4e0c Revert "CHROMA_GUIDE: Remove redundant comments, uplift" -2018-06-09 55ede0a Revert "Updated CHROMA_GUIDE.md" -2018-06-09 17a28ba New chroma `-docker.ch' that verifies image ID passed to `image rm' -2018-06-09 868812a -make.ch,*-make-targets: Check Makefile exists, use 7 second cache, #24 -2018-06-09 73df278 -sh.ch: Attach fish, has -c option, though different syntax, let's try -2018-06-09 3a73b8e Updated CHROMA_GUIDE.md -2018-06-09 29d04c8 CHROMA_GUIDE: Remove redundant comments, uplift -2018-06-09 22ce1d8 -sh.ch,*-highlight: Attach to 2 other shells, Zsh and Bash -2018-06-09 f54e44f New chroma `-sh.ch', colorizes code passed to `sh' with -c option -2018-06-09 f5d2375 CHROMA_GUIDE: Add example code block (rendered broken in mdown) -2018-06-09 08f4b28 CHROMA_GUIDE: Switch to asciidoc (rename) -2018-06-09 4e03609 CHROMA_GUIDE.md -2018-06-09 bbcf2d6 -source.ch: Word "source" should be highlighted as builtin -2018-06-09 6739b8b New chroma – `source' to handle . and source builtins -2018-06-09 b961211 gitignore: ignore more paths -2018-06-09 59d5d09 Updated README.md -2018-06-09 f6d4d19 Updated README.md -2018-06-09 eb31324 Update README.md (figlet logo) -2018-06-09 71dcc5f Performance status 298 / 479 -2018-06-09 00c5f8f *-highlight: Add comments -2018-06-09 232903c -awk.ch: Highlight `sub' function, not working {, } highlighting -2018-06-09 b5241ba *-highlight: Much better $( ) recursion, would say problems-free, maybe -2018-06-08 6c69437 *-highlight: Larger buffer (110 -> 250) for $( ) matching -2018-06-08 f2b7a96 -awk.ch: Syntax check code passed to awk. Awk is very forgiving, though -2018-06-08 c53d8ba -vim.ch: Pass almost everything to big-loop, check if vim exists -2018-06-08 7fbf7cd chroma: New chroma `vim', shows last opened files under prompt -2018-06-08 06e4570 gitignore: Extend .gitignore -2018-06-08 3184ba1 chroma: All chroma functions end chroma mode on e.g. | and similar -2018-06-08 070077d *-highlight,-example.ch: Rename arg_type -> __arg_type, use it to end -2018-06-08 6c2411e -awk.ch: Use the new theme style `subtle-bg' -2018-06-08 9ec8d63 themes: All themes (remaining 4) to support `subtle-bg' style -2018-06-08 66e848b fast-theme: New theme key `subtle-bg', default & clean.ini support it -2018-06-08 1e794f9 -awk.ch: More keywords highlighted -2018-06-08 f3bbaca -awk.ch: Don't highlight keywords when they only contain proper keyword -2018-06-08 e4d5283 -awk.ch: Fix mistake (indices), was highlighting 1 extra trailing letter -2018-06-08 eebbb19 -awk.ch: Initialize FSH_LIST -2018-06-08 8ec24ca *-highlight: Missing math function for awk -2018-06-08 d8e423a -awk.ch: Highlight more keywords, via more general code -2018-06-07 ee26e66 Commit missing -fast-make-targets -2018-06-07 9d4f2b5 New chroma `-awk.ch', colorizes regex characters and a keyword (print) -2018-06-07 def5133 -example.ch: Add comments -2018-06-07 f31a2d0 New chroma -make.ch, verifies if target is correct -2018-06-07 623b8ce -perl.ch: Use correct keys in FAST_HIGHLIGHT hash -2018-06-07 090f420 themes: Make all themes provide {in,}correct-subtle styles -2018-06-07 2201fb6 New -perl.ch chroma, syntax-checks perl code; 2 new theme entries -2018-06-06 4b9598e *-highlight: Fix bug in math highlight – allow variables starting with _ -2018-06-06 708afec *-highlight: Fix FAST_BLIST_PATTERNS not expanding path to absolute one -2018-06-06 caef05a -example.ch: Update, fix typos, remove unused code -2018-06-06 3fb192a Updated README.md -2018-06-06 6de0c82 images: git_chroma.png -2018-06-06 2852fdd -grep.ch (new): Special highlighting for grep – -grep.ch chroma function -2018-06-06 f216785 -example.ch: Added comments -2018-06-06 4ab5b36 -example.ch: Add comments -2018-06-06 380cd12 -example.ch: Added comments -2018-06-06 c8947cc -example.ch: Add comments -2018-06-06 f2e273e -example.ch: Add comments -2018-06-06 2f3565b plugin.zsh: Fix parse error -2018-06-06 4f1a9bd plugin.zsh: Added $fpath handling, to match what README contains -2018-06-06 cc9adb5 -example.ch: Change and extend comments -2018-06-06 3128fff -git.ch: More intelligent `checkout' highlighting – ref is first -2018-06-06 4b6f54b -git.ch: Support for `checkout' subcommand -2018-06-06 1930d37 -example.ch: Added example chroma function -2018-06-05 d79cd85 -git.ch: Add comments -2018-06-05 1473c9e -git.ch: Add comments -2018-06-05 0cb1419 -git.ch: Message passed after -m is checked for the 72 chars boundary -2018-06-05 3f99944 -git.ch: Architectural uplift of git chroma -2018-06-05 e044d13 -git.ch: Single place to add entry to $reply (target: region_highlight) -2018-06-05 3a84364 -git.ch: Handle quoted non-option arguments, also partly quoted: "abc -2018-06-05 d635bf4 -fast-run-git-command, it handles cache automatically, decimates source -2018-06-05 102ea78 -git.ch: Smart handling of `git push', remotes and branches are verified -2018-06-04 be88850 Performance status [+] 39+77=116 / -26+24=-2 -2018-06-04 0e033f8 Experimental chroma support, currently active only on command `git' -2018-06-04 43ae221 *-highlight: Emacs mode-line -2018-06-04 938ad29 test: New "-git" parsing option, test results, -git.ch included -2018-06-04 e433fbc fast-theme: Explicitly return 0; added Emacs mode-line -2018-06-04 66e9b3c *-highlight: Detection of $( ) now doesn't go for $(( )) as a candidate -2018-06-04 488a580 chroma: Empty chroma function for `git' -2018-06-04 f54d770 *-highlight: Rename $cur_cmd to $active_command -2018-06-04 3f24e68 *-highlight: Make sudo and always-block compatible with `case' handling -2018-06-02 cd82637 themes: forest.ini to support 3 new `case' styles -2018-06-02 e1e993e themes: safari.ini & zdharma.ini to support 3 new `case' styles -2018-06-02 2e78a02 themes: clean.ini & default.ini to support 3 new `case' styles -2018-06-02 c1c3aab themes: free.ini to support 3 new `case' styles -2018-06-02 70a7e18 fast-theme,*-highlight: 3 new styles for `case' higlighting -2018-06-02 8d90dc2 *-highlight: Support for `case' highlighting -2018-06-02 10d291c *-highlight: Softer state manipulation, less rigid =1 etc. assignments -2018-06-02 6159507 *-highlight: Don't highlight closing ) with style `assign' -2018-06-02 1fc2450 *-highlight: One complex math command optimization, top of the loop -2018-06-02 cc49247 *-highlight: Fix improper state after assignment (command | regular) -2018-06-02 02942b8 Updated README.md -2018-06-02 5e28259 images: eval_cmp.png -2018-06-02 df92fed *-highlight: Fix removal of trailing "/' when recursing in eval -2018-06-02 4f61938 Performance status 46 / 44 -2018-06-02 a5ade0e *-highlight: Recursive highlighting of eval string argument -2018-06-02 e91847b *-highlight: Don't recurse when not at main *-process call -2018-06-02 fca8603 *-highlight: Support assignments of arrays when key is taken from array -2018-06-02 5d70f01 *-highlight: Math highlighting recognizes ${+VAR} -2018-06-02 c48eb0d *-highlight: Math colorizing recognizes variables in braces ${HISTISZE} -2018-06-02 53dd85a *-highlight: Allow -- for precommand modifiers command & exec -2018-06-02 d9fe110 *-highlight: Detect globbing also when `##' occurs -2018-06-02 55c923d Performance status 132 / 66 -2018-06-02 3bd8f07 themes: safari.ini to have globbing color specifically selected -2018-06-02 2b55260 themes: free.ini to have globbing color specifically selected -2018-06-02 494868e themes: clean.ini to have globbing color specifically selected -2018-06-01 fca6b3d images: herestring.png #9 -2018-06-01 f9842c1 themes: forest.ini to use underline instead of bg color #9 -2018-06-01 c25c539 themes: Small tune-up of forest & zdharma themes for here-string #9 -2018-06-01 988d504 themes: Rudimentary (all same) configuration of here-string tokens #9 -2018-06-01 99842d2 fast-theme,*-highlight: Support for here-string, can use bg color #9 -2018-06-01 f739c30 Updated README.md -2018-06-01 7fa8451 images: execfd.png execfd_cmp.png -2018-06-01 d7384f1 themes: All themes gained `exec-descriptor=` key, now supported by code -2018-06-01 d66d140 themes: Fix improper effect of s/red/.../ substitution in clean,forest -2018-06-01 f7ee5e2 fast-theme,*-highlight: Support highlighting of {FD} etc. passed to exec -2018-06-01 e5c5534 *-highlight: Proper states for precmd (command,exec) option handling -2018-06-01 647b198 images: New cmdsubst.png -2018-06-01 74bdc4c Updated README.md -2018-06-01 86eb15e images: theme.png -2018-06-01 5169e82 Updated README.md -2018-06-01 1c462b7 Updated README.md -2018-06-01 4c21da4 images: cmdsubst.png -2018-06-01 b39996e *-highlight: Switch theme to secondary when descending into $() #15 -2018-06-01 bf96045 themes: Equip all themes with key `secondary' (an alternate theme) #15 -2018-06-01 aa1b112 fast-theme: Generate secondary theme (from key `secondary' in theme) #15 -2018-06-01 6dd3bd3 *-highlight: Support for multiple active themes #15 -2018-06-01 8a32944 *-highlight: Fix "$() found?" comparison -2018-06-01 3651605 *-highlight: Significant change: the parser is called recursively on $() -2018-05-31 882d88b test,*-highlight: New -ooo performance test; highlighter takes arguments -2018-05-31 5ba1178 *-highlight: Optimization - compute __arg length once -2018-05-30 b2a0126 *-highlight: Allow multiple separate options for `command', `exec' (#10) -2018-05-30 5804e9a *-highlight: Correct state after option for precommand (#10) -2018-05-30 1247b64 *-highlight: Simpler and more accurate option-testing for exec, command (#10) -2018-05-30 d87fed4 *-highlight: Correctly highlight options for `command' and `exec' (#10) -2018-05-30 8c3e75e *-highlight: Double-hyphen (--) stops option recognition and colorizing -2018-05-30 1c5a56c *-highlight: Support ${VAR} at command position (not only $VAR) -2018-05-30 f19d761 Updated README.md -2018-05-30 4a27351 images: for-loop -2018-05-30 4d650de themes: zdharma.ini to support for-loop -2018-05-30 45cafbc themes: safari.ini to support for-loop -2018-05-30 8bb9ee0 themes: free.ini to support for-loop -2018-05-30 f25a059 themes: forest.ini to support for-loop -2018-05-29 093d79e themes: default.ini to support for-loop -2018-05-29 446cb7b clean.ini,fast-theme: Clean-theme & theme subsystem to support for-loop -2018-05-29 1bb701f *-highlight: Move $variable highlighting from case to if-block -2018-05-29 b8413e9 *-highlight: For-loop highlighting, working, needs few upgrades -2018-05-28 7bec6e5 *-highlight: Three more simple vs. complex math operation optimizations -2018-05-27 baae683 *-highlight: Optimise complex math command into single one with & and ~ -2018-05-27 2dc3103 *-highlight: Optimise complex math command into single one with & and ~ -2018-05-27 291f905 _fast-theme: Update -t/--test description -2018-05-27 ec305f6 fast-theme: Help message treats about -t/--test -2018-05-27 0e1d19a Updated README.md -2018-05-27 5c3c911 Updated README.md -2018-05-26 76af248 themes: A fix for zdharma theme, 61 -> 63, a lighter color for builtins -2018-05-26 8eca0f2 *fast-theme: Ability to test theme after setting it (-t/--test) -2018-05-26 d3a7922 *-highlight: Fix in_array_assignment setting when closing ) found -2018-05-26 796c482 *-highlight: Make parameters' names exotic blank-var detection to work -2018-05-26 ae3913f _fast-theme: Complete theme names -2018-05-26 d212945 *-highlight,plugin.zsh,default.ini: Uplift of fg=112-fix code -2018-05-26 ee56f65 *-highlight,plugin.zsh: Final fix for fg=112 assignment – use zstyle -2018-05-26 391f5a4 fast-theme: Set `theme' zstyle in `:plugin:fast...' to given theme -2018-05-26 e0dc086 plugin.zsh: Fix the fg=112 assignment done for `variable' style -2018-05-26 17c9286 Updated README.md -2018-05-26 4774c1c fast-theme: Add completion for this function -2018-05-26 d971f39 fast-theme: Detect lack of theme name in arguments -2018-05-26 74f0d4d fast-theme: Use standard option parsing (zparseopts) and typical options -2018-05-26 d9c6180 New theme: `forest' -2018-05-26 419c156 New theme: `zdharma' -2018-05-26 a7735df gitignore -2018-05-26 99db69a New theme: `free' -2018-05-26 73619ff New theme: `clean' -2018-05-25 52307fb Theme support, 1 extra theme – `safari' -2018-05-25 41df55b *-highlight: (k) subscript flag is sufficient, no need for (K) -2018-05-25 cb21c05 Updated README.md -2018-05-25 a580cff *-highlight: FAST_BLIST_PATTERNS -``` diff --git a/.config/zsh/.zsh/fsh/LICENSE b/.config/zsh/.zsh/fsh/LICENSE deleted file mode 100644 index 3d6b811..0000000 --- a/.config/zsh/.zsh/fsh/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2010-2016 zsh-syntax-highlighting contributors -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted -provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions - and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors - may be used to endorse or promote products derived from this software without specific prior - written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/.config/zsh/.zsh/fsh/README.md b/.config/zsh/.zsh/fsh/README.md deleted file mode 100644 index 6c069f3..0000000 --- a/.config/zsh/.zsh/fsh/README.md +++ /dev/null @@ -1,290 +0,0 @@ -[![paypal](https://img.shields.io/badge/-Donate-yellow.svg?longCache=true&style=for-the-badge)](https://www.paypal.me/ZdharmaInitiative) -[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=D54B3S7C6HGME) -[![patreon](https://img.shields.io/badge/-Patreon-orange.svg?longCache=true&style=for-the-badge)](https://www.patreon.com/psprint) -
New: You can request a feature when donating, even fancy or advanced ones get implemented this way. [There are -reports](DONATIONS.md) about what is being done with the money received. - -# Fast Syntax Highlighting (F-Sy-H) - -Feature rich syntax highlighting for Zsh. - -
- image could not be loaded -
- -### Table of Contents - -- [News](#news) -- [Installation](#installation) -- [Features](#features) -- [Performance](#performance) -- [IRC Channel](#irc-channel) - -### Other Contents -- [License](https://github.com/zdharma/fast-syntax-highlighting/blob/master/LICENSE) -- [Changelog](https://github.com/zdharma/fast-syntax-highlighting/blob/master/CHANGELOG.md) -- [Theme Guide](https://github.com/zdharma/fast-syntax-highlighting/blob/master/THEME_GUIDE.md) -- [Chroma Guide](https://github.com/zdharma/fast-syntax-highlighting/blob/master/CHROMA_GUIDE.adoc) - -# News - -* 15-06-2019 - - A new architecture for defining the highlighting for **specific commands**: it now - uses **abstract definitions** instead of **top-down, regular code**. The first effect - is the highlighting for the `git` command it is now **maximally faithful**, it - follows the `git` command almost completely. - [Screencast](https://asciinema.org/a/253411) - -# Installation - -### Manual - -Clone the Repository. - -```zsh -git clone https://github.com/zdharma/fast-syntax-highlighting ~/path/to/fsh -``` - -And add the following to your `zshrc` file. -```zsh -source ~/path/to/fsh/fast-syntax-highlighting.plugin.zsh -``` - -### Zinit - -Add the following to your `zshrc` file. - -```zsh -zinit light zdharma/fast-syntax-highlighting -``` - -Here's an example of how to load the plugin together with a few other popular -ones with the use of -[Turbo](https://zdharma.org/zinit/wiki/INTRODUCTION/#turbo_mode_zsh_62_53), -i.e.: speeding up the Zsh startup by loading the plugin right after the first -prompt, in background: - -```zsh -zinit wait lucid for \ - atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay" \ - zdharma/fast-syntax-highlighting \ - blockf \ - zsh-users/zsh-completions \ - atload"!_zsh_autosuggest_start" \ - zsh-users/zsh-autosuggestions -``` - -### Antigen - -Add the following to your `zshrc` file. - -```zsh -antigen bundle zdharma/fast-syntax-highlighting -``` - -### Zgen - -Add the following to your `.zshrc` file in the same place you're doing -your other `zgen load` calls in. - -```zsh -zgen load zdharma/fast-syntax-highlighting -``` - - -### Oh-My-Zsh - -Clone the Repository. - -```zsh -git clone https://github.com/zdharma/fast-syntax-highlighting.git \ - ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting -``` - -And add `fast-syntax-highlighting` to your plugin list. - -# Features - -### Themes - -Switch themes via `fast-theme {theme-name}`. - -
- image could not be loaded -
- -Run `fast-theme -t {theme-name}` option to obtain the snippet above. - -Run `fast-theme -l` to list available themes. - -### Variables - -Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line): - -
- image could not be loaded -
- -
- image could not be loaded -
- -### Brackets - -
- image could not be loaded -
- -### Conditions - -Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line): - -
- image could not be loaded -
- -### Strings - -Exact highlighting that recognizes quotings. - -
- image could not be loaded -
- - -### here-strings - -
- image could not be loaded -
- -### `exec` descriptor-variables - -Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line): - -
- image could not be loaded -
- -### for-loops and alternate syntax (brace `{`/`}` blocks) - -
- image could not be loaded -
- -### Function definitions - -Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper 2 lines): - -
- image could not be loaded -
- -### Recursive `eval` and `$( )` highlighting - -Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line): - -
- image could not be loaded -
- -### Chroma functions - -Highlighting that is specific for a given command. - -
- image could not be loaded -
- -The [chromas](https://github.com/zdharma/fast-syntax-highlighting/tree/master/chroma) -that are enabled by default can be found -[here](https://github.com/zdharma/fast-syntax-highlighting/blob/master/fast-highlight#L166). - -### Math-mode highlighting - -
- image could not be loaded -
- -### Zcalc highlighting - -
- image could not be loaded -
- -# Performance -Performance differences can be observed in this Asciinema recording, where a `10 kB` function is being edited. - -
- - asciicast - -
- -## IRC Channel - -Channel `#zinit@freenode` is a support place for all author's projects. Connect to: -[chat.freenode.net:6697](ircs://chat.freenode.net:6697/%23zinit) (SSL) or [chat.freenode.net:6667](irc://chat.freenode.net:6667/%23zinit) - and join #zinit. - -Following is a quick access via Webchat [![IRC](https://kiwiirc.com/buttons/chat.freenode.net/zinit.png)](https://kiwiirc.com/client/chat.freenode.net:+6697/#zinit) diff --git a/.config/zsh/.zsh/fsh/THEME_GUIDE.md b/.config/zsh/.zsh/fsh/THEME_GUIDE.md deleted file mode 100644 index 1d66dac..0000000 --- a/.config/zsh/.zsh/fsh/THEME_GUIDE.md +++ /dev/null @@ -1,76 +0,0 @@ -# Theme Guide for F-Sy-H - -`fast-theme` tool is used to select a theme. There are 6 shipped themes, they can be listed with `fast-theme -l`. -Themes are basic [INI files](https://github.com/zdharma/fast-syntax-highlighting/tree/master/themes) where each -key is a *style*. -Besides shipped themes, user can point this tool to any other theme, by simple `fast-theme ~/mytheme.ini`. To -obtain template to work on when creating own theme, issue `fast-theme --copy-shipped-theme {theme-name}`. - -To alter just a few styles and not create a whole new theme, use **overlay**. What is overlay? It is in the same -format as full theme, but can have only a few styles defined, and these styles will overwrite styles in main-theme. -Example overlay file: - -```ini -; overlay.ini -[base] -commandseparator = yellow,bold -comment = 17 - -[command-point] -function = green -command = 180 -``` - -File name `overlay.ini` is treated specially. - -When specifing path, following short-hands can be used: - -``` -XDG: = ~/.config/fsh (respects $XDG_CONFIG_HOME env var) -LOCAL: = /usr/local/share/fsh/ -HOME: = ~/.fsh/ -OPT: = /opt/local/share/fsh/ -``` - -So for example, issue `fast-theme XDG:overlay` to load `~/.config/fsh/overlay.ini` as overlay. The `.ini` -extension is optional. - -## Secondary Theme - -Each theme has key `secondary`, e.g. for theme `free`: - -```ini -; free.ini -[base] -default = none -unknown-token = red,bold -; ... -; ... -; ... -secondary = zdharma -``` - -Secondary theme (`zdharma` in the example) will be used for highlighting of argument for `eval` -and of `$( ... )` interior (i.e. of interior of command substitution). Basically, recursive -highlighting uses alternate theme to make the highlighted code distinct: - -![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/cmdsubst.png) - -In the above screen-shot the interior of `$( ... )` uses different colors than the rest of the -code. Example for `eval`: - -![image](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/eval_cmp.png) - -First line doesn't use recursive highlighting, highlights `eval` argument as regular string. -Second line switches theme to `zdharma` and does full recursive highlighting of eval argument. - -## Custom Working Directory - -Set `$FAST_WORK_DIR` before loading the plugin to have e.g. processed theme files (ready to -load, in Zsh format, not INI) kept under specified location. This is handy if e.g. you install -Fast-Syntax-Highlighting system-wide (e.g. from AUR on ArchLinux) and want to have per-user -theme setup. - -You can use "~" in the path, e.g. `FAST_WORK_DIR=~/.fsh` and also the `XDG:`, `LOCAL:`, `OPT:`, -etc. short-hands, so e.g. `FAST_WORK_DIR=XDG` or `FAST_WORK_DIR=XDG:` is allowed (in this case -it will be changed to `$HOME/.config/fsh` by default by F-Sy-H loader). diff --git a/.config/zsh/.zsh/fsh/_fast-theme b/.config/zsh/.zsh/fsh/_fast-theme deleted file mode 100644 index 67f8a4d..0000000 --- a/.config/zsh/.zsh/fsh/_fast-theme +++ /dev/null @@ -1,39 +0,0 @@ -#compdef fast-theme - -# -# Copyright (c) 2018 Sebastian Gniazdowski -# -# Completion for theme-switching function, fast-theme, -# part of zdharma/fast-syntax-highlighting. -# - -integer ret=1 -local -a arguments - -arguments=( - {-h,--help}'[display help text]' - {-l,--list}'[list available themes]' - {-r,--reset}'[unset any theme (revert to default highlighting)]' - {-R,--ov-reset}'[unset overlay, use styles only from main-theme (requires restart)]' - {-q,--quiet}'[no default messages]' - {-s,--show}'[get and display the theme currently being set]' - {-v,--verbose}'[more messages during operation]' - {-t,--test}'[test theme after setting it (show example code)]' - {-p,--palette}'[just print all 256 colors and exit (useful when creating a theme)]' - {-w,--workdir}'[cd into $FAST_WORK_DIR (if not set, then into the plugin directory)]' -) - -typeset -a themes -themes=( "$FAST_WORK_DIR"/themes/*.ini(:t:r) ) - -if [[ -d ${XDG_CONFIG_HOME:-$HOME/.config}/fsh ]] { - typeset -a themes2 - themes2=( "${XDG_CONFIG_HOME:-$HOME/.config}"/fsh/*.ini(:t:r) ) - themes+=( XDG:${^themes2[@]} ) -} - -_wanted themes expl "Themes" \ - compadd "$@" -a - themes && ret=0 -_arguments -s $arguments && ret=0 - -return $ret diff --git a/.config/zsh/.zsh/fsh/fast-highlight b/.config/zsh/.zsh/fsh/fast-highlight deleted file mode 100644 index d47ed5b..0000000 --- a/.config/zsh/.zsh/fsh/fast-highlight +++ /dev/null @@ -1,1463 +0,0 @@ -# -*- mode: sh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors -# Copyright (c) 2016-2019 Sebastian Gniazdowski (modifications) -# All rights reserved. -# -# The only licensing for this file follows. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- - -typeset -gA __fast_highlight_main__command_type_cache FAST_BLIST_PATTERNS -typeset -g FAST_WORK_DIR -: ${FAST_WORK_DIR:=$FAST_BASE_DIR} -FAST_WORK_DIR=${~FAST_WORK_DIR} -() { - emulate -L zsh -o extendedglob - local -A map - map=( "XDG:" "${XDG_CONFIG_HOME:-$HOME/.config}/fsh/" - "LOCAL:" "/usr/local/share/fsh/" - "HOME:" "$HOME/.fsh/" - "OPT:" "/opt/local/share/fsh/" - ) - FAST_WORK_DIR=${${FAST_WORK_DIR/(#m)(#s)(XDG|LOCAL|HOME|OPT):(#c0,1)/${map[${MATCH%:}:]}}%/} -} - -# Define default styles. You can set this after loading the plugin in -# Zshrc and use 256 colors via numbers, like: fg=150 -typeset -gA FAST_HIGHLIGHT_STYLES -if [[ -e $FAST_WORK_DIR/current_theme.zsh ]]; then - source $FAST_WORK_DIR/current_theme.zsh -else -# built-in theme -zstyle :plugin:fast-syntax-highlighting theme default -: ${FAST_HIGHLIGHT_STYLES[default]:=none} -: ${FAST_HIGHLIGHT_STYLES[unknown-token]:=fg=red,bold} -: ${FAST_HIGHLIGHT_STYLES[reserved-word]:=fg=yellow} -: ${FAST_HIGHLIGHT_STYLES[subcommand]:=fg=yellow} -: ${FAST_HIGHLIGHT_STYLES[alias]:=fg=green} -: ${FAST_HIGHLIGHT_STYLES[suffix-alias]:=fg=green} -: ${FAST_HIGHLIGHT_STYLES[global-alias]:=bg=blue} -: ${FAST_HIGHLIGHT_STYLES[builtin]:=fg=green} -: ${FAST_HIGHLIGHT_STYLES[function]:=fg=green} -: ${FAST_HIGHLIGHT_STYLES[command]:=fg=green} -: ${FAST_HIGHLIGHT_STYLES[precommand]:=fg=green} -: ${FAST_HIGHLIGHT_STYLES[commandseparator]:=none} -: ${FAST_HIGHLIGHT_STYLES[hashed-command]:=fg=green} -: ${FAST_HIGHLIGHT_STYLES[path]:=fg=magenta} -: ${FAST_HIGHLIGHT_STYLES[path-to-dir]:=fg=magenta,underline} -: ${FAST_HIGHLIGHT_STYLES[path_pathseparator]:=} -: ${FAST_HIGHLIGHT_STYLES[globbing]:=fg=blue,bold} -: ${FAST_HIGHLIGHT_STYLES[globbing-ext]:=fg=13} -: ${FAST_HIGHLIGHT_STYLES[history-expansion]:=fg=blue,bold} -: ${FAST_HIGHLIGHT_STYLES[single-hyphen-option]:=fg=cyan} -: ${FAST_HIGHLIGHT_STYLES[double-hyphen-option]:=fg=cyan} -: ${FAST_HIGHLIGHT_STYLES[back-quoted-argument]:=none} -: ${FAST_HIGHLIGHT_STYLES[single-quoted-argument]:=fg=yellow} -: ${FAST_HIGHLIGHT_STYLES[double-quoted-argument]:=fg=yellow} -: ${FAST_HIGHLIGHT_STYLES[dollar-quoted-argument]:=fg=yellow} -: ${FAST_HIGHLIGHT_STYLES[back-or-dollar-double-quoted-argument]:=fg=cyan} -: ${FAST_HIGHLIGHT_STYLES[back-dollar-quoted-argument]:=fg=cyan} -: ${FAST_HIGHLIGHT_STYLES[assign]:=none} -: ${FAST_HIGHLIGHT_STYLES[redirection]:=none} -: ${FAST_HIGHLIGHT_STYLES[comment]:=fg=black,bold} -: ${FAST_HIGHLIGHT_STYLES[variable]:=fg=113} -: ${FAST_HIGHLIGHT_STYLES[mathvar]:=fg=blue,bold} -: ${FAST_HIGHLIGHT_STYLES[mathnum]:=fg=magenta} -: ${FAST_HIGHLIGHT_STYLES[matherr]:=fg=red} -: ${FAST_HIGHLIGHT_STYLES[assign-array-bracket]:=fg=green} -: ${FAST_HIGHLIGHT_STYLES[for-loop-variable]:=none} -: ${FAST_HIGHLIGHT_STYLES[for-loop-operator]:=fg=yellow} -: ${FAST_HIGHLIGHT_STYLES[for-loop-number]:=fg=magenta} -: ${FAST_HIGHLIGHT_STYLES[for-loop-separator]:=fg=yellow,bold} -: ${FAST_HIGHLIGHT_STYLES[here-string-tri]:=fg=yellow} -: ${FAST_HIGHLIGHT_STYLES[here-string-text]:=bg=18} -: ${FAST_HIGHLIGHT_STYLES[here-string-var]:=fg=cyan,bg=18} -: ${FAST_HIGHLIGHT_STYLES[case-input]:=fg=green} -: ${FAST_HIGHLIGHT_STYLES[case-parentheses]:=fg=yellow} -: ${FAST_HIGHLIGHT_STYLES[case-condition]:=bg=blue} -: ${FAST_HIGHLIGHT_STYLES[paired-bracket]:=bg=blue} -: ${FAST_HIGHLIGHT_STYLES[bracket-level-1]:=fg=green,bold} -: ${FAST_HIGHLIGHT_STYLES[bracket-level-2]:=fg=yellow,bold} -: ${FAST_HIGHLIGHT_STYLES[bracket-level-3]:=fg=cyan,bold} -: ${FAST_HIGHLIGHT_STYLES[single-sq-bracket]:=fg=green} -: ${FAST_HIGHLIGHT_STYLES[double-sq-bracket]:=fg=green} -: ${FAST_HIGHLIGHT_STYLES[double-paren]:=fg=yellow} -: ${FAST_HIGHLIGHT_STYLES[correct-subtle]:=fg=12} -: ${FAST_HIGHLIGHT_STYLES[incorrect-subtle]:=fg=red} -: ${FAST_HIGHLIGHT_STYLES[subtle-separator]:=fg=green} -: ${FAST_HIGHLIGHT_STYLES[subtle-bg]:=bg=18} -: ${FAST_HIGHLIGHT_STYLES[secondary]:=free} -fi - -# This can overwrite some of *_STYLES fields -[[ -r $FAST_WORK_DIR/theme_overlay.zsh ]] && source $FAST_WORK_DIR/theme_overlay.zsh - -typeset -gA __FAST_HIGHLIGHT_TOKEN_TYPES - -__FAST_HIGHLIGHT_TOKEN_TYPES=( - - # Precommand - - 'builtin' 1 - 'command' 1 - 'exec' 1 - 'nocorrect' 1 - 'noglob' 1 - 'pkexec' 1 # immune to #121 because it's usually not passed --option flags - - # Control flow - # Tokens that, at (naively-determined) "command position", are followed by - # a de jure command position. All of these are reserved words. - - $'\x7b' 2 # block '{' - $'\x28' 2 # subshell '(' - '()' 2 # anonymous function - 'while' 2 - 'until' 2 - 'if' 2 - 'then' 2 - 'elif' 2 - 'else' 2 - 'do' 2 - 'time' 2 - 'coproc' 2 - '!' 2 # reserved word; unrelated to $histchars[1] - - # Command separators - - '|' 3 - '||' 3 - ';' 3 - '&' 3 - '&&' 3 - '|&' 3 - '&!' 3 - '&|' 3 - # ### 'case' syntax, but followed by a pattern, not by a command - # ';;' ';&' ';|' -) - -# A hash instead of multiple globals -typeset -gA FAST_HIGHLIGHT - -# Brackets highlighter active by default -: ${FAST_HIGHLIGHT[use_brackets]:=1} - -FAST_HIGHLIGHT+=( - chroma-fast-theme →chroma/-fast-theme.ch - chroma-alias →chroma/-alias.ch - chroma-autoload →chroma/-autoload.ch - chroma-autorandr →chroma/-autorandr.ch - chroma-docker →chroma/-docker.ch - chroma-example →chroma/-example.ch - chroma-ionice →chroma/-ionice.ch - chroma-make →chroma/-make.ch - chroma-nice →chroma/-nice.ch - chroma-nmcli →chroma/-nmcli.ch - chroma-node →chroma/-node.ch - chroma-perl →chroma/-perl.ch - chroma-printf →chroma/-printf.ch - chroma-ruby →chroma/-ruby.ch - chroma-scp →chroma/-scp.ch - chroma-ssh →chroma/-ssh.ch - - chroma-git →chroma/main-chroma.ch%git - chroma-hub →chroma/-hub.ch - chroma-lab →chroma/-lab.ch - chroma-svn →chroma/-subversion.ch - chroma-svnadmin →chroma/-subversion.ch - chroma-svndumpfilter →chroma/-subversion.ch - - chroma-egrep →chroma/-grep.ch - chroma-fgrep →chroma/-grep.ch - chroma-grep →chroma/-grep.ch - - chroma-awk →chroma/-awk.ch - chroma-gawk →chroma/-awk.ch - chroma-mawk →chroma/-awk.ch - - chroma-source →chroma/-source.ch - chroma-. →chroma/-source.ch - - chroma-bash →chroma/-sh.ch - chroma-fish →chroma/-sh.ch - chroma-sh →chroma/-sh.ch - chroma-zsh →chroma/-sh.ch - - chroma-whatis →chroma/-whatis.ch - chroma-man →chroma/-whatis.ch - - chroma-- →chroma/-precommand.ch - chroma-xargs →chroma/-precommand.ch - chroma-nohup →chroma/-precommand.ch - chroma-strace →chroma/-precommand.ch - chroma-ltrace →chroma/-precommand.ch - - chroma-hg →chroma/-subcommand.ch - chroma-cvs →chroma/-subcommand.ch - chroma-pip →chroma/-subcommand.ch - chroma-pip2 →chroma/-subcommand.ch - chroma-pip3 →chroma/-subcommand.ch - chroma-gem →chroma/-subcommand.ch - chroma-bundle →chroma/-subcommand.ch - chroma-yard →chroma/-subcommand.ch - chroma-cabal →chroma/-subcommand.ch - chroma-npm →chroma/-subcommand.ch - chroma-nvm →chroma/-subcommand.ch - chroma-yarn →chroma/-subcommand.ch - chroma-brew →chroma/-subcommand.ch - chroma-port →chroma/-subcommand.ch - chroma-yum →chroma/-subcommand.ch - chroma-dnf →chroma/-subcommand.ch - chroma-tmux →chroma/-subcommand.ch - chroma-pass →chroma/-subcommand.ch - chroma-aws →chroma/-subcommand.ch - chroma-apt →chroma/-subcommand.ch - chroma-apt-get →chroma/-subcommand.ch - chroma-apt-cache →chroma/-subcommand.ch - chroma-aptitude →chroma/-subcommand.ch - chroma-keyctl →chroma/-subcommand.ch - chroma-systemctl →chroma/-subcommand.ch - chroma-asciinema →chroma/-subcommand.ch - chroma-ipfs →chroma/-subcommand.ch - chroma-zinit →chroma/main-chroma.ch%zinit - chroma-aspell →chroma/-subcommand.ch - chroma-bspc →chroma/-subcommand.ch - chroma-cryptsetup →chroma/-subcommand.ch - chroma-diskutil →chroma/-subcommand.ch - chroma-exercism →chroma/-subcommand.ch - chroma-gulp →chroma/-subcommand.ch - chroma-i3-msg →chroma/-subcommand.ch - chroma-openssl →chroma/-subcommand.ch - chroma-solargraph →chroma/-subcommand.ch - chroma-subliminal →chroma/-subcommand.ch - chroma-svnadmin →chroma/-subcommand.ch - chroma-travis →chroma/-subcommand.ch - chroma-udisksctl →chroma/-subcommand.ch - chroma-xdotool →chroma/-subcommand.ch - chroma-zmanage →chroma/-subcommand.ch - chroma-zsystem →chroma/-subcommand.ch - chroma-zypper →chroma/-subcommand.ch - - chroma-fpath+=\( →chroma/-fpath_peq.ch - chroma-fpath=\( →chroma/-fpath_peq.ch - chroma-FPATH+= →chroma/-fpath_peq.ch - chroma-FPATH= →chroma/-fpath_peq.ch - #chroma-which →chroma/-which.ch - #chroma-vim →chroma/-vim.ch -) - -if [[ $OSTYPE == darwin* ]] { - noglob unset FAST_HIGHLIGHT[chroma-man] FAST_HIGHLIGHT[chroma-whatis] -} - -# Assignments seen, to know if math parameter exists -typeset -gA FAST_ASSIGNS_SEEN - -# Exposing tokens found on command position, -# for other scripts to process -typeset -ga ZLAST_COMMANDS - -# Get the type of a command. -# -# Uses the zsh/parameter module if available to avoid forks, and a -# wrapper around 'type -w' as fallback. -# -# Takes a single argument. -# -# The result will be stored in REPLY. --fast-highlight-main-type() { - REPLY=$__fast_highlight_main__command_type_cache[(e)$1] - [[ -z $REPLY ]] && { - - if zmodload -e zsh/parameter; then - if (( $+aliases[(e)$1] )); then - REPLY=alias - elif (( ${+galiases[(e)$1]} )); then - REPLY="global alias" - elif (( $+functions[(e)$1] )); then - REPLY=function - elif (( $+builtins[(e)$1] )); then - REPLY=builtin - elif (( $+commands[(e)$1] )); then - REPLY=command - elif (( $+saliases[(e)${1##*.}] )); then - REPLY='suffix alias' - elif (( $reswords[(Ie)$1] )); then - REPLY=reserved - # zsh 5.2 and older have a bug whereby running 'type -w ./sudo' implicitly - # runs 'hash ./sudo=/usr/local/bin/./sudo' (assuming /usr/local/bin/sudo - # exists and is in $PATH). Avoid triggering the bug, at the expense of - # falling through to the $() below, incurring a fork. (Issue #354.) - # - # The second disjunct mimics the isrelative() C call from the zsh bug. - elif [[ $1 != */* || ${+ZSH_ARGZERO} = "1" ]] && ! builtin type -w -- $1 >/dev/null 2>&1; then - REPLY=none - fi - fi - - [[ -z $REPLY ]] && REPLY="${$(LC_ALL=C builtin type -w -- $1 2>/dev/null)##*: }" - - [[ $REPLY = "none" ]] && { - [[ -n ${FAST_BLIST_PATTERNS[(k)${${(M)1:#/*}:-$PWD/$1}]} ]] || { - [[ -d $1 ]] && REPLY="dirpath" || { - for cdpath_dir in $cdpath; do - [[ -d $cdpath_dir/$1 ]] && { REPLY="dirpath"; break; } - done - } - } - } - - __fast_highlight_main__command_type_cache[(e)$1]=$REPLY - - } -} - -# Below are variables that must be defined in outer -# scope so that they are reachable in *-process() --fast-highlight-fill-option-variables() { - if [[ -o ignore_braces ]] || eval '[[ -o ignore_close_braces ]] 2>/dev/null'; then - FAST_HIGHLIGHT[right_brace_is_recognised_everywhere]=0 - else - FAST_HIGHLIGHT[right_brace_is_recognised_everywhere]=1 - fi - - if [[ -o path_dirs ]]; then - FAST_HIGHLIGHT[path_dirs_was_set]=1 - else - FAST_HIGHLIGHT[path_dirs_was_set]=0 - fi - - if [[ -o multi_func_def ]]; then - FAST_HIGHLIGHT[multi_func_def]=1 - else - FAST_HIGHLIGHT[multi_func_def]=0 - fi - - if [[ -o interactive_comments ]]; then - FAST_HIGHLIGHT[ointeractive_comments]=1 - else - FAST_HIGHLIGHT[ointeractive_comments]=0 - fi -} - -# Main syntax highlighting function. --fast-highlight-process() -{ - emulate -L zsh - setopt extendedglob bareglobqual nonomatch typesetsilent - - [[ $CONTEXT == "select" ]] && return 0 - - (( FAST_HIGHLIGHT[path_dirs_was_set] )) && setopt PATH_DIRS - (( FAST_HIGHLIGHT[ointeractive_comments] )) && local interactive_comments= # _set_ to empty - - # Variable declarations and initializations - # in_array_assignment true between 'a=(' and the matching ')' - # braces_stack: "R" for round, "Q" for square, "Y" for curly - # _mybuf, cdpath_dir are used in sub-functions - local _start_pos=$3 _end_pos __start __end highlight_glob=1 __arg __style in_array_assignment=0 MATCH expanded_path braces_stack __buf=$1$2 _mybuf __workbuf cdpath_dir active_command alias_target _was_double_hyphen=0 __nul=$'\0' __tmp - # __arg_type can be 0, 1, 2 or 3, i.e. precommand, control flow, command separator - # __idx and _end_idx are used in sub-functions - # for this_word and next_word look below at commented integers and at state machine description - integer __arg_type=0 MBEGIN MEND in_redirection __len=${#__buf} __PBUFLEN=${#1} already_added offset __idx _end_idx this_word=1 next_word=0 __pos __asize __delimited=0 itmp iitmp - local -a match mbegin mend __inputs __list - - # This comment explains the numbers: - # BIT_for - word after reserved-word-recognized `for' - # BIT_afpcmd - word after a precommand that can take options, like `command' and `exec' - # integer BIT_start=1 BIT_regular=2 BIT_sudo_opt=4 BIT_sudo_arg=8 BIT_always=16 BIT_for=32 BIT_afpcmd=64 - # integer BIT_chroma=8192 - - integer BIT_case_preamble=512 BIT_case_item=1024 BIT_case_nempty_item=2048 BIT_case_code=4096 - - # Braces stack - # T - typeset, local, etc. - - # State machine - # - # The states are: - # - :__start: Command word - # - :sudo_opt: A leading-dash option to sudo (such as "-u" or "-i") - # - :sudo_arg: The argument to a sudo leading-dash option that takes one, - # when given as a separate word; i.e., "foo" in "-u foo" (two - # words) but not in "-ufoo" (one word). - # - :regular: "Not a command word", and command delimiters are permitted. - # Mainly used to detect premature termination of commands. - # - :always: The word 'always' in the «{ foo } always { bar }» syntax. - # - # When the kind of a word is not yet known, $this_word / $next_word may contain - # multiple states. For example, after "sudo -i", the next word may be either - # another --flag or a command name, hence the state would include both :__start: - # and :sudo_opt:. - # - # The tokens are always added with both leading and trailing colons to serve as - # word delimiters (an improvised array); [[ $x == *:foo:* ]] and x=${x//:foo:/} - # will DTRT regardless of how many elements or repetitions $x has.. - # - # Handling of redirections: upon seeing a redirection token, we must stall - # the current state --- that is, the value of $this_word --- for two iterations - # (one for the redirection operator, one for the word following it representing - # the redirection target). Therefore, we set $in_redirection to 2 upon seeing a - # redirection operator, decrement it each iteration, and stall the current state - # when it is non-zero. Thus, upon reaching the next word (the one that follows - # the redirection operator and target), $this_word will still contain values - # appropriate for the word immediately following the word that preceded the - # redirection operator. - # - # The "the previous word was a redirection operator" state is not communicated - # to the next iteration via $next_word/$this_word as usual, but via - # $in_redirection. The value of $next_word from the iteration that processed - # the operator is discarded. - # - - # Command exposure for other scripts - ZLAST_COMMANDS=() - # Restart observing of assigns - FAST_ASSIGNS_SEEN=() - # Restart function's gathering - FAST_HIGHLIGHT[chroma-autoload-elements]="" - # Restart FPATH elements gathering - FAST_HIGHLIGHT[chroma-fpath_peq-elements]="" - # Restart svn zinit's ICE gathering - FAST_HIGHLIGHT[chroma-zinit-ice-elements-svn]=0 - FAST_HIGHLIGHT[chroma-zinit-ice-elements-id-as]="" - - [[ -n $ZCALC_ACTIVE ]] && { - _start_pos=0; _end_pos=__len; __arg=$__buf - -fast-highlight-math-string - return 0 - } - - # Processing buffer - local proc_buf=$__buf needle - for __arg in ${interactive_comments-${(z)__buf}} \ - ${interactive_comments+${(zZ+c+)__buf}}; do - - # Initialize $next_word to its default value? - (( in_redirection = in_redirection > 0 ? in_redirection - 1 : in_redirection )); - (( next_word = (in_redirection == 0) ? 2 : next_word )) # else Stall $next_word. - (( next_word = next_word | (this_word & (BIT_case_code|8192)) )) - - # If we have a good delimiting construct just ending, and '{' - # occurs, then respect this and go for alternate syntax, i.e. - # treat '{' (\x7b) as if it's on command position - [[ $__arg = '{' && $__delimited = 2 ]] && { (( this_word = (this_word & ~2) | 1 )); __delimited=0; } - - __asize=${#__arg} - - # Reset state of working variables - already_added=0 - __style=${FAST_THEME_NAME}unknown-token - (( this_word & 1 )) && { in_array_assignment=0; [[ $__arg == 'noglob' ]] && highlight_glob=0; } - - # Compute the new $_start_pos and $_end_pos, skipping over whitespace in $__buf. - if [[ $__arg == ';' ]] ; then - braces_stack=${braces_stack#T} - __delimited=0 - - # Both ; and \n are rendered as a ";" (SEPER) by the ${(z)..} flag. - needle=$';\n' - [[ $proc_buf = (#b)[^$needle]#([$needle]##)* ]] && offset=${mbegin[1]}-1 - (( _start_pos += offset )) - (( _end_pos = _start_pos + __asize )) - - # Prepare next loop cycle - (( this_word & BIT_case_item )) || { (( in_array_assignment )) && (( this_word = 2 | (this_word & BIT_case_code) )) || { (( this_word = 1 | (this_word & BIT_case_code) )); highlight_glob=1; }; } - in_redirection=0 - - # Chance to highlight ';' - [[ ${proc_buf[offset+1]} != $'\n' ]] && { - [[ ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}commandseparator]} != "none" ]] && \ - (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}commandseparator]}") - } - - proc_buf=${proc_buf[offset + __asize + 1,__len]} - _start_pos=$_end_pos - continue - else - offset=0 - if [[ $proc_buf = (#b)(#s)(([[:space:]]|\\[[:space:]])##)* ]]; then - # The first, outer parenthesis - offset=${mend[1]} - fi - (( _start_pos += offset )) - (( _end_pos = _start_pos + __asize )) - - # No-hit will result in value 0 - __arg_type=${__FAST_HIGHLIGHT_TOKEN_TYPES[$__arg]} - fi - - (( this_word & 1 )) && ZLAST_COMMANDS+=( $__arg ); - - proc_buf=${proc_buf[offset + __asize + 1,__len]} - - # Handle the INTERACTIVE_COMMENTS option. - # - # We use the (Z+c+) flag so the entire comment is presented as one token in $__arg. - if [[ -n ${interactive_comments+'set'} && $__arg == ${histchars[3]}* ]]; then - if (( this_word & 3 )); then - __style=${FAST_THEME_NAME}comment - else - __style=${FAST_THEME_NAME}unknown-token # prematurely terminated - fi - # ADD - (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - _start_pos=$_end_pos - continue - fi - - # Redirection? - [[ $__arg == (<0-9>|)(\<|\>)* && $__arg != (\<|\>)$'\x28'* && $__arg != "<<<" ]] && \ - in_redirection=2 - - # Special-case the first word after 'sudo'. - if (( ! in_redirection )); then - (( this_word & 4 )) && [[ $__arg != -* ]] && (( this_word = this_word ^ 4 )) - - # Parse the sudo command line - if (( this_word & 4 )); then - case $__arg in - # Flag that requires an argument - '-'[Cgprtu]) - (( this_word = this_word & ~1 )) - (( next_word = 8 | (this_word & BIT_case_code) )) - ;; - # This prevents misbehavior with sudo -u -otherargument - '-'*) - (( this_word = this_word & ~1 )) - (( next_word = next_word | 1 | 4 )) - ;; - esac - elif (( this_word & 8 )); then - (( next_word = next_word | 4 | 1 )) - elif (( this_word & 64 )); then - [[ $__arg = -[pvV-]## && $active_command = "command" ]] && (( this_word = (this_word & ~1) | 2, next_word = (next_word | 65) & ~2 )) - [[ $__arg = -[cla-]## && $active_command = "exec" ]] && (( this_word = (this_word & ~1) | 2, next_word = (next_word | 65) & ~2 )) - [[ $__arg = \{[a-zA-Z_][a-zA-Z0-9_]#\} && $active_command = "exec" ]] && { - # Highlight {descriptor} passed to exec - (( this_word = (this_word & ~1) | 2, next_word = (next_word | 65) & ~2 )) - (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}exec-descriptor]}") - already_added=1 - } - fi - fi - - (( this_word & 8192 )) && { - __list=( ${(z@)${aliases[$active_command]:-${active_command##*/}}##[[:space:]]#(command|builtin|exec|noglob|nocorrect|pkexec)[[:space:]]#} ) - ${${FAST_HIGHLIGHT[chroma-${__list[1]}]}%\%*} ${(M)FAST_HIGHLIGHT[chroma-${__list[1]}]%\%*} 0 "$__arg" $_start_pos $_end_pos 2>/dev/null && continue - } - - (( this_word & 1 )) && { - # !in_redirection needed particularly for exec {A}>b {C}>d - (( !in_redirection )) && active_command=$__arg - _mybuf=${${aliases[$active_command]:-${active_command##*/}}##[[:space:]]#(command|builtin|exec|noglob|nocorrect|pkexec)[[:space:]]#} - [[ "$_mybuf" = (#b)(FPATH+(#c0,1)=)* ]] && _mybuf="${match[1]} ${(j: :)${(s,:,)${_mybuf#FPATH+(#c0,1)=}}}" - [[ -n ${FAST_HIGHLIGHT[chroma-${_mybuf%% *}]} ]] && { - __list=( ${(z@)_mybuf} ) - if (( ${#__list} > 1 )) || [[ $active_command != $_mybuf ]]; then - __style=${FAST_THEME_NAME}alias - (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - - ${${FAST_HIGHLIGHT[chroma-${__list[1]}]}%\%*} ${(M)FAST_HIGHLIGHT[chroma-${__list[1]}]%\%*} 1 "${__list[1]}" "-100000" $_end_pos 2>/dev/null || \ - (( this_word = next_word, next_word = 2 )) - - for _mybuf in "${(@)__list[2,-1]}"; do - (( next_word = next_word | (this_word & (BIT_case_code|8192)) )) - ${${FAST_HIGHLIGHT[chroma-${__list[1]}]}%\%*} ${(M)FAST_HIGHLIGHT[chroma-${__list[1]}]%\%*} 0 "$_mybuf" "-100000" $_end_pos 2>/dev/null || \ - (( this_word = next_word, next_word = 2 )) - done - - # This might have been done multiple times in chroma, but - # as _end_pos doesn't change, it can be done one more time - _start_pos=$_end_pos - - continue - else - ${${FAST_HIGHLIGHT[chroma-${__list[1]}]}%\%*} ${(M)FAST_HIGHLIGHT[chroma-${__list[1]}]%\%*} 1 "$__arg" $_start_pos $_end_pos 2>/dev/null && continue - fi - } || (( 1 )) - } - - expanded_path="" - - # The Great Fork: is this a command word? Is this a non-command word? - if (( this_word & 16 )) && [[ $__arg == 'always' ]]; then - # try-always construct - __style=${FAST_THEME_NAME}reserved-word # de facto a reserved word, although not de jure - (( next_word = 1 | (this_word & BIT_case_code) )) - elif (( (this_word & 1) && (in_redirection == 0) )) || [[ $braces_stack = T* ]]; then # T - typedef, etc. - if (( __arg_type == 1 )); then - __style=${FAST_THEME_NAME}precommand - [[ $__arg = "command" || $__arg = "exec" ]] && (( next_word = next_word | 64 )) - elif [[ $__arg = (sudo|doas) ]]; then - __style=${FAST_THEME_NAME}precommand - (( next_word = (next_word & ~2) | 4 | 1 )) - else - _mybuf=${${(Q)__arg}#\"} - if (( ${+parameters} )) && \ - [[ $_mybuf = (#b)(*)(*)\$([a-zA-Z_][a-zA-Z0-9_]#|[0-9]##)(*) || \ - $_mybuf = (#b)(*)(*)\$\{([a-zA-Z_][a-zA-Z0-9_:-]#|[0-9]##)(*) ]] && \ - (( ${+parameters[${match[3]%%:-*}]} )) - then - -fast-highlight-main-type ${match[1]}${match[2]}${(P)match[3]%%:-*}${match[4]#\}} - elif [[ $braces_stack = T* ]]; then # T - typedef, etc. - REPLY=none - else - : ${expanded_path::=${~_mybuf}} - -fast-highlight-main-type $expanded_path - fi - - case $REPLY in - reserved) # reserved word - [[ $__arg = "[[" ]] && __style=${FAST_THEME_NAME}double-sq-bracket || __style=${FAST_THEME_NAME}reserved-word - if [[ $__arg == $'\x7b' ]]; then # Y - '{' - braces_stack='Y'$braces_stack - - elif [[ $__arg == $'\x7d' && $braces_stack = Y* ]]; then # Y - '}' - # We're at command word, so no need to check right_brace_is_recognised_everywhere - braces_stack=${braces_stack#Y} - __style=${FAST_THEME_NAME}reserved-word - (( next_word = next_word | 16 )) - - elif [[ $__arg == "[[" ]]; then # A - [[ - braces_stack='A'$braces_stack - - # Counting complex brackets (for brackets-highlighter): 1. [[ as command - _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) $(( _start_pos-__PBUFLEN + 1 )) ) - elif [[ $__arg == "for" ]]; then - (( next_word = next_word | 32 )) # BIT_for - - elif [[ $__arg == "case" ]]; then - (( next_word = BIT_case_preamble )) - - elif [[ $__arg = (typeset|declare|local|float|integer|export|readonly) ]]; then - braces_stack='T'$braces_stack - fi - ;; - 'suffix alias') __style=${FAST_THEME_NAME}suffix-alias;; - 'global alias') __style=${FAST_THEME_NAME}global-alias;; - - alias) - if [[ $__arg = ?*'='* ]]; then - # The so called (by old code) "insane_alias" - __style=${FAST_THEME_NAME}unknown-token - else - __style=${FAST_THEME_NAME}alias - (( ${+aliases} )) && alias_target=${aliases[$__arg]} || alias_target="${"$(alias -- $__arg)"#*=}" - [[ ${__FAST_HIGHLIGHT_TOKEN_TYPES[$alias_target]} = "1" && $__arg_type != "1" ]] && __FAST_HIGHLIGHT_TOKEN_TYPES[$__arg]="1" - fi - ;; - - builtin) [[ $__arg = "[" ]] && { - __style=${FAST_THEME_NAME}single-sq-bracket - _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) ) - } || __style=${FAST_THEME_NAME}builtin - # T - typeset, etc. mode - [[ $__arg = (typeset|declare|local|float|integer|export|readonly) ]] && braces_stack='T'$braces_stack - [[ $__arg = eval ]] && (( next_word = next_word | 256 )) - ;; - - function) __style=${FAST_THEME_NAME}function;; - - command) __style=${FAST_THEME_NAME}command;; - - hashed) __style=${FAST_THEME_NAME}hashed-command;; - - dirpath) __style=${FAST_THEME_NAME}path-to-dir;; - - none) # Assign? - if [[ $__arg == [a-zA-Z_][a-zA-Z0-9_]#(|\[[^\]]#\])(|[^\]]#\])(|[+])=* || $__arg == [0-9]##(|[+])=* || ( $braces_stack = T* && ${__arg_type} != 3 ) ]] { - __style=${FAST_THEME_NAME}assign - FAST_ASSIGNS_SEEN[${__arg%%=*}]=1 - - # Handle array assignment - [[ $__arg = (#b)*=(\()*(\))* || $__arg = (#b)*=(\()* ]] && { - (( __start=_start_pos-__PBUFLEN+${mbegin[1]}-1, __end=__start+1, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}assign-array-bracket]}") - # Counting complex brackets (for brackets-highlighter): 2. ( in array assign - _FAST_COMPLEX_BRACKETS+=( $__start ) - (( mbegin[2] >= 1 )) && { - (( __start=_start_pos-__PBUFLEN+${mbegin[2]}-1, __end=__start+1, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}assign-array-bracket]}") - # Counting complex brackets (for brackets-highlighter): 3a. ) in array assign - _FAST_COMPLEX_BRACKETS+=( $__start ) - } || in_array_assignment=1 - } || { [[ ${braces_stack[1]} != 'T' ]] && (( next_word = (next_word | 1) & ~2 )); } - - # Handle no-string highlight, string "/' highlight, math mode highlight - local ctmp="\"" dtmp="'" - itmp=${__arg[(i)$ctmp]}-1 iitmp=${__arg[(i)$dtmp]}-1 - integer jtmp=${__arg[(b:itmp+2:i)$ctmp]} jjtmp=${__arg[(b:iitmp+2:i)$dtmp]} - (( itmp < iitmp && itmp <= __asize - 1 )) && (( jtmp > __asize && (jtmp = __asize), 1 > 0 )) && \ - (( __start=_start_pos-__PBUFLEN+itmp, __end=_start_pos-__PBUFLEN+jtmp, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}") && \ - { itmp=${__arg[(i)=]}; __arg=${__arg[itmp,__asize]}; (( _start_pos += itmp - 1 )); - -fast-highlight-string; (( _start_pos = _start_pos - itmp + 1, 1 > 0 )); } || \ - { - (( iitmp <= __asize - 1 )) && (( jjtmp > __asize && (jjtmp = __asize), 1 > 0 )) && \ - (( __start=_start_pos-__PBUFLEN+iitmp, __end=_start_pos-__PBUFLEN+jjtmp, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}single-quoted-argument]}") - } || \ - { - itmp=${__arg[(i)=]}; __arg=${__arg[itmp,__asize]}; (( _start_pos += itmp - 1 )); - [[ ${__arg[2,4]} = '$((' ]] && { -fast-highlight-math-string; - (( __start=_start_pos-__PBUFLEN+2, __end=__start+2, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-paren]}") - # Counting complex brackets (for brackets-highlighter): 4. $(( in assign argument - _FAST_COMPLEX_BRACKETS+=( $__start $(( __start + 1 )) ) - (( jtmp = ${__arg[(I)\)\)]}-1, jtmp > 0 )) && { - (( __start=_start_pos-__PBUFLEN+jtmp, __end=__start+2, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-paren]}") - # Counting complex brackets (for brackets-highlighter): 5. )) in assign argument - _FAST_COMPLEX_BRACKETS+=( $__start $(( __start + 1 )) ) - } - } || -fast-highlight-string; - (( _start_pos = _start_pos - itmp + 1, 1 > 0 )) - } - - } elif [[ $__arg = ${histchars[1]}* && -n ${__arg[2]} ]] { - __style=${FAST_THEME_NAME}history-expansion - - } elif [[ $__arg == ${histchars[2]}* ]] { - __style=${FAST_THEME_NAME}history-expansion - - } elif (( __arg_type == 3 )) { - # This highlights empty commands (semicolon follows nothing) as an error. - # Zsh accepts them, though. - (( this_word & 3 )) && __style=${FAST_THEME_NAME}commandseparator - - } elif [[ $__arg[1,2] == '((' ]] { - # Arithmetic evaluation. - # - # Note: prior to zsh-5.1.1-52-g4bed2cf (workers/36669), the ${(z)...} - # splitter would only output the '((' token if the matching '))' had - # been typed. Therefore, under those versions of zsh, BUFFER="(( 42" - # would be highlighted as an error until the matching "))" are typed. - # - # We highlight just the opening parentheses, as a reserved word; this - # is how [[ ... ]] is highlighted, too. - - # ADD - (( __start=_start_pos-__PBUFLEN, __end=__start+2, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-paren]}") - already_added=1 - - # Counting complex brackets (for brackets-highlighter): 6. (( as command - _FAST_COMPLEX_BRACKETS+=( $__start $(( __start + 1 )) ) - - -fast-highlight-math-string - - # ADD - [[ $__arg[-2,-1] == '))' ]] && { - (( __start=_end_pos-__PBUFLEN-2, __end=__start+2, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-paren]}") - (( __delimited = __delimited ? 2 : __delimited )) - - # Counting complex brackets (for brackets-highlighter): 7. )) for as-command (( - _FAST_COMPLEX_BRACKETS+=( $__start $(( __start + 1 )) ) - } - - } elif [[ $__arg == '()' ]] { - _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) $(( _start_pos-__PBUFLEN + 1 )) ) - # anonymous function - __style=${FAST_THEME_NAME}reserved-word - } elif [[ $__arg == $'\x28' ]] { - # subshell '(', stack: letter 'R' - __style=${FAST_THEME_NAME}reserved-word - braces_stack='R'$braces_stack - - } elif [[ $__arg == $'\x29' ]] { - # ')', stack: letter 'R' for subshell - [[ $braces_stack = R* ]] && { braces_stack=${braces_stack#R}; __style=${FAST_THEME_NAME}reserved-word; } - - } elif (( this_word & 14 )) { - __style=${FAST_THEME_NAME}default - - } elif [[ $__arg = (';;'|';&'|';|') ]] && (( this_word & BIT_case_code )) { - (( next_word = (next_word | BIT_case_item) & ~(BIT_case_code+3) )) - __style=${FAST_THEME_NAME}default - - } elif [[ $__arg = \$\([^\(]* ]] { - already_added=1 - } - ;; - *) - # ADD - # (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end commandtypefromthefuture-$REPLY") - already_added=1 - ;; - esac - fi - # in_redirection || BIT_regular || BIT_sudo_opt || BIT_sudo_arg - elif (( in_redirection + this_word & 14 )) - then # $__arg is a non-command word - case $__arg in - ']]') - # A - [[ - [[ $braces_stack = A* ]] && { - __style=${FAST_THEME_NAME}double-sq-bracket - (( __delimited = __delimited ? 2 : __delimited )) - # Counting complex brackets (for brackets-highlighter): 8a. ]] for as-command [[ - _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) $(( _start_pos-__PBUFLEN+1 )) ) - } || { - [[ $braces_stack = *A* ]] && { - __style=${FAST_THEME_NAME}unknown-token - # Counting complex brackets (for brackets-highlighter): 8b. ]] for as-command [[ - _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) $(( _start_pos-__PBUFLEN+1 )) ) - } || __style=${FAST_THEME_NAME}default - } - braces_stack=${braces_stack#A} - ;; - ']') - __style=${FAST_THEME_NAME}single-sq-bracket - _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) ) - ;; - $'\x28') - # '(' inside [[ - __style=${FAST_THEME_NAME}reserved-word - braces_stack='R'$braces_stack - ;; - $'\x29') # ')' - subshell or end of array assignment - if (( in_array_assignment )); then - in_array_assignment=0 - (( next_word = next_word | 1 )) - (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}assign-array-bracket]}") - already_added=1 - # Counting complex brackets (for brackets-highlighter): 3b. ) in array assign - _FAST_COMPLEX_BRACKETS+=( $__start ) - elif [[ $braces_stack = R* ]]; then - braces_stack=${braces_stack#R} - __style=${FAST_THEME_NAME}reserved-word - # Zsh doesn't tokenize final ) if it's just single ')', - # but logically what's below is correct, so it is kept - # in case Zsh will be changed / fixed, etc. - elif [[ $braces_stack = F* ]]; then - __style=${FAST_THEME_NAME}builtin - fi - ;; - $'\x28\x29') # '()' - possibly a function definition - # || false # TODO: or if the previous word was a command word - (( FAST_HIGHLIGHT[multi_func_def] )) && (( next_word = next_word | 1 )) - __style=${FAST_THEME_NAME}reserved-word - _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) $(( _start_pos-__PBUFLEN + 1 )) ) - # Remove possible annoying unknown-token __style, or misleading function __style - reply[-1]=() - __fast_highlight_main__command_type_cache[$active_command]="function" - ;; - '--'*) [[ $__arg == "--" ]] && { _was_double_hyphen=1; __style=${FAST_THEME_NAME}double-hyphen-option; } || { - (( !_was_double_hyphen )) && { - [[ "$__arg" = (#b)(--[a-zA-Z0-9_]##)=(*) ]] && { - (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-hyphen-option]}") - (( __start=_start_pos-__PBUFLEN+1+mend[1], __end=_end_pos-__PBUFLEN, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}optarg-${${${(M)match[2]:#<->}:+number}:-string}]}") - already_added=1 - } || __style=${FAST_THEME_NAME}double-hyphen-option - } || __style=${FAST_THEME_NAME}default - } - ;; - '-'*) (( !_was_double_hyphen )) && __style=${FAST_THEME_NAME}single-hyphen-option || __style=${FAST_THEME_NAME}default;; - \$\'*) - (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}dollar-quoted-argument]}") - -fast-highlight-dollar-string - already_added=1 - ;; - [\"\']*|[^\"\\]##([\\][\\])#\"*|[^\'\\]##([\\][\\])#\'*) - # 256 is eval-mode - if (( this_word & 256 )) && [[ $__arg = [\'\"]* ]]; then - (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}recursive-base]}") - if [[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}secondary]} ]]; then - __idx=1 - _mybuf=$FAST_THEME_NAME - FAST_THEME_NAME=${${${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}secondary]}:t:r}#(XDG|LOCAL|HOME|OPT):} - (( ${+FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}default]} )) || source $FAST_WORK_DIR/secondary_theme.zsh - else - __idx=0 - fi - (( _start_pos-__PBUFLEN >= 0 )) && \ - -fast-highlight-process "$PREBUFFER" "${${__arg%[\'\"]}#[\'\"]}" $(( _start_pos + 1 )) - (( __idx )) && FAST_THEME_NAME=$_mybuf - already_added=1 - else - [[ $__arg = *([^\\][\#][\#]|"(#b)"|"(#B)"|"(#m)"|"(#c")* && $highlight_glob -ne 0 ]] && \ - (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}globbing-ext]}") - # Reusing existing vars, treat this code like C++ STL - # header, full of underscores and unhelpful var names - itmp=0 __workbuf=$__arg __tmp="" cdpath_dir=$__arg - while [[ $__workbuf = (#b)[^\"\'\\]#(([\"\'])|[\\](*))(*) ]]; do - [[ -n ${match[3]} ]] && { - itmp+=${mbegin[1]} - # Optionally skip 1 quoted char - [[ $__tmp = \' ]] && __workbuf=${match[3]} || { itmp+=1; __workbuf=${match[3]:1}; } - } || { - itmp+=${mbegin[1]} - __workbuf=${match[4]} - # Toggle quoting - [[ ( ${match[1]} = \" && $__tmp != \' ) || ( ${match[1]} = \' && $__tmp != \" ) ]] && { - [[ $__tmp = [\"\'] ]] && { - # End of quoting - (( __start=_start_pos-__PBUFLEN+iitmp-1, __end=_start_pos-__PBUFLEN+itmp, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}${${${__tmp#\'}:+double-quoted-argument}:-single-quoted-argument}]}") - already_added=1 - - [[ $__tmp = \" ]] && { - __arg=${cdpath_dir[iitmp+1,itmp-1]} - (( _start_pos += iitmp - 1 + 1 )) - -fast-highlight-string - (( _start_pos = _start_pos - iitmp + 1 - 1 )) - } - # The end-of-quoting proper algorithm action - __tmp= - } || { - # Beginning of quoting - iitmp=itmp - # The beginning-of-quoting proper algorithm action - __tmp=${match[1]} - } - } - } - done - [[ $__tmp = [\"\'] ]] && { - (( __start=_start_pos-__PBUFLEN+iitmp-1, __end=_start_pos-__PBUFLEN+__asize, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}${${${__tmp#\'}:+double-quoted-argument}:-single-quoted-argument}]}") - already_added=1 - - [[ $__tmp = \" ]] && { - __arg=${cdpath_dir[iitmp+1,__asize]} - (( _start_pos += iitmp - 1 + 1 )) - -fast-highlight-string - (( _start_pos = _start_pos - iitmp + 1 - 1 )) - } - } - fi - ;; - \$\(\(*) - already_added=1 - -fast-highlight-math-string - # ADD - (( __start=_start_pos-__PBUFLEN+1, __end=__start+2, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-paren]}") - # Counting complex brackets (for brackets-highlighter): 9. $(( as argument - _FAST_COMPLEX_BRACKETS+=( $__start $(( __start + 1 )) ) - # ADD - [[ $__arg[-2,-1] == '))' ]] && (( __start=_end_pos-__PBUFLEN-2, __end=__start+2, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-paren]}") - # Counting complex brackets (for brackets-highlighter): 10. )) for as-argument $(( - _FAST_COMPLEX_BRACKETS+=( $__start $(( __start + 1 )) ) - ;; - '`'*) - (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}back-quoted-argument]}") - if [[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}secondary]} ]]; then - __idx=1 - _mybuf=$FAST_THEME_NAME - FAST_THEME_NAME=${${${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}secondary]}:t:r}#(XDG|LOCAL|HOME|OPT):} - (( ${+FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}default]} )) || source $FAST_WORK_DIR/secondary_theme.zsh - else - __idx=0 - fi - (( _start_pos-__PBUFLEN >= 0 )) && \ - -fast-highlight-process "$PREBUFFER" "${${__arg%[\`]}#[\`]}" $(( _start_pos + 1 )) - (( __idx )) && FAST_THEME_NAME=$_mybuf - already_added=1 - ;; - '((') # 'F' - (( after for - (( this_word & 32 )) && { - braces_stack='F'$braces_stack - __style=${FAST_THEME_NAME}double-paren - # Counting complex brackets (for brackets-highlighter): 11. (( as for-syntax - _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) $(( _start_pos-__PBUFLEN+1 )) ) - # This is set after __arg_type == 2, and also here, - # when another alternate-syntax capable command occurs - __delimited=1 - } - ;; - '))') # 'F' - (( after for - [[ $braces_stack = F* ]] && { - braces_stack=${braces_stack#F} - __style=${FAST_THEME_NAME}double-paren - # Counting complex brackets (for brackets-highlighter): 12. )) as for-syntax - _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) $(( _start_pos-__PBUFLEN+1 )) ) - (( __delimited = __delimited ? 2 : __delimited )) - } - ;; - '<<<') - (( next_word = (next_word | 128) & ~3 )) - [[ ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}here-string-tri]} != "none" ]] && (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}here-string-tri]}") - already_added=1 - ;; - *) # F - (( after for - if [[ $braces_stack = F* ]]; then - -fast-highlight-string - _mybuf=$__arg - __idx=_start_pos - while [[ $_mybuf = (#b)[^a-zA-Z\{\$]#([a-zA-Z][a-zA-Z0-9]#)(*) ]]; do - (( __start=__idx-__PBUFLEN+${mbegin[1]}-1, __end=__idx-__PBUFLEN+${mend[1]}+1-1, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-variable]}") - __idx+=${mend[1]} - _mybuf=${match[2]} - done - - _mybuf=$__arg - __idx=_start_pos - while [[ $_mybuf = (#b)[^+\<\>=:\*\|\&\^\~-]#([+\<\>=:\*\|\&\^\~-]##)(*) ]]; do - (( __start=__idx-__PBUFLEN+${mbegin[1]}-1, __end=__idx-__PBUFLEN+${mend[1]}+1-1, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-operator]}") - __idx+=${mend[1]} - _mybuf=${match[2]} - done - - _mybuf=$__arg - __idx=_start_pos - while [[ $_mybuf = (#b)[^0-9]#([0-9]##)(*) ]]; do - (( __start=__idx-__PBUFLEN+${mbegin[1]}-1, __end=__idx-__PBUFLEN+${mend[1]}+1-1, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-number]}") - __idx+=${mend[1]} - _mybuf=${match[2]} - done - - if [[ $__arg = (#b)[^\;]#(\;)[\ ]# ]]; then - (( __start=_start_pos-__PBUFLEN+${mbegin[1]}-1, __end=_start_pos-__PBUFLEN+${mend[1]}+1-1, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-separator]}") - fi - - already_added=1 - elif [[ $__arg = *([^\\][\#][\#]|"(#b)"|"(#B)"|"(#m)"|"(#c")* ]]; then - (( highlight_glob )) && __style=${FAST_THEME_NAME}globbing-ext || __style=${FAST_THEME_NAME}default - elif [[ $__arg = ([*?]*|*[^\\][*?]*) ]]; then - (( highlight_glob )) && __style=${FAST_THEME_NAME}globbing || __style=${FAST_THEME_NAME}default - elif [[ $__arg = \$* ]]; then - __style=${FAST_THEME_NAME}variable - elif [[ $__arg = $'\x7d' && $braces_stack = Y* && ${FAST_HIGHLIGHT[right_brace_is_recognised_everywhere]} = "1" ]]; then - # right brace, i.e. $'\x7d' == '}' - # Parsing rule: # { - # - # Additionally, `tt(})' is recognized in any position if neither the - # tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set.""" - braces_stack=${braces_stack#Y} - __style=${FAST_THEME_NAME}reserved-word - (( next_word = next_word | 16 )) - elif [[ $__arg = (';;'|';&'|';|') ]] && (( this_word & BIT_case_code )); then - (( next_word = (next_word | BIT_case_item) & ~(BIT_case_code+3) )) - __style=${FAST_THEME_NAME}default - elif [[ $__arg = ${histchars[1]}* && -n ${__arg[2]} ]]; then - __style=${FAST_THEME_NAME}history-expansion - elif (( __arg_type == 3 )); then - __style=${FAST_THEME_NAME}commandseparator - elif (( in_redirection == 2 )); then - __style=${FAST_THEME_NAME}redirection - elif (( ${+galiases[(e)$__arg]} )); then - __style=${FAST_THEME_NAME}global-alias - else - if [[ ${FAST_HIGHLIGHT[no_check_paths]} != 1 ]]; then - if [[ ${FAST_HIGHLIGHT[use_async]} != 1 ]]; then - if -fast-highlight-check-path noasync; then - # ADD - (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - already_added=1 - - # TODO: path separators, optimize and add to async code-path - [[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} && ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]} != ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} ]] && { - for (( __pos = _start_pos; __pos <= _end_pos; __pos++ )) ; do - # ADD - [[ ${__buf[__pos]} == "/" ]] && (( __start=__pos-__PBUFLEN, __start >= 0 )) && reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}") - done - } - else - __style=${FAST_THEME_NAME}default - fi - else - if [[ -z ${FAST_HIGHLIGHT[cache-path-${(q)__arg}-${_start_pos}]} || $(( EPOCHSECONDS - FAST_HIGHLIGHT[cache-path-${(q)__arg}-${_start_pos}-born-at] )) -gt 8 ]]; then - if [[ $LASTWIDGET != *-or-beginning-search ]]; then - exec {PCFD}< <(-fast-highlight-check-path; sleep 5) - command sleep 0 - FAST_HIGHLIGHT[path-queue]+=";$_start_pos $_end_pos;" - is-at-least 5.0.6 && __pos=1 || __pos=0 - zle -F ${${__pos:#0}:+-w} $PCFD fast-highlight-check-path-handler - already_added=1 - else - __style=${FAST_THEME_NAME}default - fi - elif [[ ${FAST_HIGHLIGHT[cache-path-${(q)__arg}-${_start_pos}]%D} -eq 1 ]]; then - (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path${${(M)FAST_HIGHLIGHT[cache-path-${(q)__arg}-${_start_pos}]%D}:+-to-dir}]}") - already_added=1 - else - __style=${FAST_THEME_NAME}default - fi - fi - else - __style=${FAST_THEME_NAME}default - fi - fi - ;; - esac - elif (( this_word & 128 )) - then - (( next_word = (next_word | 2) & ~129 )) - [[ ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}here-string-text]} != "none" ]] && (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}here-string-text]}") - -fast-highlight-string ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}here-string-var]:#none} - already_added=1 - elif (( this_word & (BIT_case_preamble + BIT_case_item) )) - then - if (( this_word & BIT_case_preamble )); then - [[ $__arg = "in" ]] && { - __style=${FAST_THEME_NAME}reserved-word - (( next_word = BIT_case_item )) - } || { - __style=${FAST_THEME_NAME}case-input - (( next_word = BIT_case_preamble )) - } - else - if (( this_word & BIT_case_nempty_item == 0 )) && [[ $__arg = "esac" ]]; then - (( next_word = 1 )) - __style=${FAST_THEME_NAME}reserved-word - elif [[ $__arg = (\(*\)|\)|\() ]]; then - [[ $__arg = *\) ]] && (( next_word = BIT_case_code | 1 )) || (( next_word = BIT_case_item | BIT_case_nempty_item )) - _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) ) - (( ${#__arg} > 1 )) && { - _FAST_COMPLEX_BRACKETS+=( $(( _start_pos+${#__arg}-1-__PBUFLEN )) ) - (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-parentheses]}") - (( __start=_start_pos+1-__PBUFLEN, __end=_end_pos-1-__PBUFLEN, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-condition]}") - already_added=1 - } || { - __style=${FAST_THEME_NAME}case-parentheses - } - else - (( next_word = BIT_case_item | BIT_case_nempty_item )) - __style=${FAST_THEME_NAME}case-condition - fi - fi - fi - if [[ $__arg = (#b)*'#'(([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])|([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F]))* || $__arg = (#b)*'rgb('(([0-9a-fA-F][0-9a-fA-F](#c0,1)),([0-9a-fA-F][0-9a-fA-F](#c0,1)),([0-9a-fA-F][0-9a-fA-F](#c0,1)))* ]]; then - if [[ -n $match[2] ]]; then - if [[ $match[2] = ?? || $match[3] = ?? || $match[4] = ?? ]]; then - (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end bg=#${(l:2::0:)match[2]}${(l:2::0:)match[3]}${(l:2::0:)match[4]}") - else - (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end bg=#$match[2]$match[3]$match[4]") - fi - else - (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end bg=#$match[5]$match[6]$match[7]") - fi - already_added=1 - fi - - # ADD - (( already_added == 0 )) && [[ ${FAST_HIGHLIGHT_STYLES[$__style]} != "none" ]] && (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - - if (( (__arg_type == 3) && ((this_word & (BIT_case_preamble|BIT_case_item)) == 0) )); then - if [[ $__arg == ';' ]] && (( in_array_assignment )); then - # literal newline inside an array assignment - (( next_word = 2 | (next_word & BIT_case_code) )) - elif [[ -n ${braces_stack[(r)A]} ]]; then - # 'A' in stack -> inside [[ ... ]] - (( next_word = 2 | (next_word & BIT_case_code) )) - else - braces_stack=${braces_stack#T} - (( next_word = 1 | (next_word & BIT_case_code) )) - highlight_glob=1 - # A new command means that we should not expect that alternate - # syntax will occur (this is also in the ';' short-path), but - # || and && mean going down just 1 step, not all the way to 0 - [[ $__arg != ("||"|"&&") ]] && __delimited=0 || (( __delimited = __delimited == 2 ? 1 : __delimited )) - fi - elif (( ( (__arg_type == 1) || (__arg_type == 2) ) && (this_word & 1) )); then # (( __arg_type == 1 || __arg_type == 2 )) && (( this_word & 1 )) - __delimited=1 - (( next_word = 1 | (next_word & (64 | BIT_case_code)) )) - elif [[ $__arg == "repeat" ]] && (( this_word & 1 )); then - __delimited=1 - # skip the repeat-count word - in_redirection=2 - # The redirection mechanism assumes $this_word describes the word - # following the redirection. Make it so. - # - # That word can be a command word with shortloops (`repeat 2 ls`) - # or a command separator (`repeat 2; ls` or `repeat 2; do ls; done`). - # - # The repeat-count word will be handled like a redirection target. - (( this_word = 3 )) - fi - _start_pos=$_end_pos - # This is the default/common codepath. - (( this_word = in_redirection == 0 ? next_word : this_word )) #else # Stall $this_word. - done - - # Do we have whole buffer? I.e. start at zero - [[ $3 != 0 ]] && return 0 - - # The loop overwrites ")" with "x", except those from $( ) substitution - # - # __pos: current nest level, starts from 0 - # __workbuf: copy of __buf, with limit on 250 characters - # __idx: index in whole command line buffer - # __list: list of coordinates of ) which shouldn't be ovewritten - _mybuf=${__buf[1,250]} __workbuf=$_mybuf __idx=0 __pos=0 __list=() - - while [[ $__workbuf = (#b)[^\(\)]#([\(\)])(*) ]]; do - if [[ ${match[1]} == \( ]]; then - __arg=${_mybuf[__idx+${mbegin[1]}-1,__idx+${mbegin[1]}-1+2]} - [[ $__arg = '$('[^\(] ]] && __list+=( $__pos ) - [[ $__arg = '$((' ]] && _mybuf[__idx+${mbegin[1]}-1]=x - # Increase parenthesis level - __pos+=1 - else - # Decrease parenthesis level - __pos=__pos-1 - [[ -z ${__list[(r)$__pos]} ]] && [[ $__pos -gt 0 ]] && _mybuf[__idx+${mbegin[1]}]=x - fi - __idx+=${mbegin[2]}-1 - __workbuf=${match[2]} - done - - # Run on fake buffer with replaced parentheses: ")" into "x" - if [[ "$_mybuf" = *$__nul* ]]; then - # Try to avoid conflict with the \0, however - # we have to split at *some* character - \7 - # is ^G, so one cannot have null and ^G at - # the same time on the command line - __nul=$'\7' - fi - - __inputs=( ${(ps:$__nul:)${(S)_mybuf//(#b)*\$\(([^\)]#)(\)|(#e))/${mbegin[1]};${mend[1]}${__nul}}%$__nul*} ) - if [[ "${__inputs[1]}" != "$_mybuf" && -n "${__inputs[1]}" ]]; then - if [[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}secondary]} ]]; then - __idx=1 - __tmp=$FAST_THEME_NAME - FAST_THEME_NAME=${${${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}secondary]}:t:r}#(XDG|LOCAL|HOME|OPT):} - (( ${+FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}default]} )) || source $FAST_WORK_DIR/secondary_theme.zsh - else - __idx=0 - fi - for _mybuf in $__inputs; do - (( __start=${_mybuf%%;*}-__PBUFLEN-1, __end=${_mybuf##*;}-__PBUFLEN, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${__tmp}recursive-base]}") - # Pass authentic buffer for recursive analysis - -fast-highlight-process "$PREBUFFER" "${__buf[${_mybuf%%;*},${_mybuf##*;}]}" $(( ${_mybuf%%;*} - 1 )) - done - # Restore theme - (( __idx )) && FAST_THEME_NAME=$__tmp - fi - - return 0 -} - --fast-highlight-check-path() -{ - (( _start_pos-__PBUFLEN >= 0 )) || \ - { [[ $1 != "noasync" ]] && print -r -- "- $_start_pos $_end_pos"; return 1; } - [[ $1 != "noasync" ]] && { - print -r -- ${sysparams[pid]} - # This is to fill cache - print -r -- $__arg - } - - : ${expanded_path:=${(Q)~__arg}} - [[ -n ${FAST_BLIST_PATTERNS[(k)${${(M)expanded_path:#/*}:-$PWD/$expanded_path}]} ]] && { [[ $1 != "noasync" ]] && print -r -- "- $_start_pos $_end_pos"; return 1; } - - [[ -z $expanded_path ]] && { [[ $1 != "noasync" ]] && print -r -- "- $_start_pos $_end_pos"; return 1; } - [[ -d $expanded_path ]] && { [[ $1 != "noasync" ]] && print -r -- "$_start_pos ${_end_pos}D" || __style=${FAST_THEME_NAME}path-to-dir; return 0; } - [[ -e $expanded_path ]] && { [[ $1 != "noasync" ]] && print -r -- "$_start_pos $_end_pos" || __style=${FAST_THEME_NAME}path; return 0; } - - # Search the path in CDPATH, only for CD command - [[ $active_command = "cd" ]] && for cdpath_dir in $cdpath; do - [[ -d $cdpath_dir/$expanded_path ]] && { [[ $1 != "noasync" ]] && print -r -- "$_start_pos ${_end_pos}D" || __style=${FAST_THEME_NAME}path-to-dir; return 0; } - [[ -e $cdpath_dir/$expanded_path ]] && { [[ $1 != "noasync" ]] && print -r -- "$_start_pos $_end_pos" || __style=${FAST_THEME_NAME}path; return 0; } - done - - # It's not a path. - [[ $1 != "noasync" ]] && print -r -- "- $_start_pos $_end_pos" - return 1 -} - --fast-highlight-check-path-handler() { - local IFS=$'\n' pid PCFD=$1 line stripped val - integer idx - - if read -r -u $PCFD pid; then - if read -r -u $PCFD val; then - if read -r -u $PCFD line; then - stripped=${${line#- }%D} - FAST_HIGHLIGHT[cache-path-${(q)val}-${stripped%% *}-born-at]=$EPOCHSECONDS - idx=${${FAST_HIGHLIGHT[path-queue]}[(I)$stripped]} - (( idx > 0 )) && { - if [[ $line != -* ]]; then - FAST_HIGHLIGHT[cache-path-${(q)val}-${stripped%% *}]="1${(M)line%D}" - region_highlight+=("${line%% *} ${${line##* }%D} ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path${${(M)line%D}:+-to-dir}]}") - else - FAST_HIGHLIGHT[cache-path-${(q)val}-${stripped%% *}]=0 - fi - val=${FAST_HIGHLIGHT[path-queue]} - val[idx-1,idx+${#stripped}]="" - FAST_HIGHLIGHT[path-queue]=$val - [[ ${FAST_HIGHLIGHT[cache-path-${(q)val}-${stripped%% *}]%D} = 1 && ${#val} -le 27 ]] && zle -R - } - fi - fi - kill -9 $pid 2>/dev/null - fi - - zle -F -w ${PCFD} - exec {PCFD}<&- -} - -zle -N -- fast-highlight-check-path-handler -fast-highlight-check-path-handler - -# Highlight special blocks inside double-quoted strings -# -# The while [[ ... ]] pattern is logically ((A)|(B)|(C)|(D)|(E))(*), where: -# - A matches $var[abc] -# - B matches ${(...)var[abc]} -# - C matches $ -# - D matches \$ or \" or \' -# - E matches \* -# -# and the first condition -n ${match[7] uses D to continue searching when -# backslash-something (not ['"$]) is occured. -# -# $1 - additional style to glue-in to added style --fast-highlight-string() -{ - (( _start_pos-__PBUFLEN >= 0 )) || return 0 - _mybuf=$__arg - __idx=_start_pos - - # 7 8 - while [[ $_mybuf = (#b)[^\$\\]#((\$(#B)([#+^=~](#c1,2))(#c0,1)(#B)([a-zA-Z_:][a-zA-Z0-9_:]#|[0-9]##)(#b)(\[[^\]]#\])(#c0,1))|(\$[{](#B)([#+^=~](#c1,2))(#c0,1)(#b)(\([a-zA-Z0-9_:@%#]##\))(#c0,1)[a-zA-Z0-9_:#]##(\[[^\]]#\])(#c0,1)[}])|\$|[\\][\'\"\$]|[\\](*))(*) ]]; do - [[ -n ${match[7]} ]] && { - # Skip following char – it is quoted. Choice is - # made to not highlight such quoting - __idx+=${mbegin[1]}+1 - _mybuf=${match[7]:1} - } || { - __idx+=${mbegin[1]}-1 - _end_idx=__idx+${mend[1]}-${mbegin[1]}+1 - _mybuf=${match[8]} - - # ADD - (( __start=__idx-__PBUFLEN, __end=_end_idx-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${${1:+$1}:-${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}back-or-dollar-double-quoted-argument]}}") - - __idx=_end_idx - } - done - return 0 -} - -# Highlight math and non-math context variables inside $(( )) and (( )) -# -# The while [[ ... ]] pattern is logically ((A)|(B)|(C)|(D))(*), where: -# - A matches $var[abc] -# - B matches ${(...)var[abc]} -# - C matches $ -# - D matches words [a-zA-Z]## (variables) -# -# Parameters used: _mybuf, __idx, _end_idx, __style --fast-highlight-math-string() -{ - (( _start_pos-__PBUFLEN >= 0 )) || return 0 - _mybuf=$__arg - __idx=_start_pos - - # 7 - while [[ $_mybuf = (#b)[^\$_a-zA-Z0-9]#((\$(#B)(+|)(#B)([a-zA-Z_:][a-zA-Z0-9_:]#|[0-9]##)(#b)(\[[^\]]##\])(#c0,1))|(\$[{](#B)(+|)(#b)(\([a-zA-Z0-9_:@%#]##\))(#c0,1)[a-zA-Z0-9_:#]##(\[[^\]]##\])(#c0,1)[}])|\$|[a-zA-Z_][a-zA-Z0-9_]#|[0-9]##)(*) ]]; do - __idx+=${mbegin[1]}-1 - _end_idx=__idx+${mend[1]}-${mbegin[1]}+1 - _mybuf=${match[7]} - - [[ ${match[1]} = [0-9]* ]] && __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}mathnum]} || { - [[ ${match[1]} = [a-zA-Z_]* ]] && { - [[ ${+parameters[${match[1]}]} = 1 || ${FAST_ASSIGNS_SEEN[${match[1]}]} = 1 ]] && \ - __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}mathvar]} || \ - __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}matherr]} - } || { - [[ ${match[1]} = "$"* ]] && { - match[1]=${match[1]//[\{\}+]/} - if [[ ${match[1]} = "$" || ${FAST_ASSIGNS_SEEN[${match[1]:1}]} = 1 ]] || \ - { eval "[[ -n \${(P)\${match[1]:1}} ]]" } 2>> /dev/null; then - __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}back-or-dollar-double-quoted-argument]} - else - __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}matherr]} - fi - } - } - } - - # ADD - [[ $__style != "none" && -n $__style ]] && (( __start=__idx-__PBUFLEN, __end=_end_idx-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end $__style") - - __idx=_end_idx - done -} - -# Highlight special chars inside dollar-quoted strings --fast-highlight-dollar-string() -{ - (( _start_pos-__PBUFLEN >= 0 )) || return 0 - local i j k __style - local AA - integer c - - # Starting dollar-quote is at 1:2, so __start parsing at offset 3 in the string. - for (( i = 3 ; i < _end_pos - _start_pos ; i += 1 )) ; do - (( j = i + _start_pos - 1 )) - (( k = j + 1 )) - - case ${__arg[$i]} in - "\\") __style=${FAST_THEME_NAME}back-dollar-quoted-argument - for (( c = i + 1 ; c <= _end_pos - _start_pos ; c += 1 )); do - [[ ${__arg[$c]} != ([0-9xXuUa-fA-F]) ]] && break - done - AA=$__arg[$i+1,$c-1] - # Matching for HEX and OCT values like \0xA6, \xA6 or \012 - if [[ "$AA" == (#m)(#s)(x|X)[0-9a-fA-F](#c1,2) - || "$AA" == (#m)(#s)[0-7](#c1,3) - || "$AA" == (#m)(#s)u[0-9a-fA-F](#c1,4) - || "$AA" == (#m)(#s)U[0-9a-fA-F](#c1,8) - ]]; then - (( k += MEND )) - (( i += MEND )) - else - if (( __asize > i+1 )) && [[ $__arg[i+1] == [xXuU] ]]; then - # \x not followed by hex digits is probably an error - __style=${FAST_THEME_NAME}unknown-token - fi - (( k += 1 )) # Color following char too. - (( i += 1 )) # Skip parsing the escaped char. - fi - ;; - *) continue ;; - - esac - # ADD - (( __start=j-__PBUFLEN, __end=k-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - done -} - --fast-highlight-init() { - _FAST_COMPLEX_BRACKETS=() - __fast_highlight_main__command_type_cache=() -} - -typeset -ga FSH_LIST --fsh_sy_h_shappend() { - FSH_LIST+=( "$(( $1 - 1 ));;$(( $2 ))" ) -} - -functions -M fsh_sy_h_append 2 2 -fsh_sy_h_shappend 2>/dev/null - -# vim:ft=zsh:sw=2:sts=2 diff --git a/.config/zsh/.zsh/fsh/fast-string-highlight b/.config/zsh/.zsh/fsh/fast-string-highlight deleted file mode 100644 index cc8d860..0000000 --- a/.config/zsh/.zsh/fsh/fast-string-highlight +++ /dev/null @@ -1,77 +0,0 @@ -# vim:ft=zsh:sw=4:sts=4 - -# -# $1 - PREBUFFER -# $2 - BUFFER -# -function -fast-highlight-string-process { - emulate -LR zsh - setopt extendedglob warncreateglobal typesetsilent - - local -A pos_to_level level_to_pos pair_map final_pairs - local input=$1$2 _mybuf=$1$2 __style __quoting - integer __idx=0 __pair_idx __level=0 __start __end - local -a match mbegin mend - - pair_map=( "(" ")" "{" "}" "[" "]" ) - - while [[ $_mybuf = (#b)([^"{}()[]\\\"'"]#)((["({[]})\"'"])|[\\](*))(*) ]]; do - if [[ -n ${match[4]} ]] { - __idx+=${mbegin[2]} - - [[ $__quoting = \' ]] && _mybuf=${match[4]} || { _mybuf=${match[4]:1}; (( ++ __idx )); } - } else { - __idx+=${mbegin[2]} - [[ -z $__quoting && -z ${_FAST_COMPLEX_BRACKETS[(r)$((__idx-${#PREBUFFER}-1))]} ]] && { - if [[ ${match[2]} = ["({["] ]]; then - pos_to_level[$__idx]=$(( ++__level )) - level_to_pos[$__level]=$__idx - elif [[ ${match[2]} = ["]})"] ]]; then - if (( __level > 0 )); then - __pair_idx=${level_to_pos[$__level]} - pos_to_level[$__idx]=$(( __level -- )) - [[ ${pair_map[${input[__pair_idx]}]} = ${input[__idx]} ]] && { - final_pairs[$__idx]=$__pair_idx - final_pairs[$__pair_idx]=$__idx - } - else - pos_to_level[$__idx]=-1 - fi - fi - } - - if [[ ${match[2]} = \" && $__quoting != \' ]] { - [[ $__quoting = '"' ]] && __quoting="" || __quoting='"'; - } - if [[ ${match[2]} = \' && $__quoting != \" ]] { - if [[ $__quoting = ("'"|"$'") ]] { - __quoting="" - } else { - if [[ $match[1] = *\$ ]] { - __quoting="\$'"; - } else { - __quoting="'"; - } - } - } - _mybuf=${match[5]} - } - done - - for __idx in ${(k)pos_to_level}; do - (( ${+final_pairs[$__idx]} )) && __style=${FAST_THEME_NAME}bracket-level-$(( ( (pos_to_level[$__idx]-1) % 3 ) + 1 )) || __style=${FAST_THEME_NAME}unknown-token - (( __start=__idx-${#PREBUFFER}-1, __end=__idx-${#PREBUFFER}, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - done - - # If cursor is on a bracket, then highlight corresponding bracket, if any. - if [[ $WIDGET != zle-line-finish ]]; then - __idx=$(( CURSOR + 1 )) - if (( ${+pos_to_level[$__idx]} )) && (( ${+final_pairs[$__idx]} )); then - (( __start=final_pairs[$__idx]-${#PREBUFFER}-1, __end=final_pairs[$__idx]-${#PREBUFFER}, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}paired-bracket]}") && \ - reply+=("$CURSOR $__idx ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}paired-bracket]}") - fi - fi - return 0 -} diff --git a/.config/zsh/.zsh/fsh/fast-syntax-highlighting.plugin.zsh b/.config/zsh/.zsh/fsh/fast-syntax-highlighting.plugin.zsh deleted file mode 100644 index c05dc4f..0000000 --- a/.config/zsh/.zsh/fsh/fast-syntax-highlighting.plugin.zsh +++ /dev/null @@ -1,384 +0,0 @@ -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors -# Copyright (c) 2017-2019 Sebastian Gniazdowski (modifications) -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - - -# Standarized way of handling finding plugin dir, -# regardless of functionargzero and posixargzero, -# and with an option for a plugin manager to alter -# the plugin directory (i.e. set ZERO parameter) -# http://zdharma.org/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html -0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" -0="${${(M)0:#/*}:-$PWD/$0}" - -typeset -g FAST_HIGHLIGHT_VERSION=1.55 -typeset -g FAST_BASE_DIR="${0:h}" -typeset -ga _FAST_MAIN_CACHE -# Holds list of indices pointing at brackets that -# are complex, i.e. e.g. part of "[[" in [[ ... ]] -typeset -ga _FAST_COMPLEX_BRACKETS - -typeset -g FAST_WORK_DIR=${FAST_WORK_DIR:-${XDG_CACHE_HOME:-~/.cache}/fast-syntax-highlighting} -: ${FAST_WORK_DIR:=$FAST_BASE_DIR} -# Expand any tilde in the (supposed) path. -FAST_WORK_DIR=${~FAST_WORK_DIR} - -# Last (currently, possibly) loaded plugin isn't "fast-syntax-highlighting"? -# And FPATH isn't containing plugin dir? -if [[ ${zsh_loaded_plugins[-1]} != */fast-syntax-highlighting && -z ${fpath[(r)${0:h}]} ]] -then - fpath+=( "${0:h}" ) -fi - -if [[ ! -w $FAST_WORK_DIR ]]; then - FAST_WORK_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/fsh" - command mkdir -p "$FAST_WORK_DIR" -fi - -# Invokes each highlighter that needs updating. -# This function is supposed to be called whenever the ZLE state changes. -_zsh_highlight() -{ - # Store the previous command return code to restore it whatever happens. - local ret=$? - - # Remove all highlighting in isearch, so that only the underlining done by zsh itself remains. - # For details see FAQ entry 'Why does syntax highlighting not work while searching history?'. - if [[ $WIDGET == zle-isearch-update ]] && ! (( $+ISEARCHMATCH_ACTIVE )); then - region_highlight=() - return $ret - fi - - emulate -LR zsh - setopt extendedglob warncreateglobal typesetsilent noshortloops - - local REPLY # don't leak $REPLY into global scope - local -a reply - - # Do not highlight if there are more than 300 chars in the buffer. It's most - # likely a pasted command or a huge list of files in that case.. - [[ -n ${ZSH_HIGHLIGHT_MAXLENGTH:-} ]] && [[ $#BUFFER -gt $ZSH_HIGHLIGHT_MAXLENGTH ]] && return $ret - - # Do not highlight if there are pending inputs (copy/paste). - [[ $PENDING -gt 0 ]] && return $ret - - # Reset region highlight to build it from scratch - # may need to remove path_prefix highlighting when the line ends - if [[ $WIDGET == zle-line-finish ]] || _zsh_highlight_buffer_modified; then - -fast-highlight-init - -fast-highlight-process "$PREBUFFER" "$BUFFER" 0 - (( FAST_HIGHLIGHT[use_brackets] )) && { - _FAST_MAIN_CACHE=( $reply ) - -fast-highlight-string-process "$PREBUFFER" "$BUFFER" - } - region_highlight=( $reply ) - else - local char="${BUFFER[CURSOR+1]}" - if [[ "$char" = ["{([])}"] || "${FAST_HIGHLIGHT[prev_char]}" = ["{([])}"] ]]; then - FAST_HIGHLIGHT[prev_char]="$char" - (( FAST_HIGHLIGHT[use_brackets] )) && { - reply=( $_FAST_MAIN_CACHE ) - -fast-highlight-string-process "$PREBUFFER" "$BUFFER" - region_highlight=( $reply ) - } - fi - fi - - { - local cache_place - local -a region_highlight_copy - - # Re-apply zle_highlight settings - - # region - if (( REGION_ACTIVE == 1 )); then - _zsh_highlight_apply_zle_highlight region standout "$MARK" "$CURSOR" - elif (( REGION_ACTIVE == 2 )); then - () { - local needle=$'\n' - integer min max - if (( MARK > CURSOR )) ; then - min=$CURSOR max=$(( MARK + 1 )) - else - min=$MARK max=$CURSOR - fi - (( min = ${${BUFFER[1,$min]}[(I)$needle]} )) - (( max += ${${BUFFER:($max-1)}[(i)$needle]} - 1 )) - _zsh_highlight_apply_zle_highlight region standout "$min" "$max" - } - fi - - # yank / paste (zsh-5.1.1 and newer) - (( $+YANK_ACTIVE )) && (( YANK_ACTIVE )) && _zsh_highlight_apply_zle_highlight paste standout "$YANK_START" "$YANK_END" - - # isearch - (( $+ISEARCHMATCH_ACTIVE )) && (( ISEARCHMATCH_ACTIVE )) && _zsh_highlight_apply_zle_highlight isearch underline "$ISEARCHMATCH_START" "$ISEARCHMATCH_END" - - # suffix - (( $+SUFFIX_ACTIVE )) && (( SUFFIX_ACTIVE )) && _zsh_highlight_apply_zle_highlight suffix bold "$SUFFIX_START" "$SUFFIX_END" - - return $ret - - } always { - typeset -g _ZSH_HIGHLIGHT_PRIOR_BUFFER="$BUFFER" - typeset -g _ZSH_HIGHLIGHT_PRIOR_RACTIVE="$REGION_ACTIVE" - typeset -gi _ZSH_HIGHLIGHT_PRIOR_CURSOR=$CURSOR - } -} - -# Apply highlighting based on entries in the zle_highlight array. -# This function takes four arguments: -# 1. The exact entry (no patterns) in the zle_highlight array: -# region, paste, isearch, or suffix -# 2. The default highlighting that should be applied if the entry is unset -# 3. and 4. Two integer values describing the beginning and end of the -# range. The order does not matter. -_zsh_highlight_apply_zle_highlight() { - local entry="$1" default="$2" - integer first="$3" second="$4" - - # read the relevant entry from zle_highlight - local region="${zle_highlight[(r)${entry}:*]}" - - if [[ -z "$region" ]]; then - # entry not specified at all, use default value - region=$default - else - # strip prefix - region="${region#${entry}:}" - - # no highlighting when set to the empty string or to 'none' - if [[ -z "$region" ]] || [[ "$region" == none ]]; then - return - fi - fi - - integer start end - if (( first < second )); then - start=$first end=$second - else - start=$second end=$first - fi - region_highlight+=("$start $end $region") -} - - -# ------------------------------------------------------------------------------------------------- -# API/utility functions for highlighters -# ------------------------------------------------------------------------------------------------- - -# Whether the command line buffer has been modified or not. -# -# Returns 0 if the buffer has changed since _zsh_highlight was last called. -_zsh_highlight_buffer_modified() -{ - [[ "${_ZSH_HIGHLIGHT_PRIOR_BUFFER:-}" != "$BUFFER" ]] || [[ "$REGION_ACTIVE" != "$_ZSH_HIGHLIGHT_PRIOR_RACTIVE" ]] || { _zsh_highlight_cursor_moved && [[ "$REGION_ACTIVE" = 1 || "$REGION_ACTIVE" = 2 ]] } -} - -# Whether the cursor has moved or not. -# -# Returns 0 if the cursor has moved since _zsh_highlight was last called. -_zsh_highlight_cursor_moved() -{ - [[ -n $CURSOR ]] && [[ -n ${_ZSH_HIGHLIGHT_PRIOR_CURSOR-} ]] && (($_ZSH_HIGHLIGHT_PRIOR_CURSOR != $CURSOR)) -} - -# ------------------------------------------------------------------------------------------------- -# Setup functions -# ------------------------------------------------------------------------------------------------- - -# Helper for _zsh_highlight_bind_widgets -# $1 is name of widget to call -_zsh_highlight_call_widget() -{ - integer ret - builtin zle "$@" - ret=$? - _zsh_highlight - return $ret -} - -# Rebind all ZLE widgets to make them invoke _zsh_highlights. -_zsh_highlight_bind_widgets() -{ - setopt localoptions noksharrays - local -F2 SECONDS - local prefix=orig-s${SECONDS/./}-r$(( RANDOM % 1000 )) # unique each time, in case we're sourced more than once - - # Load ZSH module zsh/zleparameter, needed to override user defined widgets. - zmodload zsh/zleparameter 2>/dev/null || { - print -r -- >&2 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' - return 1 - } - - # Override ZLE widgets to make them invoke _zsh_highlight. - local -U widgets_to_bind - widgets_to_bind=(${${(k)widgets}:#(.*|run-help|which-command|beep|set-local-history|yank|zle-line-pre-redraw|zle-keymap-select)}) - - # Always wrap special zle-line-finish widget. This is needed to decide if the - # current line ends and special highlighting logic needs to be applied. - # E.g. remove cursor imprint, don't highlight partial paths, ... - widgets_to_bind+=(zle-line-finish) - - # Always wrap special zle-isearch-update widget to be notified of updates in isearch. - # This is needed because we need to disable highlighting in that case. - widgets_to_bind+=(zle-isearch-update) - - local cur_widget - for cur_widget in $widgets_to_bind; do - case $widgets[$cur_widget] in - - # Already rebound event: do nothing. - user:_zsh_highlight_widget_*);; - - # The "eval"'s are required to make $cur_widget a closure: the value of the parameter at function - # definition time is used. - # - # We can't use ${0/_zsh_highlight_widget_} because these widgets are always invoked with - # NO_function_argzero, regardless of the option's setting here. - - # User defined widget: override and rebind old one with prefix "orig-". - user:*) zle -N -- $prefix-$cur_widget ${widgets[$cur_widget]#*:} - eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget ${(q)prefix}-${(q)cur_widget} -- \"\$@\" }" - zle -N -- $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;; - - # Completion widget: override and rebind old one with prefix "orig-". - completion:*) zle -C $prefix-$cur_widget ${${(s.:.)widgets[$cur_widget]}[2,3]} - eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget ${(q)prefix}-${(q)cur_widget} -- \"\$@\" }" - zle -N -- $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;; - - # Builtin widget: override and make it call the builtin ".widget". - builtin) eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget .${(q)cur_widget} -- \"\$@\" }" - zle -N -- $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;; - - # Incomplete or nonexistent widget: Bind to z-sy-h directly. - *) - if [[ $cur_widget == zle-* ]] && [[ -z $widgets[$cur_widget] ]]; then - _zsh_highlight_widget_${cur_widget}() { :; _zsh_highlight } - zle -N -- $cur_widget _zsh_highlight_widget_$cur_widget - else - # Default: unhandled case. - print -r -- >&2 "zsh-syntax-highlighting: unhandled ZLE widget ${(qq)cur_widget}" - fi - esac - done -} - -# ------------------------------------------------------------------------------------------------- -# Setup -# ------------------------------------------------------------------------------------------------- - -# Try binding widgets. -_zsh_highlight_bind_widgets || { - print -r -- >&2 'zsh-syntax-highlighting: failed binding ZLE widgets, exiting.' - return 1 -} - -# Reset scratch variables when commandline is done. -_zsh_highlight_preexec_hook() -{ - typeset -g _ZSH_HIGHLIGHT_PRIOR_BUFFER= - typeset -gi _ZSH_HIGHLIGHT_PRIOR_CURSOR=0 - typeset -ga _FAST_MAIN_CACHE - _FAST_MAIN_CACHE=() -} - -autoload -Uz add-zsh-hook -add-zsh-hook preexec _zsh_highlight_preexec_hook 2>/dev/null || { - print -r -- >&2 'zsh-syntax-highlighting: failed loading add-zsh-hook.' -} - -/fshdbg() { - print -r -- "$@" >>! /tmp/reply -} - -ZSH_HIGHLIGHT_MAXLENGTH=10000 - -# Load zsh/parameter module if available -zmodload zsh/parameter 2>/dev/null -zmodload zsh/system 2>/dev/null - -autoload -Uz -- is-at-least fast-theme .fast-read-ini-file .fast-run-git-command \ - .fast-make-targets .fast-run-command .fast-zts-read-all -autoload -Uz -- →chroma/-git.ch →chroma/-hub.ch →chroma/-lab.ch →chroma/-example.ch \ - →chroma/-grep.ch →chroma/-perl.ch →chroma/-make.ch →chroma/-awk.ch \ - →chroma/-vim.ch →chroma/-source.ch →chroma/-sh.ch →chroma/-docker.ch \ - →chroma/-autoload.ch →chroma/-ssh.ch →chroma/-scp.ch →chroma/-which.ch \ - →chroma/-printf.ch →chroma/-ruby.ch →chroma/-whatis.ch →chroma/-alias.ch \ - →chroma/-subcommand.ch →chroma/-autorandr.ch →chroma/-nmcli.ch \ - →chroma/-fast-theme.ch →chroma/-node.ch →chroma/-fpath_peq.ch \ - →chroma/-precommand.ch →chroma/-subversion.ch →chroma/-ionice.ch \ - →chroma/-nice.ch →chroma/main-chroma.ch →chroma/-ogit.ch →chroma/-zinit.ch - -source "${0:h}/fast-highlight" -source "${0:h}/fast-string-highlight" - -local __fsyh_theme -zstyle -s :plugin:fast-syntax-highlighting theme __fsyh_theme - -[[ ( "${+termcap}" != 1 || "${termcap[Co]}" != <-> || "${termcap[Co]}" -lt "256" ) && "$__fsyh_theme" = (default|) ]] && { - FAST_HIGHLIGHT_STYLES[defaultvariable]="none" - FAST_HIGHLIGHT_STYLES[defaultglobbing-ext]="fg=blue,bold" - FAST_HIGHLIGHT_STYLES[defaulthere-string-text]="bg=blue" - FAST_HIGHLIGHT_STYLES[defaulthere-string-var]="fg=cyan,bg=blue" - FAST_HIGHLIGHT_STYLES[defaultcorrect-subtle]="bg=blue" - FAST_HIGHLIGHT_STYLES[defaultsubtle-bg]="bg=blue" - [[ "${FAST_HIGHLIGHT_STYLES[variable]}" = "fg=113" ]] && FAST_HIGHLIGHT_STYLES[variable]="none" - [[ "${FAST_HIGHLIGHT_STYLES[globbing-ext]}" = "fg=13" ]] && FAST_HIGHLIGHT_STYLES[globbing-ext]="fg=blue,bold" - [[ "${FAST_HIGHLIGHT_STYLES[here-string-text]}" = "bg=18" ]] && FAST_HIGHLIGHT_STYLES[here-string-text]="bg=blue" - [[ "${FAST_HIGHLIGHT_STYLES[here-string-var]}" = "fg=cyan,bg=18" ]] && FAST_HIGHLIGHT_STYLES[here-string-var]="fg=cyan,bg=blue" - [[ "${FAST_HIGHLIGHT_STYLES[correct-subtle]}" = "fg=12" ]] && FAST_HIGHLIGHT_STYLES[correct-subtle]="bg=blue" - [[ "${FAST_HIGHLIGHT_STYLES[subtle-bg]}" = "bg=18" ]] && FAST_HIGHLIGHT_STYLES[subtle-bg]="bg=blue" -} - -unset __fsyh_theme - -alias fsh-alias=fast-theme - --fast-highlight-fill-option-variables - -if [[ ! -e $FAST_WORK_DIR/secondary_theme.zsh ]] { - if { type curl &>/dev/null } { - curl -fsSL -o "$FAST_WORK_DIR/secondary_theme.zsh" \ - https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/share/free_theme.zsh \ - &>/dev/null - } elif { type wget &>/dev/null } { - wget -O "$FAST_WORK_DIR/secondary_theme.zsh" \ - https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/share/free_theme.zsh \ - &>/dev/null - } - touch "$FAST_WORK_DIR/secondary_theme.zsh" -} - -if [[ $(uname -a) = (#i)*darwin* ]] { - typeset -gA FAST_HIGHLIGHT - FAST_HIGHLIGHT[chroma-man]= -} - -[[ $COLORTERM == (24bit|truecolor) || ${terminfo[colors]} -eq 16777216 ]] || zmodload zsh/nearcolor &>/dev/null diff --git a/.config/zsh/.zsh/fsh/fast-theme b/.config/zsh/.zsh/fsh/fast-theme deleted file mode 100644 index 06ad005..0000000 --- a/.config/zsh/.zsh/fsh/fast-theme +++ /dev/null @@ -1,385 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# Copyright (c) 2018, 2019 Philippe Troin (F-i-f on GitHub) -# -# Theme support using ini-files. -# - -zmodload zsh/zutil 2>/dev/null - -emulate -LR zsh -setopt extendedglob typesetsilent warncreateglobal -autoload colors; colors - -typeset -g FAST_WORK_DIR -: ${FAST_WORK_DIR:=$FAST_BASE_DIR} -FAST_WORK_DIR=${~FAST_WORK_DIR} - -local -A map -map=( "XDG:" "${XDG_CONFIG_HOME:-$HOME/.config}/fsh/" - "LOCAL:" "/usr/local/share/fsh/" - "HOME:" "$HOME/.fsh/" - "OPT:" "/opt/local/share/fsh/" -) - -FAST_WORK_DIR=${${FAST_WORK_DIR/(#m)(#s)(XDG|LOCAL|HOME|OPT):(#c0,1)/${map[${MATCH%:}:]}}%/} - -local OPT_HELP OPT_VERBOSE OPT_QUIET OPT_RESET OPT_LIST OPT_TEST OPT_SECONDARY OPT_SHOW OPT_COPY OPT_OV_RESET -local OPT_PALETTE OPT_CDWD OPT_XCHG OPT_OV_XCHG -local -A opthash -zparseopts -E -D -A opthash h -help v -verbose q -quiet r -reset l -list t -test -secondary \ - s -show -copy-shipped-theme: R -ov-reset p -palette w -workdir \ - x -xchg y -ov-xchg || \ - { echo "Improper options given, see help (-h/--help)"; return 1; } - -(( ${+opthash[-h]} + ${+opthash[--help]} )) && OPT_HELP="-h" -(( ${+opthash[-v]} + ${+opthash[--verbose]} )) && OPT_VERBOSE="-v" -(( ${+opthash[-q]} + ${+opthash[--quiet]} )) && OPT_QUIET="-q" -(( ${+opthash[-r]} + ${+opthash[--reset]} )) && OPT_RESET="-r" -(( ${+opthash[-l]} + ${+opthash[--list]} )) && OPT_LIST="-l" -(( ${+opthash[-t]} + ${+opthash[--test]} )) && OPT_TEST="-t" -(( ${+opthash[--secondary]} )) && OPT_SECONDARY="--secondary" -(( ${+opthash[-s]} + ${+opthash[--show]} )) && OPT_SHOW="-s" -(( ${+opthash[--copy-shipped-theme]} )) && OPT_COPY="${opthash[--copy-shipped-theme]}" -(( ${+opthash[-R]} + ${+opthash[--ov-reset]} )) && OPT_OV_RESET="-R" -(( ${+opthash[-p]} + ${+opthash[--palette]} )) && OPT_PALETTE="-p" -(( ${+opthash[-w]} + ${+opthash[--workdir]} )) && OPT_CDWD="-w" -(( ${+opthash[-x]} + ${+opthash[--xchg]} )) && OPT_XCHG="-x" -(( ${+opthash[-y]} + ${+opthash[--ov-xchg]} )) && OPT_OV_XCHG="-y" - -local -a match mbegin mend -local MATCH; integer MBEGIN MEND - -[[ -n "$OPT_CDWD" ]] && { - builtin cd $FAST_WORK_DIR - return 0 -} - -[[ -n "$OPT_PALETTE" ]] && { - local n - local -a __colors - for n in {000..255} - do - __colors+=("%F{$n}$n%f") - done - print -cP $__colors - return -} - -[[ -n "$OPT_SHOW" ]] && { - print -r -- "Currently active theme: ${fg_bold[yellow]}$FAST_THEME_NAME$reset_color" - ( source "$FAST_WORK_DIR"/current_theme.zsh 2>/dev/null && print "Main theme (loaded at startup of a session): ${fg_bold[yellow]}$FAST_THEME_NAME$reset_color" || print "No main theme is set"; ) - return 0 -} - -[[ -n "$OPT_COPY" ]] && { - [[ ! -f "$FAST_BASE_DIR"/themes/"${OPT_COPY%.ini}.ini" ]] && { print "Theme \`$OPT_COPY' doesn't exist in FSH plugin dir ($FAST_BASE_DIR/themes)"; return 1; } - [[ ! -r "$FAST_BASE_DIR"/themes/"${OPT_COPY%.ini}.ini" ]] && { print "Theme \`$OPT_COPY' isn't readable in FSH plugin dir ($FAST_BASE_DIR/themes)"; return 1; } - [[ -n "$1" ]] && { - [[ ! -e "$1" && ! -e ${1:h} ]] && { print "Destination path doesn't exist, aborting"; return 1; } - } - command cp -vf "$FAST_BASE_DIR"/themes/"${OPT_COPY%.ini}.ini" "${${1:-.}%.ini}.ini" || return 1 - return 0 -} - -[[ -n "$OPT_RESET" ]] && { command rm -f "$FAST_WORK_DIR"/{current_theme.zsh,secondary_theme.zsh}; [[ -z "$OPT_QUIET" ]] && print "Reset done (no theme is now set, restart is required)"; return 0; } - -[[ -n "$OPT_OV_RESET" ]] && { command rm -f "$FAST_WORK_DIR"/theme_overlay.zsh; [[ -z "$OPT_QUIET" ]] && print "Overlay-reset done, it is inactive (restart is required)"; return 0; } - -[[ -n "$OPT_LIST" ]] && { - [[ -z "$OPT_QUIET" ]] && print -r -- "Available themes:" - print -rl -- "$FAST_BASE_DIR"/themes/*.ini(:t:r) - return 0 -} - -[[ -n "$OPT_HELP" ]] && { - print -r -- "Usage: fast-theme [-h/--help] [-v/--verbose] [-q/--quiet] [-t/--test] " - print -r -- " fast-theme [-r/--reset] [-l/--list] [-s/--show] [-p/--palette] [-w/--workdir]" - print -r -- " fast-theme --copy-shipped-theme {theme-name} [destination-path]" - print -r -- "" - print -r -- "Default action (after providing or ) is to switch" - print -r -- "current session and any future sessions to the new theme. Using ," - print -r -- "i.e.: a path to an ini file means using custom, own theme. The path can use an" - print -r -- "\"XDG:\" shorthand (e.g.: \"XDG:mytheme\") that will point to ~/.config/fsh/.ini" - print -r -- "(or \$XDG_CONFIG_HOME/fsh/.ini in general if the variable is set in the" - print -r -- "environment). If the INI file pointed in the path is \"*overlay*\", then it is" - print -r -- "not a full theme, but an additional theme-snippet that overwrites only selected" - print -r -- "styles of the main theme." - print -r -- "" - print -r -- "Other path-shorthands:" - print -r -- "LOCAL: = /usr/local/share/fsh/" - print -r -- "HOME: = $HOME/.fsh/" - print -r -- "OPT: = /opt/local/share/fsh/" - print -r -- "" - print -r -- "-r/--reset - unset any theme, use default highlighting (requires restart)" - print -r -- "-R/--ov-reset - unset overlay, use styles only from main-theme (requires restart)" - print -r -- "-l/--list - list names of available themes" - print -r -- "-t/--test - show test block of code after switching theme" - print -r -- "-s/--show - get and display the theme currently being set" - print -r -- "-p/--palette - just print all 256 colors and exit (useful when creating a theme)" - print -r -- "-w/--workdir - cd into \$FAST_WORK_DIR (if not set, then into the plugin directory)" - print -r -- "-v/--verbose - more messages during operation" - print -r -- "-q/--quiet - no default messages" - print -r -- "" - print -r -- "The option --copy-shipped-theme allows easy copying of one of the 6 shipped" - print -r -- "themes into given destination path. Normal use means changing directory to" - print -r -- "e.g.: ~/.config/fsh, and then issuing e.g.: \`fast-theme --copy-shipped-theme" - print -r -- "clean mytheme', to obtain a template for own new theme." - return 0 -} - -[[ -z "$1" ]] && { print -u2 "Provide a theme (its name or path to its file) to switch to, aborting (see -h/--help)"; return 1; } - -# FAST_HIGHLIGHT_STYLES key onto ini-file key -map=( - default "-" - unknown-token "-" - reserved-word "-" - subcommand "- reserved-word" - alias "- command builtin" - suffix-alias "- alias command builtin" - builtin "-" - function "- builtin command" - command "-" - precommand "- command" - commandseparator "-" - hashed-command "- command" - path "-" - path_pathseparator "pathseparator" - globbing "- back-or-dollar-double-quoted-argument" # fallback: variable in string "text $var text" - globbing-ext "- double-quoted-argument" # fallback: the string "abc..." - history-expansion "-" - single-hyphen-option "- single-quoted-argument" - double-hyphen-option "- double-quoted-argument" - back-quoted-argument "-" - single-quoted-argument "-" - double-quoted-argument "-" - dollar-quoted-argument "-" - back-or-dollar-double-quoted-argument "- back-dollar-quoted-argument" - back-dollar-quoted-argument "- back-or-dollar-double-quoted-argument" - assign "- reserved-word" - redirection "- reserved-word" - comment "-" - variable "-" - mathvar "- forvar variable" - mathnum "- fornum" - matherr "- incorrect-subtle" - assign-array-bracket "-" - for-loop-variable "forvar mathvar variable" - for-loop-number "fornum mathnum" - for-loop-operator "foroper reserved-word" - for-loop-separator "forsep commandseparator" - exec-descriptor "- reserved-word" - here-string-tri "-" - here-string-text "- subtle-bg" - here-string-var "- back-or-dollar-double-quoted-argument" - secondary "-" - recursive-base "- default" - case-input "- variable" - case-parentheses "- reserved-word" - case-condition "- correct-subtle" - correct-subtle "-" - incorrect-subtle "-" - subtle-separator "- commandseparator" - subtle-bg "- correct-subtle" - path-to-dir "- path" - paired-bracket "- subtle-bg correct-subtle" - bracket-level-1 "-" - bracket-level-2 "-" - bracket-level-3 "-" - global-alias "- alias suffix-alias" - single-sq-bracket "-" - double-sq-bracket "-" - double-paren "-" - optarg-string "- double-quoted-argument" - optarg-number "- mathnum" -) - -# In which order to generate entries -local -a order -order=( - default unknown-token reserved-word alias suffix-alias builtin function command precommand - commandseparator hashed-command path path_pathseparator globbing globbing-ext history-expansion - single-hyphen-option double-hyphen-option back-quoted-argument single-quoted-argument - double-quoted-argument dollar-quoted-argument back-or-dollar-double-quoted-argument - back-dollar-quoted-argument assign redirection comment variable mathvar - mathnum matherr assign-array-bracket for-loop-variable for-loop-number for-loop-operator - for-loop-separator exec-descriptor here-string-tri here-string-text here-string-var secondary - case-input case-parentheses case-condition correct-subtle incorrect-subtle subtle-separator subtle-bg - path-to-dir paired-bracket bracket-level-1 bracket-level-2 bracket-level-3 - global-alias subcommand single-sq-bracket double-sq-bracket double-paren - optarg-string optarg-number recursive-base -) - -[[ -n "$OPT_VERBOSE" ]] && print "Number of styles available for customization: ${#order}" - -# Named colors -local -a color -color=( red green blue yellow cyan magenta black white default ) - -# -# Execution starts here -# - -local -A out -local THEME_NAME THEME_PATH="$1" -if [[ "$1" = */* || "$1" = (XDG|LOCAL|HOME|OPT):* ]]; then - 1="${${1/(#s)XDG:/${${XDG_CONFIG_HOME:-$HOME/.config}%/}/fsh/}%.ini}.ini" - 1="${${1/(#s)LOCAL://usr/local/share/fsh/}%.ini}.ini" - 1="${${1/(#s)HOME:/$HOME/.fsh/}%.ini}.ini" - 1="${${1/(#s)OPT://opt/local/share/fsh/}%.ini}.ini" - 1=${~1} # allow user to quote ~ - - [[ ! -f "$1" ]] && { print -u2 "No such theme \`$1', aborting"; return 1; } - [[ ! -r "$1" ]] && { print -u2 "Theme \`$1' unreadable, aborting"; return 1; } - - THEME_NAME="${1:t:r}" - .fast-read-ini-file "$1" out "" -else - [[ ! -f "$FAST_BASE_DIR/themes/$1.ini" ]] && { print -u2 "No such theme \`$1', aborting"; return 1; } - [[ ! -r "$FAST_BASE_DIR/themes/$1.ini" ]] && { print -u2 "Theme \`$1' unreadable, aborting"; return 1; } - - THEME_NAME="$1" - .fast-read-ini-file "$FAST_BASE_DIR/themes/$1.ini" out "" -fi - -[[ -z "$OPT_SECONDARY" ]] && { [[ "$THEME_NAME" = *"overlay"* ]] && local outfile="theme_overlay.zsh" || local outfile="current_theme.zsh"; } || local outfile="secondary_theme.zsh" -[[ -z "$OPT_XCHG" && -z "$OPT_OV_XCHG" ]] && command rm -f "$FAST_WORK_DIR"/"$outfile" - -# Set a zstyle and a parameter to carry theme name -if [[ -z "$OPT_SECONDARY" && -z "$OPT_XCHG" && -z "$OPT_OV_XCHG" ]]; then - [[ "$THEME_NAME" != *"overlay"* ]] && { - print -r -- 'zstyle :plugin:fast-syntax-highlighting theme "'"$THEME_NAME"'"' >>! "$FAST_WORK_DIR"/"$outfile" - print -r -- 'typeset -g FAST_THEME_NAME="'"$THEME_NAME"'"' >>! "$FAST_WORK_DIR"/"$outfile" - zstyle :plugin:fast-syntax-highlighting theme "$THEME_NAME" - typeset -g FAST_THEME_NAME="$THEME_NAME" - } -elif [[ -z "$OPT_XCHG" && -z "$OPT_OV_XCHG" ]]; then - local FAST_THEME_NAME="$THEME_NAME" -fi - -# Store from which file the theme or overlay is being loaded -[[ "$THEME_NAME" != *"overlay" && -z "$OPT_OV_XCHG" ]] && FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}-path]="$THEME_PATH" || FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}-ov-path]="$THEME_PATH" - -# Generate current_theme.zsh or secondary_theme.zsh, traversing ini-file associative array -local k kk -local inikey inival result result2 first_val isbg -integer ov_counter=0 first -for k in "${order[@]}"; do - first=1 - for kk in ${(s. .)map[$k]} default; do - [[ "$kk" = "-" ]] && kk="$k" - (( first )) && first_val="$kk" - inikey="${out[(i)<*>_${kk}]}" - [[ -n "$inikey" ]] && { - (( !first )) && [[ -z "$OPT_QUIET" ]] && { - [[ $kk = default ]] && { - [[ "$THEME_NAME" != *"overlay"* ]] && print "Missing style: $first_val" - } || print "For style $first_val, went for fallback style $kk" - } - break - } - first=0 - [[ "$THEME_NAME" = *"overlay"* ]] && break - done - - # ORIG: Clear orig-style when loading a new theme, not overlay - [[ -z "$OPT_OV_XCHG" ]] && unset "FAST_HIGHLIGHT_STYLES[orig-style-$k]" - # ORIG: Restore orig-style when loading a new overlay - [[ -n "$OPT_OV_XCHG" && -n "${FAST_HIGHLIGHT_STYLES[orig-style-$k]}" ]] && { FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}$k]="${FAST_HIGHLIGHT_STYLES[orig-style-$k]}"; unset "FAST_HIGHLIGHT_STYLES[orig-style-$k]"; } - # Set only the keys provided in theme - [[ -z "$inikey" ]] && { [[ -z "$OPT_QUIET" && "$THEME_NAME" != *"overlay"* ]] && print "Missing style $first_val"; continue; } - - inival="${out[$inikey]}" - if [[ "$k" = "secondary" && -z "$OPT_SECONDARY" && -n "$inival" ]]; then - fast-theme -q --secondary "$inival" - fi - - result="" - if [[ $k = secondary ]]; then - result="$inival" - else - for kk in ${(s:,:)inival} - do - if [[ $kk = (none|(no-|)(bold|blink|conceal|reverse|standout|underline)) ]]; then - result+="${result:+,}$kk" - else - isbg=0 - if [[ $kk = bg:* ]]; then - isbg=1 - kk=${kk#bg:} - fi - if [[ $kk = (${(~j:|:)color}) || $kk = [0-9]## || $kk = \#[0-9a-fA-F](#c6,6) ]]; then - result+="${result:+,}" - (( isbg )) && result+="bg=" || result+="fg=" - result+="$kk" - else - print "cannot parse style $k: unknown color or style element $kk" - fi - fi - done - fi - - if [[ "$THEME_NAME" = *"overlay"* || -n "$OPT_OV_XCHG" ]]; then - (( ++ ov_counter )) - [[ -z "$OPT_XCHG$OPT_OV_XCHG" ]] && print -r -- ': ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}'"$k"']::='"$result"'}' >>! "$FAST_WORK_DIR"/"$outfile" - # ORIG: Save original value of the overwritten style - FAST_HIGHLIGHT_STYLES[orig-style-$k]=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}$k]} - # Overwrite theme's style - FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}$k]="$result" - else - [[ -z "$OPT_XCHG$OPT_OV_XCHG" ]] && print -r -- ': ${FAST_HIGHLIGHT_STYLES['"${FAST_THEME_NAME}$k"']:='"$result"'}' >>! "$FAST_WORK_DIR"/"$outfile" - FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}$k]="$result" - fi -done - -# This can overwrite some of *_STYLES fields -# Re-apply overlay on top of the theme we switched to -[[ "$THEME_NAME" != *"overlay"* ]] && [[ -r "$FAST_WORK_DIR"/theme_overlay.zsh ]] && source "$FAST_WORK_DIR"/theme_overlay.zsh - -zcompile $FAST_WORK_DIR/$outfile 2>/dev/null - -[[ -z "$OPT_QUIET" ]] && { - if [[ "$THEME_NAME" != *"overlay"* ]]; then - print "Switched to theme \`$THEME_NAME' (current session, and future sessions)" || \ - else - print "Processed the overlay ($ov_counter keys found), it is now active (for current session, and future sessions)" - fi -} - -[[ -n "$OPT_TEST" ]] && { - print -zr ' -# Subshell, assignments, math-mode -echo $(cat /etc/hosts |& grep -i "hello337") -local param1="text ${+variable[test]} text ${var} text"; typeset param2='"'"'other $variable'"'"' -math=$(( 10 + HISTSIZ + HISTSIZE + $SAVEHIST )) size=$(( 0 )) - -# Programming-like usage, bracket matching - through distinct colors; note the backslash quoting -for (( ii = 1; ii <= size; ++ ii )); do - if [[ "${cmds[ii]} string" = "| string" ]] - then - sidx=${buffer[(in:ii:)\$\(?#[^\\\\]\)]} # find opening cmd-subst - (( sidx <= len + 100 )) && { - eidx=${buffer[(b:sidx:ii)[^\\\\]\)]} # find closing cmd-subst - } - fi -done - -# Regular command-line usage -repeat 0 { - zsh -i -c "cat /etc/shells* | grep -x --line-buffered -i '"'/bin/zsh'"'" - builtin exit $return_value - fast-theme -tq default - fsh-alias -tq default-X # alias '"'"'fsh-alias=fast-theme'"'"' works just like the previous line - command -v git | grep ".+git" && echo $'"'"'Git is installed'"'"' - git checkout -m --ours /etc/shells && git status-X - gem install asciidoctor - cat <<<$PATH | tr : \\n > /dev/null 2>/usr/local - man -a fopen fopen-X - CFLAGS="-g -Wall -O0" ./configure -} -' -} - -return 0 -# vim:ft=zsh:et:sw=4:sts=4 diff --git a/.config/zsh/.zsh/fsh/images/203654.gif b/.config/zsh/.zsh/fsh/images/203654.gif deleted file mode 100644 index c4bad36..0000000 Binary files a/.config/zsh/.zsh/fsh/images/203654.gif and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/array-assign.png b/.config/zsh/.zsh/fsh/images/array-assign.png deleted file mode 100644 index 9d35e90..0000000 Binary files a/.config/zsh/.zsh/fsh/images/array-assign.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/assign.png b/.config/zsh/.zsh/fsh/images/assign.png deleted file mode 100644 index 41fed43..0000000 Binary files a/.config/zsh/.zsh/fsh/images/assign.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/brackets.gif b/.config/zsh/.zsh/fsh/images/brackets.gif deleted file mode 100644 index f2564c0..0000000 Binary files a/.config/zsh/.zsh/fsh/images/brackets.gif and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/cmdsubst.png b/.config/zsh/.zsh/fsh/images/cmdsubst.png deleted file mode 100644 index 66e5641..0000000 Binary files a/.config/zsh/.zsh/fsh/images/cmdsubst.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/cplx_cond.png b/.config/zsh/.zsh/fsh/images/cplx_cond.png deleted file mode 100644 index 2296cbb..0000000 Binary files a/.config/zsh/.zsh/fsh/images/cplx_cond.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/eval_cmp.png b/.config/zsh/.zsh/fsh/images/eval_cmp.png deleted file mode 100644 index 77138fc..0000000 Binary files a/.config/zsh/.zsh/fsh/images/eval_cmp.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/execfd.png b/.config/zsh/.zsh/fsh/images/execfd.png deleted file mode 100644 index f9a1d65..0000000 Binary files a/.config/zsh/.zsh/fsh/images/execfd.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/execfd_cmp.png b/.config/zsh/.zsh/fsh/images/execfd_cmp.png deleted file mode 100644 index 628f46a..0000000 Binary files a/.config/zsh/.zsh/fsh/images/execfd_cmp.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/for-loop-cmp.png b/.config/zsh/.zsh/fsh/images/for-loop-cmp.png deleted file mode 100644 index 64472e0..0000000 Binary files a/.config/zsh/.zsh/fsh/images/for-loop-cmp.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/for-loop.png b/.config/zsh/.zsh/fsh/images/for-loop.png deleted file mode 100644 index 7f779ac..0000000 Binary files a/.config/zsh/.zsh/fsh/images/for-loop.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/function.png b/.config/zsh/.zsh/fsh/images/function.png deleted file mode 100644 index 7450061..0000000 Binary files a/.config/zsh/.zsh/fsh/images/function.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/git_chroma.png b/.config/zsh/.zsh/fsh/images/git_chroma.png deleted file mode 100644 index a3bbba5..0000000 Binary files a/.config/zsh/.zsh/fsh/images/git_chroma.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/global-alias.png b/.config/zsh/.zsh/fsh/images/global-alias.png deleted file mode 100644 index 8722681..0000000 Binary files a/.config/zsh/.zsh/fsh/images/global-alias.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/heredoc.png b/.config/zsh/.zsh/fsh/images/heredoc.png deleted file mode 100644 index d88d55b..0000000 Binary files a/.config/zsh/.zsh/fsh/images/heredoc.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/herestring.png b/.config/zsh/.zsh/fsh/images/herestring.png deleted file mode 100644 index 4cd8716..0000000 Binary files a/.config/zsh/.zsh/fsh/images/herestring.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/highlight-less.png b/.config/zsh/.zsh/fsh/images/highlight-less.png deleted file mode 100644 index 54bad72..0000000 Binary files a/.config/zsh/.zsh/fsh/images/highlight-less.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/highlight-much.png b/.config/zsh/.zsh/fsh/images/highlight-much.png deleted file mode 100644 index 73d483f..0000000 Binary files a/.config/zsh/.zsh/fsh/images/highlight-much.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/ideal-string.png b/.config/zsh/.zsh/fsh/images/ideal-string.png deleted file mode 100644 index d7d526d..0000000 Binary files a/.config/zsh/.zsh/fsh/images/ideal-string.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/in_string.png b/.config/zsh/.zsh/fsh/images/in_string.png deleted file mode 100644 index 86932c8..0000000 Binary files a/.config/zsh/.zsh/fsh/images/in_string.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/math.gif b/.config/zsh/.zsh/fsh/images/math.gif deleted file mode 100644 index b445294..0000000 Binary files a/.config/zsh/.zsh/fsh/images/math.gif and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/parameter.png b/.config/zsh/.zsh/fsh/images/parameter.png deleted file mode 100644 index 47f0bb5..0000000 Binary files a/.config/zsh/.zsh/fsh/images/parameter.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/theme.png b/.config/zsh/.zsh/fsh/images/theme.png deleted file mode 100644 index 285e4e4..0000000 Binary files a/.config/zsh/.zsh/fsh/images/theme.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/typeset.png b/.config/zsh/.zsh/fsh/images/typeset.png deleted file mode 100644 index 06881fc..0000000 Binary files a/.config/zsh/.zsh/fsh/images/typeset.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/images/zcalc.png b/.config/zsh/.zsh/fsh/images/zcalc.png deleted file mode 100644 index d2c286d..0000000 Binary files a/.config/zsh/.zsh/fsh/images/zcalc.png and /dev/null differ diff --git a/.config/zsh/.zsh/fsh/share/free_theme.zsh b/.config/zsh/.zsh/fsh/share/free_theme.zsh deleted file mode 100644 index 0f32d66..0000000 --- a/.config/zsh/.zsh/fsh/share/free_theme.zsh +++ /dev/null @@ -1,61 +0,0 @@ -: ${FAST_HIGHLIGHT_STYLES[freedefault]:=none} -: ${FAST_HIGHLIGHT_STYLES[freeunknown-token]:=fg=red,bold} -: ${FAST_HIGHLIGHT_STYLES[freereserved-word]:=fg=150} -: ${FAST_HIGHLIGHT_STYLES[freealias]:=fg=180} -: ${FAST_HIGHLIGHT_STYLES[freesuffix-alias]:=fg=180} -: ${FAST_HIGHLIGHT_STYLES[freebuiltin]:=fg=180} -: ${FAST_HIGHLIGHT_STYLES[freefunction]:=fg=180} -: ${FAST_HIGHLIGHT_STYLES[freecommand]:=fg=180} -: ${FAST_HIGHLIGHT_STYLES[freeprecommand]:=fg=180} -: ${FAST_HIGHLIGHT_STYLES[freecommandseparator]:=none} -: ${FAST_HIGHLIGHT_STYLES[freehashed-command]:=fg=180} -: ${FAST_HIGHLIGHT_STYLES[freepath]:=fg=166} -: ${FAST_HIGHLIGHT_STYLES[freepath_pathseparator]:=} -: ${FAST_HIGHLIGHT_STYLES[freeglobbing]:=fg=112} -: ${FAST_HIGHLIGHT_STYLES[freeglobbing-ext]:=fg=118} -: ${FAST_HIGHLIGHT_STYLES[freehistory-expansion]:=fg=blue,bold} -: ${FAST_HIGHLIGHT_STYLES[freesingle-hyphen-option]:=fg=110} -: ${FAST_HIGHLIGHT_STYLES[freedouble-hyphen-option]:=fg=110} -: ${FAST_HIGHLIGHT_STYLES[freeback-quoted-argument]:=none} -: ${FAST_HIGHLIGHT_STYLES[freesingle-quoted-argument]:=fg=150} -: ${FAST_HIGHLIGHT_STYLES[freedouble-quoted-argument]:=fg=150} -: ${FAST_HIGHLIGHT_STYLES[freedollar-quoted-argument]:=fg=150} -: ${FAST_HIGHLIGHT_STYLES[freeback-or-dollar-double-quoted-argument]:=fg=110} -: ${FAST_HIGHLIGHT_STYLES[freeback-dollar-quoted-argument]:=fg=110} -: ${FAST_HIGHLIGHT_STYLES[freeassign]:=none} -: ${FAST_HIGHLIGHT_STYLES[freeredirection]:=none} -: ${FAST_HIGHLIGHT_STYLES[freecomment]:=fg=black,bold} -: ${FAST_HIGHLIGHT_STYLES[freevariable]:=none} -: ${FAST_HIGHLIGHT_STYLES[freemathvar]:=fg=blue,bold} -: ${FAST_HIGHLIGHT_STYLES[freemathnum]:=fg=166} -: ${FAST_HIGHLIGHT_STYLES[freematherr]:=fg=red} -: ${FAST_HIGHLIGHT_STYLES[freeassign-array-bracket]:=fg=180} -: ${FAST_HIGHLIGHT_STYLES[freefor-loop-variable]:=none} -: ${FAST_HIGHLIGHT_STYLES[freefor-loop-number]:=fg=150} -: ${FAST_HIGHLIGHT_STYLES[freefor-loop-operator]:=fg=150} -: ${FAST_HIGHLIGHT_STYLES[freefor-loop-separator]:=fg=109} -: ${FAST_HIGHLIGHT_STYLES[freeexec-descriptor]:=fg=yellow,bold} -: ${FAST_HIGHLIGHT_STYLES[freehere-string-tri]:=fg=yellow} -: ${FAST_HIGHLIGHT_STYLES[freehere-string-text]:=bg=19} -: ${FAST_HIGHLIGHT_STYLES[freehere-string-var]:=fg=110,bg=19} -: ${FAST_HIGHLIGHT_STYLES[freesecondary]:=zdharma} -: ${FAST_HIGHLIGHT_STYLES[freecase-input]:=fg=180} -: ${FAST_HIGHLIGHT_STYLES[freecase-parentheses]:=fg=116} -: ${FAST_HIGHLIGHT_STYLES[freecase-condition]:=bg=19} -: ${FAST_HIGHLIGHT_STYLES[freecorrect-subtle]:=bg=55} -: ${FAST_HIGHLIGHT_STYLES[freeincorrect-subtle]:=bg=52} -: ${FAST_HIGHLIGHT_STYLES[freesubtle-separator]:=none} -: ${FAST_HIGHLIGHT_STYLES[freesubtle-bg]:=bg=18} -: ${FAST_HIGHLIGHT_STYLES[freepath-to-dir]:=fg=166,underline} -: ${FAST_HIGHLIGHT_STYLES[freepaired-bracket]:=bg=blue} -: ${FAST_HIGHLIGHT_STYLES[freebracket-level-1]:=fg=130} -: ${FAST_HIGHLIGHT_STYLES[freebracket-level-2]:=fg=70} -: ${FAST_HIGHLIGHT_STYLES[freebracket-level-3]:=fg=69} -: ${FAST_HIGHLIGHT_STYLES[freeglobal-alias]:=bg=19} -: ${FAST_HIGHLIGHT_STYLES[freesubcommand]:=fg=150} -: ${FAST_HIGHLIGHT_STYLES[freesingle-sq-bracket]:=fg=180} -: ${FAST_HIGHLIGHT_STYLES[freedouble-sq-bracket]:=fg=180} -: ${FAST_HIGHLIGHT_STYLES[freedouble-paren]:=fg=150} -: ${FAST_HIGHLIGHT_STYLES[freeoptarg-string]:=fg=150} -: ${FAST_HIGHLIGHT_STYLES[freeoptarg-number]:=fg=166} -: ${FAST_HIGHLIGHT_STYLES[freerecursive-base]:=fg=183} diff --git a/.config/zsh/.zsh/fsh/test/parse.zsh b/.config/zsh/.zsh/fsh/test/parse.zsh deleted file mode 100755 index 53dec62..0000000 --- a/.config/zsh/.zsh/fsh/test/parse.zsh +++ /dev/null @@ -1,220 +0,0 @@ -#!/bin/sh - -# -# This file runs the highlighter on a specified file -# i.e. parses the file with the highlighter. Outputs -# running time (stderr) and resulting region_highlight -# (file parse.out, or $2 if given). -# -# Can be also run in line-wise mode on own input (-o -# option in $1), no region_highlight file then. -# - -[[ -z "$ZSH_VERSION" ]] && exec /usr/bin/env /usr/local/bin/zsh-5.5.1 -f -c "source \"$0\" \"$1\" \"$2\" \"$3\"" - -ZERO="${(%):-%N}" - -if [[ -e "${ZERO}/../fast-highlight" ]]; then - source "${ZERO}/../fast-highlight" - source "${ZERO}/../fast-string-highlight" - fpath+=( "${ZERO}/.." ) -elif [[ -e "../fast-highlight" ]]; then - source "../fast-highlight" - source "../fast-string-highlight" - fpath+=( "$PWD/.." ) -elif [[ -e "${ZERO}/fast-highlight" ]]; then - source "${ZERO}/fast-highlight" - source "${ZERO}/fast-string-highlight" - fpath+=( "${ZERO}" ) -elif [[ -e "./fast-highlight" ]]; then - source "./fast-highlight" - source "./fast-string-highlight" - fpath+=( "./" ) -else - print -u2 "Could not find fast-highlight, aborting" - exit 1 -fi - -zmodload zsh/zprof -autoload is-at-least chroma/-git.ch - -setopt interactive_comments extendedglob - -# Own input? -if [[ "$1" = "-o" || "$1" = "-oo" || "$1" = "-ooo" || "$1" = "-git" || "$1" = "-hue" || "$1" = "-hol" ]]; then - typeset -a input - input=() - if [[ "$1" = "-o" ]]; then - input+=( "./parse.zsh ../fast-highlight parse2.out" ) - input+=( "rm -f parse*.out" ) - input+=( "./mh-parse.zsh ../fast-highlight > out" ) - input+=( "if [[ -o multibyte ]]; then echo multibyte is set; fi" ) - input+=( "[[ \"a\" = *[[:alpha:]_-][[:alpha:]]# ]] && echo yes" ) - input+=( 'git tag -a v0.98 -m "Syntax highlighting of the history entries"' ) - input+=( 'func() { echo "a" >! phist2.db; echo "b" >>! phist2.db; fc -Rap "phist2.db"; list=( ${history[@]} ); echo "${history[1]}"; }' ) - (( ${+ZSH_EXECUTION_STRING} == 0 )) && { print -zr "${(F)input}"; return 0; } - elif [[ "$1" = "-oo" ]]; then - input+=( 'typeset -a list\n() {\necho "a" >! phist2.db\necho "b" >>! phist2.db\nfc -Rap "phist2.db"\nlist=( ${history[@]} )\necho "${history[2]}"\necho "${history[1]}"\necho "${#history}";\ninteger size="${#history}"\nsize+=1\necho "$size" / "${history[$size]}"\nlist=( "${history[$size]}" ${history[@]} )\n}' ) - input+=( 'typeset -a list\n() {\necho "a" >! phist2.db\necho "b" >>! phist2.db\nfc -Rap "phist2.db"\nlist=( ${history[@]} )\necho "${history[2]}"\necho "${history[1]}"\necho "${#history}";\ninteger size="${#history}"\nsize+=1\necho "$size" / "${history[$size]}"\nlist=( "${history[$size]}" ${history[@]} )\n}' ) - input+=( 'typeset -a list\n() {\necho "a" >! phist2.db\necho "b" >>! phist2.db\nfc -Rap "phist2.db"\nlist=( ${history[@]} )\necho "${history[2]}"\necho "${history[1]}"\necho "${#history}";\ninteger size="${#history}"\nsize+=1\necho "$size" / "${history[$size]}"\nlist=( "${history[$size]}" ${history[@]} )\n}' ) - input+=( 'typeset -a list\n() {\necho "a" >! phist2.db\necho "b" >>! phist2.db\nfc -Rap "phist2.db"\nlist=( ${history[@]} )\necho "${history[2]}"\necho "${history[1]}"\necho "${#history}";\ninteger size="${#history}"\nsize+=1\necho "$size" / "${history[$size]}"\nlist=( "${history[$size]}" ${history[@]} )\n}' ) - input+=( 'typeset -a list\n() {\necho "a" >! phist2.db\necho "b" >>! phist2.db\nfc -Rap "phist2.db"\nlist=( ${history[@]} )\necho "${history[2]}"\necho "${history[1]}"\necho "${#history}";\ninteger size="${#history}"\nsize+=1\necho "$size" / "${history[$size]}"\nlist=( "${history[$size]}" ${history[@]} )\n}' ) - input+=( 'typeset -a list\n() {\necho "a" >! phist2.db\necho "b" >>! phist2.db\nfc -Rap "phist2.db"\nlist=( ${history[@]} )\necho "${history[2]}"\necho "${history[1]}"\necho "${#history}";\ninteger size="${#history}"\nsize+=1\necho "$size" / "${history[$size]}"\nlist=( "${history[$size]}" ${history[@]} )\n}' ) - input+=( 'typeset -a list\n() {\necho "a" >! phist2.db\necho "b" >>! phist2.db\nfc -Rap "phist2.db"\nlist=( ${history[@]} )\necho "${history[2]}"\necho "${history[1]}"\necho "${#history}";\ninteger size="${#history}"\nsize+=1\necho "$size" / "${history[$size]}"\nlist=( "${history[$size]}" ${history[@]} )\n}' ) - (( ${+ZSH_EXECUTION_STRING} == 0 )) && { print -zr "${(F)input}"; return 0; } - elif [[ "$1" = "-ooo" ]]; then - local in=' -# This is an example code that is diverse and allows to test a theme -text="An example quite long string $with variable in it" -local param1="text $variable" param2='"'"'other $variable'"'"' -math=$(( 10 + HISTSIZ + HISTSIZE + $SAVEHIST )) size=$(( 0 )) - -for (( ii = 1; ii <= size; ++ ii )); do - if [[ "${cmds[ii]} string" = "| string" ]] - then - sidx=${buffer[(in:ii:)\$\(?#[^\\\\]\)]} # find opening $( - (( sidx <= len )) && { - eidx=${buffer[(b:sidx:ii)[^\\\\]\)]} # find closing ) - } - fi -done' - (( ${+ZSH_EXECUTION_STRING} == 0 )) && { print -zr "$in"; return 0; } - input+=( "$in" ) - input+=( "$in" ) - elif [[ "$1" = "-git" ]]; then - local in="git lp -git push origin master - git commit -git add safari.ini zdharma.ini -git st . -git diff --cached -git commit --allow-empty -git checkout themes/zdharma.ini -git commit --amend -git commit -m \"Example commit message\" -git tag -a 'v1.18' -m 'Here-string is highlighted, descriptor-variables passed to exec are correctly highlighted' -git tag -l -n9 -git checkout cb66b11 -" - (( ${+ZSH_EXECUTION_STRING} == 0 )) && { print -zr "$in"; return 0; } - input+=( "$in" ) - input+=( "$in" ) - elif [[ "$1" = "-hue" ]]; then - local in="var=\$other; local var=\$other - () { eval \"\$var\"; } - case \$other in - \$var) - ( echo OK; ) - ;; - esac - sudo -i -s ls -1 /var/log - () { ( eval \"command ls -1\" ); } argument" - - (( ${+ZSH_EXECUTION_STRING} == 0 )) && { print -zr "$in"; return 0; } - - input+=( "$in" "$in" ) - elif [[ "$1" = "-hol" ]]; then - local in="var=\$( other ) -local var2=\$(( other + 1 )) -() { eval \"\$var\"; } -sudo -i -s ls -1 >/tmp/ls-log.txt /var/log -IFS=\$'\\n' print -rl -- \$(command ls -1 | tee -a /tmp/ls-1.txt) -var3=\$(( HISTSIZE + 10 + \$var )) -local var4=\$( other command ) -touch \$(( HISTSIZE + \$SAVEHIST + 10 )) -case \$other in - \$var) - ( echo OK; ) - ;; - \$var3) - ( if { true } { noglob echo yes } ) -esac -( builtin cd /var/log; ls -1; noglob cd \"/var/log\" 'log' ) -noglob cat <<<\"\$PATH\" | tr : \"\\n\" -if [[ \"\$var\" -gt 10 ]]; then - (( var = HISTSIZE + \$SAVEHIST )) -fi -/var/log -sidx=\${buffer[(in:ii:)\\\$\\(?#[^\\\\\\\\]\\)]} # find opening cmd-subst -{ - exec {MYFD}<&0 {MYFD2}>&1 - ( read <&\$MYFD line; echo \$line >&\$MYFD2 && { builtin print \${match[1]}Written. } ) -} always { - (( MYFD > 0 )) && { print -rl -- -myfd:\$MYFD >&\$MYFD2 && print \"Sent.\" '(to filedescriptor)'; } -} -command sleep \"\$(( \$a + b + \${cde} + \${(s::)fgh[ijk]} + \\\$l + \\m + \\\" ))\" -for (( i = 0; i <= 2; ++ i )) { print \$i; } -" - - (( ${+ZSH_EXECUTION_STRING} == 0 )) && { print -zr "$in"; return 0; } - - input+=( "$in" ) - fi - - typeset -a long_input - integer i - for (( i=1; i<= 50; i ++ )); do - long_input+=( "${input[@]}" ) - done - - typeset -F SECONDS - SECONDS=0 - - local right_brace_is_recognised_everywhere - integer path_dirs_was_set multi_func_def ointeractive_comments - -fast-highlight-fill-option-variables - - local BUFFER - for BUFFER in "${long_input[@]}"; do - reply=( ) - () { - -fast-highlight-init - -fast-highlight-process "" "$BUFFER" "0" - -fast-highlight-string-process "" "$BUFFER" - } - done - - print "Running time: $SECONDS" - zprof | head -# File input? -elif [[ -r "$1" ]]; then - # Load from given file - local BUFFER="$(<$1)" - - typeset -F SECONDS - SECONDS=0 - - reply=( ) - -fast-highlight-init - - local right_brace_is_recognised_everywhere - integer path_dirs_was_set multi_func_def ointeractive_comments - -fast-highlight-fill-option-variables - - () { - -fast-highlight-process "" "$BUFFER" "0" - -fast-highlight-string-process "" "$BUFFER" - } - - print "Running time: $SECONDS" - zprof | head - - # This output can be diffed to detect changes in operation - if [[ -z "$2" ]]; then - print -rl -- "${reply[@]}" >! out.parse - else - print -rl -- "${reply[@]}" >! "$2" - fi -else - if [[ -z "$1" ]]; then - print -u2 "Usage: ./parse.zsh {to-parse file} [region_highlight output file]" - exit 2 - else - print -u2 "Unreadable to-parse file \`$1', aborting" - exit 3 - fi -fi - -exit 0 - -# vim:ft=zsh diff --git a/.config/zsh/.zsh/fsh/test/to-parse.zsh b/.config/zsh/.zsh/fsh/test/to-parse.zsh deleted file mode 100644 index 855d7a4..0000000 --- a/.config/zsh/.zsh/fsh/test/to-parse.zsh +++ /dev/null @@ -1,823 +0,0 @@ -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - -typeset -gA __hsmw_highlight_main__command_type_cache - -# Define default styles. -typeset -gA HSMW_HIGHLIGHT_STYLES -: ${HSMW_HIGHLIGHT_STYLES[default]:=none} -: ${HSMW_HIGHLIGHT_STYLES[unknown-token]:=fg=red,bold} -: ${HSMW_HIGHLIGHT_STYLES[reserved-word]:=fg=yellow} -: ${HSMW_HIGHLIGHT_STYLES[alias]:=fg=green} -: ${HSMW_HIGHLIGHT_STYLES[suffix-alias]:=fg=green} -: ${HSMW_HIGHLIGHT_STYLES[builtin]:=fg=green} -: ${HSMW_HIGHLIGHT_STYLES[function]:=fg=green} -: ${HSMW_HIGHLIGHT_STYLES[command]:=fg=green} -: ${HSMW_HIGHLIGHT_STYLES[precommand]:=fg=green} -: ${HSMW_HIGHLIGHT_STYLES[commandseparator]:=none} -: ${HSMW_HIGHLIGHT_STYLES[hashed-command]:=fg=green} -: ${HSMW_HIGHLIGHT_STYLES[path]:=fg=magenta} -: ${HSMW_HIGHLIGHT_STYLES[path_pathseparator]:=} -: ${HSMW_HIGHLIGHT_STYLES[path_prefix]:=fg=magenta} -: ${HSMW_HIGHLIGHT_STYLES[path_prefix_pathseparator]:=} -: ${HSMW_HIGHLIGHT_STYLES[globbing]:=fg=blue,bold} -: ${HSMW_HIGHLIGHT_STYLES[history-expansion]:=fg=blue,bold} -: ${HSMW_HIGHLIGHT_STYLES[single-hyphen-option]:=none} -: ${HSMW_HIGHLIGHT_STYLES[double-hyphen-option]:=none} -: ${HSMW_HIGHLIGHT_STYLES[back-quoted-argument]:=none} -: ${HSMW_HIGHLIGHT_STYLES[single-quoted-argument]:=fg=yellow} -: ${HSMW_HIGHLIGHT_STYLES[double-quoted-argument]:=fg=yellow} -: ${HSMW_HIGHLIGHT_STYLES[dollar-quoted-argument]:=fg=yellow} -: ${HSMW_HIGHLIGHT_STYLES[dollar-double-quoted-argument]:=fg=cyan} -: ${HSMW_HIGHLIGHT_STYLES[back-double-quoted-argument]:=fg=cyan} -: ${HSMW_HIGHLIGHT_STYLES[back-dollar-quoted-argument]:=fg=cyan} -: ${HSMW_HIGHLIGHT_STYLES[assign]:=none} -: ${HSMW_HIGHLIGHT_STYLES[redirection]:=none} -: ${HSMW_HIGHLIGHT_STYLES[comment]:=fg=black,bold} - -# Get the type of a command. -# -# Uses the zsh/parameter module if available to avoid forks, and a -# wrapper around 'type -w' as fallback. -# -# Takes a single argument. -# -# The result will be stored in REPLY. --hsmw-highlight-main-type() { - if (( $+__hsmw_highlight_main__command_type_cache )); then - REPLY=$__hsmw_highlight_main__command_type_cache[(e)$1] - if [[ -n "$REPLY" ]]; then - return - fi - fi - if (( $#options_to_set )); then - setopt localoptions $options_to_set; - fi - unset REPLY - if zmodload -e zsh/parameter; then - if (( $+aliases[(e)$1] )); then - REPLY=alias - elif (( $+saliases[(e)${1##*.}] )); then - REPLY='suffix alias' - elif (( $reswords[(Ie)$1] )); then - REPLY=reserved - elif (( $+functions[(e)$1] )); then - REPLY=function - elif (( $+builtins[(e)$1] )); then - REPLY=builtin - elif (( $+commands[(e)$1] )); then - REPLY=command - # zsh 5.2 and older have a bug whereby running 'type -w ./sudo' implicitly - # runs 'hash ./sudo=/usr/local/bin/./sudo' (assuming /usr/local/bin/sudo - # exists and is in $PATH). Avoid triggering the bug, at the expense of - # falling through to the $(x) below, incurring a fork. (Issue #354.) - # - # The second disjunct mimics the isrelative() C call from the zsh bug. - elif { [[ $1 != */* ]] || is-at-least 5.3 } && - ! builtin type -w -- $1 >/dev/null 2>&1; then - REPLY=none - fi - fi - if ! (( $+REPLY )); then - REPLY="${$(LC_ALL=C builtin type -w -- $1 2>/dev/null)#*: }" - fi - if (( $+__hsmw_highlight_main__command_type_cache )); then - __hsmw_highlight_main__command_type_cache[(e)$1]=$REPLY - fi -} - -# Check whether the first argument is a redirection operator token. -# Report result via the exit code. --hsmw-highlight-is-redirection() { - # A redirection operator token: - # - starts with an optional single-digit number; - # - then, has a '<' or '>' character; - # - is not a process substitution [<(...) or >(...)]. - [[ $1 == (<0-9>|)(\<|\>)* ]] && [[ $1 != (\<|\>)$'\x28'* ]] -} - -# Resolve alias. -# -# Takes a single argument. -# -# The result will be stored in REPLY. --hsmw-highlight-resolve-alias() { - if zmodload -e zsh/parameter; then - REPLY=${aliases[$arg]} - else - REPLY="${"$(alias -- $arg)"#*=}" - fi -} - -# Check that the top of $braces_stack has the expected value. If it does, set -# the style according to $2; otherwise, set style=unknown-token. -# -# $1: character expected to be at the top of $braces_stack -# $2: assignment to execute it if matches --hsmw-highlight-stack-pop() { - if [[ $braces_stack[1] == $1 ]]; then - braces_stack=${braces_stack:1} - eval "$2" - else - style=unknown-token - fi -} - -# Main syntax highlighting function. --hsmw-highlight-process() -{ - ## Before we even 'emulate -L', we must test a few options that would reset. - if [[ -o interactive_comments ]]; then - local interactive_comments= # set to empty - fi - if [[ -o ignore_braces ]] || eval '[[ -o ignore_close_braces ]] 2>/dev/null'; then - local right_brace_is_recognised_everywhere=false - else - local right_brace_is_recognised_everywhere=true - fi - if [[ -o path_dirs ]]; then - integer path_dirs_was_set=1 - else - integer path_dirs_was_set=0 - fi - if [[ -o multi_func_def ]]; then - integer multi_func_def=1 - else - integer multi_func_def=0 - fi - emulate -L zsh - setopt localoptions extendedglob bareglobqual - - ## Variable declarations and initializations - local start_pos=0 end_pos highlight_glob=true arg style - local in_array_assignment=false # true between 'a=(' and the matching ')' - typeset -a __HSMW_HIGHLIGHT_TOKENS_COMMANDSEPARATOR - typeset -a __HSMW_HIGHLIGHT_TOKENS_PRECOMMANDS - typeset -a __HSMW_HIGHLIGHT_TOKENS_CONTROL_FLOW - local -a options_to_set # used in callees - local buf="$1" - integer len="${#buf}" - integer pure_buf_len=len # historical, was $#BUFFER, i.e. len without $PREBUFFER; used e.g. in *_check_path - - local braces_stack # "R" for round, "Q" for square, "Y" for curly - - if (( path_dirs_was_set )); then - options_to_set+=( PATH_DIRS ) - fi - unset path_dirs_was_set - - __HSMW_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=( - '|' '||' ';' '&' '&&' - '|&' - '&!' '&|' - # ### 'case' syntax, but followed by a pattern, not by a command - # ';;' ';&' ';|' - ) - __HSMW_HIGHLIGHT_TOKENS_PRECOMMANDS=( - 'builtin' 'command' 'exec' 'nocorrect' 'noglob' - 'pkexec' # immune to #121 because it's usually not passed --option flags - ) - - # Tokens that, at (naively-determined) "command position", are followed by - # a de jure command position. All of these are reserved words. - __HSMW_HIGHLIGHT_TOKENS_CONTROL_FLOW=( - $'\x7b' # block - $'\x28' # subshell - '()' # anonymous function - 'while' - 'until' - 'if' - 'then' - 'elif' - 'else' - 'do' - 'time' - 'coproc' - '!' # reserved word; unrelated to $histchars[1] - ) - - local -a match mbegin mend - - # State machine - # - # The states are: - # - :start: Command word - # - :sudo_opt: A leading-dash option to sudo (such as "-u" or "-i") - # - :sudo_arg: The argument to a sudo leading-dash option that takes one, - # when given as a separate word; i.e., "foo" in "-u foo" (two - # words) but not in "-ufoo" (one word). - # - :regular: "Not a command word", and command delimiters are permitted. - # Mainly used to detect premature termination of commands. - # - :always: The word 'always' in the «{ foo } always { bar }» syntax. - # - # When the kind of a word is not yet known, $this_word / $next_word may contain - # multiple states. For example, after "sudo -i", the next word may be either - # another --flag or a command name, hence the state would include both :start: - # and :sudo_opt:. - # - # The tokens are always added with both leading and trailing colons to serve as - # word delimiters (an improvised array); [[ $x == *:foo:* ]] and x=${x//:foo:/} - # will DTRT regardless of how many elements or repetitions $x has.. - # - # Handling of redirections: upon seeing a redirection token, we must stall - # the current state --- that is, the value of $this_word --- for two iterations - # (one for the redirection operator, one for the word following it representing - # the redirection target). Therefore, we set $in_redirection to 2 upon seeing a - # redirection operator, decrement it each iteration, and stall the current state - # when it is non-zero. Thus, upon reaching the next word (the one that follows - # the redirection operator and target), $this_word will still contain values - # appropriate for the word immediately following the word that preceded the - # redirection operator. - # - # The "the previous word was a redirection operator" state is not communicated - # to the next iteration via $next_word/$this_word as usual, but via - # $in_redirection. The value of $next_word from the iteration that processed - # the operator is discarded. - # - local this_word=':start:' next_word - integer in_redirection - # Processing buffer - local proc_buf="$buf" - for arg in ${interactive_comments-${(z)buf}} \ - ${interactive_comments+${(zZ+c+)buf}}; do - # Initialize $next_word. - if (( in_redirection )); then - (( --in_redirection )) - fi - if (( in_redirection == 0 )); then - # Initialize $next_word to its default value. - next_word=':regular:' - else - # Stall $next_word. - fi - - # Initialize per-"simple command" [zshmisc(1)] variables: - # - # $already_added (see next paragraph) - # $style how to highlight $arg - # $in_array_assignment boolean flag for "between '(' and ')' of array assignment" - # $highlight_glob boolean flag for "'noglob' is in effect" - # - # $already_added is set to 1 to disable adding an entry to region_highlight - # for this iteration. Currently, that is done for "" and $'' strings, - # which add the entry early so escape sequences within the string override - # the string's color. - integer already_added=0 - style=unknown-token - if [[ $this_word == *':start:'* ]]; then - in_array_assignment=false - if [[ $arg == 'noglob' ]]; then - highlight_glob=false - fi - fi - - # Compute the new $start_pos and $end_pos, skipping over whitespace in $buf. - if [[ $arg == ';' ]] ; then - # We're looking for either a semicolon or a newline, whichever comes - # first. Both of these are rendered as a ";" (SEPER) by the ${(z)..} - # flag. - # - # We can't use the (Z+n+) flag because that elides the end-of-command - # token altogether, so 'echo foo\necho bar' (two commands) becomes - # indistinguishable from 'echo foo echo bar' (one command with three - # words for arguments). - local needle=$'[;\n]' - integer offset=$(( ${proc_buf[(i)$needle]} - 1 )) - (( start_pos += offset )) - (( end_pos = start_pos + $#arg )) - else - # The line was: - # - # integer offset=$(((len-start_pos)-${#${proc_buf##([[:space:]]|\\[[:space:]])#}})) - # - # - len-start_pos is length of current proc_buf; basically: initial length minus where - # we are, and proc_buf is chopped to the "where we are" (compare the "previous value - # of start_pos" below, and the len-(start_pos-offset) = len-start_pos+offset) - # - what's after main minus sign is: length of proc_buf without spaces at the beginning - # - so what the line actually did, was computing length of the spaces! - # - this can be done via (#b) flag, like below - if [[ "$proc_buf" = (#b)(#s)(([[:space:]]|\\[[:space:]])##)* ]]; then - # The first, outer parenthesis - integer offset="${#match[1]}" - else - integer offset=0 - fi - ((start_pos+=offset)) - ((end_pos=$start_pos+${#arg})) - fi - - # Compute the new $proc_buf. We advance it - # (chop off characters from the beginning) - # beyond what end_pos points to, by skipping - # as many characters as end_pos was advanced. - # - # end_pos was advanced by $offset (via start_pos) - # and by $#arg. Note the `start_pos=$end_pos` - # below. - # - # As for the [,len]. We could use [,len-start_pos+offset] - # here, but to make it easier on eyes, we use len and - # rely on the fact that Zsh simply handles that. The - # length of proc_buf is len-start_pos+offset because - # we're chopping it to match current start_pos, so its - # length matches the previous value of start_pos. - # - # Why [,-1] is slower than [,length] isn't clear. - proc_buf="${proc_buf[offset + $#arg + 1,len]}" - - # Handle the INTERACTIVE_COMMENTS option. - # - # We use the (Z+c+) flag so the entire comment is presented as one token in $arg. - if [[ -n ${interactive_comments+'set'} && $arg[1] == $histchars[3] ]]; then - if [[ $this_word == *(':regular:'|':start:')* ]]; then - style=comment - else - style=unknown-token # prematurely terminated - fi - -hsmw-add-highlight $start_pos $end_pos $style - already_added=1 - continue - fi - - # Analyse the current word. - if -hsmw-highlight-is-redirection $arg ; then - # A '<' or '>', possibly followed by a digit - in_redirection=2 - fi - - # Special-case the first word after 'sudo'. - if (( ! in_redirection )); then - if [[ $this_word == *':sudo_opt:'* ]] && [[ $arg != -* ]]; then - this_word=${this_word//:sudo_opt:/} - fi - fi - - # Parse the sudo command line - if (( ! in_redirection )); then - if [[ $this_word == *':sudo_opt:'* ]]; then - case "$arg" in - # Flag that requires an argument - '-'[Cgprtu]) this_word=${this_word//:start:/}; - next_word=':sudo_arg:';; - # This prevents misbehavior with sudo -u -otherargument - '-'*) this_word=${this_word//:start:/}; - next_word+=':start:'; - next_word+=':sudo_opt:';; - *) ;; - esac - elif [[ $this_word == *':sudo_arg:'* ]]; then - next_word+=':sudo_opt:' - next_word+=':start:' - fi - fi - - # The Great Fork: is this a command word? Is this a non-command word? - if [[ $this_word == *':always:'* && $arg == 'always' ]]; then - # try-always construct - style=reserved-word # de facto a reserved word, although not de jure - next_word=':start:' - elif [[ $this_word == *':start:'* ]] && (( in_redirection == 0 )); then # $arg is the command word - if [[ -n ${(M)__HSMW_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]]; then - style=precommand - elif [[ "$arg" = "sudo" ]]; then - style=precommand - next_word=${next_word//:regular:/} - next_word+=':sudo_opt:' - next_word+=':start:' - else - -hsmw-highlight-expand-path $arg - local expanded_arg="$REPLY" - -hsmw-highlight-main-type ${expanded_arg} - local res="$REPLY" - () { - # Special-case: command word is '$foo', like that, without braces or anything. - # - # That's not entirely correct --- if the parameter's value happens to be a reserved - # word, the parameter expansion will be highlighted as a reserved word --- but that - # incorrectness is outweighed by the usability improvement of permitting the use of - # parameters that refer to commands, functions, and builtins. - local -a match mbegin mend - local MATCH; integer MBEGIN MEND - if [[ $res == none ]] && (( ${+parameters} )) && - [[ ${arg[1]} == \$ ]] && [[ ${arg:1} = ([[:alpha:]_][[:alnum:]_]#|[[:digit:]]##) ]] && - (( ${+parameters[${MATCH}]} )) - then - -hsmw-highlight-main-type ${(P)MATCH} - res=$REPLY - fi - } - case $res in - reserved) # reserved word - style=reserved-word - if [[ $arg == $'\x7b' ]]; then - braces_stack='Y'"$braces_stack" - elif [[ $arg == $'\x7d' ]]; then - # We're at command word, so no need to check $right_brace_is_recognised_everywhere - -hsmw-highlight-stack-pop 'Y' style=reserved-word - if [[ $style == reserved-word ]]; then - next_word+=':always:' - fi - fi - ;; - 'suffix alias') style=suffix-alias;; - alias) () { - integer insane_alias - case $arg in - # Issue #263: aliases with '=' on their LHS. - # - # There are three cases: - # - # - Unsupported, breaks 'alias -L' output, but invokable: - ('='*) :;; - # - Unsupported, not invokable: - (*'='*) insane_alias=1;; - # - The common case: - (*) :;; - esac - if (( insane_alias )); then - style=unknown-token - else - style=alias - -hsmw-highlight-resolve-alias $arg - local alias_target="$REPLY" - [[ -n ${(M)__HSMW_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$alias_target"} && -z ${(M)__HSMW_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]] && __HSMW_HIGHLIGHT_TOKENS_PRECOMMANDS+=($arg) - fi - } - ;; - builtin) style=builtin;; - function) style=function;; - command) style=command;; - hashed) style=hashed-command;; - none) if -hsmw-highlight-check-assign; then - style=assign - if [[ $arg[-1] == '(' ]]; then - in_array_assignment=true - else - # assignment to a scalar parameter. - # (For array assignments, the command doesn't start until the ")" token.) - next_word+=':start:' - fi - elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then - style=history-expansion - elif [[ $arg[0,1] == $histchars[2,2] ]]; then - style=history-expansion - elif [[ -n ${(M)__HSMW_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then - if [[ $this_word == *':regular:'* ]]; then - # This highlights empty commands (semicolon follows nothing) as an error. - # Zsh accepts them, though. - style=commandseparator - else - style=unknown-token - fi - elif (( in_redirection == 2 )); then - style=redirection - elif [[ $arg[1,2] == '((' ]]; then - # Arithmetic evaluation. - # - # Note: prior to zsh-5.1.1-52-g4bed2cf (workers/36669), the ${(z)...} - # splitter would only output the '((' token if the matching '))' had - # been typed. Therefore, under those versions of zsh, BUFFER="(( 42" - # would be highlighted as an error until the matching "))" are typed. - # - # We highlight just the opening parentheses, as a reserved word; this - # is how [[ ... ]] is highlighted, too. - style=reserved-word - -hsmw-add-highlight $start_pos $((start_pos + 2)) $style - already_added=1 - if [[ $arg[-2,-1] == '))' ]]; then - -hsmw-add-highlight $((end_pos - 2)) $end_pos $style - already_added=1 - fi - elif [[ $arg == '()' ]]; then - # anonymous function - style=reserved-word - elif [[ $arg == $'\x28' ]]; then - # subshell - style=reserved-word - braces_stack='R'"$braces_stack" - else - if -hsmw-highlight-check-path; then - style=$REPLY - else - style=unknown-token - fi - fi - ;; - *) -hsmw-add-highlight $start_pos $end_pos commandtypefromthefuture-$res - already_added=1 - ;; - esac - fi - fi - if (( ! already_added )) && [[ $style == unknown-token ]] && # not handled by the 'command word' codepath - { (( in_redirection )) || [[ $this_word == *':regular:'* ]] || [[ $this_word == *':sudo_opt:'* ]] || [[ $this_word == *':sudo_arg:'* ]] } - then # $arg is a non-command word - case $arg in - $'\x29') # subshell or end of array assignment - if $in_array_assignment; then - style=assign - in_array_assignment=false - next_word+=':start:' - else - -hsmw-highlight-stack-pop 'R' style=reserved-word - fi;; - $'\x28\x29') # possibly a function definition - if (( multi_func_def )) || false # TODO: or if the previous word was a command word - then - next_word+=':start:' - fi - style=reserved-word - ;; - $'\x7d') # right brace - # - # Parsing rule: # { - # - # Additionally, `tt(})' is recognized in any position if neither the - # tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set.""" - if $right_brace_is_recognised_everywhere; then - -hsmw-highlight-stack-pop 'Y' style=reserved-word - if [[ $style == reserved-word ]]; then - next_word+=':always:' - fi - else - # Fall through to the catchall case at the end. - fi - ;| - '--'*) style=double-hyphen-option;; - '-'*) style=single-hyphen-option;; - "'"*) style=single-quoted-argument;; - '"'*) style=double-quoted-argument - -hsmw-add-highlight $start_pos $end_pos $style - -hsmw-highlight-string - already_added=1 - ;; - \$\'*) style=dollar-quoted-argument - -hsmw-add-highlight $start_pos $end_pos $style - -hsmw-highlight-dollar-string - already_added=1 - ;; - '`'*) style=back-quoted-argument;; - [*?]*|*[^\\][*?]*) - $highlight_glob && style=globbing || style=default;; - *) if false; then - elif [[ $arg = $'\x7d' ]] && $right_brace_is_recognised_everywhere; then - # was handled by the $'\x7d' case above - elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then - style=history-expansion - elif [[ -n ${(M)__HSMW_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then - if [[ $this_word == *':regular:'* ]]; then - style=commandseparator - else - style=unknown-token - fi - elif (( in_redirection == 2 )); then - style=redirection - else - if -hsmw-highlight-check-path; then - style=$REPLY - else - style=default - fi - fi - ;; - esac - fi - if ! (( already_added )); then - -hsmw-add-highlight $start_pos $end_pos $style - [[ $style == path || $style == path_prefix ]] && -hsmw-highlight-path-separators - fi - if [[ -n ${(M)__HSMW_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then - if [[ $arg == ';' ]] && $in_array_assignment; then - # literal newline inside an array assignment - next_word=':regular:' - else - next_word=':start:' - highlight_glob=true - fi - elif - [[ -n ${(M)__HSMW_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} && $this_word == *':start:'* ]] || - [[ -n ${(M)__HSMW_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} && $this_word == *':start:'* ]]; then - next_word=':start:' - elif [[ $arg == "repeat" && $this_word == *':start:'* ]]; then - # skip the repeat-count word - in_redirection=2 - # The redirection mechanism assumes $this_word describes the word - # following the redirection. Make it so. - # - # That word can be a command word with shortloops (`repeat 2 ls`) - # or a command separator (`repeat 2; ls` or `repeat 2; do ls; done`). - # - # The repeat-count word will be handled like a redirection target. - this_word=':start::regular:' - fi - start_pos=$end_pos - if (( in_redirection == 0 )); then - # This is the default/common codepath. - this_word=$next_word - else - # Stall $this_word. - fi - done -} - -# Check if $arg is variable assignment --hsmw-highlight-check-assign() -{ - setopt localoptions extended_glob - [[ $arg == [[:alpha:]_][[:alnum:]_]#(|\[*\])(|[+])=* ]] || - [[ $arg == [0-9]##(|[+])=* ]] -} - --hsmw-highlight-path-separators() -{ - local pos style_pathsep - style_pathsep=${style}_pathseparator - [[ -z "$HSMW_HIGHLIGHT_STYLES[$style_pathsep]" || "$HSMW_HIGHLIGHT_STYLES[$style]" == "$HSMW_HIGHLIGHT_STYLES[$style_pathsep]" ]] && return 0 - for (( pos = start_pos; $pos <= end_pos; pos++ )) ; do - if [[ ${buf[pos]} == "/" ]]; then - -hsmw-add-highlight $((pos - 1)) $pos $style_pathsep - fi - done -} - -# Check if $arg is a path. -# If yes, return 0 and in $REPLY the style to use. -# Else, return non-zero (and the contents of $REPLY is undefined). --hsmw-highlight-check-path() -{ - -hsmw-highlight-expand-path $arg; - local expanded_path="$REPLY" - - REPLY=path - - [[ -z $expanded_path ]] && return 1 - [[ -L $expanded_path ]] && return 0 - [[ -e $expanded_path ]] && return 0 - - # Search the path in CDPATH - local cdpath_dir - for cdpath_dir in $cdpath ; do - [[ -e "$cdpath_dir/$expanded_path" ]] && return 0 - done - - # If dirname($arg) doesn't exist, neither does $arg. - [[ ! -d ${expanded_path:h} ]] && return 1 - - # If this word ends the buffer, check if it's the prefix of a valid path. - if [[ ${buf[1]} != "-" && $pure_buf_len == $end_pos ]]; then - local -a tmp - tmp=( ${expanded_path}*(N) ) - (( $#tmp > 0 )) && REPLY=path_prefix && return 0 - fi - - # It's not a path. - return 1 -} - -# Highlight special chars inside double-quoted strings --hsmw-highlight-string() -{ - setopt localoptions noksharrays - local -a match mbegin mend - local MATCH; integer MBEGIN MEND - local i j k style - # Starting quote is at 1, so start parsing at offset 2 in the string. - for (( i = 2 ; i < end_pos - start_pos ; i += 1 )) ; do - (( j = i + start_pos - 1 )) - (( k = j + 1 )) - case "$arg[$i]" in - '$' ) style=dollar-double-quoted-argument - # Look for an alphanumeric parameter name. - if [[ ${arg:$i} = ([[:alpha:]_][[:alnum:]_]#|[[:digit:]]##) ]] ; then - (( k += $#MATCH )) # highlight the parameter name - (( i += $#MATCH )) # skip past it - elif [[ ${arg:$i} = [{]([[:alpha:]_][[:alnum:]_]#|[[:digit:]]##)[}]* ]] ; then - (( k += $#MATCH )) # highlight the parameter name and braces - (( i += $#MATCH )) # skip past it - else - continue - fi - ;; - "\\") style=back-double-quoted-argument - if [[ \\\`\"\$ == *$arg[$i+1]* ]]; then - (( k += 1 )) # Color following char too. - (( i += 1 )) # Skip parsing the escaped char. - else - continue - fi - ;; - *) continue ;; - - esac - -hsmw-add-highlight $j $k $style - done -} - -# Highlight special chars inside dollar-quoted strings --hsmw-highlight-dollar-string() -{ - setopt localoptions noksharrays - local -a match mbegin mend - local MATCH; integer MBEGIN MEND - local i j k style - local AA - integer c - # Starting dollar-quote is at 1:2, so start parsing at offset 3 in the string. - for (( i = 3 ; i < end_pos - start_pos ; i += 1 )) ; do - (( j = i + start_pos - 1 )) - (( k = j + 1 )) - case "$arg[$i]" in - "\\") style=back-dollar-quoted-argument - for (( c = i + 1 ; c <= end_pos - start_pos ; c += 1 )); do - [[ "$arg[$c]" != ([0-9xXuUa-fA-F]) ]] && break - done - AA=$arg[$i+1,$c-1] - # Matching for HEX and OCT values like \0xA6, \xA6 or \012 - if [[ "$AA" =~ "^(x|X)[0-9a-fA-F]{1,2}" - || "$AA" =~ "^[0-7]{1,3}" - || "$AA" =~ "^u[0-9a-fA-F]{1,4}" - || "$AA" =~ "^U[0-9a-fA-F]{1,8}" - ]]; then - (( k += $#MATCH )) - (( i += $#MATCH )) - else - if (( $#arg > $i+1 )) && [[ $arg[$i+1] == [xXuU] ]]; then - # \x not followed by hex digits is probably an error - style=unknown-token - fi - (( k += 1 )) # Color following char too. - (( i += 1 )) # Skip parsing the escaped char. - fi - ;; - *) continue ;; - - esac - -hsmw-add-highlight $j $k $style - done -} - -# Called with a single positional argument. -# Perform filename expansion (tilde expansion) on the argument and set $REPLY to the expanded value. -# Does not perform filename generation (globbing). --hsmw-highlight-expand-path() -{ - (( $# == 1 )) || print -r -- >&2 "hsmw-highlight: BUG: -hsmw-highlight-expand-path: called without argument" - - # The $~1 syntax normally performs filename generation, but not when it's on the right-hand side of ${x:=y}. - setopt localoptions nonomatch - unset REPLY - : ${REPLY:=${(Q)~1}} -} - -# ------------------------------------------------------------------------------------------------- -# Main highlighter initialization -# ------------------------------------------------------------------------------------------------- - --hsmw-highlight-init() { - __hsmw_highlight_main__command_type_cache=() -} - --hsmw-add-highlight() -{ - local -i start end - local highlight - start=$1 - end=$2 - shift 2 - for highlight; do - if (( $+HSMW_HIGHLIGHT_STYLES[$highlight] )); then - reply+=("$start $end $HSMW_HIGHLIGHT_STYLES[$highlight]") - break - fi - done -} - -__HSMW_MH_SOURCED=1 - -# vim:ft=zsh diff --git a/.config/zsh/.zsh/fsh/tests/_output/.gitkeep b/.config/zsh/.zsh/fsh/tests/_output/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/.config/zsh/.zsh/fsh/tests/_support/.gitkeep b/.config/zsh/.zsh/fsh/tests/_support/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/.config/zsh/.zsh/fsh/tests/_support/bootstrap b/.config/zsh/.zsh/fsh/tests/_support/bootstrap deleted file mode 100644 index 0107661..0000000 --- a/.config/zsh/.zsh/fsh/tests/_support/bootstrap +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env zsh -# Write your bootstrap code here diff --git a/.config/zsh/.zsh/fsh/tests/example.zunit b/.config/zsh/.zsh/fsh/tests/example.zunit deleted file mode 100644 index 910f840..0000000 --- a/.config/zsh/.zsh/fsh/tests/example.zunit +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env zunit -@setup { - load "../fast-highlight" -} - -@test 'ls /usr/bin' { - PREBUFFER="" - BUFFER="ls /usr/bin" - run -fast-highlight-process "$PREBUFFER" "$BUFFER" 0 \; print -rl -- \$reply - - assert "$lines[1]" same_as "0 2 fg=green" - assert "$lines[2]" same_as "3 11 fg=magenta,underline" -} - -# vim:ft=zsh:sw=4:sts=4:et diff --git a/.config/zsh/.zsh/fsh/tests/main.zunit b/.config/zsh/.zsh/fsh/tests/main.zunit deleted file mode 100644 index 110f34c..0000000 --- a/.config/zsh/.zsh/fsh/tests/main.zunit +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env zunit -@setup { - load "../fast-highlight" - setopt interactive_comments - -fast-highlight-fill-option-variables -} - -@test 'ls /usr/bin' { -reply=() - PREBUFFER="" - BUFFER="ls /usr/bin" - evl -fast-highlight-process "$PREBUFFER" "$BUFFER" 0 - - assert "$reply[1]" same_as "0 2 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}command]}" - assert "$reply[2]" same_as "3 11 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path-to-dir]}" - assert "$reply[3]" same_as "" -} - -@test 'ls /bin/df' { - reply=() - PREBUFFER="" - BUFFER="ls /bin/df" - evl -fast-highlight-process "$PREBUFFER" "$BUFFER" 0 - - assert "$reply[1]" same_as "0 2 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}command]}" - assert "$reply[2]" same_as "3 10 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]}" - assert "$reply[3]" same_as "" -} - - -@test 'ls /bin/ls\\n # a comment\\nls /usr/bin' { - reply=() - PREBUFFER="" - BUFFER=$'ls /bin/df\n # a comment\nls /usr/bin' - evl -fast-highlight-process "$PREBUFFER" "$BUFFER" 0 - - assert "$reply[1]" same_as "0 2 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}command]}" - assert "$reply[2]" same_as "3 10 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]}" - assert "$reply[3]" same_as "12 23 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}comment]}" - assert "$reply[4]" same_as "24 26 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}command]}" - assert "$reply[5]" same_as "27 35 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path-to-dir]}" - assert "$reply[6]" same_as "" -} - - -@test 'exec {FD}< <( ls /bin )' { - reply=() - PREBUFFER="" - BUFFER=$'exec {FD}< <( ls /bin )' - evl -fast-highlight-process "$PREBUFFER" "$BUFFER" 0 - - assert "$reply[1]" same_as "0 4 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}precommand]}" - assert "$reply[2]" same_as "5 9 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}exec-descriptor]}" - assert "$reply[3]" same_as "" -} - - -@test 'case x in x) a;; (y) ;; esac' { - reply=() - PREBUFFER="" - BUFFER=$'case x in\nx) a;;\n(y)\n;;\nesac' - evl -fast-highlight-process "$PREBUFFER" "$BUFFER" 0 - - assert "$reply[1]" same_as "0 4 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}reserved-word]}" - assert "$reply[2]" same_as "5 6 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-input]}" - assert "$reply[3]" same_as "7 9 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-parentheses]}" - assert "$reply[4]" same_as "10 11 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-condition]}" - assert "$reply[5]" same_as "11 12 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-parentheses]}" - assert "$reply[6]" same_as "13 14 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}unknown-token]}" - assert "$reply[7]" same_as "17 18 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-parentheses]}" - assert "$reply[8]" same_as "18 19 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-condition]}" - assert "$reply[9]" same_as "19 20 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-parentheses]}" - assert "$reply[10]" same_as "24 28 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}reserved-word]}" - assert "$reply[11]" same_as "" -} - -@test '-fast-highlight-process "$PREBUFFER" "$BUFFER" 0' { - reply=() - PREBUFFER="" - BUFFER='-fast-highlight-process "$PREBUFFER" "$BUFFER" 0' - evl -fast-highlight-process "\$PREBUFFER" "\$BUFFER" 0 - - assert "$reply[1]" same_as "0 23 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}function]}" - assert "$reply[2]" same_as "24 36 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}" - assert "$reply[3]" same_as "25 35 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}back-or-dollar-double-quoted-argument]}" - assert "$reply[4]" same_as "37 46 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}" - assert "$reply[5]" same_as "38 45 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}back-or-dollar-double-quoted-argument]}" - assert "$reply[6]" same_as "" -} - -@test 'tr : \\\\n <<<$PATH' { - reply=() - PREBUFFER="" - BUFFER='command tr : \\n << 59 -> CIELab: 241 -; comment: -; #434749 -> 16 -> CIELab: 238 -; keyword: -; #b77c4b -> 137 -> CIELab: 173 -; number, string: -; #5794a2 -> 67 -> CIELab: 66 -; title, section, name, selector-id: -; #778ce0 -> 104 -> CIELab: 104 -; attribute, variable, type: -; #d55383 -> 168 -> CIELab: 168 -; symbol, link: -; #e66493 -> 168 -> CIELab: 168 -; builtin, deletion: -; #bd5ac0 -> 133 -> CIELab: 170 -; formula-bg: -; #363a3b -> 16 -> CIELab: 237 -; -; Token.Literal: "#dc5be0" -> CIELab: 170 (Orchid; naive: 170) -; Token.Operator: "#677dcf" -> CIELab: 68 (SteelBlue3; naive: 68) -; - -[base] -default = none -unknown-token = 196 -secondary = sv-orple -recursive-base = 183 - -[background] -correct-subtle = bg:18 -incorrect-subtle = bg:238 -subtle-bg = bg:17 -global-alias = bg:20 - -;; -;; COLOR-GROUPS -;; - -[gray] -comment = 243 - - - -[pastel] -here-string-tri = 217 - - - -[no-color] -assign = none -back-quoted-argument = none -redirection = none -variable = none - - - - -[magenta-3] -dollar-quoted-argument = 173 -double-quoted-argument = 173 -history-expansion = 173 -globbing-ext = 173 -precommand = 173 - -[light-salmon-3] -builtin = 137 -subcommand = 137 -single-quoted-argument = 137 - -[steel-blue-3] -command = 68 -double-sq-bracket = 68 -double-paren = 68 -single-sq-bracket = 68 - -[steel-blue] -reserved-word = 67 - - - -[medium-purple] -; backslash in $'...' -back-dollar-quoted-argument = 104 -commandseparator = 104 -single-hyphen-option = 104 - -[dark-khaki] -double-hyphen-option = 143 - - - -[hot-pink-3] -alias = 168 -exec-descriptor = 168 -function = 168 -hashed-command = 168 -here-string-var = 168 -suffix-alias = 168 - -[pale-green-3] -assign-array-bracket = 114 -; variable $... or backslash in "..." (i.e. variable in string) -back-or-dollar-double-quoted-argument = 114 -globbing = 114 -here-string-text = 114 - - - -[orchid] -path = 170 -path-to-dir = 170,underline -pathseparator = - - - -;; -;; FUNCTIONALITY-GROUPS -;; - -[brackets] -paired-bracket = black,bg:216 -bracket-level-1 = 117 -bracket-level-2 = 217 -bracket-level-3 = 220 - -[math] -mathvar = 68 -mathnum = 173 -matherr = 124 - -[for-loop] -forvar = 68 -fornum = 173 -; operator -foroper = 133 -; separator -forsep = 104 - -[case] -case-input = 168 -case-parentheses = 217 -case-condition = bg:25 diff --git a/.config/zsh/.zsh/fsh/themes/safari.ini b/.config/zsh/.zsh/fsh/themes/safari.ini deleted file mode 100644 index e103c4d..0000000 --- a/.config/zsh/.zsh/fsh/themes/safari.ini +++ /dev/null @@ -1,83 +0,0 @@ -; Light theme with colors of a Sahara oasis - -[base] -default = none -unknown-token = red,bold -commandseparator = none -redirection = none -here-string-tri = yellow -here-string-text = bg:19 -here-string-var = 153,bg:19 -exec-descriptor = yellow,bold -comment = black,bold -correct-subtle = bg:55 -incorrect-subtle = bg:52 -subtle-bg = bg:18 -secondary = zdharma -recursive-base = 183 - -[command-point] -reserved-word = 150 -subcommand = 150 -alias = 185 -suffix-alias = 185 -global-alias = bg:19 -builtin = 185 -function = 185 -command = 185 -precommand = 185 -hashed-command = 185 -single-sq-bracket = 185 -double-sq-bracket = 185 -double-paren = 150 - -[paths] -path = 187 -pathseparator = -path-to-dir = 187,underline -globbing = 180 -globbing-ext = 184 - -[brackets] -paired-bracket = bg:blue -bracket-level-1 = 178 -bracket-level-2 = 148 -bracket-level-3 = 141 - -[arguments] -single-hyphen-option = 152 -double-hyphen-option = 152 -back-quoted-argument = none -single-quoted-argument = 151 -double-quoted-argument = 151 -dollar-quoted-argument = 151 - -[in-string] -; backslash in $'...' -back-dollar-quoted-argument = 153 -; backslash or $... in "..." (i.e. variable inside a string) -back-or-dollar-double-quoted-argument = 153 - -[other] -variable = none -assign = none -assign-array-bracket = 185 -history-expansion = blue,bold - -[math] -mathvar = blue,bold -mathnum = 187 -matherr = red - -[for-loop] -forvar = none -fornum = 187 -; operator -foroper = 151 -; separator -forsep = 109 - -[case] -case-input = 185 -case-parentheses = 116 -case-condition = bg:19 diff --git a/.config/zsh/.zsh/fsh/themes/spa.ini b/.config/zsh/.zsh/fsh/themes/spa.ini deleted file mode 100644 index 651acdb..0000000 --- a/.config/zsh/.zsh/fsh/themes/spa.ini +++ /dev/null @@ -1,82 +0,0 @@ -; 144, 187, 110, 203 -[base] -default = none -unknown-token = 196 -commandseparator = 150 -redirection = none -here-string-tri = yellow -here-string-text = bg:19 -here-string-var = 186,bg:19 -exec-descriptor = yellow,bold -comment = black,bold -correct-subtle = bg:55 -incorrect-subtle = bg:52 -subtle-bg = bg:17 -secondary = zdharma -recursive-base = 183 - -[command-point] -reserved-word = 144 -subcommand = 144 -alias = 187 -suffix-alias = 187 -global-alias = bg:19 -builtin = 150 -function = 187 -command = 187 -precommand = 187 -hashed-command = 187 -single-sq-bracket = 150 -double-sq-bracket = 150 -double-paren = 144 - -[paths] -path = 110 -pathseparator = -path-to-dir = 110,underline -globbing = 220 -globbing-ext = 225 - -[brackets] -paired-bracket = bg:blue -bracket-level-1 = 115 -bracket-level-2 = 177 -bracket-level-3 = 220 - -[arguments] -single-hyphen-option = 185 -double-hyphen-option = 185 -back-quoted-argument = none -single-quoted-argument = 110 -double-quoted-argument = 110 -dollar-quoted-argument = 110 - -[in-string] -; backslash in $'...' -back-dollar-quoted-argument = 186 -; backslash or $... in "..." (i.e. variable in string) -back-or-dollar-double-quoted-argument = 186 - -[other] -variable = none -assign = none -assign-array-bracket = 187 -history-expansion = blue,bold - -[math] -mathvar = 150 -mathnum = 110 -matherr = 196 - -[for-loop] -forvar = 71 -fornum = 110 -; operator -foroper = 203 -; separator -forsep = 147 - -[case] -case-input = 187 -case-parentheses = 116 -case-condition = bg:19 diff --git a/.config/zsh/.zsh/fsh/themes/sv-orple.ini b/.config/zsh/.zsh/fsh/themes/sv-orple.ini deleted file mode 100644 index f7e8fc5..0000000 --- a/.config/zsh/.zsh/fsh/themes/sv-orple.ini +++ /dev/null @@ -1,100 +0,0 @@ -; https://www.syntaxenvy.com/0073437 -; -; comment: -; #363355 -> 61 -; keyword: -; #dda69f -> 181 (138) -; number, string: -; #ca887e -> 174 (173) -; title, section, name, selector-id: -; #b3afd9 -> 146 (146) -; attribute, variable, type: -; #be85c0 -> 139 (140) -; symbol, link: -; #d6a2d8 -> 182 (182) -; builtin, deletion: -; #969c77 -> 108 (108) -; formula-bg: -; #211f37 -> 16 (17) - -[base] -default = none -unknown-token = 124 -commandseparator = 146 -redirection = none -here-string-tri = 138 -here-string-text = bg:25 -here-string-var = 140,bg:25 -exec-descriptor = 140 -comment = 61 -correct-subtle = bg:55 -incorrect-subtle = bg:52 -subtle-bg = bg:17 -secondary = clean -recursive-base = 186 - -[command-point] -reserved-word = 138 -subcommand = 182 -alias = 140 -suffix-alias = 140 -global-alias = bg:17 -builtin = 173 -function = 140 -command = 108 -precommand = 138 -hashed-command = 140 -single-sq-bracket = 173 -double-sq-bracket = 173 -double-paren = 138 - -[paths] -path = 182 -pathseparator = -path-to-dir = 182,underline -globbing = 138 -globbing-ext = 141 - -[brackets] -paired-bracket = bg:blue -bracket-level-1 = 173 -bracket-level-2 = 177 -bracket-level-3 = 220 - -[arguments] -single-hyphen-option = 140 -double-hyphen-option = 140 -back-quoted-argument = none -single-quoted-argument = 173 -double-quoted-argument = 173 -dollar-quoted-argument = 173 - -[in-string] -; backslash in $'...' -back-dollar-quoted-argument = 146 -; backslash or $... in "..." (i.e. variable in string) -back-or-dollar-double-quoted-argument = 140 - -[other] -variable = none -assign = none -assign-array-bracket = 182 -history-expansion = blue,bold - -[math] -mathvar = 140 -mathnum = 173 -matherr = 124 - -[for-loop] -forvar = 140 -fornum = 173 -; operator -foroper = 147 -; separator -forsep = 182 - -[case] -case-input = 140 -case-parentheses = 17 -case-condition = bg:25 diff --git a/.config/zsh/.zsh/fsh/themes/sv-plant.ini b/.config/zsh/.zsh/fsh/themes/sv-plant.ini deleted file mode 100644 index 2191b21..0000000 --- a/.config/zsh/.zsh/fsh/themes/sv-plant.ini +++ /dev/null @@ -1,100 +0,0 @@ -; https://www.syntaxenvy.com/0854668 -; -; comment: -; #5b4e3f -> 58 -; keyword: -; #a1f2b2 -> 157 -; number, string: -; #91cf9e -> 115 (114) -; title, section, name, selector-id: -; #dadff0 -> 189 -; attribute, variable, type: -; #debb91 -> 180 -; symbol, link: -; #f1dcc6 -> 224 -; builtin, deletion: -; #95cbc1 -> 115 -; formula: -; #3f352a -> 16 - -[base] -default = none -unknown-token = 124 -commandseparator = 189 -redirection = none -here-string-tri = 157 -here-string-text = bg:25 -here-string-var = 180,bg:25 -exec-descriptor = 180 -comment = 58 -correct-subtle = bg:55 -incorrect-subtle = bg:52 -subtle-bg = bg:17 -secondary = zdharma -recursive-base = 183 - -[command-point] -reserved-word = 157 -subcommand = 224 -alias = 180 -suffix-alias = 180 -global-alias = bg:58 -builtin = 115 -function = 180 -command = 180 -precommand = 157 -hashed-command = 180 -single-sq-bracket = 115 -double-sq-bracket = 115 -double-paren = 157 - -[paths] -path = 224 -pathseparator = -path-to-dir = 224,underline -globbing = 157 -globbing-ext = 159 - -[brackets] -paired-bracket = bg:blue -bracket-level-1 = 115 -bracket-level-2 = 177 -bracket-level-3 = 220 - -[arguments] -single-hyphen-option = 180 -double-hyphen-option = 180 -back-quoted-argument = none -single-quoted-argument = 114 -double-quoted-argument = 114 -dollar-quoted-argument = 114 - -[in-string] -; backslash in $'...' -back-dollar-quoted-argument = 189 -; backslash or $... in "..." (i.e. variable in string) -back-or-dollar-double-quoted-argument = 180 - -[other] -variable = none -assign = none -assign-array-bracket = 224 -history-expansion = blue,bold - -[math] -mathvar = 180 -mathnum = 114 -matherr = 124 - -[for-loop] -forvar = 180 -fornum = 114 -; operator -foroper = 147 -; separator -forsep = 224 - -[case] -case-input = 180 -case-parentheses = 58 -case-condition = bg:25 diff --git a/.config/zsh/.zsh/fsh/themes/zdharma.ini b/.config/zsh/.zsh/fsh/themes/zdharma.ini deleted file mode 100644 index 95e3e7e..0000000 --- a/.config/zsh/.zsh/fsh/themes/zdharma.ini +++ /dev/null @@ -1,81 +0,0 @@ -[base] -default = none -unknown-token = red,bold -commandseparator = none -redirection = none -here-string-tri = 141 -here-string-text = bg:19 -here-string-var = 177,bg:19 -exec-descriptor = yellow,bold -comment = black,bold -correct-subtle = bg:55 -incorrect-subtle = bg:52 -subtle-bg = bg:17 -secondary = safari -recursive-base = 186 - -[command-point] -reserved-word = 146 -reserved-word = 146 -alias = 63 -suffix-alias = 63 -global-alias = bg:19 -builtin = 63 -function = 63 -command = 63 -precommand = 63 -hashed-command = 63 -single-sq-bracket = 63 -double-sq-bracket = 63 -double-paren = 146 - -[paths] -path = 154 -pathseparator = -path-to-dir = 154,underline -globbing = 114 -globbing-ext = 153 - -[brackets] -paired-bracket = bg:blue -bracket-level-1 = 117 -bracket-level-2 = 141 -bracket-level-3 = 90 - -[arguments] -single-hyphen-option = 177 -double-hyphen-option = 177 -back-quoted-argument = none -single-quoted-argument = 146 -double-quoted-argument = 146 -dollar-quoted-argument = 146 - -[in-string] -; backslash in $'...' -back-dollar-quoted-argument = 177 -; backslash or $... in "..." -back-or-dollar-double-quoted-argument = 177 - -[other] -variable = none -assign = none -assign-array-bracket = 63 -history-expansion = blue,bold - -[math] -mathvar = blue,bold -mathnum = 154 -matherr = red - -[for-loop] -forvar = none -fornum = 154 -; operator -foroper = 146 -; separator -forsep = 109 - -[case] -case-input = 63 -case-parentheses = 141 -case-condition = bg:19 diff --git a/.config/zsh/.zsh/fsh/→chroma/-alias.ch b/.config/zsh/.zsh/fsh/→chroma/-alias.ch deleted file mode 100644 index d581341..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-alias.ch +++ /dev/null @@ -1,29 +0,0 @@ -# vim:ft=zsh:et:sw=4 -(( next_word = 2 | 8192 )) -[[ "$__arg_type" = 3 ]] && return 2 - -local __first_call="$1" __wrd="${2%%=*}" __start_pos="$3" __end_pos="$4" - -if (( __first_call )) || [[ "$2" = -* ]]; then - return 1 -else - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - elif (( $+aliases[(e)$__wrd] )) || (( ${+galiases[(e)$__wrd]} )); then - (( __start=__start_pos-${#PREBUFFER}, __end=__start_pos+${#__wrd}-${#PREBUFFER}, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") - elif (( $+functions[(e)$__wrd] )) || (( $+builtins[(e)$__wrd] )) || (( $+commands[(e)$__wrd] )) || (( $reswords[(Ie)$__wrd] )); then - (( __start=__start_pos-${#PREBUFFER}, __end=__start_pos+${#__wrd}-${#PREBUFFER}, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") - else - return 1 - fi - if [[ "$__wrd" != "$2" ]]; then - return 1 - fi -fi - -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 diff --git a/.config/zsh/.zsh/fsh/→chroma/-autoload.ch b/.config/zsh/.zsh/fsh/→chroma/-autoload.ch deleted file mode 100644 index 78a8924..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-autoload.ch +++ /dev/null @@ -1,104 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# Tracks autoload command - highlights function names if they exist somewhere -# in $fpath. Also warns that the autoloaded function is already defined. -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# -# $2 - the current token, also accessible by $__arg from the above scope - -# basically a private copy of $__arg; the token can be eg.: "grep" -# -# $3 - a private copy of $_start_pos, i.e. the position of the token in the -# command line buffer, used to add region_highlight entry (see man), -# because Zsh colorizes by *ranges* in command line buffer -# -# $4 - a private copy of $_end_pos from the above scope -# - -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style __chars -integer __idx1 __idx2 -local -a __results __deserialized __noshsplit - -# First call, i.e. command starts, i.e. "grep" token etc. -(( __first_call )) && { - FAST_HIGHLIGHT[chroma-autoload-counter]=0 - FAST_HIGHLIGHT[chroma-autoload-counter-all]=1 - FAST_HIGHLIGHT[chroma-autoload-message]="" - #FAST_HIGHLIGHT[chroma-autoload-message-shown]="" - [[ -z ${FAST_HIGHLIGHT[chroma-autoload-message-shown-at]} ]] && FAST_HIGHLIGHT[chroma-autoload-message-shown-at]=0 - FAST_HIGHLIGHT[chroma-autoload-elements]="" - __style=${FAST_THEME_NAME}command - -} || { - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - (( FAST_HIGHLIGHT[chroma-autoload-counter-all] += 1, __idx2 = FAST_HIGHLIGHT[chroma-autoload-counter-all] )) - - # Following call, i.e. not the first one. - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if [[ "$__wrd" = [-+]* ]]; then - # Detected option, add style for it. - [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ - __style=${FAST_THEME_NAME}single-hyphen-option - else - # Count non-option tokens. - (( FAST_HIGHLIGHT[chroma-autoload-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-autoload-counter] )) - - if [[ $__wrd != (\$|\"\$)* && $__wrd != (/|\"/|\'/)* && $__wrd != \`* ]]; then - __results=( ${^fpath}/$__wrd(N) ) - __deserialized=( "${(Q@)${(z@)FAST_HIGHLIGHT[chroma-fpath_peq-elements]}}" ) - __results+=( ${^__deserialized}/$__wrd(N) ) - [[ "${#__results}" -gt 0 ]] && { - __style=${FAST_THEME_NAME}correct-subtle - __deserialized=( "${(Q@)${(z@)FAST_HIGHLIGHT[chroma-autoload-elements]}}" ) - [[ -z "${__deserialized[1]}" && ${#__deserialized} -eq 1 ]] && __deserialized=() - # Cannot use ${abc:+"$abc"} trick with ${~...}, so handle most - # cases of the possible shwordsplit through an additional array - __noshsplit=( ${~__wrd} ) - __deserialized+=( "${(j: :)__noshsplit}" ) - FAST_HIGHLIGHT[chroma-autoload-elements]="${(j: :)${(q@)__deserialized}}" - # Make the function defined for big-loop's *main-type mechanism - __fast_highlight_main__command_type_cache[${(j: :)__noshsplit}]="function" - } || __style=${FAST_THEME_NAME}incorrect-subtle - fi - - if (( ${+functions[${(Q)__wrd}]} )); then - FAST_HIGHLIGHT[chroma-autoload-message]+="Warning: Function ${(Q)__wrd} already defined (e.g. loaded)"$'\n' - fi - fi - - # Display only when processing last autoload argument - if (( ${#${(z)BUFFER}} == FAST_HIGHLIGHT[chroma-autoload-counter-all] )); then - # Display only if already shown message differs or when it timeouts - if [[ ${FAST_HIGHLIGHT[chroma-autoload-message]} != ${FAST_HIGHLIGHT[chroma-autoload-message-shown]} || - $(( EPOCHSECONDS - FAST_HIGHLIGHT[chroma-autoload-message-shown-at] )) -gt 7 - ]]; then - FAST_HIGHLIGHT[chroma-autoload-message-shown]=${FAST_HIGHLIGHT[chroma-autoload-message]} - FAST_HIGHLIGHT[chroma-autoload-message-shown-at]=$EPOCHSECONDS - zle -M "${FAST_HIGHLIGHT[chroma-autoload-message]}" - fi - fi -} - -# Add region_highlight entry (via `reply' array). -# -# This is a common place of adding such entry, but any above code -# can do it itself and skip setting __style to disable this code. -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through (no return 1 occured), do obligatory things ourselves. -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-autorandr.ch b/.config/zsh/.zsh/fsh/→chroma/-autorandr.ch deleted file mode 100644 index 9687db3..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-autorandr.ch +++ /dev/null @@ -1,22 +0,0 @@ -# vim:ft=zsh:et:sw=4 -(( next_word = 2 | 8192 )) -[[ "$__arg_type" = 3 ]] && return 2 - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" - -if (( __first_call )) || [[ "$__wrd" = -* ]]; then - return 1 -else - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - if [[ -d "${XDG_CONFIG_HOME:-$HOME/.config}/autorandr/$__wrd" ]] then - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") - fi -fi - -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 diff --git a/.config/zsh/.zsh/fsh/→chroma/-awk.ch b/.config/zsh/.zsh/fsh/→chroma/-awk.ch deleted file mode 100644 index 47b3ec7..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-awk.ch +++ /dev/null @@ -1,108 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# -# $2 - the current token, also accessible by $__arg from the above scope - -# basically a private copy of $__arg; the token can be eg.: "grep" -# -# $3 - a private copy of $_start_pos, i.e. the position of the token in the -# command line buffer, used to add region_highlight entry (see man), -# because Zsh colorizes by *ranges* in command line buffer -# -# $4 - a private copy of $_end_pos from the above scope -# - -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style __chars __val __style2 -integer __idx1 __idx2 - -# First call, i.e. command starts, i.e. "grep" token etc. -(( __first_call )) && { - FAST_HIGHLIGHT[chroma-awk-counter]=0 - FAST_HIGHLIGHT[chroma-awk-f-seen]=0 - return 1 -} || { - # Following call, i.e. not the first one. - - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if [[ "$__wrd" = -* ]]; then - # Detected option, add style for it. - [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ - __style=${FAST_THEME_NAME}single-hyphen-option - [[ "$__wrd" = "-f" ]] && FAST_HIGHLIGHT[chroma-awk-f-seen]=1 - else - # Count non-option tokens. - (( FAST_HIGHLIGHT[chroma-awk-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-awk-counter] )) - - # First non-option token is the pattern (regex), we will - # highlight it. - if (( FAST_HIGHLIGHT[chroma-awk-counter] == 1 && FAST_HIGHLIGHT[chroma-awk-f-seen] == 0 )); then - if print -r -- "${(Q)__wrd}" | gawk --source 'BEGIN { exit } END { exit 0 }' -f - >/dev/null 2>&1; then - __style2="${FAST_THEME_NAME}subtle-bg" - else - __style2="${FAST_THEME_NAME}incorrect-subtle" - fi - - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style2]}") - - # Highlight keywords - FSH_LIST=() - : "${__wrd//(#m)(BEGIN|END|FIELDWIDTHS|RS|ARGC|ARGV|ENVIRON|NF|NR|IGNORECASE|FILENAME|if|then|else|while|toupper|tolower|function|print|sub)/$(( fsh_sy_h_append($MBEGIN, $MEND) ))}"; - for __val in "${FSH_LIST[@]}" ; do - [[ ${__wrd[${__val%%;;*}]} = [a-zA-Z0-9_] || ${__wrd[${__val##*;;}+1]} = [a-zA-Z0-9_] ]] && continue - __idx1=$(( __start_pos + ${__val%%;;*} )) - __idx2=__idx1+${__val##*;;}-${__val%%;;*}+1 - (( __start=__idx1-${#PREBUFFER}, __end=__idx2-${#PREBUFFER}-1, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}reserved-word]},${FAST_HIGHLIGHT_STYLES[$__style2]}") - done - - # Highlight regex characters - __chars="*+\\)(\{\}[]^" - __idx1=__start_pos - __idx2=__start_pos - while [[ "$__wrd" = (#b)[^$__chars]#([\\][\\])#((+|\*|\[|\]|\)|\(|\^|\}|\{)|[\\](+|\*|\[|\]|\)|\(|\^|\{|\}))(*) ]]; do - if [[ -n "${match[3]}" ]]; then - __idx1+=${mbegin[3]}-1 - __idx2=__idx1+${mend[3]}-${mbegin[3]}+1 - (( __start=__idx1-${#PREBUFFER}, __end=__idx2-${#PREBUFFER}, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}mathnum]},${FAST_HIGHLIGHT_STYLES[$__style2]}") - __idx1=__idx2 - else - __idx1+=${mbegin[5]}-1 - fi - __wrd="${match[5]}" - done - elif (( FAST_HIGHLIGHT[chroma-awk-counter] >= 2 || FAST_HIGHLIGHT[chroma-awk-f-seen] == 1 )); then - FAST_HIGHLIGHT[chroma-awk-f-seen]=0 - # Handle paths, etc. normally - just pass-through to the big - # highlighter (the main FSH highlighter, used before chromas). - return 1 - fi - fi -} - -# Add region_highlight entry (via `reply' array). -# -# This is a common place of adding such entry, but any above -# code can do it itself (and it does) and skip setting __style -# to disable this code. -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through (no return 1 occured), do obligatory things ourselves. -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-docker.ch b/.config/zsh/.zsh/fsh/→chroma/-docker.ch deleted file mode 100644 index 31772f2..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-docker.ch +++ /dev/null @@ -1,90 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# Chroma function for command `docker'. It verifies command line, by denoting -# wrong and good arguments by color. Currently implemented: verification of -# image IDs passed to: docker image rm . -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# $2 - the current token, also accessible by $__arg from the above scope - -# basically a private copy of $__arg -# $3 - a private copy of $_start_pos, i.e. the position of the token in the -# command line buffer, used to add region_highlight entry (see man), -# because Zsh colorizes by *ranges* in command line buffer -# $4 - a private copy of $_end_pos from the above scope -# - -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style -integer __idx1 __idx2 -local -a __lines_list - -(( __first_call )) && { - # Called for the first time - new command - # FAST_HIGHLIGHT is used because it survives between calls, and - # allows to use a single global hash only, instead of multiple - # global variables - FAST_HIGHLIGHT[chroma-docker-counter]=0 - FAST_HIGHLIGHT[chroma-docker-got-subcommand]=0 - FAST_HIGHLIGHT[chroma-docker-subcommand]="" - FAST_HIGHLIGHT[chrome-docker-got-msg1]=0 - return 1 -} || { - # Following call, i.e. not the first one - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - - if [[ "$__wrd" = -* && ${FAST_HIGHLIGHT[chroma-docker-got-subcommand]} -eq 0 ]]; then - __style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option} - else - if (( FAST_HIGHLIGHT[chroma-docker-got-subcommand] == 0 )); then - FAST_HIGHLIGHT[chroma-docker-got-subcommand]=1 - FAST_HIGHLIGHT[chroma-docker-subcommand]="$__wrd" - __style=${FAST_THEME_NAME}subcommand - (( FAST_HIGHLIGHT[chroma-docker-counter] += 1 )) - else - __wrd="${__wrd//\`/x}" - __arg="${__arg//\`/x}" - __wrd="${(Q)__wrd}" - if [[ "${FAST_HIGHLIGHT[chroma-docker-subcommand]}" = "image" ]]; then - [[ "$__wrd" != -* ]] && { - (( FAST_HIGHLIGHT[chroma-docker-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-docker-counter] )) - - if (( __idx1 == 2 )); then - __style=${FAST_THEME_NAME}subcommand - elif (( __idx1 == 3 )); then - .fast-run-command "docker images -q" chroma-docker-list "" - [[ -n "${__lines_list[(r)$__wrd]}" ]] && { - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") - } || { - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") - } - fi - } || __style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option} - else - return 1 - fi - fi - fi -} - -# Add region_highlight entry (via `reply' array) -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through, do obligatory things ourselves -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-example.ch b/.config/zsh/.zsh/fsh/→chroma/-example.ch deleted file mode 100644 index 8814922..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-example.ch +++ /dev/null @@ -1,120 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# Example chroma function. It colorizes first two arguments as `builtin' style, -# third and following arguments as `globbing' style. First two arguments may -# be "strings", they will be passed through to normal higlighter (by returning 1). -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# -# $2 - the current token, also accessible by $__arg from the above scope - -# basically a private copy of $__arg; the token can be eg.: "grep" -# -# $3 - a private copy of $_start_pos, i.e. the position of the token in the -# command line buffer, used to add region_highlight entry (see man), -# because Zsh colorizes by *ranges* in command line buffer -# -# $4 - a private copy of $_end_pos from the above scope -# -# -# Overall functioning is: when command "example" is occured, this function -# is called with $1 == 1, it ("example") is the first token ($2), then for any -# following token, this function is called with $1 == 0, until end of command -# is occured (i.e. till enter is pressed or ";" is put into source, or the -# command line simply ends). -# -# Other tips are: -# - $CURSOR holds cursor position -# - $BUFFER holds whole command line buffer -# - $LBUFFER holds command line buffer that is left from the cursor, i.e. it's a -# BUFFER substring 1 .. $CURSOR -# - $RBUFFER is the same as LBUFFER but holds part of BUFFER right to the cursor -# -# The function receives $BUFFER but via sequence of tokens, which are shell words, -# e.g. "a b c" is a shell word, while a b c are 3 shell words. -# -# FAST_HIGHLIGHT is a friendly hash array which allows to store strings without -# creating global parameters (variables). If you need hash, just use it first -# declaring, under some distinct name like: typeset -gA CHROMA_EXPLE_DICT. -# Remember to reset the hash and others at __first_call == 1, so that you have -# a fresh state for new command. - -# Keep chroma-takever state meaning: until ;, handle highlighting via chroma. -# So the below 8192 assignment takes care that next token will be routed to chroma. -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style -integer __idx1 __idx2 - -(( __first_call )) && { - # Called for the first time - new command. - # FAST_HIGHLIGHT is used because it survives between calls, and - # allows to use a single global hash only, instead of multiple - # global string variables. - FAST_HIGHLIGHT[chroma-example-counter]=0 - - # Set style for region_highlight entry. It is used below in - # '[[ -n "$__style" ]] ...' line, which adds highlight entry, - # like "10 12 fg=green", through `reply' array. - # - # Could check if command `example' exists and set `unknown-token' - # style instead of `command' - __style=${FAST_THEME_NAME}command - -} || { - # Following call, i.e. not the first one - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - - if [[ "$__wrd" = -* ]]; then - # Detected option, add style for it. - [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ - __style=${FAST_THEME_NAME}single-hyphen-option - else - # Count non-option tokens - (( FAST_HIGHLIGHT[chroma-example-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-example-counter] )) - - # Colorize 1..2 as builtin, 3.. as glob - if (( FAST_HIGHLIGHT[chroma-example-counter] <= 2 )); then - if [[ "$__wrd" = \"* ]]; then - # Pass through, fsh main code will do the highlight! - return 1 - else - __style=${FAST_THEME_NAME}builtin - fi - else - __style=${FAST_THEME_NAME}globbing - fi - fi -} - -# Add region_highlight entry (via `reply' array). -# If 1 will be added to __start_pos, this will highlight "oken". -# If 1 will be subtracted from __end_pos, this will highlight "toke". -# $PREBUFFER is for specific situations when users does command \ -# i.e. when multi-line command using backslash is entered. -# -# This is a common place of adding such entry, but any above code can do -# it itself (and it does in other chromas) and skip setting __style to -# this way disable this code. -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through, do obligatory things ourselves. -# _start_pos=$_end_pos advainces pointers in command line buffer. -# -# To pass through means to `return 1'. The highlighting of -# this single token is then done by fast-syntax-highlighting's -# main code and chroma doesn't have to do anything. -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-fast-theme.ch b/.config/zsh/.zsh/fsh/→chroma/-fast-theme.ch deleted file mode 100644 index 15bc210..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-fast-theme.ch +++ /dev/null @@ -1,40 +0,0 @@ -# vim:ft=zsh:et:sw=4 -(( next_word = 2 | 8192 )) -[[ "$__arg_type" = 3 ]] && return 2 - -local __first_call="$1" __wrd="${(Q)2}" __start_pos="$3" __end_pos="$4" -local __style - -if (( __first_call )); then - FAST_HIGHLIGHT[chroma-fast-theme-first]=0 - return 1 -elif (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 -elif (( ${FAST_HIGHLIGHT[chroma-fast-theme-first]} )) || [[ $__wrd = -* ]]; then - return 1 -else - FAST_HIGHLIGHT[chroma-fast-theme-first]=1 -fi - -if [[ "$__wrd" = */* || "$__wrd" = (XDG|LOCAL|HOME|OPT):* ]]; then - __wrd="${${__wrd/(#s)XDG:/${${XDG_CONFIG_HOME:-$HOME/.config}%/}/fsh/}%.ini}.ini" - __wrd="${${__wrd/(#s)LOCAL://usr/local/share/fsh/}%.ini}.ini" - __wrd="${${__wrd/(#s)HOME:/$HOME/.fsh/}%.ini}.ini" - __wrd="${${__wrd/(#s)OPT://opt/local/share/fsh/}%.ini}.ini" - __wrd=${~__wrd} # allow user to quote ~ -else - __wrd="$FAST_BASE_DIR/themes/$__wrd.ini" -fi - -if [[ -f $__wrd ]]; then - __style=${FAST_THEME_NAME}path -else - __style=${FAST_THEME_NAME}incorrect-subtle -fi - -(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 diff --git a/.config/zsh/.zsh/fsh/→chroma/-fpath_peq.ch b/.config/zsh/.zsh/fsh/→chroma/-fpath_peq.ch deleted file mode 100644 index 072cee3..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-fpath_peq.ch +++ /dev/null @@ -1,61 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# This chroma does a narrow, obscure but prestigious parsing of fpath+=( elem1 -# elem2 ... ) construct to provide *the* *future* contents of $fpath to -# -autoload.ch, so that it can detect functions in those provided directories -# `elem1', `elem2', etc. and highlight the functions with `correct-subtle' -# instead of `incorrect-subtle'. Basically all thit is for command-lines like: -# -# % fpath+=( `pwd` ); autoload my-fun-from-PWD - -# Keep chroma-takever state meaning: until ; or similar (see $__arg_type below) -# The 8192 sum takes care that the next token will be routed to this chroma -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local -a deserialized - -(( __first_call )) && { - case $__wrd in - (fpath=\() - FAST_HIGHLIGHT[fpath_peq_mode]=1 - ;; - (fpath+=\() - FAST_HIGHLIGHT[fpath_peq_mode]=2 - ;; - (FPATH=) - FAST_HIGHLIGHT[fpath_peq_mode]=4 - ;; - (FPATH+=) - FAST_HIGHLIGHT[fpath_peq_mode]=8 - ;; - esac - if (( FAST_HIGHLIGHT[fpath_peq_mode] & 5 )); then - FAST_HIGHLIGHT[chroma-fpath_peq-elements]="! ${FAST_HIGHLIGHT[chroma-fpath_peq-elements]}" - fi - return 1 -} || { - # Following call, i.e. not the first one - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - [[ "$__wrd" != ")" ]] && { - deserialized=( "${(Q@)${(z@)FAST_HIGHLIGHT[chroma-fpath_peq-elements]}}" ) - [[ -z "${deserialized[1]}" && ${#deserialized} -eq 1 ]] && deserialized=() - # Support ~ and $VAR, for [a-zA-Z_][a-ZA-Z0-9_]# characters in "VAR" - deserialized+=( "${(Q)${${(j: :)__wrd}//(#b)((\$([0-9]##|[a-zA-Z_][a-zA-Z0-9_]#))|(\$\{([0-9]##|[a-zA-Z_][a-zA-Z0-9_]#)\})|(#s)~)/${(P)${${${${match[1]##\$\{(#c0,1)}%\}}:#\~}:-HOME}}}}" ) - FAST_HIGHLIGHT[chroma-fpath_peq-elements]="${(j: :)${(q@)deserialized}}" - } - - return 1 -} - -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-git.ch b/.config/zsh/.zsh/fsh/→chroma/-git.ch deleted file mode 100644 index 12a97b3..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-git.ch +++ /dev/null @@ -1,954 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# Chroma function for command `git'. It colorizes the part of command -# line that holds `git' invocation. - -(( FAST_HIGHLIGHT[-git.ch-chroma-def] )) && return 1 - -FAST_HIGHLIGHT[-git.ch-chroma-def]=1 - -typeset -gA fsh__git__chroma__def -fsh__git__chroma__def=( - ## - ## No subcommand - ## - ## {{{ - - subcmd:NULL "NULL_0_opt" - NULL_0_opt "(-C|--exec-path=|--git-dir=|--work-tree=|--namespace=|--super-prefix=) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action - || -c - <<>> __style=\${FAST_THEME_NAME}single-hyphen-option // NO-OP - <<>> __style=\${FAST_THEME_NAME}optarg-string // NO-OP - || (--version|--help|--html-path|--man-path|--info-path|-p|--paginate| - -P|--no-pager|--no-replace-objects|--bare) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - - "subcommands" "::→chroma/-git-get-subcommands" # run a function (the :: causes this) and use `reply' - #"subcommands" "(fetch|pull)" # run a function (the :: causes this) and use `reply' - - "subcmd-hook" "→chroma/-git-check-if-alias" - - "subcommands-blacklist" "mv,other" - - ## }}} - - ## - ## `FETCH' - ## - ## {{{ - - subcmd:fetch "FETCH_MULTIPLE_0_opt^ // FETCH_ALL_0_opt^ // FETCH_0_opt // - REMOTE_GR_1_arg // REF_#_arg // NO_MATCH_#_opt" - - # Special options (^ - has directives, currently - an :add and :del directive) - "FETCH_MULTIPLE_0_opt^" " - --multiple - <<>> __style=\${FAST_THEME_NAME}double-hyphen-option // NO-OP - || --multiple:add - <<>> REMOTE_GR_#_arg - || --multiple:del - <<>> REMOTE_GR_1_arg // REF_#_arg" # when --multiple is passed, then - # there is no refspec argument, only remotes-ids - # follow unlimited # of them, hence the # in the - # REMOTE_GR_#_arg - - # Special options (^ - has directives - an :del-directive) - "FETCH_ALL_0_opt^" " - --all - <<>> __style=\${FAST_THEME_NAME}double-hyphen-option // NO-OP - || --all:del - <<>> REMOTE_GR_1_arg // REF_#_arg" # --all can be only followed by options - - # FETCH_0_opt. FETCH-options (FETCH is an identifier) at position 0 -> - # -> before any argument - FETCH_0_opt " - (--depth=|--deepen=|--shallow-exclude=|--shallow-since=|--receive-pack=| - --refmap=|--recurse-submodules=|-j|--jobs=|--submodule-prefix=| - --recurse-submodules-default=|-o|--server-option=|--upload-pack| - --negotiation-tip=) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action - || (--help|--all|-a|--append|--unshallow|--update-shallow|--dry-run|-f|--force| - -k|--keep|--multiple|-p|--prune|-n|--no-tags|-t|--tags|--no-recurse-submodules| - -u|--update-head-ok|-q|--quiet|-v|--verbose|--progress| - -4|--ipv4|-6|--ipv6) - <<>> __style=\${FAST_THEME_NAME}single-hyphen-option // NO-OP" - # Above: note the two <<>>-separated blocks for options that have - # some arguments – the second pair of action/handler is being - # run when an option argument is occurred (first one: the option - # itself). If there is only one <<>>-separated block, then the option - # is set to be argument-less. The argument is a) -o/--option argument - # and b) -o/--option=argument. - - REMOTE_GR_1_arg "NO-OP // ::→chroma/-git-verify-remote-or-group" # This definition is generic, reused later - "REF_#_arg" "NO-OP // ::→chroma/-git-verify-ref" # This too - "REMOTE_GR_#_arg" "NO-OP // ::→chroma/-git-verify-remote-or-group" # and this too - # The hash `#' above denotes: an argument at any position - # It will nicely match any following (above the first explicitly - # numbered ones) arguments passed when using --multiple - - # A generic action - NO_MATCH_\#_opt "* <<>> __style=\${FAST_THEME_NAME}incorrect-subtle // NO-OP" - NO_MATCH_\#_arg "__style=\${FAST_THEME_NAME}incorrect-subtle // NO-OP" - - ## }}} - - ## - ## PUSH - ## - ## {{{ - - subcmd:push "PUSH_0_opt // REMOTE_1_arg // REF_#_arg // NO_MATCH_#_opt" - - PUSH_0_opt " - (--receive-pack=|--exec=|--repo=|--push-option=|--signed=| - --force-with-lease=|--signed=|--recurse-submodules=) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action - || (--help|--all|--mirror|--tags|--follow-tags|--atomic|-n|--dry-run| - --porcelain|--delete|--tags|--follow-tags|--signed|--no-signed| - --atomic|--no-atomic|-o|--push-option|--force-with-lease| - --no-force-with-lease|-f|--force|-u|--set-upstream|--thin| - --no-thin|-q|--quiet|-v|--verbose|--progress|--no-recurse-submodules| - --verify|--no-verify|-4|--ipv4|-6|--ipv6) - <<>> __style=\${FAST_THEME_NAME}single-hyphen-option // NO-OP" - - REMOTE_1_arg "NO-OP // ::→chroma/-git-verify-remote" # This definition is generic, reused later - - ### }}} - - ## - ## PULL - ## - ## {{{ - - subcmd:pull "PULL_0_opt // REMOTE_1_arg // REF_#_arg // NO_MATCH_#_opt" - - PULL_0_opt " - (--recurse-submodules=|-S|--gpg-sign=|--log=|-s|--strategy=|-X| - --strategy-option=|--rebase=|--depth=|--deepen=|--shallow-exclude=| - --shallow-since=|--negotiation-tip|--upload-pack|-o|--server-option=| - --no-recurse-submodules=) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action - || (--help|-q|--quiet|-v|--verbose|--progress|--no-recurse-submodules| - --commit|--no-commit|--edit|--no-edit|--ff|--no-ff|--ff-only| - --log|--no-log|--signoff|--no-signoff|--stat|-n|--no-stat|--squash| - --no-squash|--verify-signatures|--no-verify-signatures|--summary| - --no-summary|--allow-unrelated-histories|-r|--rebase|--no-rebase| - --autostash|--no-autostash|--all|-a|--append|--unshallow| - --update-shallow|-f|--force|-k|--keep|--no-tags|-u|--update-head-ok| - --progress|-4|--ipv4|-6|--ipv6|--recurse-submodules) - <<>> __style=\${FAST_THEME_NAME}single-hyphen-option // NO-OP" - - ## }}} - - ## - ## COMMIT - ## - ## {{{ - - subcmd:commit "COMMIT_#_opt // FILE_#_arg // NO_MATCH_#_opt" - - "COMMIT_#_opt" " - (-m|--message=|-am) - <<>> NO-OP // ::→chroma/-git-commit-msg-opt-action - <<>> NO-OP // ::→chroma/-git-commit-msg-opt-ARG-action - || (--help|-a|--all|-p|--patch|--reset-author|--short|--branch| - --porcelain|--long|-z|--null|-s|--signoff|-n|--no-verify| - --allow-empty|--allow-empty-message|-e|--edit|--no-edit| - --amend|--no-post-rewrite|-i|--include|-o|--only|--untracked-files| - -v|--verbose|-q|--quiet|--dry-run|--status|--no-status|--no-gpg-sign) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - || (-C|--reuse-message=|-c|--reedit-message=|--fixup=|--squash=| - -F|--file=|--author=|--date=|-t|--template=|--cleanup=| - -u|--untracked-files=|-S|--gpg-sign=) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action" - - # A generic action - "FILE_#_arg" "NO-OP // ::→chroma/-git-verify-file" - - ## }}} - - ## - ## MERGE - ## - ## {{{ - - subcmd:merge "MERGE_0_opt // COMMIT_#_arg" - MERGE_0_opt - "(-m) - <<>> NO-OP // ::→chroma/-git-commit-msg-opt-action - <<>> NO-OP // ::→chroma/-git-commit-msg-opt-ARG-action - (-S|--gpg-sign=|--log=|-e|--strategy=|-X|--strategy-option=|-F| - --file) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action - || (--help|--commit|--no-commit|-e|--edit|--no-edit|--ff|--no-ff|--ff-only| - --log|--no-log|--signoff|--no-signoff|-n|--stat|--no-stat|--squash| - --no-squash|--verify-signatures|--no-verify-signatures|--summary| - --no-summary|-q|--quiet|-v|--verbose|--progress|--no-progress| - --allow-unrelated-histories|--rerere-autoupdate|--no-rerere-autoupdate| - --abort|--continue) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - COMMIT_\#_arg "NO-OP // ::→chroma/-git-verify-commit" - - ## }}} - - ## - ## RESET - ## - ## {{{ - - subcmd:reset "RESET_0_opt^ // RESET_0_opt // RESET_#_arg // NO_MATCH_#_opt" - "RESET_0_opt^" " - (--soft|--mixed|--hard|--merge|--keep) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - || (--soft|--mixed|--hard|--merge|--keep):del - <<>> RESET_0_opt // RESET_#_arg - || (--soft|--mixed|--hard|--merge|--keep):add - <<>> RESET_1_arg // NO_MATCH_#_arg - " - - RESET_0_opt " - (-q|-p|--patch) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - RESET_1_arg "NO-OP // ::→chroma/-git-verify-commit" - - "RESET_#_arg" "NO-OP // ::→chroma/-git-RESET-verify-commit-or-file" - - - ## }}} - - ## - ## REVERT - ## - ## {{{ - - subcmd:revert "REVERT_SEQUENCER_0_opt^ // REVERT_0_opt // REVERT_#_arg // NO_MATCH_#_opt" - REVERT_0_opt " - (-m|--mainline|-S|--gpg-sign=|--strategy=|-X|--strategy-option=) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action - || (-e|--edit|--no-edit|-n|--no-commit|-s|--signoff) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - "REVERT_SEQUENCER_0_opt^" " - (--continue|--quit|--abort) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - || (--continue|--quit|--abort):del - <<>> REVERT_0_opt // REVERT_#_arg - || (--continue|--quit|--abort):add - <<>> NO_MATCH_#_arg" - - "REVERT_#_arg" "NO-OP // ::→chroma/-git-verify-commit" - - ## }}} - - ## - ## DIFF - ## - ## TODO: When a second argument is also a path and it points to a directory, then - ## git appends the previous file name to it – good to implement this too - ## {{{ - - subcmd:diff "DIFF_NO_INDEX_0_opt^ // DIFF_0_opt // COMMIT_FILE_DIR_#_arg // NO_MATCH_#_opt" - - "DIFF_NO_INDEX_0_opt^" " - --no-index - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - || --no-index:del - <<>> COMMIT_FILE_DIR_#_arg - || --no-index:add - <<>> FILE_1_arg // FILE_2_arg // NO_MATCH_#_arg" - DIFF_0_opt " - (-U|--unified=|--anchored=|--diff-algorithm=|--stat=|--dirstat| - --submodule=|--color=|--color-moved=|--color-moved-ws=|--word-diff=| - --word-diff-regex=|--color-words=|--ws-error-highlight=|--abbrev=| - -B|--break-rewrites=|-M|--find-renames=|-C|--find-copies=|-l| - --diff-filter=|-S|-G|--find-object=|--relative=|-O|--relative=| - --inter-hunk-context=|--ignore-submodules=|--src-prefix=|--dst-prefix=| - --line-prefix=) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action - || (-p|--patch|-u|-s|--no-patch|--raw|--patch-with-raw|--indent-heuristic| - --no-indent-heuristic|--minimal|--patience|--histogram|--stat| - --compact-summary|--numstat|--shortstat|--dirstat|--summary| - --patch-with-stat|-z|--name-only|--name-status|--submodule|--no-color| - --color-moved|--word-diff|--color-words|--no-renames|--check| - --full-index|--binary|--abbrev|--break-rewrites|--find-renames| - --find-copies|--find-copies-harder|-D|--pickaxe-all|--pickaxe-regex| - --irreversible-delete|-R|--relative|-a|--text|--ignore-cr-at-eol| - --ignore-space-at-eol|-b|--ignore-space-change|-w|--ignore-all-space| - --ignore-blank-lines|-W|--function-context|--exit-code|--quiet| - --ext-diff|--no-ext-diff|--textconv|--no-textconv|--ignore-submodules| - --no-prefix|--ita-invisible-in-index|-1|--base|-2|--ours|-3|--theirs| - -0|--cached) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - # A generic action - "COMMIT_FILE_DIR_#_arg" "NO-OP // ::→chroma/-git-verify-commit-or-file-or-dir" - - # A generic action - "FILE_1_arg" "NO-OP // ::→chroma/-git-verify-file" - - # A generic action - "FILE_2_arg" "NO-OP // ::→chroma/-git-verify-file" - - ## }}} - - ## - ## ADD - ## - ## {{{ - - subcmd:add "ADD_0_opt // FILE_OR_DIR_#_arg // NO_MATCH_#_opt" - - ADD_0_opt " - --chmod= - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action - || (-v|--verbose|-f|--force|-i|--interactive|-n|--dry-run| - -p|--patch|-e|--edit|--all|--no-all|-A|--all|--no-all| - --ignore-removal|--no-ignore-removal|-u|--update|-N| - --intent-to-add|--refresh|--ignore-errors|--ignore-missing| - --renormalize|--no-warn-embedded-repo) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - FILE_OR_DIR_#_arg "NO-OP // ::→chroma/-git-verify-file-or-dir" - - ## }}} - - ## - ## CHECKOUT - ## - ## {{{ - - subcmd:checkout "CHECKOUT_BRANCH_0_opt^ // - CHECKOUT_0_opt // FILE_OR_DIR_OR_BRANCH_OR_COMMIT_1_arg // FILE_#_arg // - FILE_#_arg // NO_MATCH_#_opt" - - "CHECKOUT_BRANCH_0_opt^" " - (-b|-B|--orphan) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - || (-b|-B|--orphan):del - <<>> FILE_OR_DIR_OR_BRANCH_OR_COMMIT_1_arg // FILE_#_arg // FILE_#_arg - || (-b|-B|--orphan):add - <<>> NEW_BRANCH_1_arg // COMMIT_2_arg // NO_MATCH_#_arg" - - NEW_BRANCH_1_arg "NO-OP // ::→chroma/-git-verify-correct-branch-name" - - COMMIT_2_arg "NO-OP // ::→chroma/-git-verify-commit" - - CHECKOUT_0_opt " - --conflict= - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action - || (-q|--quiet|--progress|--no-progress|-f|--force|--ours|--theirs| - -b|-B|-t|--track|--no-track|-l|--detach|--orphan| - --ignore-skip-worktree-bits|-m|--merge|-p|--patch| - --ignore-other-worktrees|--no-ignore-other-worktrees) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - # A generic action - COMMIT_1_arg "NO-OP // ::→chroma/-git-verify-commit" - - # Unused - FILE_OR_BRANCH_OR_COMMIT_1_arg "NO-OP // ::→chroma/-git-file-or-ubranch-or-commit-verify" - FILE_OR_DIR_OR_BRANCH_OR_COMMIT_1_arg "NO-OP // ::→chroma/-git-file-or-dir-or-ubranch-or-commit-verify" - - ## }}} - - ## - ## REMOTE - ## - ## {{{ - - subcmd:remote "REMOTE_0_opt // REMOTE_ADD_1_arg // REMOTE_RENAME_1_arg // REMOTE_REMOVE_1_arg // - REMOTE_SET_HEAD_1_arg // REMOTE_SET_BRANCHES_1_arg // - REMOTE_GET_URL_1_arg // REMOTE_SET_URL_1_arg // REMOTE_SHOW_1_arg // - REMOTE_PRUNE_1_arg // REMOTE_UPDATE_1_arg" - - REMOTE_0_opt "(-v|--verbose) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - REMOTE_ADD_1_arg "add ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> - add:REMOTE_ADD_OPTS_1_opt // REMOTE_A_NAME_2_arg // - REMOTE_A_URL_3_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" - - REMOTE_RENAME_1_arg "rename ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> - add:REMOTE_2_arg // REMOTE_A_NAME_3_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" - - REMOTE_REMOVE_1_arg "remove ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> - add:REMOTE_2_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" - - REMOTE_SET_HEAD_1_arg "set-head ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> - add:REMOTE_2_arg // BRANCH_3_arg // - REMOTE_SET_HEAD_OPTS_1_opt // REMOTE_SET_HEAD_OPTS_2_opt // - NO_MATCH_#_opt // NO_MATCH_#_arg" - - REMOTE_SET_BRANCHES_1_arg "set-branches ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> - add:REMOTE_SET_BRANCHES_OPTS_1_opt // REMOTE_2_arg // - BRANCH_#_arg // NO_MATCH_#_opt" - - REMOTE_GET_URL_1_arg "get-url ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> - add:REMOTE_GET_URL_OPTS_1_opt // REMOTE_2_arg // - NO_MATCH_#_opt // NO_MATCH_#_arg" - - REMOTE_SET_URL_1_arg "set-url ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> - add:REMOTE_SET_URL_OPTS_1_opt^ // - REMOTE_2_arg // REMOTE_A_URL_3_arg // REMOTE_A_URL_4_arg // - NO_MATCH_#_opt // NO_MATCH_#_arg" - - REMOTE_SHOW_1_arg "show ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> - add:REMOTE_SHOW_OPTS_1_opt // REMOTE_#_arg // NO_MATCH_#_opt" - - REMOTE_PRUNE_1_arg "prune ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> - add:REMOTE_PRUNE_OPTS_1_opt // REMOTE_#_arg // NO_MATCH_#_opt" - - REMOTE_UPDATE_1_arg "update ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> - add:REMOTE_UPDATE_OPTS_1_opt // REMOTE_GR_#_arg // NO_MATCH_#_opt" - - REMOTE_ADD_OPTS_1_opt " - (-t|-m|--mirror=) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action - || (-f|--tags|--no-tags) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - REMOTE_SET_HEAD_OPTS_1_opt " - (-a|--auto|-d|--delete) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - REMOTE_SET_HEAD_OPTS_2_opt " - (-a|--auto|-d|--delete) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - REMOTE_SET_BRANCHES_OPTS_1_opt " - --add - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - REMOTE_GET_URL_OPTS_1_opt " - (--push|--all) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - "REMOTE_SET_URL_OPTS_1_opt^" " - --push|--add|--delete - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - || (--add|--delete):del - <<>> REMOTE_A_URL_4_arg" - - REMOTE_SHOW_OPTS_1_opt " - -n - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - REMOTE_PRUNE_OPTS_1_opt " - (-n|--dry-run) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - REMOTE_UPDATE_OPTS_1_opt " - (-p|--prune) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - REMOTE_A_NAME_2_arg "NO-OP // ::→chroma/-git-verify-correct-branch-name" - REMOTE_A_NAME_3_arg "NO-OP // ::→chroma/-git-verify-correct-branch-name" - REMOTE_A_URL_3_arg "NO-OP // ::→chroma/main-chroma-std-verify-url" - REMOTE_A_URL_4_arg "NO-OP // ::→chroma/main-chroma-std-verify-url" - BRANCH_3_arg "NO-OP // ::→chroma/-git-verify-branch" - BRANCH_\#_arg "NO-OP // ::→chroma/-git-verify-branch" - REMOTE_2_arg "NO-OP // ::→chroma/-git-verify-remote" - REMOTE_\#_arg "NO-OP // ::→chroma/-git-verify-remote" - - ## }}} - - ## - ## LOG - ## - - subcmd:log "LOG_0_opt // LOG_1_arg // FILE_#_arg // NO_MATCH_#_opt" - - LOG_0_opt " - (--decorate=|--decorate-refs=|--decorate-refs-exclude=|-L|-n|--max-count=| - --skip=|--since=|--after=|--until=|--before=|--author=|--committer=| - --grep-reflog=|--grep=|--min-parents=|--max-parents=|--branches=|--tags=| - --remotes=|--glob=|--exclude=|--no-walk=|--pretty=|--format=|--encoding=| - --expand-tabs=|--notes=|--show-notes=|--date=|--show-linear-break=|-U| - --unified=|--anchored=|--diff-algorithm=|--stat=|--dirstat=|--submodule=| - --color=|--color-moved=|--color-moved-ws=|--word-diff=|--word-diff-regex=| - --color-words=|--ws-error-highlight=|--abbrev=|-B|--break-rewrites=|-M| - --find-renames=|-C|--find-copies=|-l|--diff-filter=|-S|-G|--find-object=| - --relative=|-O|--relative=|--inter-hunk-context=|--ignore-submodules=| - --src-prefix=|--dst-prefix=|--line-prefix=) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action - - || (--follow|--decorate|--no-decorate|--source|--use-mailmap|--full-diff| - --log-size|--all-match|--invert-grep|-i|--regexp-ignore-case|--basic-regexp| - -E|--extended-regexp|-F|--fixed-strings|-P|--perl-regexp|--remove-empty| - --merges|--no-merges|--no-min-parents|--no-max-parents|--first-parent| - --not|--all|--branches|--tags|--remotes|--reflog|--single-worktree| - --ignore-missing|--bisect|--stdin|--cherry-mark|--cherry-pick|--left-only| - --right-only|--cherry|-g|--walk-reflogs|--merge|--boundary|--simplify-by-decoration| - --full-history|--dense|--sparse|--simplify-merges|--ancestry-path|--date-order| - --author-date-order|--topo-order|--reverse|--no-walk|--do-walk|--pretty| - --abbrev-commit|--no-abbrev-commit|--oneline|--expand-tabs|--no-expand-tabs| - --notes|--no-notes|--show-notes|--no-standard-notes|--show-signature| - --relative-date|--parents|--children|--left-right|--graph|--show-linear-break| - -c|--cc|-m|-r|-t|-p|-u|--patch|-s|--no-patch|--raw|--patch-with-raw| - --indent-heuristic|--no-indent-heuristic|--minimal|--patience|--histogram| - --stat|--compact-summary|--numstat|--shortstat|--dirstat|--summary| - --patch-with-stat|-z|--name-only|--name-status|--submodule|--color|--no-color| - --color-moved|--word-diff|--color-words|--no-renames|--check|--full-index| - --binary|--abbrev|--break-rewrites|--find-renames| - --find-copies|--find-copies-harder|-D|--irreversible-delete| - --pickaxe-all|--pickaxe-regex|-R|--relative|-a|--text|--ignore-cr-at-eol| - --ignore-space-at-eol|-b|--ignore-space-change|-w|--ignore-all-space| - --ignore-blank-lines|-W|--function-context|--ext-diff|--no-ext-diff| - --textconv|--no-textconv|--ignore-submodules|--no-prefix| - --ita-invisible-in-index) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - LOG_1_arg "NO-OP // ::→chroma/-git-verify-rev-range-or-file" - - ## - ## TAG - ## - - subcmd:tag "TAG_D_0_opt^ // TAG_L_0_opt^ // TAG_V_0_opt^ // TAG_0_opt^" - - "TAG_0_opt^" " - (-u|--local-user=|--cleanup=) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action - || -m - <<>> NO-OP // ::→chroma/-git-commit-msg-opt-action - <<>> NO-OP // ::→chroma/-git-commit-msg-opt-ARG-action - || (-F|--file) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - <<>> NO-OP // ::→chroma/-git-verify-file - || (-a|--annotate|-s|--sign|-f|-e|--edit) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - || (-u|--local-user=|--cleanup=|-m|-F|--file|-a|--annotate|-s|--sign| - -f|-e|--edit):add - <<>> TAG_NEW_1_arg // COMMIT_2_arg // NO_MATCH_#_arg // - NO_MATCH_#_opt" - - TAG_NEW_1_arg "NO-OP // ::→chroma/-git-verify-correct-branch-name" - - TAG_1_arg "NO-OP // ::→chroma/-git-verify-tag-name" - - "TAG_D_0_opt^" " - (-d) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - || -d:add - <<>> TAG_#_arg // NO_MATCH_#_opt - || -d:del - <<>> TAG_0_opt // TAG_NEW_1_arg // COMMIT_2_arg" - - "TAG_#_arg" "NO-OP // ::→chroma/-git-verify-tag-name" - - "TAG_L_0_opt^" " - (-l) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - || -l:add - <<>> TAG_L_0_opt // TAG_PAT_#_arg // NO_MATCH_#_opt - || -l:del - <<>> TAG_0_opt // TAG_NEW_1_arg // COMMIT_2_arg" - - TAG_L_0_opt " - (-n|--contains|--no-contains|--points-at|--column=|--sort=|--format=| - --color=) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action - || (--column|--no-column|--create-reflog|--merged|--no-merged|--color|-i) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - "TAG_PAT_#_arg" "NO-OP // ::→chroma/main-chroma-std-verify-pattern" - - "TAG_V_0_opt^" " - (-v) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - || -v:add - <<>> TAG_V_0_opt // TAG_#_arg // NO_MATCH_#_opt - || -v:del - <<>> TAG_0_opt // TAG_NEW_1_arg // COMMIT_2_arg" - - TAG_V_0_opt " - --format= - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action" - - ## - ## All remaining subcommands - ## - ## {{{ - - "subcmd:*" "CATCH_ALL_#_opt" - "CATCH_ALL_#_opt" "* <<>> NO-OP // ::→chroma/main-chroma-std-aopt-SEMI-action" - - ## }}} -) - -# Called after entering just "git" on the command line -→chroma/-git-first-call() { - # Called for the first time - new command - # FAST_HIGHLIGHT is used because it survives between calls, and - # allows to use a single global hash only, instead of multiple - # global variables - FAST_HIGHLIGHT[chroma-git-counter]=0 - FAST_HIGHLIGHT[chroma-git-got-subcommand]=0 - FAST_HIGHLIGHT[chroma-git-subcommand]="" - FAST_HIGHLIGHT[chrome-git-got-msg1]=0 - FAST_HIGHLIGHT[chrome-git-got-anymsg]=0 - FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]=0 - FAST_HIGHLIGHT[chroma-git-checkout-new]=0 - FAST_HIGHLIGHT[chroma-git-fetch-multiple]=0 - FAST_HIGHLIGHT[chroma-git-branch-change]=0 - FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=0 - FAST_HIGHLIGHT[chroma-git-reset-etc-saw-commit]=0 - FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file]=0 - return 1 -} - -→chroma/-git-check-if-alias() { - local _wrd="$1" - local -a _result - - typeset -ga fsh__chroma__git__aliases - _result=( ${(M)fsh__chroma__git__aliases[@]:#${_wrd}[[:space:]]##*} ) - →chroma/main-chroma-print "Got is-alias-_result: $_result" - [[ -n "$_result" ]] && \ - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]="${${${_result#* }## ##}%% *}" -} - -# A hook that returns the list of git's -# available subcommands in $reply -→chroma/-git-get-subcommands() { - local __svalue - integer __ivalue - LANG=C .fast-run-command "git help -a" chroma-${FAST_HIGHLIGHT[chroma-current]}-subcmd-list "" $(( 15 * 60 )) - if [[ "${__lines_list[1]}" = See* ]]; then - # (**) - # git >= v2.20, the aliases in the `git help -a' command - __lines_list=( ${${${${(M)__lines_list[@]:#([[:space:]](#c3,3)[a-zA-Z0-9_]*|Command aliases)}##[[:space:]]##}//(#s)Command\ aliases(#e)/Command_aliases}} ) - __svalue="+${__lines_list[(I)Command_aliases]}" - __lines_list[1,__svalue-1]=( ${(@)__lines_list[1,__svalue-1]%%[[:space:]]##*} ) - else - # (**) - # git < v2.20, add aliases through extra code - __lines_list=( ${(s: :)${(M)__lines_list[@]:# [a-z]*}} ) - - __svalue=${#__lines_list} - # This allows to check if the command is an alias - we want to - # highlight the aliased command just like the target command of - # the alias - .fast-run-command "+git config --get-regexp 'alias.*'" chroma-${FAST_HIGHLIGHT[chroma-current]}-alias-list "[[:space:]]#alias." $(( 15 * 60 )) - fi - - __tmp=${#__lines_list} - typeset -ga fsh__chroma__git__aliases - fsh__chroma__git__aliases=( ${__lines_list[__svalue+1,__tmp]} ) - [[ ${__lines_list[__svalue]} != "Command_aliases" ]] && (( ++ __svalue, __ivalue=0, 1 )) || (( __ivalue=1 )) - __lines_list[__svalue,__tmp]=( ${(@)__lines_list[__svalue+__ivalue,__tmp]%%[[:space:]]##*} ) - reply=( "${__lines_list[@]}" ) -} - -# A generic handler -→chroma/-git-verify-remote() { - local _wrd="$4" - .fast-run-git-command "git remote" "chroma-git-remotes-$PWD" "" 10 - [[ -n ${__lines_list[(r)$_wrd]} ]] && { - __style=${FAST_THEME_NAME}correct-subtle; return 0 - } || { - [[ $_wrd != *:* ]] && { __style=${FAST_THEME_NAME}incorrect-subtle; return 1; } - } -} - -# A generic handler - checks if given ref is correct -→chroma/-git-verify-ref() { - local _wrd="$4" - _wrd="${_wrd%%:*}" - .fast-run-git-command "git for-each-ref --format='%(refname:short)' refs/heads" "chroma-git-refs-$PWD" "refs/heads" 10 - [[ -n ${__lines_list[(r)$_wrd]} ]] && \ - { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \ - { __style=${FAST_THEME_NAME}incorrect-subtle; return 1; } -} - -# A generic handler - checks if given remote or group is correct -→chroma/-git-verify-remote-or-group() { - →chroma/-git-verify-remote "$@" && return 0 - # The check for a group is to follow below - integer _start="$2" _end="$3" - local _scmd="$1" _wrd="$4" -} - -# A generic handler - checks whether the file exists -→chroma/-git-verify-file() { - integer _start="$2" _end="$3" __pos __start __end - local _wrd="$4" bg - - [[ -f $_wrd ]] && { - (( __start=_start, __end=_end, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") - bg=${(M)FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]%bg=*} - ((1)) - } || { - (( __start=_start, __end=_end, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") - bg=${(M)FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]%bg=*} - } - - [[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} && \ - ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]} != \ - ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} - ]] && \ - for (( __pos = 1; __pos <= (_end-_start); __pos++ )) { - [[ ${_wrd[__pos]} == "/" ]] && { - [[ ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} = *bg=* ]] && { - (( __start=_start+__pos-__PBUFLEN, __start >= 0 )) && \ - reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}") - ((1)) - } || { - (( __start=_start+__pos-__PBUFLEN, __start >= 0 )) && \ - reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}${bg:+,$bg}") - } - } - } -} - -# A generic handler - checks whether the file exists -→chroma/-git-verify-file-or-dir() { - integer _start="$2" _end="$3" __pos __start __end retval - local _wrd="$4" bg - - __style= - [[ -f $_wrd || -d $_wrd ]] && { - (( __start=_start, __end=_end, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") - bg=${(M)FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]%bg=*} - ((1)) - } || { - (( __start=_start, __end=_end, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") - bg=${(M)FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]%bg=*} - retval=1 - } - - [[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} && \ - ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]} != \ - ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} - ]] && \ - for (( __pos = 1; __pos <= (_end-_start); __pos++ )) { - [[ ${_wrd[__pos]} == "/" ]] && { - [[ ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} = *bg=* ]] && { - (( __start=_start+__pos-__PBUFLEN, __start >= 0 )) && \ - reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}") - ((1)) - } || { - (( __start=_start+__pos-__PBUFLEN, __start >= 0 )) && \ - reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}${bg:+,$bg}") - } - } - } - return $retval -} - -→chroma/-git-verify-branch() { - local _wrd="$4" - .fast-run-git-command "git for-each-ref --format='%(refname:short)'" "chroma-git-branches-$PWD" "refs/heads" 10 - if [[ -n ${__lines_list[(r)$_wrd]} ]] { - __style=${FAST_THEME_NAME}correct-subtle; return 0 - } elif [[ -n ${__lines_list[(r)origin/$_wrd]} ]] { - __style=${FAST_THEME_NAME}correct-subtle; return 0 - } else { - __style=${FAST_THEME_NAME}incorrect-subtle; return 1 - } -} - -→chroma/-git-verify-also-unfetched-ref() { - local _wrd="$4" - .fast-run-git-command "git config --get checkout.defaultRemote" \ - "chroma-git-defaultRemote-$PWD" "" 10 - local remote="${__lines_list[1]:-origin}" - .fast-run-git-command "git rev-list --count --no-walk - --glob=\"refs/remotes/$remote/$_wrd\"" \ - "chroma-git-unfetched-ref-$PWD" "" 10 - - (( __lines_list[1] )) && { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \ - { __style=${FAST_THEME_NAME}incorrect-subtle; return 1; } -} - -# A generic handler -→chroma/-git-file-or-ubranch-or-commit-verify() { - →chroma/-git-verify-commit "$@" && return - →chroma/-git-verify-file "$@" && return - →chroma/-git-verify-branch "$@" && return - →chroma/-git-verify-also-unfetched-ref "$@" -} - -# A generic handler -→chroma/-git-file-or-dir-or-ubranch-or-commit-verify() { - →chroma/-git-verify-commit "$@" && return - →chroma/-git-verify-file-or-dir "$@" && return - →chroma/-git-verify-branch "$@" && return - →chroma/-git-verify-also-unfetched-ref "$@" -} - -# A generic handler -→chroma/-git-verify-correct-branch-name() { - local _wrd="$4" - →chroma/-git-verify-commit "$@" && \ - { __style=${FAST_THEME_NAME}incorrect-subtle; return 0; } - - →chroma/-git-verify-remote "$@" && \ - { __style=${FAST_THEME_NAME}incorrect-subtle; return 0; } - - [[ "$_wrd" != ./* && "$_wrd" != *..* && "$_wrd" != *[~\^\ $'\t']* && - "$_wrd" != */ && "$_wrd" != *.lock && "$_wrd" != *\\* ]] && \ - { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \ - { __style=${FAST_THEME_NAME}incorrect-subtle; return 1; } -} - -# A generic handler that checks if given commit reference is correct -→chroma/-git-verify-commit() { - local _wrd="$4" - __lines_list=() - .fast-run-git-command --status "git rev-parse --verify --quiet \"$_wrd\"" \ - "chroma-git-commits-$PWD-$_wrd" "" $(( 1.5 * 60 )) - if (( __lines_list[1] == 0 )); then - __style=${FAST_THEME_NAME}correct-subtle - return 0 - fi - __style=${FAST_THEME_NAME}incorrect-subtle - return 1 -} - -# A generic handler that checks if given commit reference -# is correct or if it's a file that exists -→chroma/-git-verify-commit-or-file() { - →chroma/-git-verify-commit "$@" && return - →chroma/-git-verify-file "$@" -} - -# A generic handler that checks if given commit reference -# is correct or if it's a file or directives that exists -→chroma/-git-verify-commit-or-file-or-dir() { - →chroma/-git-verify-commit "$@" && return - →chroma/-git-verify-file-or-dir "$@" -} - -# A generic handler that checks if given revision range -# is correct or if a file of that name exists -→chroma/-git-verify-rev-range-or-file() { - local _wrd="$4" - - →chroma/-git-verify-commit "$@" && return 0 - - if [[ "$_wrd" = *..* ]]; then - (( FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file] )) && { - →chroma/-git-verify-file "$@" && return 0 - __style=${FAST_THEME_NAME}unknown-token - return 1 - } - - __style="" - return 0 - fi - - →chroma/-git-verify-file "$@" && \ - { FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file]=1; return 0; } - - __style="" - return 1 -} - -→chroma/-git-verify-tag-name() { - local _wrd="$4" - .fast-run-git-command "git tag" "chroma-git-tags-$PWD" "" $(( 2*60 )) - [[ -n ${__lines_list[(r)$_wrd]} ]] && \ - __style=${FAST_THEME_NAME}correct-subtle || \ - __style=${FAST_THEME_NAME}incorrect-subtle -} - -# A handler for the commit's -m/--message options.Currently -# does the same what →chroma/main-chroma-std-aopt-action does -→chroma/-git-commit-msg-opt-action() { - →chroma/main-chroma-std-aopt-action "$@" -} - -# A handler for the commit's -m/--message options' argument -→chroma/-git-commit-msg-opt-ARG-action() { - integer _start="$2" _end="$3" - local _scmd="$1" _wrd="$4" - - (( __start >= 0 )) || return - - # Match the message body in case of an --message= option - if [[ "$_wrd" = (#b)(--message=)(*) && -n "${match[2]}" ]]; then - _wrd="${(Q)${match[2]//\`/x}}" - # highlight --message=>>something<< - reply+=("$(( __start+10 )) $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}") - elif [[ "$_wrd" != --message ]]; then - # highlight the message's body - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}") - fi - - integer length=${FAST_HIGHLIGHT[git-cmsg-len]:-50} - - if (( ${#_wrd} > length )); then - for (( __idx1 = 1, __idx2 = 1; __idx1 <= length; ++ __idx1, ++ __idx2 )); do - # Use __arg from the fast-highlight-process's scope - while [[ "${__arg[__idx2]}" != "${_wrd[__idx1]}" ]]; do - (( ++ __idx2 )) - (( __idx2 > __asize )) && { __idx2=-1; break; } - done - (( __idx2 == -1 )) && break - done - if (( __idx2 != -1 )); then - if [[ -n "${match[1]}" ]]; then - reply+=("$(( __start+__idx2 )) $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") - else - reply+=("$(( __start+__idx2-1 )) $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") - fi - fi - fi -} - -# A RESET handler -# TODO: differentiate tree-ish from commit -→chroma/-git-RESET-verify-commit-or-file() { - →chroma/-git-verify-commit "$@" && { - →chroma/-git-verify-file "$@" && { - # TODO: with -p/--patch, the are optional, - # and this argument will be taken as a commit in a - # specific circumstances - FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file]=1 - return 0 - } - - (( FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file] || - FAST_HIGHLIGHT[chroma-git-reset-etc-saw-commit] )) && \ - { __style=${FAST_THEME_NAME}unknown-token; return 1; } - - FAST_HIGHLIGHT[chroma-git-reset-etc-saw-commit]=1 - - __style=${FAST_THEME_NAME}correct-subtle - - return 0 - } - - →chroma/-git-verify-file "$@" && \ - { FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file]=1; return 0; } - - return 1 -} - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-grep.ch b/.config/zsh/.zsh/fsh/→chroma/-grep.ch deleted file mode 100644 index 54309bf..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-grep.ch +++ /dev/null @@ -1,89 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# -# $2 - the current token, also accessible by $__arg from the above scope - -# basically a private copy of $__arg; the token can be eg.: "grep" -# -# $3 - a private copy of $_start_pos, i.e. the position of the token in the -# command line buffer, used to add region_highlight entry (see man), -# because Zsh colorizes by *ranges* in command line buffer -# -# $4 - a private copy of $_end_pos from the above scope -# - -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style __chars -integer __idx1 __idx2 - -# First call, i.e. command starts, i.e. "grep" token etc. -(( __first_call )) && { - FAST_HIGHLIGHT[chroma-grep-counter]=0 - return 1 -} || { - # Following call, i.e. not the first one. - - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if [[ "$__wrd" = -* ]]; then - # Detected option, add style for it. - [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ - __style=${FAST_THEME_NAME}single-hyphen-option - else - # Count non-option tokens. - (( FAST_HIGHLIGHT[chroma-grep-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-grep-counter] )) - - # First non-option token is the pattern (regex), we will - # highlight it. - if (( FAST_HIGHLIGHT[chroma-grep-counter] == 1 )); then - [[ "$__wrd" = \"* ]] && __style=${FAST_THEME_NAME}double-quoted-argument - [[ "$__wrd" = \'* ]] && __style=${FAST_THEME_NAME}single-quoted-argument - [[ "$__wrd" = \$\'* ]] && __style=${FAST_THEME_NAME}dollar-quoted-argument - [[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - __style="" - - __chars="*+\\)([]^\$" - __idx1=__start_pos - __idx2=__start_pos - while [[ "$__wrd" = (#b)[^$__chars]#([\\][\\])#((+|\*|\[|\]|\)|\(|\^|\$)|[\\](+|\*|\[|\]|\)|\(|\^|\$))(*) ]]; do - if [[ -n "${match[3]}" ]]; then - __idx1+=${mbegin[3]}-1 - __idx2=__idx1+${mend[3]}-${mbegin[3]}+1 - (( __start=__idx1-${#PREBUFFER}, __end=__idx2-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-operator]}") - __idx1=__idx2 - else - __idx1+=${mbegin[5]}-1 - fi - __wrd="${match[5]}" - done - elif (( FAST_HIGHLIGHT[chroma-grep-counter] == 2 )); then - # Handle paths, etc. normally - just pass-through to the big - # highlighter (the main FSH highlighter, used before chromas). - return 1 - fi - fi -} - -# Add region_highlight entry (via `reply' array). -# -# This is a common place of adding such entry, but any above -# code can do it itself (and it does) and skip setting __style -# to disable this code. -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through (no return 1 occured), do obligatory things ourselves. -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-hub.ch b/.config/zsh/.zsh/fsh/→chroma/-hub.ch deleted file mode 100644 index 2f0626a..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-hub.ch +++ /dev/null @@ -1,51 +0,0 @@ -# vim:ft=zsh:et:sw=4 -(( next_word = 2 | 8192 )) -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" - -if (( __first_call )); then - chroma/-git.ch $* - return 1 -fi -[[ "$__arg_type" = 3 ]] && return 2 - -if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 -fi - -if [[ "$__wrd" != -* ]] && (( FAST_HIGHLIGHT[chroma-git-got-subcommand] == 0 )); then - .fast-run-command "git config --get-regexp 'alias.*'" chroma-git-alias-list "" $(( 5 * 60 )) - # Grep for line: alias.{user-entered-subcmd}[[:space:]], and remove alias. prefix - __lines_list=( ${${(M)__lines_list[@]:#alias.${__wrd}[[:space:]]##*}#alias.} ) - - if (( ${#__lines_list} > 0 )); then - # (*) - # First remove alias name (#*[[:space:]]) and the space after it, then - # remove any leading spaces from what's left (##[[:space:]]##), then - # remove everything except the first word that's in the left line - # (%%[[:space:]]##*, i.e.: "everything from right side up to any space") - FAST_HIGHLIGHT[chroma-git-subcommand]="${${${__lines_list[1]#*[[:space:]]}##[[:space:]]##}%%[[:space:]]##*}" - else - FAST_HIGHLIGHT[chroma-git-subcommand]="$__wrd" - fi - if [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "browse" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "ci-status" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "compare" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "create" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "delete" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "fork" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "issue" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "pr" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "pull-request" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "release" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "sync" ]]; then - FAST_HIGHLIGHT[chroma-git-got-subcommand]=1 - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}subcommand]}") - (( FAST_HIGHLIGHT[chroma-git-counter] += 1 )) - (( this_word = next_word )) - _start_pos=$4 - return 0 - fi -fi - -chroma/-git.ch $* diff --git a/.config/zsh/.zsh/fsh/→chroma/-ionice.ch b/.config/zsh/.zsh/fsh/→chroma/-ionice.ch deleted file mode 100644 index f328f83..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-ionice.ch +++ /dev/null @@ -1,117 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2018 Sebastian Gniazdowski -# Copyright (C) 2019 by Philippe Troin (F-i-f on GitHub) -# All rights reserved. -# -# The only licensing for this file follows. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- - -setopt local_options extendedglob warn_create_global typeset_silent - -# Keep chroma-takever state meaning: until ;, handle highlighting via chroma. -# So the below 8192 assignment takes care that next token will be routed to chroma. -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style option_start=0 option_end=0 number_start=0 number_end=0 -local -a match mbegin mend - -(( __first_call )) && { - # Called for the first time - new command. - # FAST_HIGHLIGHT is used because it survives between calls, and - # allows to use a single global hash only, instead of multiple - # global string variables. - FAST_HIGHLIGHT[ionice-option-argument]=0 - - # Set style for region_highlight entry. It is used below in - # '[[ -n "$__style" ]] ...' line, which adds highlight entry, - # like "10 12 fg=green", through `reply' array. - # - # Could check if command `example' exists and set `unknown-token' - # style instead of `command' - __style=${FAST_THEME_NAME}precommand - -} || { - # Following call, i.e. not the first one - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - - if (( FAST_HIGHLIGHT[ionice-option-argument] )); then - (( FAST_HIGHLIGHT[ionice-option-argument] = 0 )) - [[ $__wrd == [0-9]# ]] && __style=${FAST_THEME_NAME}mathnum || __style=${FAST_THEME_NAME}incorrect-subtle - else - case $__wrd in - --(class(data|)|(u|p(g|))id)) - __style=${FAST_THEME_NAME}double-hyphen-option - FAST_HIGHLIGHT[ionice-option-argument]=1 - ;; - -[cnpPu]) - __style=${FAST_THEME_NAME}single-hyphen-option - FAST_HIGHLIGHT[ionice-option-argument]=1 - ;; - --*) - __style=${FAST_THEME_NAME}double-hyphen-option - ;; - -*) - __style=${FAST_THEME_NAME}single-hyphen-option - ;; - *) - this_word=1 - next_word=2 - return 1 - ;; - esac - fi -} - -# Add region_highlight entry (via `reply' array). -# If 1 will be added to __start_pos, this will highlight "oken". -# If 1 will be subtracted from __end_pos, this will highlight "toke". -# $PREBUFFER is for specific situations when users does command \ -# i.e. when multi-line command using backslash is entered. -# -# This is a common place of adding such entry, but any above code can do -# it itself (and it does in other chromas) and skip setting __style to -# this way disable this code. -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through, do obligatory things ourselves. -# _start_pos=$_end_pos advainces pointers in command line buffer. -# -# To pass through means to `return 1'. The highlighting of -# this single token is then done by fast-syntax-highlighting's -# main code and chroma doesn't have to do anything. -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-lab.ch b/.config/zsh/.zsh/fsh/→chroma/-lab.ch deleted file mode 100644 index 9c76e03..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-lab.ch +++ /dev/null @@ -1,59 +0,0 @@ -# vim:ft=zsh:et:sw=4 -# -# The `lab' tool after which this chroma is modeled after: -# https://github.com/zaquestion/lab -# -(( next_word = 2 | 8192 )) -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" - -if (( __first_call )); then - chroma/-git.ch $* - return 1 -fi -[[ "$__arg_type" = 3 ]] && return 2 - -if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 -fi - -if [[ "$__wrd" != -* ]] && (( FAST_HIGHLIGHT[chroma-git-got-subcommand] == 0 )); then - .fast-run-command "git config --get-regexp 'alias.*'" chroma-git-alias-list "" $(( 5 * 60 )) - # Grep for line: alias.{user-entered-subcmd}[[:space:]], and remove alias. prefix - __lines_list=( ${${(M)__lines_list[@]:#alias.${__wrd}[[:space:]]##*}#alias.} ) - - if (( ${#__lines_list} > 0 )); then - # (*) - # First remove alias name (#*[[:space:]]) and the space after it, then - # remove any leading spaces from what's left (##[[:space:]]##), then - # remove everything except the first word that's in the left line - # (%%[[:space:]]##*, i.e.: "everything from right side up to any space") - FAST_HIGHLIGHT[chroma-git-subcommand]="${${${__lines_list[1]#*[[:space:]]}##[[:space:]]##}%%[[:space:]]##*}" - else - FAST_HIGHLIGHT[chroma-git-subcommand]="$__wrd" - fi - if [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "browse" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "ci" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "mr" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "project" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "snippet" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "ci-status" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "compare" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "create" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "delete" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "fork" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "issue" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "pr" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "pull-request" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "release" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "sync" ]]; then - FAST_HIGHLIGHT[chroma-git-got-subcommand]=1 - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}subcommand]}") - (( FAST_HIGHLIGHT[chroma-git-counter] += 1 )) - (( this_word = next_word )) - _start_pos=$4 - return 0 - fi -fi - -chroma/-git.ch $* diff --git a/.config/zsh/.zsh/fsh/→chroma/-make.ch b/.config/zsh/.zsh/fsh/→chroma/-make.ch deleted file mode 100644 index e91746d..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-make.ch +++ /dev/null @@ -1,105 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# Chroma function for command `make'. -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# $2 - the current token, also accessible by $__arg from the above scope - -# basically a private copy of $__arg -# $3 - a private copy of $_start_pos, i.e. the position of the token in the -# command line buffer, used to add region_highlight entry (see man), -# because Zsh colorizes by *ranges* in command line buffer -# $4 - a private copy of $_end_pos from the above scope -# - -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style -integer __idx1 __idx2 -local -a __lines_list reply2 - -(( __first_call )) && { - # Called for the first time - new command. - # FAST_HIGHLIGHT is used because it survives between calls, and - # allows to use a single global hash only, instead of multiple - # global variables. - FAST_HIGHLIGHT[chroma-make-counter]=0 - FAST_HIGHLIGHT[chroma-make-skip-two]=0 - FAST_HIGHLIGHT[chroma-make-custom-dir]="./" - FAST_HIGHLIGHT[chroma-make-custom-file]="Makefile" - FAST_HIGHLIGHT[chroma-make-got-custom-dir-opt]=0 - FAST_HIGHLIGHT[chroma-make-got-custom-file-opt]=0 - return 1 -} || { - # Following call, i.e. not the first one. - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - - if [[ "$__wrd" = -* || "$__wrd" = *=* ]]; then - [[ "$__wrd" = *=* ]] && { - __style=${FAST_THEME_NAME}variable - } || { - __style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option} - } - - if [[ "$__wrd" = (-I|-o|-W) ]]; then - FAST_HIGHLIGHT[chroma-make-skip-two]=1 - elif [[ "$__wrd" = "-C" ]]; then - FAST_HIGHLIGHT[chroma-make-got-custom-dir-opt]=1 - elif [[ "$__wrd" = "-f" ]]; then - FAST_HIGHLIGHT[chroma-make-got-custom-file-opt]=1 - fi - else - if (( FAST_HIGHLIGHT[chroma-make-skip-two] )); then - FAST_HIGHLIGHT[chroma-make-skip-two]=0 - elif (( FAST_HIGHLIGHT[chroma-make-got-custom-dir-opt] )); then - FAST_HIGHLIGHT[chroma-make-got-custom-dir-opt]=0 - FAST_HIGHLIGHT[chroma-make-custom-dir]="$__wrd" - elif (( FAST_HIGHLIGHT[chroma-make-got-custom-file-opt] )); then - FAST_HIGHLIGHT[chroma-make-got-custom-file-opt]=0 - FAST_HIGHLIGHT[chroma-make-custom-file]="$__wrd" - else - # Count non-option tokens. - (( FAST_HIGHLIGHT[chroma-make-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-make-counter] )) - if (( FAST_HIGHLIGHT[chroma-make-counter] == 1 )); then - __wrd="${__wrd//\`/x}" - __wrd="${(Q)__wrd}" - - if [[ -f "${FAST_HIGHLIGHT[chroma-make-custom-dir]%/}/${FAST_HIGHLIGHT[chroma-make-custom-file]}" ]] && \ - .fast-make-targets < "${FAST_HIGHLIGHT[chroma-make-custom-dir]%/}/${FAST_HIGHLIGHT[chroma-make-custom-file]}" - then - if [[ "${reply2[(r)$__wrd]}" ]]; then - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") - else - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") - fi - fi - else - # Pass-through to the big-loop outside - return 1 - fi - fi - fi -} - -# Add region_highlight entry (via `reply' array) -# -# This is a common place of adding such entry, but any above -# code can do it itself (and it does) and skip setting __style -# to disable this code. -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through, do obligatory things ourselves -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-nice.ch b/.config/zsh/.zsh/fsh/→chroma/-nice.ch deleted file mode 100644 index 7fa8a94..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-nice.ch +++ /dev/null @@ -1,138 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2018 Sebastian Gniazdowski -# Copyright (C) 2019 by Philippe Troin (F-i-f on GitHub) -# All rights reserved. -# -# The only licensing for this file follows. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- - -setopt local_options extendedglob warn_create_global typeset_silent - -# Keep chroma-takever state meaning: until ;, handle highlighting via chroma. -# So the below 8192 assignment takes care that next token will be routed to chroma. -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style option_start=0 option_end=0 number_start=0 number_end=0 -local -a match mbegin mend - -(( __first_call )) && { - # Called for the first time - new command. - # FAST_HIGHLIGHT is used because it survives between calls, and - # allows to use a single global hash only, instead of multiple - # global string variables. - FAST_HIGHLIGHT[nice-arg-count]=0 - FAST_HIGHLIGHT[nice-increment-argument]=0 - - # Set style for region_highlight entry. It is used below in - # '[[ -n "$__style" ]] ...' line, which adds highlight entry, - # like "10 12 fg=green", through `reply' array. - # - # Could check if command `example' exists and set `unknown-token' - # style instead of `command' - __style=${FAST_THEME_NAME}precommand - -} || { - # Following call, i.e. not the first one - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - - if (( FAST_HIGHLIGHT[nice-increment-argument] )); then - (( FAST_HIGHLIGHT[nice-increment-argument] = 0 )) - [[ $__wrd = (-|+|)[0-9]## ]] \ - && __style=${FAST_THEME_NAME}mathnum \ - || __style=${FAST_THEME_NAME}incorrect-subtle - else - case $__wrd in - -(-|+|)[0-9]##) - (( option_start = __start_pos-${#PREBUFFER} , - option_end = option_start+1 , - number_start = option_end , - number_end = __end_pos-${#PREBUFFER} )) - option_style=${FAST_THEME_NAME}single-hyphen-option - ;; - (#b)(--adjustment)(=(-|+|)[0-9]#|)) - (( option_start = __start_pos-${#PREBUFFER} , - option_end = option_start+mend[1] )) - option_style=${FAST_THEME_NAME}double-hyphen-option - [[ -z $match[2] ]] \ - && (( FAST_HIGHLIGHT[nice-increment-argument] = 1 )) \ - || (( option_end += 1 , - number_start = option_start+mbegin[2]-mbegin[1]+1 , - number_end = __end_pos-${#PREBUFFER} )) - ;; - -n) - __style=${FAST_THEME_NAME}double-hyphen-option - FAST_HIGHLIGHT[nice-increment-argument]=1 - ;; - --*) - __style=${FAST_THEME_NAME}double-hyphen-option - ;; - -*) - __style=${FAST_THEME_NAME}single-hyphen-option - ;; - *) - this_word=1 - next_word=2 - return 1 - ;; - esac - - (( option_start > 0 && option_end )) \ - && reply+=("$option_start $option_end ${FAST_HIGHLIGHT_STYLES[$option_style]}") - (( number_start > 0 && number_end )) \ - && reply+=("$number_start $number_end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}mathnum]}") - fi -} - -# Add region_highlight entry (via `reply' array). -# If 1 will be added to __start_pos, this will highlight "oken". -# If 1 will be subtracted from __end_pos, this will highlight "toke". -# $PREBUFFER is for specific situations when users does command \ -# i.e. when multi-line command using backslash is entered. -# -# This is a common place of adding such entry, but any above code can do -# it itself (and it does in other chromas) and skip setting __style to -# this way disable this code. -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through, do obligatory things ourselves. -# _start_pos=$_end_pos advainces pointers in command line buffer. -# -# To pass through means to `return 1'. The highlighting of -# this single token is then done by fast-syntax-highlighting's -# main code and chroma doesn't have to do anything. -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-nmcli.ch b/.config/zsh/.zsh/fsh/→chroma/-nmcli.ch deleted file mode 100644 index be444e5..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-nmcli.ch +++ /dev/null @@ -1,58 +0,0 @@ -# vim:ft=zsh:et:sw=4 -(( next_word = 2 | 8192 )) -[[ "$__arg_type" = 3 ]] && return 2 - -typeset -A subcommands -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" subcommand -subcommands=( - help "_" - general "help status hostname permissions logging _" - networking "help on off connectivity _" - radio "help all wifi wwan _" - connection "help show up down add modify clone edit delete monitor reload load import export _" - device "help status show set connect reapply modify disconnect delete monitor wifi lldp _" - agent "help secret polkit all _" - monitor "help _" - _ "_" -) - -if (( __first_call )); then - FAST_HIGHLIGHT[chroma-nmcli-subcommand-a]="" - FAST_HIGHLIGHT[chroma-nmcli-subcommand-b]="" - return 1 -elif (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 -elif [[ "$2" = -* ]]; then - return 1 -elif [[ -z ${FAST_HIGHLIGHT[chroma-nmcli-subcommand-a]} ]]; then - for subcommand in ${(@k)subcommands}; do - [[ $subcommand = $__wrd* ]] && break || subcommand="_" - done - if [[ $subcommand = _ ]]; then - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") - else - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}subcommand]}") - fi - FAST_HIGHLIGHT[chroma-nmcli-subcommand-a]="$subcommand" -elif [[ -z ${FAST_HIGHLIGHT[chroma-nmcli-subcommand-b]} ]]; then - for subcommand in ${(s. .)subcommands[${FAST_HIGHLIGHT[chroma-nmcli-subcommand-a]}]}; do - [[ "$subcommand" = $__wrd* ]] && break || subcommand="_" - done - if [[ $subcommand = _ ]]; then - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") - else - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}subcommand]}") - fi - FAST_HIGHLIGHT[chroma-nmcli-subcommand-b]="$subcommand" -else - return 1 -fi - -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 diff --git a/.config/zsh/.zsh/fsh/→chroma/-node.ch b/.config/zsh/.zsh/fsh/→chroma/-node.ch deleted file mode 100644 index 65f214c..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-node.ch +++ /dev/null @@ -1,37 +0,0 @@ -# vim:ft=zsh:et:sw=4 -(( next_word = 2 | 8192 )) -[[ "$__arg_type" = 3 ]] && return 2 - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style - -if (( __first_call )); then - FAST_HIGHLIGHT[chroma-node-file]=1 -elif (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 -elif [[ "$__wrd" = -- ]]; then - FAST_HIGHLIGHT[chroma-node-file]=2 -elif (( FAST_HIGHLIGHT[chroma-node-file] != 2 )) && [[ "$__wrd" = -* ]]; then - if [[ "$__wrd" = -*e* || "$__wrd" = --eval ]]; then - FAST_HIGHLIGHT[chroma-node-file]=0 - fi -elif (( FAST_HIGHLIGHT[chroma-node-file] )); then - if [[ "$__wrd" = debug || "$__wrd" = inspect ]]; then - __style=${FAST_THEME_NAME}subcommand - else - FAST_HIGHLIGHT[chroma-node-file]=0 - if [[ -f ${~__wrd} || -f ${~__wrd}.js || -f ${~__wrd}/index.js ]]; then - __style=${FAST_THEME_NAME}path - else - __style=${FAST_THEME_NAME}incorrect-subtle - fi - fi - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - (( this_word = next_word )) - _start_pos=$_end_pos - - return 0 -fi - -return 1 diff --git a/.config/zsh/.zsh/fsh/→chroma/-ogit.ch b/.config/zsh/.zsh/fsh/→chroma/-ogit.ch deleted file mode 100644 index 6f76674..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-ogit.ch +++ /dev/null @@ -1,383 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# Copyright (c) 2018 plexigras -# -# The old chroma function for command `git'. It colorizes the part of command -# line that holds `git' invocation. -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# $2 - the current token, also accessible by $__arg from the above scope - -# basically a private copy of $__arg -# $3 - a private copy of $_start_pos, i.e. the position of the token in the -# command line buffer, used to add region_highlight entry (see man), -# because Zsh colorizes by *ranges* in command line buffer -# $4 - a private copy of $_end_pos from the above scope -# - -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style -integer __idx1 __idx2 -local -a __lines_list chroma_git_remote_subcommands -chroma_git_remote_subcommands=(add rename remove set-head set-branches get-url set-url set-url set-url show prune update) - -if (( __first_call )); then - # Called for the first time - new command - # FAST_HIGHLIGHT is used because it survives between calls, and - # allows to use a single global hash only, instead of multiple - # global variables - FAST_HIGHLIGHT[chroma-git-counter]=0 - FAST_HIGHLIGHT[chroma-git-got-subcommand]=0 - FAST_HIGHLIGHT[chroma-git-subcommand]="" - FAST_HIGHLIGHT[chrome-git-got-msg1]=0 - FAST_HIGHLIGHT[chrome-git-got-anymsg]=0 - FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]=0 - FAST_HIGHLIGHT[chroma-git-checkout-new]=0 - FAST_HIGHLIGHT[chroma-git-fetch-multiple]=0 - FAST_HIGHLIGHT[chroma-git-branch-change]=0 - FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=0 - return 1 -else - # Following call, i.e. not the first one - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if [[ "$__wrd" = "--" ]]; then - FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]=1 - __style=${FAST_THEME_NAME}double-hyphen-option - elif [[ "$__wrd" = -* && ${FAST_HIGHLIGHT[chroma-git-got-subcommand]} -eq 0 ]]; then - # Options occuring before a subcommand - if (( FAST_HIGHLIGHT[chroma-git-option-with-argument-active] == 0 )); then - if [[ "$__wrd" = -[^[:space:]-]#C ]]; then - FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=2 - elif [[ "$__wrd" = -[^[:space:]-]#c ]]; then - FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=1 - fi - fi - return 1 - else - # If at e.g. '>' or destination/source spec (of the redirection) - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - # If at main git option taking argument in a separate word (-C and -c) - elif (( FAST_HIGHLIGHT[chroma-git-option-with-argument-active] > 0 && \ - 0 == FAST_HIGHLIGHT[chroma-git-got-subcommand] )) - then - # Remember the value - __idx2=${FAST_HIGHLIGHT[chroma-git-option-with-argument-active]} - # Reset the is-argument mark-field - FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=0 - - (( __idx2 == 2 )) && return 1 - # Other options' args (i.e. arg of -c) aren't routed to the big-loop - # as they aren't paths and aren't handled in any special way there - elif (( FAST_HIGHLIGHT[chroma-git-got-subcommand] == 0 )); then - FAST_HIGHLIGHT[chroma-git-got-subcommand]=1 - - # Check if the command is an alias - we want to highlight the - # aliased command just like the target command of the alias - .fast-run-command "git config --get-regexp 'alias.*'" chroma-git-alias-list "" $(( 10 * 60 )) - # Grep for line: alias.{user-entered-subcmd}[[:space:]], and remove alias. prefix - __lines_list=( ${${(M)__lines_list[@]:#alias.${__wrd}[[:space:]]##*}#alias.} ) - - if (( ${#__lines_list} > 0 )); then - # (*) - # First remove alias name (#*[[:space:]]) and the space after it, then - # remove any leading spaces from what's left (##[[:space:]]##), then - # remove everything except the first word that's in the left line - # (%%[[:space:]]##*, i.e.: "everything from right side up to any space") - FAST_HIGHLIGHT[chroma-git-subcommand]="${${${__lines_list[1]#*[[:space:]]}##[[:space:]]##}%%[[:space:]]##*}" - else - FAST_HIGHLIGHT[chroma-git-subcommand]="$__wrd" - fi - if (( __start_pos >= 0 )); then - # if subcommand exists - LANG=C .fast-run-command "git help -a" chroma-git-subcmd-list "" $(( 10 * 60 )) - # (s: :) will split on every space, but because the expression - # isn't double-quoted, the empty elements will be eradicated - # Some further knowledge-base: s-flag is special, it skips - # empty elements and creates an array (not a concatenated - # string) even when double-quoted. The normally needed @-flag - # that logically breaks the concaetnated string back into array - # in case of double-quoting has additional effect for s-flag: - # it finally blocks empty-elements eradication. - if [[ "${__lines_list[1]}" = See* ]]; then - # (**) - # git >= v2.20 - __lines_list=( ${(M)${${${(M)__lines_list[@]:# [[:blank:]]#[a-z]*}##[[:blank:]]##}%%[[:blank:]]##*}:#${FAST_HIGHLIGHT[chroma-git-subcommand]}} ) - else - # (**) - # git < v2.20 - __lines_list=( ${(M)${(s: :)${(M)__lines_list[@]:# [a-z]*}}:#${FAST_HIGHLIGHT[chroma-git-subcommand]}} ) - fi - - # Above we've checked: - # 1) If given subcommand is an alias (*) - # 2) If the command, or command pointed by the alias, exists (**) - # 3) There's little problem, git v2.20 outputs aliases in git help -a, - # which means that alias will be recognized as correct if it will - # point at another alias or on itself. That's a minor problem, a - # TODO for future planned optimization for v2.20 Git - # 4) Notice that the above situation is better than the previous - the - # alias is being verified to point to a valid git subcommand - # That's all that's needed to decide on the correctnes: - if (( ${#__lines_list} > 0 )); then - __style=${FAST_THEME_NAME}subcommand - else - __style=${FAST_THEME_NAME}incorrect-subtle - fi - fi - # The counter includes the subcommand itself - (( FAST_HIGHLIGHT[chroma-git-counter] += 1 )) - else - __wrd="${__wrd//\`/x}" - __arg="${__arg//\`/x}" - __wrd="${(Q)__wrd}" - if [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "push" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "pull" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "fetch" ]] \ - && (( ${FAST_HIGHLIGHT[chroma-git-fetch-multiple]} == 0 )); then - # if not option - if [[ "$__wrd" != -* || "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" -eq 1 ]]; then - (( FAST_HIGHLIGHT[chroma-git-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-git-counter] )) - if (( __idx1 == 2 )); then - .fast-run-git-command "git remote" "chroma-git-remotes" "" - else - __wrd="${__wrd%%:*}" - .fast-run-git-command "git for-each-ref --format='%(refname:short)' refs/heads" "chroma-git-branches" "refs/heads" - fi - # if remote/ref exists - if [[ -n ${__lines_list[(r)$__wrd]} ]]; then - (( __start=__start_pos-${#PREBUFFER}, __end=__start_pos+${#__wrd}-${#PREBUFFER}, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") - # if ref (__idx1 == 3) does not exist and subcommand is push - elif (( __idx1 != 2 )) && [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "push" ]]; then - (( __start=__start_pos-${#PREBUFFER}, __end=__start_pos+${#__wrd}-${#PREBUFFER}, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") - # if not existing remote name, because not an URL (i.e. no colon) - elif [[ $__idx1 -eq 2 && $__wrd != *:* ]]; then - (( __start=__start_pos-${#PREBUFFER}, __end=__start_pos+${#__wrd}-${#PREBUFFER}, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") - fi - # if option - else - if [[ "$__wrd" = "--multiple" && "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "fetch" ]]; then - FAST_HIGHLIGHT[chroma-git-fetch-multiple]=1 - __style=${FAST_THEME_NAME}double-hyphen-option - else - return 1 - fi - fi - elif (( ${FAST_HIGHLIGHT[chroma-git-fetch-multiple]} )) \ - && [[ "$__wrd" != -* || "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" -eq 1 ]]; then - .fast-run-git-command "git remote" "chroma-git-remotes" "" - if [[ -n ${__lines_list[(r)$__wrd]} ]]; then - __style=${FAST_THEME_NAME}correct-subtle - fi - elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "commit" ]]; then - match[1]="" - match[2]="" - # if previous argument is -m or current argument is --message=something - if (( FAST_HIGHLIGHT[chrome-git-got-msg1] == 1 && ! FAST_HIGHLIGHT[chrome-git-got-anymsg] )) \ - || [[ "$__wrd" = (#b)(--message=)(*) && "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" = 0 ]]; then - FAST_HIGHLIGHT[chrome-git-got-msg1]=0 - FAST_HIGHLIGHT[chrome-git-got-anymsg]=1 - if [[ -n "${match[1]}" ]]; then - __wrd="${(Q)${match[2]//\`/x}}" - # highlight (--message=)something - (( __start=__start_pos-${#PREBUFFER}, __end=__start_pos-${#PREBUFFER}+10, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-hyphen-option]}") - # highlight --message=(something) - (( __start=__start_pos-${#PREBUFFER}+10, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}") - else - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}") - fi - local __firstline=${__wrd%%$'\n'*} - if (( ${#__firstline} > 50 )); then - for (( __idx1 = 1, __idx2 = 1; __idx1 <= 50; ++ __idx1, ++ __idx2 )); do - while [[ "${__arg[__idx2]}" != "${__firstline[__idx1]}" ]]; do - (( ++ __idx2 )) - (( __idx2 > __asize )) && { __idx2=-1; break; } - done - (( __idx2 == -1 )) && break - done - if (( __idx2 != -1 )); then - if [[ -n "${match[1]}" ]]; then - (( __start=__start_pos-${#PREBUFFER}+__idx2, __end=__end_pos-${#PREBUFFER}-$#__wrd+$#__firstline-1, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") - else - (( __start=__start_pos-${#PREBUFFER}+__idx2-1, __end=__end_pos-${#PREBUFFER}-$#__wrd+$#__firstline-1, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") - fi - fi - fi - # if before -- - elif [[ "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" = 0 ]]; then - if [[ "$__wrd" = -[^[:space:]-]#m ]]; then - FAST_HIGHLIGHT[chrome-git-got-msg1]=1 - __style=${FAST_THEME_NAME}single-hyphen-option - else - return 1 - fi - # if after -- is file - elif [[ -e "$__wrd" ]]; then - __style=${FAST_THEME_NAME}path - else - __style=${FAST_THEME_NAME}incorrect-subtle - fi - elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "checkout" ]] \ - || [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "revert" ]] \ - || [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "merge" ]] \ - || [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "diff" ]] \ - || [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "reset" ]] \ - || [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "rebase" ]]; then - - # if doing `git checkout -b ...' - if [[ "$__wrd" = -[^[:space:]-]#b && "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "checkout" ]]; then - FAST_HIGHLIGHT[chroma-git-checkout-new]=1 - __style=${FAST_THEME_NAME}single-hyphen-option - # if command is not checkout -b something - elif [[ "${FAST_HIGHLIGHT[chroma-git-checkout-new]}" = 0 ]]; then - # if not option - if [[ "$__wrd" != -* || "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" = 1 ]]; then - (( FAST_HIGHLIGHT[chroma-git-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-git-counter] )) - if (( __idx1 == 2 )) || \ - [[ "$__idx1" = 3 && "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "diff" ]]; then - # if is ref - if command git rev-parse --verify --quiet "$__wrd" >/dev/null 2>&1; then - __style=${FAST_THEME_NAME}correct-subtle - # if is file and subcommand is checkout or diff - elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "checkout" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "reset" \ - || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "diff" ]] && [[ -e ${~__wrd} ]]; then - __style=${FAST_THEME_NAME}path - elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "checkout" && \ - "1" = "$(command git rev-list --count --no-walk --glob="refs/remotes/${$(git \ - config --get checkout.defaultRemote):-*}/$__wrd")" ]] - then - __style=${FAST_THEME_NAME}correct-subtle - else - __style=${FAST_THEME_NAME}incorrect-subtle - fi - fi - # if option - else - return 1 - fi - # if option - elif [[ "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" = 0 && "$__wrd" = -* ]]; then - return 1 - fi - elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "remote" && "$__wrd" != -* ]]; then - (( FAST_HIGHLIGHT[chroma-git-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-git-counter] )) - if [[ "$__idx1" = 2 ]]; then - if (( ${chroma_git_remote_subcommands[(I)$__wrd]} )); then - FAST_HIGHLIGHT[chroma-git-remote-subcommand]="$__wrd" - __style=${FAST_THEME_NAME}subcommand - else - __style=${FAST_THEME_NAME}incorrect-subtle - fi - elif [[ "$__idx1" = 3 && "$FAST_HIGHLIGHT[chroma-git-remote-subcommand]" = "add" ]]; then - .fast-run-git-command "git remote" "chroma-git-remotes" "" - if [[ -n ${__lines_list[(r)$__wrd]} ]]; then - __style=${FAST_THEME_NAME}incorrect-subtle - fi - elif [[ "$__idx1" = 3 && -n "$FAST_HIGHLIGHT[chroma-git-remote-subcommand]" ]]; then - .fast-run-git-command "git remote" "chroma-git-remotes" "" - if [[ -n ${__lines_list[(r)$__wrd]} ]]; then - __style=${FAST_THEME_NAME}correct-subtle - else - __style=${FAST_THEME_NAME}incorrect-subtle - fi - fi - elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "branch" ]]; then - if [[ "$__wrd" = --delete \ - || "$__wrd" = --edit-description \ - || "$__wrd" = --set-upstream-to=* \ - || "$__wrd" = --unset-upstream \ - || "$__wrd" = -[^[:space:]-]#d \ - || "$__wrd" = -[^[:space:]-]#D ]]; then - FAST_HIGHLIGHT[chroma-git-branch-change]=1 - return 1 - elif [[ "$__wrd" != -* ]]; then - .fast-run-git-command "git for-each-ref --format='%(refname:short)' refs/heads" "chroma-git-branches" "refs/heads" - if [[ -n ${__lines_list[(r)$__wrd]} ]]; then - __style=${FAST_THEME_NAME}correct-subtle - elif (( FAST_HIGHLIGHT[chroma-git-branch-change] )); then - __style=${FAST_THEME_NAME}incorrect-subtle - fi - else - return 1 - fi - elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "tag" ]]; then - if [[ "${FAST_HIGHLIGHT[chroma-git-option-with-argument-active]}" -le 0 ]]; then - if [[ "$__wrd" = -[^[:space:]-]#(u|m) ]]; then - FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=1 - elif [[ "$__wrd" = -[^[:space:]-]#F ]]; then - FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=2 - elif [[ "$__wrd" = -[^[:space:]-]#d ]]; then - FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=3 - elif [[ "$__wrd" = (--contains|--no-contains|--points-at|--merged|--no-merged) ]]; then - FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=4 - fi - if [[ "$__wrd" != -* ]]; then - (( FAST_HIGHLIGHT[chroma-git-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-git-counter] )) - if [[ ${FAST_HIGHLIGHT[chroma-git-counter]} -eq 2 ]]; then - .fast-run-git-command "git for-each-ref --format='%(refname:short)' refs/heads" "chroma-git-branches" "refs/heads" - .fast-run-git-command "+git tag" "chroma-git-tags" "" - [[ -n ${__lines_list[(r)$__wrd]} ]] && __style=${FAST_THEME_NAME}incorrect-subtle - elif [[ ${FAST_HIGHLIGHT[chroma-git-counter]} -eq 3 ]]; then - fi - else - return 1 - fi - else - case "${FAST_HIGHLIGHT[chroma-git-option-with-argument-active]}" in - (1) - __style=${FAST_THEME_NAME}optarg-string - ;; - (2) - FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=0 - return 1; - ;; - (3) - .fast-run-git-command "git tag" "chroma-git-tags" "" - [[ -n ${__lines_list[(r)$__wrd]} ]] && \ - __style=${FAST_THEME_NAME}correct-subtle || \ - __style=${FAST_THEME_NAME}incorrect-subtle - ;; - (4) - if git rev-parse --verify --quiet "$__wrd" >/dev/null 2>&1; then - __style=${FAST_THEME_NAME}correct-subtle - else - __style=${FAST_THEME_NAME}incorrect-subtle - fi - ;; - esac - FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=0 - fi - else - return 1 - fi - fi - fi -fi - -# Add region_highlight entry (via `reply' array) -if [[ -n "$__style" ]]; then - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") -fi - -# We aren't passing-through, do obligatory things ourselves -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-perl.ch b/.config/zsh/.zsh/fsh/→chroma/-perl.ch deleted file mode 100644 index 49f0ad3..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-perl.ch +++ /dev/null @@ -1,80 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# Chroma function for command `perl'. It highlights code passed to perl -# with -e option - does syntax check by calling `perl -ce', then highlights -# as correct or incorrect code. -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# $2 - the current token, also accessible by $__arg from the above scope - -# basically a private copy of $__arg -# $3 - a private copy of $_start_pos, i.e. the position of the token in the -# command line buffer, used to add region_highlight entry (see man), -# because Zsh colorizes by *ranges* in command line buffer -# $4 - a private copy of $_end_pos from the above scope -# - -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style -integer __idx1 __idx2 - -(( __first_call )) && { - # Called for the first time - new command. - # FAST_HIGHLIGHT is used because it survives between calls, and - # allows to use a single global hash only, instead of multiple - # global variables. - FAST_HIGHLIGHT[chrome-perl-got-eswitch]=0 - return 1 -} || { - # Following call, i.e. not the first one. - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - - if [[ "$__wrd" = -* && ${FAST_HIGHLIGHT[chroma-perl-got-subcommand]} -eq 0 ]]; then - __style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option} - - if [[ "$__wrd" = "-e" || ("$__wrd" = -*e* && "$__wrd" != --*) ]]; then - FAST_HIGHLIGHT[chrome-perl-got-eswitch]=1 - fi - else - __wrd="${__wrd//\`/x}" - __arg="${__arg//\`/x}" - __wrd="${(Q)__wrd}" - if (( FAST_HIGHLIGHT[chrome-perl-got-eswitch] == 1 )); then - FAST_HIGHLIGHT[chrome-perl-got-eswitch]=0 - if perl -ce "$__wrd" >/dev/null 2>&1; then - # Add correct-subtle style - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") - else - # Add incorrect-subtle style - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") - fi - else - # Pass-through to the big-loop outside - return 1 - fi - fi -} - -# Add region_highlight entry (via `reply' array) -# -# This is a common place of adding such entry, but any above -# code can do it itself (and it does) and skip setting __style -# to disable this code. -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through, do obligatory things ourselves -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-precommand.ch b/.config/zsh/.zsh/fsh/→chroma/-precommand.ch deleted file mode 100644 index 7e85a06..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-precommand.ch +++ /dev/null @@ -1,17 +0,0 @@ -# vim:ft=zsh:et:sw=4 - -local __first_call="$1" __start_pos="$3" __end_pos="$4" - -[[ "$__arg_type" = 3 ]] && return 2 - -(( __first_call )) && { - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}precommand]}") - (( next_word = (next_word & ~2) | 4 | 1 )) -} || { - return 1 -} - -(( this_word = next_word )) -_start_pos=$_end_pos -return 0 diff --git a/.config/zsh/.zsh/fsh/→chroma/-printf.ch b/.config/zsh/.zsh/fsh/→chroma/-printf.ch deleted file mode 100644 index 89d2789..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-printf.ch +++ /dev/null @@ -1,86 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# Highlights the special sequences like "%s" in string passed to `printf'. -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# -# $2 - the current token, also accessible by $__arg from the above scope - -# basically a private copy of $__arg; the token can be eg.: "grep" -# -# $3 - a private copy of $_start_pos, i.e. the position of the token in the -# command line buffer, used to add region_highlight entry (see man), -# because Zsh colorizes by *ranges* in command line buffer -# -# $4 - a private copy of $_end_pos from the above scope -# - -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style __val -integer __idx1 __idx2 - -# First call, i.e. command starts, i.e. "grep" token etc. -(( __first_call )) && { - FAST_HIGHLIGHT[chroma-printf-counter]=0 - FAST_HIGHLIGHT[chroma-printf-counter-all]=1 - FAST_HIGHLIGHT[chroma-printf-message]="" - FAST_HIGHLIGHT[chroma-printf-skip-two]=0 - return 1 -# Following call (not first one). -} || { - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - (( FAST_HIGHLIGHT[chroma-printf-counter-all] += 1, __idx2 = FAST_HIGHLIGHT[chroma-printf-counter-all] )) - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if [[ "$__wrd" = -* ]]; then - if [[ "$__wrd" = "-v" ]]; then - FAST_HIGHLIGHT[chroma-printf-skip-two]=1 - fi - return 1 - else - # Count non-option tokens. - if (( FAST_HIGHLIGHT[chroma-printf-skip-two] )); then - FAST_HIGHLIGHT[chroma-printf-skip-two]=0 - return 1 - else - (( FAST_HIGHLIGHT[chroma-printf-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-printf-counter] )) - if [[ "$__idx1" -eq 1 ]]; then - [[ "$__wrd" = \"* ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}") - [[ "$__wrd" = \'* ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}single-quoted-argument]}") - FSH_LIST=() # use fsh_sy_h_append function to write to FSH_LIST - : "${__wrd//(#m)\%[\#\+\ 0-]#[0-9]#([.][0-9]#)(#c0,1)[diouxXfFeEgGaAcsb]/$(( fsh_sy_h_append($MBEGIN, $MEND) ))}"; - for __val in "${FSH_LIST[@]}" ; do - __idx1=$(( __start_pos + ${__val%%;;*} )) - __idx2=__idx1+${__val##*;;}-${__val%%;;*}+1 - (( __start=__idx1-${#PREBUFFER}, __end=__idx2-${#PREBUFFER}-1, __start >= 0 )) && \ - reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}mathnum]}") - done - else - return 1 - fi - fi - fi -} - -# Add region_highlight entry (via `reply' array). -# -# This is a common place of adding such entry, but any above code -# can do it itself and skip setting __style to disable this code. -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through (no return 1 occured), do obligatory things ourselves. -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-ruby.ch b/.config/zsh/.zsh/fsh/→chroma/-ruby.ch deleted file mode 100644 index 3495cc8..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-ruby.ch +++ /dev/null @@ -1,81 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# Chroma function for command `ruby'. It highlights code passed to ruby -# with -e option - does syntax check by calling `ruby -ce', then highlights -# as correct or incorrect code. -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# $2 - the current token, also accessible by $__arg from the above scope - -# basically a private copy of $__arg -# $3 - a private copy of $_start_pos, i.e. the position of the token in the -# command line buffer, used to add region_highlight entry (see man), -# because Zsh colorizes by *ranges* in command line buffer -# $4 - a private copy of $_end_pos from the above scope -# - -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style -integer __idx1 __idx2 - -(( __first_call )) && { - # Called for the first time - new command. - # FAST_HIGHLIGHT is used because it survives between calls, and - # allows to use a single global hash only, instead of multiple - # global variables. - FAST_HIGHLIGHT[chrome-ruby-got-eswitch]=0 - return 1 -} || { - # Following call, i.e. not the first one. - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - - if [[ "$__wrd" = -* && ${FAST_HIGHLIGHT[chroma-ruby-got-subcommand]} -eq 0 ]]; then - __style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option} - - if [[ "$__wrd" = "-e" || ("$__wrd" = -*e* && "$__wrd" != --*) ]]; then - FAST_HIGHLIGHT[chrome-ruby-got-eswitch]=1 - fi - else - __wrd="${__wrd//\`/x}" - __arg="${__arg//\`/x}" - __wrd="${(Q)__wrd}" - if (( FAST_HIGHLIGHT[chrome-ruby-got-eswitch] == 1 )); then - FAST_HIGHLIGHT[chrome-ruby-got-eswitch]=0 - if ruby -ce "$__wrd" >/dev/null 2>&1; then - # Add correct-subtle style - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") - else - # Add incorrect-subtle style - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") - fi - else - # Pass-through to the big-loop outside - return 1 - fi - FAST_HIGHLIGHT[chrome-ruby-got-eswitch]=0 - fi -} - -# Add region_highlight entry (via `reply' array) -# -# This is a common place of adding such entry, but any above -# code can do it itself (and it does) and skip setting __style -# to disable this code. -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through, do obligatory things ourselves -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-scp.ch b/.config/zsh/.zsh/fsh/→chroma/-scp.ch deleted file mode 100644 index d162284..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-scp.ch +++ /dev/null @@ -1,87 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# Tracks scp command and emits message when one tries to pass port to hostspec. -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# -# $2 - the current token, also accessible by $__arg from the above scope - -# basically a private copy of $__arg; the token can be eg.: "grep" -# -# $3 - a private copy of $_start_pos, i.e. the position of the token in the -# command line buffer, used to add region_highlight entry (see man), -# because Zsh colorizes by *ranges* in command line buffer -# -# $4 - a private copy of $_end_pos from the above scope -# - -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style __chars -integer __idx1 __idx2 -local -a __results - -# First call, i.e. command starts, i.e. "grep" token etc. -(( __first_call )) && { - FAST_HIGHLIGHT[chroma-scp-counter]=0 - FAST_HIGHLIGHT[chroma-scp-counter-all]=1 - FAST_HIGHLIGHT[chroma-scp-message]="" - FAST_HIGHLIGHT[chroma-scp-skip-two]=0 - return 1 -} || { - (( FAST_HIGHLIGHT[chroma-scp-counter-all] += 1, __idx2 = FAST_HIGHLIGHT[chroma-scp-counter-all] )) - - # Following call, i.e. not the first one. - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - - if [[ "$__wrd" = -* ]]; then - # Detected option, add style for it. - [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ - __style=${FAST_THEME_NAME}single-hyphen-option - if [[ "$__wrd" = (-c|-F|-i|-l|-o|-P|-S) ]]; then - FAST_HIGHLIGHT[chroma-scp-skip-two]=1 - fi - else - # Count non-option tokens. - if (( FAST_HIGHLIGHT[chroma-scp-skip-two] )); then - FAST_HIGHLIGHT[chroma-scp-skip-two]=0 - else - (( FAST_HIGHLIGHT[chroma-scp-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-scp-counter] )) - if [[ "${FAST_HIGHLIGHT[chroma-scp-counter]}" -eq 1 ]]; then - if [[ "$__arg" = [^:]##:[0-9]## ]]; then - FAST_HIGHLIGHT[chroma-scp-message]+="Format of hostname incorrect, use -P to pass port number" - else - return 1 - fi - else - return 1 - fi - fi - fi - - if (( ${#${(z)BUFFER}} <= FAST_HIGHLIGHT[chroma-scp-counter-all] )); then - [[ -n "${FAST_HIGHLIGHT[chroma-scp-message]}" ]] && zle -M "${FAST_HIGHLIGHT[chroma-scp-message]}" - fi -} - -# Add region_highlight entry (via `reply' array). -# -# This is a common place of adding such entry, but any above code -# can do it itself and skip setting __style to disable this code. -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through (no return 1 occured), do obligatory things ourselves. -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-sh.ch b/.config/zsh/.zsh/fsh/→chroma/-sh.ch deleted file mode 100644 index 43fa8f9..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-sh.ch +++ /dev/null @@ -1,72 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# Chroma function for `sh' shell. It colorizes string passed with -c option. -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# $2 - the current token, also accessible by $__arg from the above scope - -# basically a private copy of $__arg -# $3 - a private copy of $_start_pos, i.e. the position of the token in the -# command line buffer, used to add region_highlight entry (see man), -# because Zsh colorizes by *ranges* in command line buffer -# $4 - a private copy of $_end_pos from the above scope -# - -(( next_word = 2 | 8192 )) - -local __first_call=$1 __wrd=$2 __start_pos=$3 __end_pos=$4 -local __style -integer __idx1 __idx2 -local -a __lines_list - -(( __first_call )) && { - # Called for the first time - new command - FAST_HIGHLIGHT[chrome-git-got-c]=0 - return 1 -} || { - # Following call, i.e. not the first one - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ $__arg_type = 3 ]] && return 2 - - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - - __wrd=${${${(Q)__wrd}#[\"\']}%[\"\']} - if [[ $__wrd = -* && $__wrd != -*c* ]]; then - __style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option} - else - if (( FAST_HIGHLIGHT[chrome-git-got-c] == 1 )); then - for (( __idx1 = 1, __idx2 = 1; __idx2 <= __asize; ++ __idx1 )); do - [[ ${__arg[__idx2]} = ${__wrd[__idx1]} ]] && break - while [[ ${__arg[__idx2]} != ${__wrd[__idx1]} ]]; do - (( ++ __idx2 )) - (( __idx2 > __asize )) && { __idx2=0; break; } - done - (( __idx2 == 0 )) && break - [[ ${__arg[__idx2]} = ${__wrd[__idx1]} ]] && break - done - - FAST_HIGHLIGHT[chrome-git-got-c]=0 - (( _start_pos-__PBUFLEN >= 0 )) && \ - -fast-highlight-process "$PREBUFFER" "${__wrd}" "$(( __start_pos + __idx2 - 1 ))" - elif [[ $__wrd = -*c* ]]; then - FAST_HIGHLIGHT[chrome-git-got-c]=1 - else - return 1 - fi - fi -} - -# Add region_highlight entry (via `reply' array) -[[ -n $__style ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through, do obligatory things ourselves -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-source.ch b/.config/zsh/.zsh/fsh/→chroma/-source.ch deleted file mode 100644 index dc27e76..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-source.ch +++ /dev/null @@ -1,75 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# Chroma for `source' builtin - verifies if file to be sourced compiles -# correctly. -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# -# $2 - the current token, also accessible by $__arg from the above scope - -# basically a private copy of $__arg; the token can be eg.: "grep" -# -# $3 - a private copy of $_start_pos, i.e. the position of the token in the -# command line buffer, used to add region_highlight entry (see man), -# because Zsh colorizes by *ranges* in command line buffer -# -# $4 - a private copy of $_end_pos from the above scope -# - -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style __chars __home=${XDG_CACHE_HOME:-$HOME/.cache}/fsh -integer __idx1 __idx2 - -# First call, i.e. command starts, i.e. "grep" token etc. -(( __first_call )) && { - FAST_HIGHLIGHT[chroma-src-counter]=0 - __style=${FAST_THEME_NAME}builtin - -} || { - # Following call, i.e. not the first one. - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - - if [[ "$__wrd" = -* ]]; then - # Detected option, add style for it. - [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ - __style=${FAST_THEME_NAME}single-hyphen-option - else - # Count non-option tokens. - (( FAST_HIGHLIGHT[chroma-src-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-src-counter] )) - - if (( FAST_HIGHLIGHT[chroma-src-counter] == 1 )); then - command mkdir -p "$__home" - command cp -f "${__wrd}" "$__home" 2>/dev/null && { - zcompile "$__home"/"${__wrd:t}" 2>/dev/null 1>&2 && __style=${FAST_THEME_NAME}correct-subtle || __style=${FAST_THEME_NAME}incorrect-subtle - } - elif (( FAST_HIGHLIGHT[chroma-src-counter] == 2 )); then - # Handle paths, etc. normally - just pass-through to the big - # highlighter (the main FSH highlighter, used before chromas). - return 1 - fi - fi -} - -# Add region_highlight entry (via `reply' array). -# -# This is a common place of adding such entry, but any above -# code can do it itself (and it does) and skip setting __style -# to disable this code. -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through (no return 1 occured), do obligatory things ourselves. -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-ssh.ch b/.config/zsh/.zsh/fsh/→chroma/-ssh.ch deleted file mode 100644 index 879158f..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-ssh.ch +++ /dev/null @@ -1,156 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# Copyright (C) 2019 by Philippe Troin (F-i-f on GitHub) -# -# Tracks ssh command and emits message when one tries to pass port to hostspec. -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# -# $2 - the current token, also accessible by $__arg from the above scope - -# basically a private copy of $__arg; the token can be eg.: "grep" -# -# $3 - a private copy of $_start_pos, i.e. the position of the token in the -# command line buffer, used to add region_highlight entry (see man), -# because Zsh colorizes by *ranges* in command line buffer -# -# $4 - a private copy of $_end_pos from the above scope -# - -emulate -LR zsh -setopt extended_glob warn_create_global typeset_silent - -# This chroma guards that port number isn't passed in hostname (no :{port} occurs). - -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style check_port=0 host_start_offset host_style user_style possible_host -local -a match mbegin mend completions_user completions_host - -# First call, i.e. command starts, i.e. "grep" token etc. -(( __first_call )) && { - FAST_HIGHLIGHT[chroma-ssh-counter]=0 - FAST_HIGHLIGHT[chroma-ssh-counter-all]=1 - FAST_HIGHLIGHT[chroma-ssh-message]="" - FAST_HIGHLIGHT[chroma-ssh-skip-two]=0 - return 1 -} || { - # Following call, i.e. not the first one. - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - - (( FAST_HIGHLIGHT[chroma-ssh-counter-all] += 1 )) - - if [[ "$__wrd" = -* ]]; then - # Detected option, add style for it. - [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ - __style=${FAST_THEME_NAME}single-hyphen-option - if [[ "$__wrd" = (-b|-c|-D|-E|-e|-F|-I|-i|-J|-L|-l|-m|-O|-o|-p|Q|R|-S|-W|-w) ]]; then - FAST_HIGHLIGHT[chroma-ssh-skip-two]=1 - fi - else - if (( FAST_HIGHLIGHT[chroma-ssh-skip-two] )); then - FAST_HIGHLIGHT[chroma-ssh-skip-two]=0 - else - # Count non-option tokens. - (( FAST_HIGHLIGHT[chroma-ssh-counter] += 1 )) - if [[ "${FAST_HIGHLIGHT[chroma-ssh-counter]}" -eq 1 ]]; then - if [[ $__arg = (#b)(([^@]#)(@)|)(*) ]] - then - [[ -n $match[2] ]] \ - && { - user_style= - () { - # Zstyle clobbers reply for sure - zstyle -a ":completion:*:users" users completions_users - } - (( ! $#completions_users )) && completions_users=(${(k)userdirs}) - if (( $#completions_users )); then - [[ $match[2] = ${~${:-(${(j:|:)completions_users})}} ]] \ - && user_style=${FAST_THEME_NAME}correct-subtle \ - || user_style=${FAST_THEME_NAME}incorrect-subtle - fi - [[ -n $user_style ]] \ - && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}-(mend[5]-mend[2]), __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$user_style]}") - } - [[ -n $match[3] ]] \ - && (( __start=__start_pos-${#PREBUFFER}+(mbegin[3]-mbegin[1]), __end=__end_pos-${#PREBUFFER}-(mend[5]-mend[3]), __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}subtle-separator]}") - - host_style= - case $match[4] in - (<->|<0-255>.<0-255>.<0-255>.<0-255>) - host_style=${FAST_THEME_NAME}mathnum - check_port=1 - ;; - (([0-9a-fA-F][0-9a-fA-F:]#|)::([0-9a-fA-F:]#[0-9a-fA-F]|)|[0-9a-fA-F]##:[0-9a-fA-F:]#[0-9a-fA-F]) - host_style=${FAST_THEME_NAME}mathnum - ;; - (*) - check_port=1 - ;; - esac - possible_host=$match[4] - (( host_start_offset = mbegin[4] - mbegin[1], host_end_offset = 0 )) - - if (( check_port )) && [[ $possible_host = (#b)(*)(:[0-9]##) ]]; then - (( __start=__start_pos-${#PREBUFFER}+(host_start_offset+mbegin[2]-mbegin[1]), __end=__end_pos-host_end_offset-${#PREBUFFER}, __start >= 0, - host_end_offset+=mend[2]-mend[1] )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") \ - && possible_host=$match[1] \ - && FAST_HIGHLIGHT[chroma-ssh-message]+="Format of hostname incorrect, use -p to pass port number" - - fi - - if [[ -z $host_style ]]; then - () { - # Zstyle clobbers reply for sure - local mbegin mend match reply - zstyle -a ":completion:*:hosts" hosts completions_host - } - (( ! $#completions_host && $+_cache_hosts )) && completions_host=($_cache_hosts[*]) - if (( $#completions_host )); then - [[ $possible_host = ${~${:-(${(j:|:)completions_host})}} ]] \ - && host_style=${FAST_THEME_NAME}correct-subtle \ - || host_style=${FAST_THEME_NAME}incorrect-subtle - fi - fi - - [[ -n $host_style ]] \ - && (( __start=__start_pos-${#PREBUFFER}+host_start_offset, __end=__end_pos-${#PREBUFFER}-host_end_offset, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$host_style]}") - else - __style=${FAST_THEME_NAME}incorrect-subtle - fi - - (( next_word = 1 )) - - fi - fi - fi - - if (( ${#${(z)BUFFER}} <= FAST_HIGHLIGHT[chroma-ssh-counter-all] )); then - [[ -n "${FAST_HIGHLIGHT[chroma-ssh-message]}" ]] && zle -M "${FAST_HIGHLIGHT[chroma-ssh-message]}" - fi -} - -# Add region_highlight entry (via `reply' array). -# -# This is a common place of adding such entry, but any above code -# can do it itself and skip setting __style to disable this code. -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through (no return 1 occured), do obligatory things ourselves. -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-subcommand.ch b/.config/zsh/.zsh/fsh/→chroma/-subcommand.ch deleted file mode 100644 index 0665548..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-subcommand.ch +++ /dev/null @@ -1,25 +0,0 @@ -# vim:ft=zsh:et:sw=4 -(( next_word = 2 | 8192 )) -[[ "$__arg_type" = 3 ]] && return 2 - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" - -if (( __first_call )); then - FAST_HIGHLIGHT[chroma-subcommand]="" - return 1 -elif (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 -elif [[ "$2" = -* ]]; then - return 1 -elif [[ -z "${FAST_HIGHLIGHT[chroma-subcommand]}" ]]; then - FAST_HIGHLIGHT[chroma-subcommand]="$__wrd" - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}subcommand]}") -else - return 1 -fi - -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 diff --git a/.config/zsh/.zsh/fsh/→chroma/-subversion.ch b/.config/zsh/.zsh/fsh/→chroma/-subversion.ch deleted file mode 100644 index 4149cc6..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-subversion.ch +++ /dev/null @@ -1,250 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2018 Sebastian Gniazdowski -# Copyright (C) 2019 by Philippe Troin (F-i-f on GitHub) -# All rights reserved. -# -# The only licensing for this file follows. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- - -→chroma/-subversion.ch/parse-revision() { - setopt local_options extendedglob warn_create_global typeset_silent - local __wrd="$1" __start_pos="$2" __end_pos="$3" __style __start __end - case $__wrd in - (r|)[0-9]##) __style=${FAST_THEME_NAME}mathnum ;; - (HEAD|BASE|COMITTED|PREV)) __style=${FAST_THEME_NAME}correct-subtle ;; - '{'[^}]##'}') __style=${FAST_THEME_NAME}subtle-bg ;; - *) __style=${FAST_THEME_NAME}incorrect-subtle ;; - esac - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") -} - -→chroma/-subversion.ch/parse-target() { - setopt local_options extendedglob warn_create_global typeset_silent - local __wrd="$1" __start_pos="$2" __end_pos="$3" __style __start __end - if [[ $__wrd == *@[^/]# ]] - then - local place=${__wrd%@[^/]#} - local rev=$__wrd[$(($#place+2)),$#__wrd] - if [[ -e $place ]]; then - local __style - [[ -d $place ]] && __style="${FAST_THEME_NAME}path-to-dir" || __style="${FAST_THEME_NAME}path" - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}-$#rev-1, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - fi - (( __start=__start_pos-${#PREBUFFER}+$#place, __end=__end_pos-${#PREBUFFER}-$#rev, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-separator]}") - →chroma/-subversion.ch/parse-revision $rev $((__start_pos+$#place+1)) $__end_pos - else - return 1 - fi -} - -setopt local_options extendedglob warn_create_global - -# Keep chroma-takever state meaning: until ;, handle highlighting via chroma. -# So the below 8192 assignment takes care that next token will be routed to chroma. -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style -integer __idx1 __idx2 - -(( __first_call )) && { - # Called for the first time - new command. - # FAST_HIGHLIGHT is used because it survives between calls, and - # allows to use a single global hash only, instead of multiple - # global string variables. - FAST_HIGHLIGHT[subversion-command]=$__wrd - FAST_HIGHLIGHT[subversion-option-argument]= - FAST_HIGHLIGHT[subversion-subcommand]= - FAST_HIGHLIGHT[subversion-subcommand-arguments]=0 - - # Set style for region_highlight entry. It is used below in - # '[[ -n "$__style" ]] ...' line, which adds highlight entry, - # like "10 12 fg=green", through `reply' array. - # - # Could check if command `example' exists and set `unknown-token' - # style instead of `command' - __style=${FAST_THEME_NAME}command - -} || { - # Following call, i.e. not the first one - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - - if [[ "$__wrd" = -* ]]; then - # Detected option, add style for it. - [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ - __style=${FAST_THEME_NAME}single-hyphen-option - case $FAST_HIGHLIGHT[subversion-command]/$FAST_HIGHLIGHT[subversion-subcommand] in - svn/) - case $__wrd in - --username|-u) FAST_HIGHLIGHT[subversion-option-argument]=any;; - --password|-p) FAST_HIGHLIGHT[subversion-option-argument]=any;; - --config-(dir|option)) FAST_HIGHLIGHT[subversion-option-argument]=any;; - esac - ;; - svn/?*) - case $__wrd in - --accept) FAST_HIGHLIGHT[subversion-option-argument]=accept;; - --change|-c) FAST_HIGHLIGHT[subversion-option-argument]=revision;; - --changelist|--cl) FAST_HIGHLIGHT[subversion-option-argument]=any;; - --(set-|)depth) FAST_HIGHLIGHT[subversion-option-argument]=depth;; - --diff(3|)-cmd) FAST_HIGHLIGHT[subversion-option-argument]=cmd;; - --editor-cmd) FAST_HIGHLIGHT[subversion-option-argument]=cmd;; - --encoding) FAST_HIGHLIGHT[subversion-option-argument]=any;; - --file) FAST_HIGHLIGHT[subversion-option-argument]=any;; - --limit|-l) FAST_HIGHLIGHT[subversion-option-argument]=number;; - --message|-m) FAST_HIGHLIGHT[subversion-option-argument]=any;; - --native-eol) FAST_HIGHLIGHT[subversion-option-argument]=eol;; - --new|--old) FAST_HIGHLIGHT[subversion-option-argument]=target;; - --revision|-r) FAST_HIGHLIGHT[subversion-option-argument]=revision-pair;; - --show-revs) FAST_HIGHLIGHT[subversion-option-argument]=show-revs;; - --strip) FAST_HIGHLIGHT[subversion-option-argument]=number;; - --with-revprop) FAST_HIGHLIGHT[subversion-option-argument]=revprop;; - esac - ;; - svnadmin/*) - case $__wrd in - --config-dir) FAST_HIGHLIGHT[subversion-option-argument]=any;; - --fs-type) FAST_HIGHLIGHT[subversion-option-argument]=any;; - --memory-cache-size|-M) FAST_HIGHLIGHT[subversion-option-argument]=number;; - --parent-dir) FAST_HIGHLIGHT[subversion-option-argument]=any;; - --revision|-r) FAST_HIGHLIGHT[subversion-option-argument]=revision-pair;; - esac - ;; - svndumpfilter/*) - case $__wrd in - --targets) FAST_HIGHLIGHT[subversion-option-argument]=any;; - esac - ;; - esac - elif [[ -n $FAST_HIGHLIGHT[subversion-option-argument] ]]; then - case $FAST_HIGHLIGHT[subversion-option-argument] in - any) - FAST_HIGHLIGHT[subversion-option-argument]= - return 1 - ;; - accept) - [[ $__wrd = (p(|ostpone)|e(|dit)|l(|aunch)|base|working|recommended|[mt][cf]|(mine|theirs)-(conflict|full)) ]] \ - && __style=${FAST_THEME_NAME}correct-subtle \ - || __style=${FAST_THEME_NAME}incorrect-subtle - ;; - depth) - [[ $__wrd = (empty|files|immediates|infinity) ]] \ - && __style=${FAST_THEME_NAME}correct-subtle \ - || __style=${FAST_THEME_NAME}incorrect-subtle - ;; - number) - [[ $__wrd = [0-9]## ]] \ - && __style=${FAST_THEME_NAME}mathnum \ - || __style=${FAST_THEME_NAME}incorrect-subtle - ;; - eol) - [[ $__wrd = (CR(|LF)|LF) ]] \ - && __style=${FAST_THEME_NAME}correct-subtle \ - || __style=${FAST_THEME_NAME}incorrect-subtle - ;; - show-revs) - [[ $__wrd = (merged|eligible) ]] \ - && __style=${FAST_THEME_NAME}correct-subtle \ - || __style=${FAST_THEME_NAME}incorrect-subtle - ;; - revision) - →chroma/-subversion.ch/parse-revision $__wrd $__start_pos $__end_pos - ;; - revision-pair) - local -a match mbegin mend - if [[ $__wrd = (#b)(\{[^}]##\}|[^:]##)(:)(*) ]]; then - →chroma/-subversion.ch/parse-revision $match[1] $__start_pos $(( __end_pos - ( mend[3]-mend[2] ) - 1 )) - →chroma/-subversion.ch/parse-revision $match[3] $(( __start_pos + ( mbegin[3]-mbegin[1] ) )) $__end_pos - (( __start=__start_pos-${#PREBUFFER}+(mbegin[2]-mbegin[1]), __end=__end_pos-${#PREBUFFER}-(mend[3]-mend[2]), __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-separator]}") - else - →chroma/-subversion.ch/parse-revision $__wrd $__start_pos $__end_pos - fi - ;; - target) - →chroma/-subversion.ch/parse-target $__wrd $__start_pos $__end_pos || return $? - ;; - cmd) - this_word=1 - return 1 - ;; - esac - FAST_HIGHLIGHT[subversion-option-argument]= - elif [[ -z $FAST_HIGHLIGHT[subversion-subcommand] ]] - then - FAST_HIGHLIGHT[subversion-subcommand]=$__wrd - local subcmds - case $FAST_HIGHLIGHT[subversion-command] in - svn) subcmds='(add|auth|blame|praise|annotate|ann|cat|changelist|cl|checkout|co|cleanup|commit|ci|copy|cp|delete|del|remove|rm|diff|di|export|help|\?|h|import|info|list|ls|lock|log|merge|mergeinfo|mkdir|move|mv|rename|ren|patch|propdel|pdel|pd|propedit|pedit|pe|propget|pget|pg|proplist|plist|pl|propset|pset|ps|relocate|resolve|resolved|revert|status|stat|st|switch|sw|unlock|update|up|upgrade|x-shelf-diff|x-shelf-drop|x-shelf-list|x-shelves|x-shelf-list-by-paths|x-shelf-log|x-shelf-save|x-shelve|x-unshelve)' ;; - svnadmin) subcmds="(crashtest|create|delrevprop|deltify|dump|dump-revprops|freeze|help|\?|h|hotcopy|info|list-dblogs|list-unused-dblogs|load|load-revprops|lock|lslocks|lstxns|pack|recover|rmlocks|rmtxns|setlog|setrevprop|setuuid|unlock|upgrade|verify)";; - svndumpfilter) subcmds='(include|exclude|help|\?)';; - esac - [[ $FAST_HIGHLIGHT[subversion-subcommand] = $~subcmds ]] \ - && __style=${FAST_THEME_NAME}subcommand \ - || __style=${FAST_THEME_NAME}incorrect-subtle - FAST_HIGHLIGHT[subversion-subcommand-arguments]=0 - else - (( FAST_HIGHLIGHT[subversion-subcommand-arguments]+=1 )) - if [[ ( $FAST_HIGHLIGHT[subversion-subcommand] == (checkout|co|export|log|merge|switch|sw) && $FAST_HIGHLIGHT[subversion-subcommand-arguments] -eq 1 ) \ - || $FAST_HIGHLIGHT[subversion-subcommand] == (blame|praise|annotate|ann|cat|copy|cp|diff|info|list|ls|mergeinfo) ]]; then - →chroma/-subversion.ch/parse-target $__wrd $__start_pos $__end_pos || return $? - else - return 1 - fi - fi -} - -# Add region_highlight entry (via `reply' array). -# If 1 will be added to __start_pos, this will highlight "oken". -# If 1 will be subtracted from __end_pos, this will highlight "toke". -# $PREBUFFER is for specific situations when users does command \ -# i.e. when multi-line command using backslash is entered. -# -# This is a common place of adding such entry, but any above code can do -# it itself (and it does in other chromas) and skip setting __style to -# this way disable this code. -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through, do obligatory things ourselves. -# _start_pos=$_end_pos advainces pointers in command line buffer. -# -# To pass through means to `return 1'. The highlighting of -# this single token is then done by fast-syntax-highlighting's -# main code and chroma doesn't have to do anything. -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-vim.ch b/.config/zsh/.zsh/fsh/→chroma/-vim.ch deleted file mode 100644 index b3fecd1..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-vim.ch +++ /dev/null @@ -1,51 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# Chroma for vim, shows last opened files under prompt. -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# -# $2 - the current token, also accessible by $__arg from the above scope - -# basically a private copy of $__arg; the token can be eg.: "grep" -# -# $3 - a private copy of $_start_pos, i.e. the position of the token in the -# command line buffer, used to add region_highlight entry (see man), -# because Zsh colorizes by *ranges* in command line buffer -# -# $4 - a private copy of $_end_pos from the above scope -# - -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style __chars -integer __idx1 __idx2 -local -a __viminfo - -# First call, i.e. command starts, i.e. "grep" token etc. -(( __first_call )) && { - (( ${+commands[vim]} )) && __style=${FAST_THEME_NAME}command || __style=${FAST_THEME_NAME}unknown-token - - { __viminfo=( ${(f)"$(<$HOME/.viminfo)"} ); } >> /dev/null - __viminfo=( "${${(M)__viminfo[@]:#>*}[@]:t}" ) - __viminfo=( "${__viminfo[@]:#COMMIT_EDITMSG}" ) - zle -M "Last opened:"$'\n'"${(F)__viminfo[1,5]}" -} || { - # Pass almost everything to big loop - return 1 -} - -# Add region_highlight entry (via `reply' array). -# -# This is a common place of adding such entry, but any above -# code can do it itself (and it does, see other chromas) and -# skip setting __style to disable this code. -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through (no return 1 occured), do obligatory things ourselves. -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-whatis.ch b/.config/zsh/.zsh/fsh/→chroma/-whatis.ch deleted file mode 100644 index 993f989..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-whatis.ch +++ /dev/null @@ -1,138 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018-2019 Sebastian Gniazdowski - -(( next_word = 2 | 8192 )) -local THEFD check __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style - -(( ! ${+FAST_HIGHLIGHT[whatis_chroma_callback_was_ran]} )) && \ - FAST_HIGHLIGHT[whatis_chroma_callback_was_ran]=0 - -(( ! ${+FAST_HIGHLIGHT[whatis_chroma_zle_-F_have_-w_opt]} )) && { - is-at-least 5.0.6 && local __res=1 || local __res=0 - FAST_HIGHLIGHT[whatis_chroma_zle_-F_have_-w_opt]="$__res" -} - --fast-whatis-chroma-callback() { - emulate -L zsh - setopt extendedglob warncreateglobal typesetsilent - - local THEFD="$1" input check=2 nl=$'\n' __wrd __style - - .fast-zts-read-all "$THEFD" input - - zle -F "$THEFD" - exec {THEFD}<&- - - __wrd="${${input#[^$nl]#$nl}%%$nl*}" - if [[ "$input" = test* ]]; then - if [[ "${input%$nl}" = *[^0-9]'0' ]]; then - if [[ "${input#test$nl}" = *nothing\ appropriate* ]]; then - FAST_HIGHLIGHT[whatis_chroma_type]=2 - else - FAST_HIGHLIGHT[whatis_chroma_type]=0 - fi - else - FAST_HIGHLIGHT[whatis_chroma_type]=1 - fi - elif [[ "$input" = type2* ]]; then - [[ "$input" != *nothing\ appropriate* ]] && check=1 || check=0 - elif [[ "$input" = type1* ]]; then - [[ "${input%$nl}" = *0 ]] && check=1 || check=0 - fi - - if (( check != 2 )); then - FAST_HIGHLIGHT[whatis-cache-$__wrd]=$check - if (( check )) then - __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]} - elif [[ ${~__wrd} = */* && -e ${~__wrd} ]] then - __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]} - else - __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]} - fi - local -a start_end - start_end=( ${(s:/:)${${(M)${${input#type?${nl}[^$nl]#$nl}}#*$nl}%$nl}} ) - (( start_end[1] >= 0 )) && region_highlight+=("$start_end[1] $start_end[2] $__style") - zle -R - fi - - FAST_HIGHLIGHT[whatis_chroma_callback_was_ran]=1 - return 0 -} - -zle -N -- -fast-whatis-chroma-callback - -if (( __first_call )) && [[ -z "${FAST_HIGHLIGHT[whatis_chroma_type]}" ]] ;then - if ! command -v whatis > /dev/null; then - FAST_HIGHLIGHT[whatis_chroma_type]=0 - return 1 - fi - - exec {THEFD}< <( - print "test" - LANG=C whatis "osx whatis fallback check" - print "$?" - ) - command true # a workaround of Zsh bug - zle -F ${${FAST_HIGHLIGHT[whatis_chroma_zle_-F_have_-w_opt]:#0}:+-w} "$THEFD" -fast-whatis-chroma-callback -fi - -[[ "$__arg_type" = 3 ]] && return 2 - -if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 -fi - -if (( __first_call )) || [[ "$__wrd" = -* ]]; then - return 1 -elif (( ! FAST_HIGHLIGHT[whatis_chroma_type] )); then - # Return 1 (i.e. treat the argument as a path) only if the callback have - # had a chance to establish the whatis_chroma_type field - (( FAST_HIGHLIGHT[whatis_chroma_callback_was_ran] )) && return 1 -else - if [[ -z "${FAST_HIGHLIGHT[whatis-cache-$__wrd]}" ]]; then - if (( FAST_HIGHLIGHT[whatis_chroma_type] == 2 )); then - exec {THEFD}< <( - print "type2" - print "$__wrd" - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER} )) - print "$__start/$__end" - LANG=C whatis "$__wrd" 2>/dev/null - ) - command true # see above - zle -F ${${FAST_HIGHLIGHT[whatis_chroma_zle_-F_have_-w_opt]:#0}:+-w} "$THEFD" -fast-whatis-chroma-callback - else - exec {THEFD}< <( - print "type1" - print "$__wrd" - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER} )) - print "$__start/$__end" - LANG=C whatis "$__wrd" &> /dev/null - print "$?" - ) - command true - zle -F ${${FAST_HIGHLIGHT[whatis_chroma_zle_-F_have_-w_opt]:#0}:+-w} "$THEFD" -fast-whatis-chroma-callback - fi - __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]} - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \ - reply+=("$__start $__end $__style") - else - check=${FAST_HIGHLIGHT[whatis-cache-$__wrd]} - if (( check )) then - __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]} - elif [[ ${~__wrd} = */* && -e ${~__wrd} ]] then - __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]} - elif (( FAST_HIGHLIGHT[whatis_chroma_type] )); then - __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]} - fi - [[ -n "$__style" ]] && \ - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \ - reply+=("$__start $__end $__style") - fi -fi -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4:sts=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-which.ch b/.config/zsh/.zsh/fsh/→chroma/-which.ch deleted file mode 100644 index 5a5d7b3..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-which.ch +++ /dev/null @@ -1,96 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018 Sebastian Gniazdowski -# -# Outputs (under prompt) result of query done with `which', `type -w', -# `whence -v', `whereis', `whatis'. -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# -# $2 - the current token, also accessible by $__arg from the above scope - -# basically a private copy of $__arg; the token can be eg.: "grep" -# -# $3 - a private copy of $_start_pos, i.e. the position of the token in the -# command line buffer, used to add region_highlight entry (see man), -# because Zsh colorizes by *ranges* in command line buffer -# -# $4 - a private copy of $_end_pos from the above scope -# - -(( next_word = 2 | 8192 )) - -local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" -local __style __output __chars -integer __idx1 __idx2 -local -a __results - -# First call, i.e. command starts, i.e. "grep" token etc. -(( __first_call )) && { - FAST_HIGHLIGHT[chroma-which-counter]=0 - FAST_HIGHLIGHT[chroma-which-counter-all]=1 - FAST_HIGHLIGHT[chroma-which-message]="" - FAST_HIGHLIGHT[chroma-which-skip-two]=0 - __style=${FAST_THEME_NAME}command - __output="" - -# Following call (not first one). -} || { - (( FAST_HIGHLIGHT[chroma-which-counter-all] += 1, __idx2 = FAST_HIGHLIGHT[chroma-which-counter-all] )) - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - fi - - if [[ "$__wrd" = -* ]]; then - # Detected option, add style for it. - [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ - __style=${FAST_THEME_NAME}single-hyphen-option - if [[ "$__wrd" = "-x" ]]; then - FAST_HIGHLIGHT[chroma-which-skip-two]=1 - fi - else - # Count non-option tokens. - if (( FAST_HIGHLIGHT[chroma-which-skip-two] )); then - FAST_HIGHLIGHT[chroma-which-skip-two]=0 - else - (( FAST_HIGHLIGHT[chroma-which-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-which-counter] )) - if [[ "$__idx1" -eq 1 ]]; then - __chars="{" - __output="$(command which "$__wrd" 2>/dev/null)" - FAST_HIGHLIGHT[chroma-which-message]+=$'\n'"command which: $__output" - __output="$(builtin which "$__wrd" 2>/dev/null)" - FAST_HIGHLIGHT[chroma-which-message]+=$'\n'"builtin which: ${${${${__output[1,100]}//$'\n'/;}//$'\t'/ }//$__chars;/$__chars}${__output[101,101]:+...}" - __output="$(builtin type -w "$__wrd" 2>/dev/null)" - FAST_HIGHLIGHT[chroma-which-message]+=$'\n'"type -w: $__output" - __output="$(builtin whence -v "$__wrd" 2>/dev/null)" - FAST_HIGHLIGHT[chroma-which-message]+=$'\n'"whence -v: $__output" - __output="$(command whereis "$__wrd" 2>/dev/null)" - FAST_HIGHLIGHT[chroma-which-message]+=$'\n'"whereis: $__output" - __output="$(command whatis "$__wrd" 2>/dev/null)" - __output="${${__output%%$'\n'*}//[[:blank:]]##/ }" - FAST_HIGHLIGHT[chroma-which-message]+=$'\n'"whatis: $__output" - fi - fi - fi - - if (( ${#${(z)BUFFER}} <= FAST_HIGHLIGHT[chroma-which-counter-all] )); then - [[ -n "${FAST_HIGHLIGHT[chroma-which-message]}" ]] && zle -M "${FAST_HIGHLIGHT[chroma-which-message]#$'\n'}" - fi -} - -# Add region_highlight entry (via `reply' array). -# -# This is a common place of adding such entry, but any above code -# can do it itself and skip setting __style to disable this code. -[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") - -# We aren't passing-through (no return 1 occured), do obligatory things ourselves. -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/-zinit.ch b/.config/zsh/.zsh/fsh/→chroma/-zinit.ch deleted file mode 100644 index 06637a8..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/-zinit.ch +++ /dev/null @@ -1,378 +0,0 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2018-2019 Sebastian Gniazdowski -# -# Chroma function for command `git'. It colorizes the part of command -# line that holds `git' invocation. - -(( FAST_HIGHLIGHT[-zinit.ch-chroma-def] )) && return 1 - -FAST_HIGHLIGHT[-zinit.ch-chroma-def]=1 - -typeset -gA fsh__zinit__chroma__def -fsh__zinit__chroma__def=( - ## - ## No subcommand - ## - ## {{{ - - subcmd:NULL "NULL_0_opt" - NULL_0_opt "(-help|--help|-h) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - "subcommands" "(help|man|self-update|cd|times|zstatus|load|light|unload|snippet|ls|ice||update|status|report|delete|loaded|list|cd|create|edit|glance|stress|changes|recently|clist|completions|cdisable|cname|cenable|cname|creinstall|cuninstall|csearch|compinit|dtrace|dstart|dstop|dunload|dreport|dclear|compile|uncompile|compiled|cdlist|cdreplay|cdclear|srv|recall|env-whitelist|bindkeys|module)" - - ## }}} - - # Generic actions - NO_MATCH_\#_opt "* <<>> __style=\${FAST_THEME_NAME}incorrect-subtle // NO-OP" - NO_MATCH_\#_arg "__style=\${FAST_THEME_NAME}incorrect-subtle // NO-OP" - - - ## - ## `ice' - ## - ## {{{ - - subcmd:ice "ICE_#_arg // NO_MATCH_#_opt" - - "ICE_#_arg" "NO-OP // ::→chroma/-zinit-check-ice-mod" - - ## }}} - - ## - ## `snippet' - ## - ## {{{ - - subcmd:snippet "SNIPPET_0_opt // SNIPPET_1_arg // NO_MATCH_#_opt // - NO_MATCH_#_arg" - - SNIPPET_0_opt "(-f|--command) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - SNIPPET_1_arg "NO-OP // ::→chroma/-zinit-verify-snippet" - - ## }}} - - ## - ## `load' - ## - ## {{{ - - "subcmd:load" - "LOAD_1_arg // LOAD_2_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" - - LOAD_1_arg "NO-OP // ::→chroma/-zinit-verify-plugin" - - LOAD_2_arg "NO-OP // ::→chroma/-zinit-verify-plugin" - - ## }}} - - ## - ## `compile|uncompile|stress|edit|glance|recall|status|cd|changes` - ## - ## {{{ - - "subcmd:(compile|uncompile|stress|edit|glance|recall|status|cd|changes)" - "PLGSNP_1_arg // PLGSNP_2_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" - - PLGSNP_1_arg "NO-OP // ::→chroma/-zinit-verify-plugin-or-snippet" - - PLGSNP_2_arg "NO-OP // ::→chroma/-zinit-verify-plugin-or-snippet" - - ## }}} - - ## - ## `update' - ## - ## {{{ - - subcmd:update "UPDATE_0_opt // PLGSNP_1_arg // PLGSNP_2_arg // - NO_MATCH_#_opt // NO_MATCH_#_arg" - - UPDATE_0_opt " - (--all|-r|--reset|-q|--quiet|-p|--parallel) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - ## }}} - - ## - ## `light' - ## - ## {{{ - - subcmd:light "LIGHT_0_opt // LOAD_1_arg // LOAD_2_arg // NO_MATCH_#_opt // - NO_MATCH_#_arg" - - LIGHT_0_opt "-b - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - ## }}} - - ## - ## `unload' - ## - ## {{{ - - subcmd:unload "UNLOAD_0_opt // UNLOAD_1_arg // UNLOAD_2_arg // NO_MATCH_#_opt // - NO_MATCH_#_arg" - - UNLOAD_0_opt "-q - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - UNLOAD_1_arg "NO-OP // ::→chroma/-zinit-verify-loaded-plugin" - - UNLOAD_2_arg "NO-OP // ::→chroma/-zinit-verify-loaded-plugin" - - ## }}} - - ## - ## `report' - ## - ## {{{ - - subcmd:report "REPORT_0_opt // UNLOAD_1_arg // UNLOAD_2_arg // NO_MATCH_#_opt // - NO_MATCH_#_arg" - - REPORT_0_opt "--all - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - ## }}} - - ## - ## `delete' - ## - ## {{{ - - "subcmd:delete" - "DELETE_0_opt // PLGSNP_1_arg // PLGSNP_2_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" - - DELETE_0_opt " - (--all|--clean|-y|--yes|-q|--quiet) - <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" - - ## }}} - - ## - ## `cenable' - ## - ## {{{ - - subcmd:cenable "COMPLETION_1_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" - - COMPLETION_1_arg "NO-OP // ::→chroma/-zinit-verify-disabled-completion" - - ## }}} - - ## - ## `cdisable' - ## - ## {{{ - - subcmd:cdisable "DISCOMPLETION_1_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" - - DISCOMPLETION_1_arg "NO-OP // ::→chroma/-zinit-verify-completion" - - ## }}} - - - ## - ## `light' - ## - ## {{{ - - subcmd:uncompile "UNCOMPILE_1_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" - - UNCOMPILE_1_arg "NO-OP // ::→chroma/-zinit-verify-compiled-plugin" - - ## }}} - - ## - ## `*' - ## - ## {{{ - - "subcmd:*" "CATCH_ALL_#_opt" - "CATCH_ALL_#_opt" "* <<>> NO-OP // ::→chroma/main-chroma-std-aopt-SEMI-action" - - ## }}} -) - -#→chroma/-zinit-first-call() { - # This is being done in the proper place - in -fast-highlight-process - #FAST_HIGHLIGHT[chroma-zinit-ice-elements-svn]=0 -#} - -→chroma/-zinit-verify-plugin() { - local _scmd="$1" _wrd="$4" - - [[ -d "$_wrd" ]] && \ - { __style=${FAST_THEME_NAME}correct-subtle; return 0; } - - typeset -a plugins - plugins=( "${ZINIT[PLUGINS_DIR]}"/*(N:t) ) - plugins=( "${plugins[@]//---//}" ) - plugins=( "${plugins[@]:#_local/zinit}" ) - plugins=( "${plugins[@]:#custom}" ) - - [[ -n "${plugins[(r)$_wrd]}" ]] && \ - __style=${FAST_THEME_NAME}correct-subtle || \ - return 1 - #__style=${FAST_THEME_NAME}incorrect-subtle - return 0 -} - -→chroma/-zinit-verify-plugin-or-snippet() { - →chroma/-zinit-verify-plugin "$1" "" "" "$4" || \ - →chroma/-zinit-verify-snippet "$1" "" "" "$4" - return $? -} - -→chroma/-zinit-verify-loaded-plugin() { - local _scmd="$1" _wrd="$4" - typeset -a plugins absolute1 absolute2 absolute3 normal - plugins=( "${ZINIT_REGISTERED_PLUGINS[@]:#_local/zinit}" ) - normal=( "${plugins[@]:#%*}" ) - absolute1=( "${(M)plugins[@]:#%*}" ) - absolute1=( "${absolute1[@]/\%\/\//%/}" ) - local hm="${HOME%/}" - absolute2=( "${absolute1[@]/$hm/HOME}" ) - absolute3=( "${absolute1[@]/\%/}" ) - plugins=( $absolute1 $absolute2 $absolute3 $normal ) - - [[ -n "${plugins[(r)$_wrd]}" ]] && \ - __style=${FAST_THEME_NAME}correct-subtle || \ - return 1 - #__style=${FAST_THEME_NAME}incorrect-subtle - - return 0 -} - -→chroma/-zinit-verify-completion() { - local _scmd="$1" _wrd="$4" - # Find enabled completions - typeset -a completions - completions=( "${ZINIT[COMPLETIONS_DIR]}"/_*(N:t) ) - completions=( "${completions[@]#_}" ) - - [[ -n "${completions[(r)${_wrd#_}]}" ]] && \ - __style=${FAST_THEME_NAME}correct-subtle || \ - return 1 - - return 0 -} - -→chroma/-zinit-verify-disabled-completion() { - local _scmd="$1" _wrd="$4" - # Find enabled completions - typeset -a completions - completions=( "${ZINIT[COMPLETIONS_DIR]}"/[^_]*(N:t) ) - - [[ -n "${completions[(r)${_wrd#_}]}" ]] && \ - __style=${FAST_THEME_NAME}correct-subtle || \ - return 1 - - return 0 -} - -→chroma/-zinit-verify-compiled-plugin() { - local _scmd="$1" _wrd="$4" - - typeset -a plugins - plugins=( "${ZINIT[PLUGINS_DIR]}"/*(N) ) - - typeset -a show_plugins p matches - for p in "${plugins[@]}"; do - matches=( $p/*.zwc(N) ) - if [ "$#matches" -ne "0" ]; then - p="${p:t}" - [[ "$p" = (_local---zinit|custom) ]] && continue - p="${p//---//}" - show_plugins+=( "$p" ) - fi - done - - [[ -n "${show_plugins[(r)$_wrd]}" ]] && \ - { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \ - return 1 -} - -→chroma/-zinit-verify-snippet() { - local _scmd="$1" url="$4" dirname local_dir - url="${${url#"${url%%[! $'\t']*}"}%/}" - id_as="${FAST_HIGHLIGHT[chroma-zinit-ice-elements-id-as]:-${ZINIT_ICE[id-as]:-$url}}" - - filename="${${id_as%%\?*}:t}" - dirname="${${id_as%%\?*}:t}" - local_dir="${${${id_as%%\?*}:h}/:\/\//--}" - [[ "$local_dir" = "." ]] && local_dir="" || local_dir="${${${${${local_dir#/}//\//--}//=/--EQ--}//\?/--QM--}//\&/--AMP--}" - local_dir="${ZINIT[SNIPPETS_DIR]}${local_dir:+/$local_dir}" - - (( ${+ZINIT_ICE[svn]} || ${FAST_HIGHLIGHT[chroma-zinit-ice-elements-svn]} )) && { - # TODO: handle the SVN path's specifics - [[ -d "$local_dir/$dirname" ]] && \ - { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \ - return 1 - } || { - # TODO: handle the non-SVN path's specifics - [[ -d "$local_dir/$dirname" ]] && \ - { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \ - return 1 - } -} - -→chroma/-zinit-check-ice-mod() { - local _scmd="$1" _wrd="$4" - [[ "$_wrd" = (svn(\'|\")*|svn) ]] && \ - FAST_HIGHLIGHT[chroma-zinit-ice-elements-svn]=1 - [[ "$_wrd" = (#b)(id-as(:|)(\'|\")(*)(\'|\")|id-as:(*)|id-as(*)) ]] && \ - FAST_HIGHLIGHT[chroma-zinit-ice-elements-id-as]="${match[4]}${match[6]}${match[7]}" - - # Copy from zinit-autoload.zsh / -zplg-recall - local -a ice_order nval_ices ext_val_ices - ext_val_ices=( ${(@)${(@Ms.|.)ZINIT_EXTS[ice-mods]:#*\'\'*}//\'\'/} ) - - ice_order=( - svn proto from teleid bindmap cloneopts id-as depth if wait load - unload blockf pick bpick src as ver silent lucid notify mv cp - atinit atclone atload atpull nocd run-atpull has cloneonly make - service trackbinds multisrc compile nocompile nocompletions - reset-prompt wrap-track reset sh \!sh bash \!bash ksh \!ksh csh - \!csh aliases countdown ps-on-unload ps-on-update trigger-load - light-mode is-snippet atdelete pack git verbose on-update-of - subscribe param extract - # Include all additional ices – after - # stripping them from the possible: '' - ${(@s.|.)${ZINIT_EXTS[ice-mods]//\'\'/}} - ) - nval_ices=( - blockf silent lucid trackbinds cloneonly nocd run-atpull - nocompletions sh \!sh bash \!bash ksh \!ksh csh \!csh - aliases countdown light-mode is-snippet git verbose - - # Include only those additional ices, - # don't have the '' in their name, i.e. - # aren't designed to hold value - ${(@)${(@s.|.)ZINIT_EXTS[ice-mods]}:#*\'\'*} - - # Must be last - svn - ) - - if [[ "$_wrd" = (#b)(${(~j:|:)${ice_order[@]:#(${(~j:|:)nval_ices[@]:#(${(~j:|:)ext_val_ices[@]})})}})(*) ]]; then - reply+=("$(( __start )) $(( __start+${mend[1]} )) ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-hyphen-option]}") - reply+=("$(( __start+${mbegin[2]} )) $(( __end )) ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}optarg-string]}") - -fast-highlight-string - return 0 - elif [[ "$_wrd" = (#b)(${(~j:|:)nval_ices[@]}) ]]; then - __style=${FAST_THEME_NAME}single-hyphen-option - return 0 - else - __style=${FAST_THEME_NAME}incorrect-subtle - return 1 - fi -} - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/fsh/→chroma/main-chroma.ch b/.config/zsh/.zsh/fsh/→chroma/main-chroma.ch deleted file mode 100644 index 323a978..0000000 --- a/.config/zsh/.zsh/fsh/→chroma/main-chroma.ch +++ /dev/null @@ -1,460 +0,0 @@ -# Copyright (c) 2018 Sebastian Gniazdowski -# -# Main chroma function. It allows to create the command-dedicated chromas -# (like -git.ch) through a definition provided by `chroma_def' array (read -# from the upper scope). -# -# $1 - 0 or 1, denoting if it's first call to the chroma, or following one -# $2 - the current token, also accessible by $__arg from the above scope - -# basically a private copy of $__arg -# $3 - a private copy of $_start_pos, i.e. the position of the token in the -# command line buffer, used to add region_highlight entry (see man), -# because Zsh colorizes by *ranges* in command line buffer -# $4 - a private copy of $_end_pos from the above scope -# - -(( next_word = 2 | 8192 )) - -→chroma/main-chroma-print() { - (( FAST_HIGHLIGHT[DEBUG] )) && print "$@" >> /tmp/fsh-dbg -} - -local __chroma_name="${1#\%}" __first_call="$2" __wrd="$3" __start_pos="$4" __end_pos="$5" - -# Not a well formed chroma name -[[ -z "$__chroma_name" ]] && return 1 - -# Load the fsh_{name-of-the-chroma}_chroma_def array -(( !FAST_HIGHLIGHT[-${__chroma_name}.ch-chroma-def] )) && →chroma/-${__chroma_name}.ch - -→chroma/main-chroma-print -r -- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -→chroma/main-chroma-print -r -- @@@@@@@ local __chroma_name="${1#\%}" __first_call="$2" __wrd="$3" __start_pos="$4" __end_pos="$5" @@@@@@@ -local __style __entry __value __action __handler __tmp __svalue __hspaces=$'\t ' __nl=$'\n' __ch_def_name -integer __idx1 __idx2 __start __end __ivalue __have_value=0 -local -a __lines_list __avalue -local -A map -map=( "#" "_H" "^" "_D" "*" "_S" ) - -(( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN )) - -# Handler that highlights the options -→chroma/main-chroma-std-aopt-action() { - integer _start="$2" _end="$3" - local _scmd="$1" _wrd="$4" - - [[ "$_wrd" = (#b)(--[a-zA-Z0-9_-]##)=(*) ]] && { - reply+=("$_start $(( _end - mend[2] + mbegin[2] - 1 )) ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-hyphen-option]}") - } || { - [[ "$_wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ - __style=${FAST_THEME_NAME}single-hyphen-option - } -} - -# Handler that highlights the options' arguments -→chroma/main-chroma-std-aopt-ARG-action() { - integer _start="$2" _end="$3" - local _scmd="$1" _wrd="$4" - - [[ "$_wrd" = (#b)(--[a-zA-Z0-9_-]##)=(*) ]] && { - reply+=("$(( _start + 1 + mend[1] )) $_end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}optarg-${${${(M)match[2]:#<->}:+number}:-string}]}") - } || __style=${FAST_THEME_NAME}optarg-${${${(M)_wrd:#(-|)<->}:+number}:-string} -} - -# This handler also highlights explicit arguments, i.e. --opt=the-explicit-arg -→chroma/main-chroma-std-aopt-SEMI-action() { - integer _start="$2" _end="$3" - local _scmd="$1" _wrd="$4" - - [[ "$_wrd" = (#b)(--[a-zA-Z0-9_-]##)=(*) ]] && { - reply+=("$_start $(( _end - mend[2] + mbegin[2] - 1 )) ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-hyphen-option]}") - reply+=("$(( _start + 1 + mend[1] )) $_end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}optarg-${${${(M)match[2]:#<->}:+number}:-string}]}") - } || { - [[ "$_wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ - __style=${FAST_THEME_NAME}single-hyphen-option - } -} - -# A handler which verifies the token as an GIT url -→chroma/main-chroma-std-verify-url() { - setopt localoptions extendedglob - local _wrd="$4" - integer url_correct=0 - # Correct matches - # Correct matches - if [[ "$_wrd" = (#b)(git|http|https|ftp|ftps|file)://([a-zA-Z0-9._~-]##)(:[0-9]##)(#c0,1)(/([a-zA-Z0-9./_~:-]##))(#c0,1) ]]; then - url_correct=1 - elif [[ "$_wrd" = (#b)rsync://([a-zA-Z0-9._~-]##)(/([a-zA-Z0-9./_~:-]##))(#c0,1) ]]; then - url_correct=1 - elif [[ "$_wrd" = (#b)ssh://([a-zA-Z0-9._~-]##@)(#c0,1)([a-zA-Z0-9._~-]##)(:[0-9]##)(#c0,1)(/([a-zA-Z0-9./_~:-]##))(#c0,1) ]]; then - url_correct=1 - elif [[ "$_wrd" = (#b)([a-zA-Z0-9._~-]##@)(#c0,1)([a-zA-Z0-9._~-]##):([a-zA-Z0-9./_~:-](#c0,1)[a-zA-Z0-9._~:-][a-zA-Z0-9./_~:-]#)(#c0,1) ]]; then - url_correct=1 - elif [[ "$_wrd" = (#b)[[:alnum:]/_~:.-]## ]]; then - url_correct=1 - fi - - (( url_correct )) && \ - { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \ - { __style=${FAST_THEME_NAME}incorrect-subtle; return 1; } -} - -# A handler which verifies the token as a shell wildcard -→chroma/main-chroma-std-verify-pattern() { - setopt localoptions extendedglob - local _wrd="$4" - __style=${FAST_THEME_NAME}globbing-ext -} - -# Creates a hash table for given option set (an *_opt field in the chroma def.) -→chroma/main-create-OPTION-hash.ch() { - local __subcmd="$1" __option_set_id="$2" __the_hash_name="$3" __ __e __el __the_hash_name __var_name - local -a __split __sp __s - - →chroma/main-chroma-print -rl "======================" " **## STARTING ##** →chroma/main-##CREATE##-option-HASH.ch // subcmd:$__subcmd // option_set_id:$__option_set_id // h-nam:$__the_hash_name" - →chroma/main-chroma-print "[D] Got option-set: ${(j:,:)__option_set_id}" - typeset -gA "$__the_hash_name" - →chroma/main-chroma-print "[E] __the_hash_name ${__the_hash_name}:[$__option_set_id]" - - # Split on || - __ch_def_name="fsh__${__chroma_name}__chroma__def[${__option_set_id}]" - __split=( "${(P@s:||:)__ch_def_name}" ) - [[ ${#__split} -eq 1 && -z "${__split[1]}" ]] && __split=() - # Remove only leading and trailing whitespace - __split=( "${__split[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) - - →chroma/main-chroma-print -rl "[F] Got ||-__split: _________" ${${(@)${${__split[@]##[[:space:]]##}[@]//[${__hspaces}]##/ }[@]//[${__nl}]##/$__nl}[@]//(#s)/:::} "_________" - for __el in $__split; do - __sp=( "${(@s:<<>>:)__el}" ) - [[ ${#__sp} -eq 1 && -z "${__sp[1]}" ]] && __sp=() - __sp=( "${__sp[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) - - →chroma/main-chroma-print -l -- "Processing an ||-part - got <<>>-split: _________" "${${__sp[@]}[@]/(#s)/-\\t}" "_________" - __e="${__sp[1]}" - local __e1=${${__e#\(}%\)(:add|:del|)} - local __e2=${(M)__e##\(*\)(:add|:del)} - # Split on | with the ( and ) and :add/:del stripped and then append - # the :add or :del depending on what's on the input line - __s=() - for __ in ${(@s:|:)__e1}; do - __s+=( $__${__e2:+${(M)__e%(:add|:del)}} ) - done - [[ ${#__s} -eq 1 && -z "${__s[1]}" ]] && __s=() - __s=( "${__s[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) - shift __sp - - for __ in $__s; do - __=${__%\^} - [[ "$__" = -*:(add|del) ]] && __var_name="${__the_hash_name}[${__}-directive]" || __var_name="${__the_hash_name}[${__}-opt-action]" - →chroma/main-chroma-print "${(r:70:: :):-${__var_name}} := >>${__sp[1]}${${${#__sp}:#(0|1)}:+ +}<<" - : ${(P)__var_name::=${__sp[1]}${${${#__sp}:#(0|1)}:+ +}} - - if (( ${#__sp} >= 2 )); then - __var_name="${__the_hash_name}[${__}-opt-arg-action]" - →chroma/main-chroma-print "${(r:70:: :):-${__var_name}} := >>${__sp[2]}<<}" - : ${(P)__var_name::=$__sp[2]} - fi - done - done -} - -# Processes given token -→chroma/main-process-token.ch() { - local __subcmd="$1" __wrd="$2" __val __var_name __main_hash_name __the_hash_name __i __size - local -a __splitted __split __added - - →chroma/main-chroma-print "\n******************* Starting →chroma/main-process-token <<$__wrd>>// subcmd:${(qq)__subcmd}" - __main_hash_name="fsh__chroma__main__${${FAST_HIGHLIGHT[chroma-current]//[^a-zA-Z0-9_]/_}//(#b)([\#\^\*])/${map[${match[1]}]}}" - __var_name="${__main_hash_name}[subcmd:$__subcmd]" - __splitted=( "${(@s://:P)__var_name}" ) - [[ ${#__splitted} -eq 1 && -z "${__splitted[1]}" ]] && __splitted=() - __splitted=( "${__splitted[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) - - →chroma/main-chroma-print -rl -- "[B] MAIN-PROCESS-TOKEN: got [OPTION/ARG-**S-E-T-S**] //-splitted from subcmd:$__subcmd: ${${(j:, :)__splitted}:-EMPTY-SET!}" "----- __splitted\\Deleted: -----" ${${(j:, :)${__splitted[@]:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})}}:-EMPTY-SET (deleted)!} "----- Added\\Deleted: -----" ${${(j:, :)${${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})}}:-EMPTY-SET (added)!} -----\ Deleted:\ ----- ${(j:, :)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}} >> /tmp/reply - - (( ! ${#__splitted} )) && { - __var_name="${__main_hash_name}[subcmd:*]" - __splitted=( "${(@s://:P)__var_name}" ) - [[ ${#__splitted} -eq 1 && -z "${__splitted[1]}" ]] && __splitted=() - __splitted=( "${__splitted[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) - (( ! ${#__splitted} )) && return 1 - } - - →chroma/main-chroma-print -rl -- "---NO-HASH-CREATE-FROM-NOW-ON---" - - if [[ -z "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]}" ]]; then - →chroma/main-chroma-print -rl -- "-z OPT-WITH-ARG-ACTIVE == true" - if [[ "$__wrd" = -* ]]; then - →chroma/main-chroma-print "1st-PATH (-z opt-with-arg-active, non-opt-arg branch, i.e. OPTION BRANCH) [#${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}]" - for __val in ${__splitted[@]:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})} ${${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})}; do - [[ "${__val}" != "${__val%%_([0-9]##|\#)##*}"_${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}_opt(\*|\^|) && "${__val}" != "${__val%%_([0-9]##|\#)*}"_"#"_opt(\*|\^|) ]] && { →chroma/main-chroma-print "DIDN'T MATCH $__val / arg counter:${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}" ; continue; } || →chroma/main-chroma-print "Got candidate: $__val" - # Create the hash cache-parameter if needed - __the_hash_name="fsh__chroma__${FAST_HIGHLIGHT[chroma-current]//[^a-zA-Z0-9_]/_}__${__subcmd//[^a-zA-Z0-9_]/_}__${${__val//(#b)([\#\^\*])/${map[${match[1]}]}}//[^a-zA-Z0-9_]/_}" - [[ "$__val" = *_opt(\*|\^|) && "${(P)+__the_hash_name}" -eq 0 ]] && →chroma/main-create-OPTION-hash.ch "$__subcmd" "$__val" "$__the_hash_name" || →chroma/main-chroma-print "Not creating, the hash already exists..." - # Try dedicated-entry for the option - __var_name="${__the_hash_name}[${${${${(M)__wrd#?*=}:+${__wrd%=*}=}:-$__wrd}}-opt-action]" - __split=( "${(@s://:P)__var_name}" ) - [[ ${#__split} -eq 1 && -z "${__split[1]}" ]] && __split=() - # If no result, then try with catch-all entry - (( ! ${#__split} )) && { - →chroma/main-chroma-print "% no ${(q-)${${${(M)__wrd#?*=}:+${__wrd%=*}=}:-$__wrd}}-opt-action, retrying with *-opt-action" "|__var_name|:$__var_name" - __var_name="${__the_hash_name}[*-opt-action]" - __split=( "${(@s://:P)__var_name}" ) - [[ ${#__split} -eq 1 && -z "${__split[1]}" ]] && __split=() - } - __svalue="$__var_name" - # Remove whitespace - __split=( "${__split[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) - →chroma/main-chroma-print -l -- "\`$__val' // ${#__split} // $__wrd: (ch.run #${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr]}), deref. of \`$__var_name'" - if (( ${#__split} )); then - →chroma/main-chroma-print -l -- "Got split of {\$#__split:$#__split} ${__wrd}-opt-action or *-opt-action" "${${(q-)__split[@]}[@]/(#s)/->\\t}" - if [[ "${__split[2]}" = *[[:blank:]]+ ]]; then - →chroma/main-chroma-print "YES handling the value (the OPT.ARGUMENT)! [${__split[2]}]" - if [[ "$__wrd" = *=* ]]; then - →chroma/main-chroma-print "The-immediate Arg-Acquiring, of option" - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]="${__svalue%-opt-action\]}-opt-arg-action]" - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-arg]="${__wrd#*=}" - __have_value=2 - else - →chroma/main-chroma-print "Enable Arg-Awaiting, of option" - →chroma/main-chroma-print "FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]=\"${__svalue%-opt-action\]}-opt-arg-action]\"" - __have_value=0 - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]="${__svalue%-opt-action\]}-opt-arg-action]" - fi - fi - - __action="${__split[1]}" - __handler="${__split[2]%[[:blank:]]+}" - - # Check for directives (like :add) - if [[ "$__val" = *_opt\^ ]]; then - __var_name="${__the_hash_name}[${${${${(M)__wrd#?*=}:+${__wrd%=*}=}:-$__wrd}}:add-directive]" - (( ${(P)+__var_name} )) && __split=( "${(@s://:P)__var_name}" ) || __split=() - [[ ${#__split} -eq 1 && -z "${__split[1]}" ]] && __split[1]=() - __ivalue=${#__split} - __var_name="${__var_name%:add-*}:del-directive]" - (( ${(P)+__var_name} )) && __split+=( "${(@s://:P)__var_name}" ) - [[ ${#__split} -eq $(( __ivalue + 1 )) && -z "${__split[__ivalue+1]}" ]] && __split[__ivalue+1]=() - __split=( "${__split[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) - __tmp=${#__split} - - # First: del-directive - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]+="${(j: :)__split[__ivalue+1,__tmp]} " - - →chroma/main-chroma-print -rl ":add / :del directives: __ivalue:$__ivalue, THE __SPLIT[#$__tmp]: " "${__split[@]}" "//" "The FAST_HIGHLIGHT[chroma-*deleted-nodes]: " ${=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]} >> /tmp/reply - - # Second: add-directive - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]+="${(j: :)__split[1,__ivalue]} " - fi - [[ "$__handler" = ::[^[:space:]]* ]] && __handler="${__handler#::}" || __handler="" - [[ -n "$__handler" && "$__handler" != "NO-OP" ]] && { →chroma/main-chroma-print -rl -- "Running handler(1): $__handler" ; "$__handler" "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]:-NULL}" "$__start" "$__end" "$__wrd"; } - [[ "$__have_value" -ne 2 && -n "$__action" && "$__action" != "NO-OP" ]] && { →chroma/main-chroma-print -rl "Running action (1): $__action" ; eval "() { $__action; }"; } - [[ "$__val" != *\* ]] && break - else - →chroma/main-chroma-print -rl -- "NO-MATCH ROUTE TAKEN" - fi - done - else - →chroma/main-chroma-print "1st-PATH-B (-z opt-with-arg-active, non-opt-arg branch, ARGUMENT BRANCH [#${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}]) //// added-nodes: ${=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}" - for __val in ${__splitted[@]:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})} ${${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})}; do - [[ "${__val}" != "${__val%%_([0-9]##|\#)*}"_"${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}"_arg(\*|\^|) && "${__val}" != "${__val%%_([0-9]##|\#)*}"_"#"_arg(\*|\^|) ]] && { →chroma/main-chroma-print "Continuing for $__val / arg counter ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}" ; continue } - # Create the hash cache-parameter if needed - __the_hash_name="fsh__chroma__${FAST_HIGHLIGHT[chroma-current]//[^a-zA-Z0-9_]/_}__${__subcmd//[^a-zA-Z0-9_]/_}__${${__val//\#/H}//[^a-zA-Z0-9_]/_}" - __action="" __handler="" - →chroma/main-chroma-print "A hit, chosen __val:$__val!" - __ch_def_name="fsh__${__chroma_name}__chroma__def[$__val]" - __split=( "${(P@s:<<>>:)__ch_def_name}" ) - __split=( "${__split[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) - - __sp=( "${(@s://:)__split[1]}" ) - __sp=( "${__sp[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) - __action="${__sp[1]#*::::: ##}" - - # Verify if it's the expected argument - [[ "${__sp[1]}" = *:::::* && "$__wrd" != ${~${__sp[1]%% ##:::::*}} ]] && \ - { →chroma/main-chroma-print -r "mismatch ${__sp[1]%% ##:::::*} != $__wrd, continuing" ; continue; } - - →chroma/main-chroma-print -l -- "Got action record for $__val, i.e. the split:" "${__sp[@]//(#s)/-\t}" "_________" - - [[ "${__sp[2]}" = ::[^[:space:]]* ]] && __handler="${__sp[2]#::}" || { [[ -n "$__handler" && "$__handler" != "NO-OP" ]] && →chroma/main-chroma-print "=== Error === In chroma definition: a handler entry ${(q)__sp[2]} without leading \`::'" ; } - [[ -n "$__handler" && "$__handler" != "NO-OP" ]] && { →chroma/main-chroma-print -rl -- "Running handler(3): $__handler" ; "$__handler" "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]:-NULL}" "$__start" "$__end" "$__wrd"; } - [[ -n "$__action" && "$__action" != "NO-OP" ]] && { →chroma/main-chroma-print -rl -- "Running action(3): $__action" ; eval "() { $__action; } \"${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]:-NULL}\" \"$__start\" \"$__end\" \"$__wrd\""; } - - # Check for argument directives (like :add) - if (( ${#__split} >= 2 )); then - for __ in "${(@)__split[2,-1]}"; do - __splitted=( "${(@s://:)__}" ) - if [[ "${__splitted[1]}" = add:* ]]; then - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]+="${__splitted[1]#add:} ${(j: :)__splitted[2,-1]} " - elif [[ "${__splitted[1]}" = del:* ]]; then - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]+="${__splitted[1]#del:} ${(j: :)__splitted[2,-1]} " - fi - done - →chroma/main-chroma-print -l "ARGUMENT :add / :del directives: THE __SPLIT[#${#__split}]: " "${__split[@]//(#s)/-\\t}" "//" "The FAST_HIGHLIGHT[chroma-*deleted-nodes]: " ${(@)${=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}//(#s)/-\\t} "The FAST_HIGHLIGHT[chroma-*added-nodes]: " ${(@)${=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}//(#s)/-\\t} - fi - - [[ "$__val" != *\* ]] && break - done - fi - else - →chroma/main-chroma-print -- "2nd-PATH (-n opt-with-arg-active) NON-EMPTY arg-active:\nThe actual opt-val <<< \$__wrd:$__wrd >>> store (after the \`Arg-Awaiting' in the chroma-run: #$(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr]-1 )) [current: #$(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr] ))])" - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-arg]="$__wrd" - __have_value=1 - fi - - # Execute the action if not during simulated opt-argument (--opt=...) - →chroma/main-chroma-print "** BEFORE: \`if (( __have_value ))'" - if (( __have_value )); then - →chroma/main-chroma-print "In the \`if (( __have_value ))' [have_value: $__have_value]" - # Split - __var_name="${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]}" - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]="" - __split=( "${(@s://:P)__var_name}" ) - [[ ${#__split} -eq 1 && -z "${__split[1]}" ]] && { →chroma/main-chroma-print -rl "NULL at __var_name:$__var_name" ; __split=(); } - __split=( "${__split[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) - - # Remember 1st level action - (( __have_value == 2 )) && __value="$__action" || __value="" - - if (( ${#__split} )); then - →chroma/main-chroma-print -l -- "Got //-split (3, for opt-ARG-action, from [$__var_name]):" "${${(q-)__split[@]}[@]/(#s)/+\\t}" - __action="${__split[1]}" - __handler="${__split[2]}" - [[ "$__handler" = ::[^[:space:]]* ]] && __handler="${__handler#::}" - - [[ -n "$__handler" && "$__handler" != "NO-OP" ]] && { →chroma/main-chroma-print -rl -- "Running handler(2): $__handler" ; "$__handler" "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]:-NULL}" "$__start" "$__end" "$__wrd"; } - [[ -n "$__action" && "$__action" != "NO-OP" ]] && { →chroma/main-chroma-print -rl -- "Running action(2): $__action" ; eval "$__action"; } - →chroma/main-chroma-print -rl -- "The __action value: [$__value]" - [[ "$__have_value" -eq 2 && -n "$__value" && "$__value" != "NO-OP" ]] && { →chroma/main-chroma-print -rl "Running action (of 1, at 2): $__value" ; eval "$__value"; } - fi - fi - →chroma/main-chroma-print -- "_________ Exiting →chroma/main-process-token.ch $__subcmd / $__wrd _________" -} - -# Iterates over the chroma def. fields and creates initial -# fields in the fsh__${__chroma_name}__chroma__def hash -→chroma/-pre_process_chroma_def.ch() { - local __key __value __ke _val __the_hash_name="$1" __var_name - local -a __split - - →chroma/main-chroma-print -rl -- "Starting PRE_PROCESS for __the_hash_name:$__the_hash_name" - - __ch_def_name="fsh__${__chroma_name}__chroma__def[subcommands]" - local __subcmds="${(P)__ch_def_name}" - if [[ "$__subcmds" = "::"* ]]; then - ${__subcmds#::} - __var_name="${__the_hash_name}[subcommands]" - : ${(P)__var_name::=(${(j:|:)reply})} - else - __var_name="${__the_hash_name}[subcommands]" - : ${(P)__var_name::=$__subcmds} - fi - →chroma/main-chroma-print "Got SUBCOMMANDS: ${(P)__var_name}" - - __ch_def_name="fsh__${__chroma_name}__chroma__def[subcmd-hook]" - local __subcmd_hook="${(P)__ch_def_name}" - if [[ -n "$__subcmd_hook" ]]; then - __var_name="${__the_hash_name}[subcmd-hook]" - : ${(P)__var_name::=$__subcmd_hook} - fi - - __ch_def_name="fsh__${__chroma_name}__chroma__def[(I)subcmd:*]" - for __key in "${(P@)__ch_def_name}"; do - __split=( "${(@s:|:)${${__key##subcmd:\((#c0,1)}%\)}}" ) - [[ ${#__split} -eq 1 && -z "${__split[1]}" ]] && __split=() - __split=( "${__split[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) - for __ke in "${__split[@]}"; do - __var_name="${__the_hash_name}[subcmd:$__ke]" - __ch_def_name="fsh__${__chroma_name}__chroma__def[$__key]" - : ${(P)__var_name::=${(P)__ch_def_name}} - →chroma/main-chroma-print -rl -- "Storred ${__var_name}=chroma_def[$__key], i.e. = ${(P)__ch_def_name}" - done - done -} - -if (( __first_call )); then - →chroma/-${__chroma_name}-first-call - FAST_HIGHLIGHT[chroma-current]="$__wrd" - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]=0 - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-got-subcommand]=0 - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]="" - FAST_HIGHLIGHT[chrome-${FAST_HIGHLIGHT[chroma-current]}-occurred-double-hyphen]=0 - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]="" - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-arg]="" - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr]=1 - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]="" - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]="" - __the_hash_name="fsh__chroma__main__${${FAST_HIGHLIGHT[chroma-current]//[^a-zA-Z0-9_]/_}//(#b)([\#\^])/${map[${match[1]}]}}" - (( 0 == ${(P)+__the_hash_name} )) && { - typeset -gA "$__the_hash_name" - →chroma/-pre_process_chroma_def.ch "$__the_hash_name" - } || →chroma/main-chroma-print "...No... [\${+$__the_hash_name} ${(P)+__the_hash_name}]" - return 1 -else - (( ++ FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr] )) - # Following call, i.e. not the first one - - # Check if chroma should end – test if token is of type - # "starts new command", if so pass-through – chroma ends - [[ "$__arg_type" = 3 ]] && return 2 - - →chroma/main-chroma-print "== @@ Starting @@ #${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr]} Main-Chroma-call == // << __WORD:$__wrd >> ## Subcommand: ${${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]}:-NULL} //@@// -n option-with-arg-active:${(q-)FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]}" - if [[ "$__wrd" = -* || -n "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]}" - ]]; then - →chroma/main-chroma-print "## The \`if -*' i.e. \`IF OPTION' MAIN branch" - →chroma/main-process-token.ch "${${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]}:-NULL}" "$__wrd" - else - # If at e.g. '>' or destination/source spec (of the redirection) - if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then - return 1 - elif (( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-got-subcommand] == 0 )) { - __the_hash_name="fsh__chroma__main__${${FAST_HIGHLIGHT[chroma-current]//[^a-zA-Z0-9_]/_}//(#b)([\#\^])/${map[${match[1]}]}}" - __var_name="${__the_hash_name}[subcommands]" - if [[ "$__wrd" = ${(P)~__var_name} ]]; then - →chroma/main-chroma-print "GOT-SUBCOMMAND := $__wrd, subcmd verification / OK" - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-got-subcommand]=1 - FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]="$__wrd" - __var_name="${__the_hash_name}[subcmd-hook]" - (( ${(P)+__var_name} )) && { →chroma/main-chroma-print -r -- "Running subcmd-hook: ${(P)__var_name}" ; "${(P)__var_name}" "$__wrd"; } - __style="${FAST_THEME_NAME}subcommand" - else - →chroma/main-chroma-print "subcmd verif / NOT OK; Incrementing the COUNTER-ARG ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]} -> $(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg] + 1 ))" >> /tmp/fsh-dbg - (( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg] += 1 )) - →chroma/main-chroma-print "UNRECOGNIZED ARGUMENT ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}" - →chroma/main-process-token.ch "${${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]}:-NULL}" "$__wrd" - fi - } else { - __wrd="${__wrd//\`/x}" - __arg="${__arg//\`/x}" - __wrd="${(Q)__wrd}" - - local __tmp_def_name="fsh__${__chroma_name}__chroma__def[subcommands-blacklist]" - if [[ ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]} = \ - (${(~j:|:)${(@s:,:)${(PA)__tmp_def_name}}}) - ]] { - return 1 - } - - →chroma/main-chroma-print "Incrementing the COUNTER-ARG ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]} -> $(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg] + 1 ))" - (( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg] += 1 )) - →chroma/main-chroma-print "ARGUMENT ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}" - - →chroma/main-chroma-print "ELSE *-got-subcommand == 1 is TRUE" - →chroma/main-process-token.ch "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]}" "$__wrd" - } - fi -fi - - -# Add region_highlight entry (via `reply' array) -if [[ -n "$__style" ]]; then - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ - && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") -fi - -# We aren't passing-through, do obligatory things ourselves -(( this_word = next_word )) -_start_pos=$_end_pos - -return 0 - -# vim:ft=zsh:et:sw=4 diff --git a/.config/zsh/.zsh/git-completion.bash b/.config/zsh/.zsh/git-completion.bash deleted file mode 100644 index 1ed0362..0000000 --- a/.config/zsh/.zsh/git-completion.bash +++ /dev/null @@ -1,3516 +0,0 @@ -# bash/zsh completion support for core Git. -# -# Copyright (C) 2006,2007 Shawn O. Pearce -# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). -# Distributed under the GNU General Public License, version 2.0. -# -# The contained completion routines provide support for completing: -# -# *) local and remote branch names -# *) local and remote tag names -# *) .git/remotes file names -# *) git 'subcommands' -# *) git email aliases for git-send-email -# *) tree paths within 'ref:path/to/file' expressions -# *) file paths within current working directory and index -# *) common --long-options -# -# To use these routines: -# -# 1) Copy this file to somewhere (e.g. ~/.git-completion.bash). -# 2) Add the following line to your .bashrc/.zshrc: -# source ~/.git-completion.bash -# 3) Consider changing your PS1 to also show the current branch, -# see git-prompt.sh for details. -# -# If you use complex aliases of form '!f() { ... }; f', you can use the null -# command ':' as the first command in the function body to declare the desired -# completion style. For example '!f() { : git commit ; ... }; f' will -# tell the completion to use commit completion. This also works with aliases -# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". -# -# Compatible with bash 3.2.57. -# -# You can set the following environment variables to influence the behavior of -# the completion routines: -# -# GIT_COMPLETION_CHECKOUT_NO_GUESS -# -# When set to "1", do not include "DWIM" suggestions in git-checkout -# and git-switch completion (e.g., completing "foo" when "origin/foo" -# exists). -# -# GIT_COMPLETION_SHOW_ALL -# -# When set to "1" suggest all options, including options which are -# typically hidden (e.g. '--allow-empty' for 'git commit'). - -case "$COMP_WORDBREAKS" in -*:*) : great ;; -*) COMP_WORDBREAKS="$COMP_WORDBREAKS:" -esac - -# Discovers the path to the git repository taking any '--git-dir=' and -# '-C ' options into account and stores it in the $__git_repo_path -# variable. -__git_find_repo_path () -{ - if [ -n "${__git_repo_path-}" ]; then - # we already know where it is - return - fi - - if [ -n "${__git_C_args-}" ]; then - __git_repo_path="$(git "${__git_C_args[@]}" \ - ${__git_dir:+--git-dir="$__git_dir"} \ - rev-parse --absolute-git-dir 2>/dev/null)" - elif [ -n "${__git_dir-}" ]; then - test -d "$__git_dir" && - __git_repo_path="$__git_dir" - elif [ -n "${GIT_DIR-}" ]; then - test -d "${GIT_DIR-}" && - __git_repo_path="$GIT_DIR" - elif [ -d .git ]; then - __git_repo_path=.git - else - __git_repo_path="$(git rev-parse --git-dir 2>/dev/null)" - fi -} - -# Deprecated: use __git_find_repo_path() and $__git_repo_path instead -# __gitdir accepts 0 or 1 arguments (i.e., location) -# returns location of .git repo -__gitdir () -{ - if [ -z "${1-}" ]; then - __git_find_repo_path || return 1 - echo "$__git_repo_path" - elif [ -d "$1/.git" ]; then - echo "$1/.git" - else - echo "$1" - fi -} - -# Runs git with all the options given as argument, respecting any -# '--git-dir=' and '-C ' options present on the command line -__git () -{ - git ${__git_C_args:+"${__git_C_args[@]}"} \ - ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null -} - -# Removes backslash escaping, single quotes and double quotes from a word, -# stores the result in the variable $dequoted_word. -# 1: The word to dequote. -__git_dequote () -{ - local rest="$1" len ch - - dequoted_word="" - - while test -n "$rest"; do - len=${#dequoted_word} - dequoted_word="$dequoted_word${rest%%[\\\'\"]*}" - rest="${rest:$((${#dequoted_word}-$len))}" - - case "${rest:0:1}" in - \\) - ch="${rest:1:1}" - case "$ch" in - $'\n') - ;; - *) - dequoted_word="$dequoted_word$ch" - ;; - esac - rest="${rest:2}" - ;; - \') - rest="${rest:1}" - len=${#dequoted_word} - dequoted_word="$dequoted_word${rest%%\'*}" - rest="${rest:$((${#dequoted_word}-$len+1))}" - ;; - \") - rest="${rest:1}" - while test -n "$rest" ; do - len=${#dequoted_word} - dequoted_word="$dequoted_word${rest%%[\\\"]*}" - rest="${rest:$((${#dequoted_word}-$len))}" - case "${rest:0:1}" in - \\) - ch="${rest:1:1}" - case "$ch" in - \"|\\|\$|\`) - dequoted_word="$dequoted_word$ch" - ;; - $'\n') - ;; - *) - dequoted_word="$dequoted_word\\$ch" - ;; - esac - rest="${rest:2}" - ;; - \") - rest="${rest:1}" - break - ;; - esac - done - ;; - esac - done -} - -# The following function is based on code from: -# -# bash_completion - programmable completion functions for bash 3.2+ -# -# Copyright © 2006-2008, Ian Macdonald -# © 2009-2010, Bash Completion Maintainers -# -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# The latest version of this software can be obtained here: -# -# http://bash-completion.alioth.debian.org/ -# -# RELEASE: 2.x - -# This function can be used to access a tokenized list of words -# on the command line: -# -# __git_reassemble_comp_words_by_ref '=:' -# if test "${words_[cword_-1]}" = -w -# then -# ... -# fi -# -# The argument should be a collection of characters from the list of -# word completion separators (COMP_WORDBREAKS) to treat as ordinary -# characters. -# -# This is roughly equivalent to going back in time and setting -# COMP_WORDBREAKS to exclude those characters. The intent is to -# make option types like --date= and : easy to -# recognize by treating each shell word as a single token. -# -# It is best not to set COMP_WORDBREAKS directly because the value is -# shared with other completion scripts. By the time the completion -# function gets called, COMP_WORDS has already been populated so local -# changes to COMP_WORDBREAKS have no effect. -# -# Output: words_, cword_, cur_. - -__git_reassemble_comp_words_by_ref() -{ - local exclude i j first - # Which word separators to exclude? - exclude="${1//[^$COMP_WORDBREAKS]}" - cword_=$COMP_CWORD - if [ -z "$exclude" ]; then - words_=("${COMP_WORDS[@]}") - return - fi - # List of word completion separators has shrunk; - # re-assemble words to complete. - for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do - # Append each nonempty word consisting of just - # word separator characters to the current word. - first=t - while - [ $i -gt 0 ] && - [ -n "${COMP_WORDS[$i]}" ] && - # word consists of excluded word separators - [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] - do - # Attach to the previous token, - # unless the previous token is the command name. - if [ $j -ge 2 ] && [ -n "$first" ]; then - ((j--)) - fi - first= - words_[$j]=${words_[j]}${COMP_WORDS[i]} - if [ $i = $COMP_CWORD ]; then - cword_=$j - fi - if (($i < ${#COMP_WORDS[@]} - 1)); then - ((i++)) - else - # Done. - return - fi - done - words_[$j]=${words_[j]}${COMP_WORDS[i]} - if [ $i = $COMP_CWORD ]; then - cword_=$j - fi - done -} - -if ! type _get_comp_words_by_ref >/dev/null 2>&1; then -_get_comp_words_by_ref () -{ - local exclude cur_ words_ cword_ - if [ "$1" = "-n" ]; then - exclude=$2 - shift 2 - fi - __git_reassemble_comp_words_by_ref "$exclude" - cur_=${words_[cword_]} - while [ $# -gt 0 ]; do - case "$1" in - cur) - cur=$cur_ - ;; - prev) - prev=${words_[$cword_-1]} - ;; - words) - words=("${words_[@]}") - ;; - cword) - cword=$cword_ - ;; - esac - shift - done -} -fi - -# Fills the COMPREPLY array with prefiltered words without any additional -# processing. -# Callers must take care of providing only words that match the current word -# to be completed and adding any prefix and/or suffix (trailing space!), if -# necessary. -# 1: List of newline-separated matching completion words, complete with -# prefix and suffix. -__gitcomp_direct () -{ - local IFS=$'\n' - - COMPREPLY=($1) -} - -# Similar to __gitcomp_direct, but appends to COMPREPLY instead. -# Callers must take care of providing only words that match the current word -# to be completed and adding any prefix and/or suffix (trailing space!), if -# necessary. -# 1: List of newline-separated matching completion words, complete with -# prefix and suffix. -__gitcomp_direct_append () -{ - local IFS=$'\n' - - COMPREPLY+=($1) -} - -__gitcompappend () -{ - local x i=${#COMPREPLY[@]} - for x in $1; do - if [[ "$x" == "$3"* ]]; then - COMPREPLY[i++]="$2$x$4" - fi - done -} - -__gitcompadd () -{ - COMPREPLY=() - __gitcompappend "$@" -} - -# Generates completion reply, appending a space to possible completion words, -# if necessary. -# It accepts 1 to 4 arguments: -# 1: List of possible completion words. -# 2: A prefix to be added to each possible completion word (optional). -# 3: Generate possible completion matches for this word (optional). -# 4: A suffix to be appended to each possible completion word (optional). -__gitcomp () -{ - local cur_="${3-$cur}" - - case "$cur_" in - --*=) - ;; - --no-*) - local c i=0 IFS=$' \t\n' - for c in $1; do - if [[ $c == "--" ]]; then - continue - fi - c="$c${4-}" - if [[ $c == "$cur_"* ]]; then - case $c in - --*=|*.) ;; - *) c="$c " ;; - esac - COMPREPLY[i++]="${2-}$c" - fi - done - ;; - *) - local c i=0 IFS=$' \t\n' - for c in $1; do - if [[ $c == "--" ]]; then - c="--no-...${4-}" - if [[ $c == "$cur_"* ]]; then - COMPREPLY[i++]="${2-}$c " - fi - break - fi - c="$c${4-}" - if [[ $c == "$cur_"* ]]; then - case $c in - *=|*.) ;; - *) c="$c " ;; - esac - COMPREPLY[i++]="${2-}$c" - fi - done - ;; - esac -} - -# Clear the variables caching builtins' options when (re-)sourcing -# the completion script. -if [[ -n ${ZSH_VERSION-} ]]; then - unset ${(M)${(k)parameters[@]}:#__gitcomp_builtin_*} 2>/dev/null -else - unset $(compgen -v __gitcomp_builtin_) -fi - -# This function is equivalent to -# -# __gitcomp "$(git xxx --git-completion-helper) ..." -# -# except that the output is cached. Accept 1-3 arguments: -# 1: the git command to execute, this is also the cache key -# 2: extra options to be added on top (e.g. negative forms) -# 3: options to be excluded -__gitcomp_builtin () -{ - # spaces must be replaced with underscore for multi-word - # commands, e.g. "git remote add" becomes remote_add. - local cmd="$1" - local incl="${2-}" - local excl="${3-}" - - local var=__gitcomp_builtin_"${cmd/-/_}" - local options - eval "options=\${$var-}" - - if [ -z "$options" ]; then - local completion_helper - if [ "$GIT_COMPLETION_SHOW_ALL" = "1" ]; then - completion_helper="--git-completion-helper-all" - else - completion_helper="--git-completion-helper" - fi - # leading and trailing spaces are significant to make - # option removal work correctly. - options=" $incl $(__git ${cmd/_/ } $completion_helper) " || return - - for i in $excl; do - options="${options/ $i / }" - done - eval "$var=\"$options\"" - fi - - __gitcomp "$options" -} - -# Variation of __gitcomp_nl () that appends to the existing list of -# completion candidates, COMPREPLY. -__gitcomp_nl_append () -{ - local IFS=$'\n' - __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" -} - -# Generates completion reply from newline-separated possible completion words -# by appending a space to all of them. -# It accepts 1 to 4 arguments: -# 1: List of possible completion words, separated by a single newline. -# 2: A prefix to be added to each possible completion word (optional). -# 3: Generate possible completion matches for this word (optional). -# 4: A suffix to be appended to each possible completion word instead of -# the default space (optional). If specified but empty, nothing is -# appended. -__gitcomp_nl () -{ - COMPREPLY=() - __gitcomp_nl_append "$@" -} - -# Fills the COMPREPLY array with prefiltered paths without any additional -# processing. -# Callers must take care of providing only paths that match the current path -# to be completed and adding any prefix path components, if necessary. -# 1: List of newline-separated matching paths, complete with all prefix -# path components. -__gitcomp_file_direct () -{ - local IFS=$'\n' - - COMPREPLY=($1) - - # use a hack to enable file mode in bash < 4 - compopt -o filenames +o nospace 2>/dev/null || - compgen -f /non-existing-dir/ >/dev/null || - true -} - -# Generates completion reply with compgen from newline-separated possible -# completion filenames. -# It accepts 1 to 3 arguments: -# 1: List of possible completion filenames, separated by a single newline. -# 2: A directory prefix to be added to each possible completion filename -# (optional). -# 3: Generate possible completion matches for this word (optional). -__gitcomp_file () -{ - local IFS=$'\n' - - # XXX does not work when the directory prefix contains a tilde, - # since tilde expansion is not applied. - # This means that COMPREPLY will be empty and Bash default - # completion will be used. - __gitcompadd "$1" "${2-}" "${3-$cur}" "" - - # use a hack to enable file mode in bash < 4 - compopt -o filenames +o nospace 2>/dev/null || - compgen -f /non-existing-dir/ >/dev/null || - true -} - -# Execute 'git ls-files', unless the --committable option is specified, in -# which case it runs 'git diff-index' to find out the files that can be -# committed. It return paths relative to the directory specified in the first -# argument, and using the options specified in the second argument. -__git_ls_files_helper () -{ - if [ "$2" == "--committable" ]; then - __git -C "$1" -c core.quotePath=false diff-index \ - --name-only --relative HEAD -- "${3//\\/\\\\}*" - else - # NOTE: $2 is not quoted in order to support multiple options - __git -C "$1" -c core.quotePath=false ls-files \ - --exclude-standard $2 -- "${3//\\/\\\\}*" - fi -} - - -# __git_index_files accepts 1 or 2 arguments: -# 1: Options to pass to ls-files (required). -# 2: A directory path (optional). -# If provided, only files within the specified directory are listed. -# Sub directories are never recursed. Path must have a trailing -# slash. -# 3: List only paths matching this path component (optional). -__git_index_files () -{ - local root="$2" match="$3" - - __git_ls_files_helper "$root" "$1" "${match:-?}" | - awk -F / -v pfx="${2//\\/\\\\}" '{ - paths[$1] = 1 - } - END { - for (p in paths) { - if (substr(p, 1, 1) != "\"") { - # No special characters, easy! - print pfx p - continue - } - - # The path is quoted. - p = dequote(p) - if (p == "") - continue - - # Even when a directory name itself does not contain - # any special characters, it will still be quoted if - # any of its (stripped) trailing path components do. - # Because of this we may have seen the same directory - # both quoted and unquoted. - if (p in paths) - # We have seen the same directory unquoted, - # skip it. - continue - else - print pfx p - } - } - function dequote(p, bs_idx, out, esc, esc_idx, dec) { - # Skip opening double quote. - p = substr(p, 2) - - # Interpret backslash escape sequences. - while ((bs_idx = index(p, "\\")) != 0) { - out = out substr(p, 1, bs_idx - 1) - esc = substr(p, bs_idx + 1, 1) - p = substr(p, bs_idx + 2) - - if ((esc_idx = index("abtvfr\"\\", esc)) != 0) { - # C-style one-character escape sequence. - out = out substr("\a\b\t\v\f\r\"\\", - esc_idx, 1) - } else if (esc == "n") { - # Uh-oh, a newline character. - # We cannot reliably put a pathname - # containing a newline into COMPREPLY, - # and the newline would create a mess. - # Skip this path. - return "" - } else { - # Must be a \nnn octal value, then. - dec = esc * 64 + \ - substr(p, 1, 1) * 8 + \ - substr(p, 2, 1) - out = out sprintf("%c", dec) - p = substr(p, 3) - } - } - # Drop closing double quote, if there is one. - # (There is not any if this is a directory, as it was - # already stripped with the trailing path components.) - if (substr(p, length(p), 1) == "\"") - out = out substr(p, 1, length(p) - 1) - else - out = out p - - return out - }' -} - -# __git_complete_index_file requires 1 argument: -# 1: the options to pass to ls-file -# -# The exception is --committable, which finds the files appropriate commit. -__git_complete_index_file () -{ - local dequoted_word pfx="" cur_ - - __git_dequote "$cur" - - case "$dequoted_word" in - ?*/*) - pfx="${dequoted_word%/*}/" - cur_="${dequoted_word##*/}" - ;; - *) - cur_="$dequoted_word" - esac - - __gitcomp_file_direct "$(__git_index_files "$1" "$pfx" "$cur_")" -} - -# Lists branches from the local repository. -# 1: A prefix to be added to each listed branch (optional). -# 2: List only branches matching this word (optional; list all branches if -# unset or empty). -# 3: A suffix to be appended to each listed branch (optional). -__git_heads () -{ - local pfx="${1-}" cur_="${2-}" sfx="${3-}" - - __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ - "refs/heads/$cur_*" "refs/heads/$cur_*/**" -} - -# Lists branches from remote repositories. -# 1: A prefix to be added to each listed branch (optional). -# 2: List only branches matching this word (optional; list all branches if -# unset or empty). -# 3: A suffix to be appended to each listed branch (optional). -__git_remote_heads () -{ - local pfx="${1-}" cur_="${2-}" sfx="${3-}" - - __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ - "refs/remotes/$cur_*" "refs/remotes/$cur_*/**" -} - -# Lists tags from the local repository. -# Accepts the same positional parameters as __git_heads() above. -__git_tags () -{ - local pfx="${1-}" cur_="${2-}" sfx="${3-}" - - __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ - "refs/tags/$cur_*" "refs/tags/$cur_*/**" -} - -# List unique branches from refs/remotes used for 'git checkout' and 'git -# switch' tracking DWIMery. -# 1: A prefix to be added to each listed branch (optional) -# 2: List only branches matching this word (optional; list all branches if -# unset or empty). -# 3: A suffix to be appended to each listed branch (optional). -__git_dwim_remote_heads () -{ - local pfx="${1-}" cur_="${2-}" sfx="${3-}" - local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers - - # employ the heuristic used by git checkout and git switch - # Try to find a remote branch that cur_es the completion word - # but only output if the branch name is unique - __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ - --sort="refname:strip=3" \ - "refs/remotes/*/$cur_*" "refs/remotes/*/$cur_*/**" | \ - uniq -u -} - -# Lists refs from the local (by default) or from a remote repository. -# It accepts 0, 1 or 2 arguments: -# 1: The remote to list refs from (optional; ignored, if set but empty). -# Can be the name of a configured remote, a path, or a URL. -# 2: In addition to local refs, list unique branches from refs/remotes/ for -# 'git checkout's tracking DWIMery (optional; ignored, if set but empty). -# 3: A prefix to be added to each listed ref (optional). -# 4: List only refs matching this word (optional; list all refs if unset or -# empty). -# 5: A suffix to be appended to each listed ref (optional; ignored, if set -# but empty). -# -# Use __git_complete_refs() instead. -__git_refs () -{ - local i hash dir track="${2-}" - local list_refs_from=path remote="${1-}" - local format refs - local pfx="${3-}" cur_="${4-$cur}" sfx="${5-}" - local match="${4-}" - local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers - - __git_find_repo_path - dir="$__git_repo_path" - - if [ -z "$remote" ]; then - if [ -z "$dir" ]; then - return - fi - else - if __git_is_configured_remote "$remote"; then - # configured remote takes precedence over a - # local directory with the same name - list_refs_from=remote - elif [ -d "$remote/.git" ]; then - dir="$remote/.git" - elif [ -d "$remote" ]; then - dir="$remote" - else - list_refs_from=url - fi - fi - - if [ "$list_refs_from" = path ]; then - if [[ "$cur_" == ^* ]]; then - pfx="$pfx^" - fer_pfx="$fer_pfx^" - cur_=${cur_#^} - match=${match#^} - fi - case "$cur_" in - refs|refs/*) - format="refname" - refs=("$match*" "$match*/**") - track="" - ;; - *) - for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do - case "$i" in - $match*) - if [ -e "$dir/$i" ]; then - echo "$pfx$i$sfx" - fi - ;; - esac - done - format="refname:strip=2" - refs=("refs/tags/$match*" "refs/tags/$match*/**" - "refs/heads/$match*" "refs/heads/$match*/**" - "refs/remotes/$match*" "refs/remotes/$match*/**") - ;; - esac - __git_dir="$dir" __git for-each-ref --format="$fer_pfx%($format)$sfx" \ - "${refs[@]}" - if [ -n "$track" ]; then - __git_dwim_remote_heads "$pfx" "$match" "$sfx" - fi - return - fi - case "$cur_" in - refs|refs/*) - __git ls-remote "$remote" "$match*" | \ - while read -r hash i; do - case "$i" in - *^{}) ;; - *) echo "$pfx$i$sfx" ;; - esac - done - ;; - *) - if [ "$list_refs_from" = remote ]; then - case "HEAD" in - $match*) echo "${pfx}HEAD$sfx" ;; - esac - __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ - "refs/remotes/$remote/$match*" \ - "refs/remotes/$remote/$match*/**" - else - local query_symref - case "HEAD" in - $match*) query_symref="HEAD" ;; - esac - __git ls-remote "$remote" $query_symref \ - "refs/tags/$match*" "refs/heads/$match*" \ - "refs/remotes/$match*" | - while read -r hash i; do - case "$i" in - *^{}) ;; - refs/*) echo "$pfx${i#refs/*/}$sfx" ;; - *) echo "$pfx$i$sfx" ;; # symbolic refs - esac - done - fi - ;; - esac -} - -# Completes refs, short and long, local and remote, symbolic and pseudo. -# -# Usage: __git_complete_refs [