From cc10b3959ecfae5efc636e9703b2d60e66270321 Mon Sep 17 00:00:00 2001 From: Sinkerine Date: Tue, 6 Feb 2018 18:07:31 -0500 Subject: [PATCH] [!] manage plugins by submodules --- .gitignore | 7 +- .gitmodules | 15 ++ custom/example.zsh | 10 - custom/patches.zsh | 1 + custom/plugins/cd-gitroot | 1 + custom/plugins/example/example.plugin.zsh | 2 - custom/plugins/zce | 1 + custom/plugins/zce/zce.plugin.zsh | 1 - custom/plugins/zce/zce.zsh | 280 ---------------------- custom/plugins/zsh-autosuggestions | 1 + custom/plugins/zsh-nvm | 1 + custom/plugins/zsh-syntax-highlighting | 1 + 12 files changed, 24 insertions(+), 297 deletions(-) delete mode 100644 custom/example.zsh create mode 100644 custom/patches.zsh create mode 160000 custom/plugins/cd-gitroot delete mode 100644 custom/plugins/example/example.plugin.zsh create mode 160000 custom/plugins/zce delete mode 100644 custom/plugins/zce/zce.plugin.zsh delete mode 100644 custom/plugins/zce/zce.zsh create mode 160000 custom/plugins/zsh-autosuggestions create mode 160000 custom/plugins/zsh-nvm create mode 160000 custom/plugins/zsh-syntax-highlighting diff --git a/.gitignore b/.gitignore index b2022081a..bdb45bc2f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ -# custom files -custom/ -!custom/plugins/example -!custom/example.zsh +# examples +example/ +example.zsh # temp files directories cache/ diff --git a/.gitmodules b/.gitmodules index 31b82411b..eaed2c408 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,3 +2,18 @@ path = plugins/fz url = https://github.com/changyuheng/fz.git branch = master +[submodule "custom/plugins/zce"] + path = custom/plugins/zce + url = https://github.com/hchbaw/zce.zsh +[submodule "custom/plugins/zsh-autosuggestions"] + path = custom/plugins/zsh-autosuggestions + url = https://github.com/zsh-users/zsh-autosuggestions +[submodule "custom/plugins/zsh-nvm"] + path = custom/plugins/zsh-nvm + url = https://github.com/lukechilds/zsh-nvm +[submodule "custom/plugins/zsh-syntax-highlighting"] + path = custom/plugins/zsh-syntax-highlighting + url = https://github.com/zsh-users/zsh-syntax-highlighting +[submodule "custom/plugins/cd-gitroot"] + path = custom/plugins/cd-gitroot + url = https://github.com/mollifier/cd-gitroot diff --git a/custom/example.zsh b/custom/example.zsh deleted file mode 100644 index c505a9673..000000000 --- a/custom/example.zsh +++ /dev/null @@ -1,10 +0,0 @@ -# You can put files here to add functionality separated per file, which -# will be ignored by git. -# Files on the custom/ directory will be automatically loaded by the init -# script, in alphabetical order. - -# For example: add yourself some shortcuts to projects you often work on. -# -# brainstormr=~/Projects/development/planetargon/brainstormr -# cd $brainstormr -# diff --git a/custom/patches.zsh b/custom/patches.zsh new file mode 100644 index 000000000..516db8ba4 --- /dev/null +++ b/custom/patches.zsh @@ -0,0 +1 @@ +ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=246' diff --git a/custom/plugins/cd-gitroot b/custom/plugins/cd-gitroot new file mode 160000 index 000000000..a1d59511e --- /dev/null +++ b/custom/plugins/cd-gitroot @@ -0,0 +1 @@ +Subproject commit a1d59511eba2b99935635b2efef00f8d2363aecd diff --git a/custom/plugins/example/example.plugin.zsh b/custom/plugins/example/example.plugin.zsh deleted file mode 100644 index 406f27445..000000000 --- a/custom/plugins/example/example.plugin.zsh +++ /dev/null @@ -1,2 +0,0 @@ -# Add your own custom plugins in the custom/plugins directory. Plugins placed -# here will override ones with the same name in the main plugins directory. diff --git a/custom/plugins/zce b/custom/plugins/zce new file mode 160000 index 000000000..487f4ede9 --- /dev/null +++ b/custom/plugins/zce @@ -0,0 +1 @@ +Subproject commit 487f4ede9f31d3b7a122514c83f537bc2f988166 diff --git a/custom/plugins/zce/zce.plugin.zsh b/custom/plugins/zce/zce.plugin.zsh deleted file mode 100644 index feac4199e..000000000 --- a/custom/plugins/zce/zce.plugin.zsh +++ /dev/null @@ -1 +0,0 @@ -source ${0:A:h}/zce.zsh diff --git a/custom/plugins/zce/zce.zsh b/custom/plugins/zce/zce.zsh deleted file mode 100644 index 45f652aa9..000000000 --- a/custom/plugins/zce/zce.zsh +++ /dev/null @@ -1,280 +0,0 @@ -# vim's EasyMotion / Emacs's ace-jump-mode for zsh. - -# Author: Takeshi Banse -# License: BSD-3 - -# Thank you very much, Kim Silkebækken and winterTTr! -# I want to use the EasyMotion/ace-jump-mode in zsh. - -# Code - -zce-genh-loop-key () { - local place="$1"; shift - local keys="$1"; shift - local val="${(P)place}" - local k= l=; for k l in ${@}; do - local -i i=l; while ((i>0)); do - val="$val ${${:-${k}${keys[i]}}# }" - ((i--)) - done - : ${(P)place::=${val# }} - done -} - -zce-genh-loop () { - local succ="$1"; shift - local posstr="$1"; shift - local qchar="$1"; shift - local buffer="$1"; shift - local keyfun="$1"; shift - local keystr="$1"; shift - local -i n="$1"; shift - local -i m="$1"; shift - local a="$1"; shift - local -a as; : ${(A)as::=${(s. .)a}} - local -a kns; : ${(A)kns::=${(@)@}} - - if ((n == 0)); then - local tmp=; - ${keyfun} tmp ${keystr} ${kns[@]} - ${succ} ${qchar} $buffer ${tmp# }${a:+" "}${a} "$posstr"; return $? - elif [[ -z "$a" ]]; then - ${keyfun} a ${keystr} ${kns[@]} - ${0} ${succ} ${posstr} ${qchar} ${buffer} ${keyfun} ${keystr} \ - ${n} ${m} $a; return $? - else - local k=${as[1]}; shift as - local -i len; ((len=n $#keys)); then - zce-genh-loop "$kont" ${(j. .)ps} $c $b zce-genh-loop-key "$keys" \ - $(($#ps - $#keys + 1)) $#keys '' ' ' $#keys - else - zce-genh-loop "$kont" ${(j. .)ps} $c $b zce-genh-loop-key "$keys" \ - 0 $#keys '' ' ' $#ps - fi -} - -zce-2 () { - local c="$1" - local b="$2" - local oks="$3" - local ops="$4" - zce-2-raw "$c" "$b" "$oks" "$ops" \ - zce-move-cursor zce-keyin-loop zce-keyin-read -} - -zce-2-raw () { - setopt localoptions extendedglob - local c="$1"; shift - local b="$1"; shift - local oks="$1"; local -a ks; : ${(A)ks::=${=1}}; shift - local ops="$1"; local -a ps; : ${(A)ps::=${(Oa)${=1}}}; shift - local movecfun="$1"; shift - local keyinfun="$1"; shift - local kreadfun="$1"; shift - local -i i; ((i=$#ps)) - - if (($i==0)); then - zce-fail; return $? - elif (($i==1)); then - $movecfun $ps[1]; return $? - fi - - local -i n=1 - local null=$'\0' - local MATCH MBEGIN MEND - ${keyinfun} '' "$b" "${b//(#m)${c}/${ks[i--][1]}}" \ - "${movecfun}" "${keyinfun}" "${kreadfun}" \ - -- ${(s. .)${:-"${oks//(#m)$'\t'/$null$ps[((n++))] }$null$ps[n]"}} -} - -zce-fail () { - return -1 -} - -zce-move-cursor () { - ((CURSOR = $1 - 1)) - return 0 -} - -zce-readc () { - if [[ "${3-}" == "t" ]] && - {[[ -z "${POSTDISPLAY-}" ]] || [[ "${POSTDISPLAY-}" != *"\n"* ]]}; then - echoti cud1 - echoti cuu1 - zle reset-prompt - fi - echoti sc - echoti cud 1 - echoti hpa 0 2>/dev/null || echo -n '\x1b[1G' - echoti el - print -Pn $2 - read -s -k 1 $1 - local ret=$? - echoti hpa 0 2>/dev/null || echo -n '\x1b[1G' - echoti el - echoti rc - return $ret -} - -zce-keyin-read () { - local s=; zstyle -s ':zce:*' prompt-key s || \ - s='%{\e[1;32m%}Target key:%{\e[0m%} ' - zce-readc "$1" "$s" -} - -zce-keyin-loop () { - local -a region_highlight - local fg=; zstyle -s ':zce:*' fg fg || fg='fg=196,bold' - local bg=; zstyle -s ':zce:*' bg bg || bg='fg=black,bold' - zce-keyin-loop-raw "$fg" "$bg" "$@" -} - -zce-keyin-loop-raw () { - setopt localoptions extendedglob - local hispec="$1"; shift - local dimspec="$1"; shift - local key="$1"; shift - local ob="$1"; shift - local nb="$1"; shift - local movecfun="$1"; shift - local keyinfun="$1"; shift - local kreadfun="$1"; shift - shift; # dashdash - - local -i c=0; ((c=$#@)) - if ((c == 0)); then - zce-fail; return -1 - elif ((c == 1)); then - zce-move-cursor ${1#*$'\0'}; return 0 - fi - - local MATCH MBEGIN MEND - if [[ -z "$key" ]]; then - BUFFER="$nb" - region_highlight=("0 $#BUFFER $dimspec") - region_highlight+=(${${@#*$'\0'}/(#m)[[:digit:]]##/$((MATCH-1)) $MATCH $hispec}) - else - nb="$ob" - local tmp; for tmp in ${(M)@:#${key}*}; do - nb[${tmp#*$'\0'}]="${${tmp%$'\0'*}[(($#key+1))]}" - done - BUFFER="$nb" - region_highlight=("0 $#BUFFER $dimspec") - region_highlight+=(${${${(M)@:#${key}*}#*$'\0'}/(#m)[[:digit:]]##/$((MATCH-1)) $MATCH $hispec}) - fi - zle -R - - local key2=; ${kreadfun} key2 && \ - ${0} $hispec $dimspec "${key}${key2}" "$ob" "$nb" \ - "$movecfun" "$keyinfun" "$kreadfun" \ - -- "${(M)@:#${key}${key2}*}" || { - zce-fail; return -1 - } -} - -with-zce () { - zmodload zsh/terminfo 2>/dev/null - setopt localoptions extendedglob braceccl - local orig_buffer="$BUFFER" - local -i orig_cursor; ((orig_cursor=CURSOR)) - ((CURSOR=$#BUFFER)); zle -R - local -a region_highlight - { - local keys=; zstyle -s ':zce:*' keys keys || \ - keys=${(j..)$(print {a-z} {A-Z})} - "$@" "$keys" || { ((CURSOR=orig_cursor)) } - } always { - BUFFER="$orig_buffer" - zle redisplay - } -} - -zce-searchin-read () { - local s=; zstyle -s ':zce:*' prompt-char s || \ - s='%{\e[1;32m%}Search for character:%{\e[0m%} ' - zce-readc "$1" "$s" t -} - -zce-raw () { - local c=; "$1" c - [[ "$c" == [[:print:]] ]] && { - zce-1 "$c" "$BUFFER" zce-2 "$2" - } -} - -zce () { with-zce zce-raw zce-searchin-read } - -zle -N zce - -# zcompiling code. - -zce-zcompile-clean () { - local d=${1:-~/.zsh/zfunc} - rm -f ${d}/zce{,zwc*(N)} -} - -zce-zcompile () { - local s=${1:?Please specify the source file itself.} - local d=${2:?Please specify the directory for the zcompiled file.} - setopt localoptions extendedglob no_shwordsplit - - echo "** zcompiling zce in ${d} for a little faster startups..." - echo "mkdir -p ${d}" | sh -x - zce-zcompile-clean - - local g=${d}/zce - echo "* writing code ${g}" - { - local - fs - : ${(A)fs::=${(Mk)functions:#(*zce*)}} - echo "#!zsh" - echo "# NOTE: Generated from zce.zsh ($0). Please DO NOT EDIT."; echo - local -a es; es=('zce-zcompile*') - echo "$(functions ${fs:#${~${(j.|.)es}}})" - echo "\nzce" - } >| ${g} - - [[ -z ${ZCE_NOZCOMPILE-} ]] || return - autoload -U zrecompile && { - echo -n "* "; zrecompile -p -R ${g} - } && { - zmodload zsh/datetime - touch --date="$(strftime "%F %T" $((EPOCHSECONDS + 10)))" ${g}.zwc - [[ -z ${ZCE_ZCOMPILE_NOKEEP-} ]] || { echo "rm -f ${g} ${g}.zwc.*" | sh -x } - echo "** All done." - echo "** Please update your .zshrc to load the zcompiled file like this," - cat <8 -- -## zce.zsh stuff. -# source ${s/$HOME/~} -autoload -w ${g}; zle -N zce -# bindkey "^Xz" zce --- 8< -- -EOT - } -} diff --git a/custom/plugins/zsh-autosuggestions b/custom/plugins/zsh-autosuggestions new file mode 160000 index 000000000..c7d4a8503 --- /dev/null +++ b/custom/plugins/zsh-autosuggestions @@ -0,0 +1 @@ +Subproject commit c7d4a85031c101ef9bce0018096622087894dd09 diff --git a/custom/plugins/zsh-nvm b/custom/plugins/zsh-nvm new file mode 160000 index 000000000..2d88fd5c8 --- /dev/null +++ b/custom/plugins/zsh-nvm @@ -0,0 +1 @@ +Subproject commit 2d88fd5c8fc0f10a3c3e2ff64ef36a02aedfd204 diff --git a/custom/plugins/zsh-syntax-highlighting b/custom/plugins/zsh-syntax-highlighting new file mode 160000 index 000000000..1f1e62929 --- /dev/null +++ b/custom/plugins/zsh-syntax-highlighting @@ -0,0 +1 @@ +Subproject commit 1f1e629290773bd6f9673f364303219d6da11129