Skip to content

Commit

Permalink
⬇️ Adapt old pypinyin
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Nov 27, 2024
1 parent b9abdbd commit 669cf71
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 29 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Wu Zhenyu <[email protected]> Wu, Zhenyu <[email protected]>
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: fix-byte-order-marker
Expand All @@ -25,7 +25,7 @@ repos:
hooks:
- id: remove-crlf
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies:
Expand All @@ -37,23 +37,23 @@ repos:
args:
- --msg-filename
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: 2.7.3
rev: 3.0.3
hooks:
- id: editorconfig-checker
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: check-mailmap
- repo: https://github.com/rhysd/actionlint
rev: v1.6.27
rev: v1.7.4
hooks:
- id: actionlint
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
rev: 0.7.19
hooks:
- id: mdformat
additional_dependencies:
Expand All @@ -67,7 +67,7 @@ repos:
- mdformat-config
- mdformat-web
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.13.0
rev: v0.15.0
hooks:
- id: markdownlint-cli2
additional_dependencies:
Expand Down
33 changes: 10 additions & 23 deletions pinyin-completion.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -48,38 +48,25 @@ _pinyin_comp()
setopt rematchpcre

# unix file names can contain '\n', so use '\0' to separate them
local IFS=$'\0' suffix result file k v
local -i i=1
local -a files results
local IFS=$'\0' suffix='' file result k v
local -a files
if [ "$words[1]" = cd ] ; then
suffix=/
else
suffix=''
fi
# print -N use '\0' to separate outputs
for file in $(print -nN ${1:h}/*"$suffix"); do
file="${file#./}"
if [[ $file =~ [^[:ascii:]] ]]; then
files+=($file)
else
result="$file"
if [[ $result == $1* ]]; then
reply+=(${(q)file})
fi
fi
done
if (( $#files )); then
results=(${(f)$(pypinyin -fslug -sz -p= $files)})
for result in $results; do
result="$file"
if [[ $result =~ [^[:ascii:]] ]]; then
for k v in ${(kv)FUZZY} ${(kv)_punctuation_map}; do
result="${result//$k/$v}"
done
if [[ $result == $1* ]]; then
reply+=(${(q)${files[i]}})
fi
i=$((i + 1))
done
fi
result="$(pypinyin -fslug -sz -p= "$result")"
fi
if [[ $result == $1* ]]; then
reply+=(${(q)file})
fi
done
}

# pinyin-comp is performed as one part of user-expand
Expand Down

0 comments on commit 669cf71

Please sign in to comment.