Skip to content

Commit

Permalink
⚡ Use cpp-pinyin
Browse files Browse the repository at this point in the history
pypinyin is too slow.
Set cpp-pinyin as a higher priority.
When cpp-pinyin is not found, use pypinyin.
  • Loading branch information
Freed-Wu committed Nov 27, 2024
1 parent 3bd53b8 commit 8249b34
Show file tree
Hide file tree
Showing 134 changed files with 136,959 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
with:
repository: zdharma-continuum/zunit
path: zunit
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: ${{env.python-version}}
cache: ${{env.cache}}
Expand Down
16 changes: 15 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
*.zwc
/tests/_output/

.cache/
*.zwc
# cd module/
# Src/mkmakemod.sh Src/zi Makefile
!module/Src/zi/Makefile.in
COMPILED_AT
compile_commands.json
*.mdh
*.mdhs
*.mdhi
*.export
*.epro
*.pro
*.syms
15 changes: 8 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
# - id: check-added-large-files
- id: fix-byte-order-marker
- id: check-case-conflict
- id: check-shebang-scripts-are-executable
- id: check-merge-conflict
- id: trailing-whitespace
# - id: trailing-whitespace
- id: mixed-line-ending
- id: end-of-file-fixer
# - id: end-of-file-fixer
- id: detect-private-key
- id: check-symlinks
- id: check-ast
Expand All @@ -30,16 +30,17 @@ repos:
- id: codespell
additional_dependencies:
- tomli
exclude: module/(Test/|patch_cfgac.diff)
- repo: https://github.com/jorisroovers/gitlint
rev: v0.19.1
hooks:
- id: gitlint
args:
- --msg-filename
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: 3.0.3
hooks:
- id: editorconfig-checker
# - repo: https://github.com/editorconfig-checker/editorconfig-checker.python
# rev: 3.0.3
# hooks:
# - id: editorconfig-checker
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ expansions

## Dependencies

- [pypinyin](https://github.com/mozillazg/python-pinyin) `>= 0.51.0`
- [cpp-pinyin](https://github.com/wolfgitpr/cpp-pinyin/)
- [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/)
- [make](https://www.gnu.org/software/make/)
- A C compiler

Or:

- [pypinyin](https://github.com/mozillazg/python-pinyin)

## Install

Expand Down
28 changes: 28 additions & 0 deletions _zpinyin
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#compdef zpinyin
local subcommands=(
setDictionaryPath
hanziToPinyin
)

_arguments -s -S \
": :(($subcommands))" \
'*:: :->option-or-argument'

if [[ $state != option-or-argument ]]; then
return
fi
local curcontext=${curcontext%:*:*}:zpinyin-$words[1]:
case $words[1] in
setDictionaryPath)
_dirs
;;
hanziToPinyin)
_arguments -s -S \
{-t,--man_tone_style}"[Pinyin::ManTone::Style]:(0 1 2 8)" \
{-e,--error}"[Pinyin::Error]:(default ignore)" \
{-c,--candidates}"[display candidates]" \
{-v,--v_to_u}"[convert v to u]" \
":hanzi" \
":\$pinyin"
;;
esac
16 changes: 16 additions & 0 deletions module/.cvsignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Makefile
META-FAQ
config.cache
config.h
config.h.in
config.log
config.modules
config.modules.sh
config.status
configure
cscope.out
stamp-h
stamp-h.in
autom4te.cache
*.swp
.git
4 changes: 4 additions & 0 deletions module/.distfiles
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DISTFILES_SRC='
META-FAQ
configure config.h.in stamp-h.in
'
60 changes: 60 additions & 0 deletions module/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Space or Tabs?
# https://stackoverflow.com/questions/35649847/objective-reasons-for-using-spaces-instead-of-tabs-for-indentation
# https://stackoverflow.com/questions/12093748/how-to-use-tabs-instead-of-spaces-in-a-shell-script
# https://github.com/editorconfig/editorconfig-defaults/blob/master/editorconfig-defaults.json
#
# 1. What happens when I press the Tab key in my text editor?
# 2. What happens when I request my editor to indent one or more lines?
# 3. What happens when I view a file containing U+0009 HORIZONTAL TAB characters?
#
# Answers:
#
# 1. Pressing the Tab key should indent the current line (or selected lines) one additional level.
# 2. As a secondary alternative, I can also tolerate an editor that,
# like Emacs, uses this key for a context-sensitive fix-my-indentation command.
# 3. Indenting one or more lines should follow the reigning convention, if consensus is sufficiently strong; otherwise,
# I greatly prefer 2-space indentation at each level. U+0009 characters should shift subsequent characters to the next tab stop.
#
# Note: VIM users should use alternate marks [[[ and ]]] as the original ones can confuse nested substitutions, e.g.: ${${${VAR}}}
#
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et

root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.sln]
indent_style = tab

[*.{md,mdx,rst}]
trim_trailing_whitespace = false

[*.{cmd,bat}]
end_of_line = crlf

[*za-*]
end_of_line = lf

[*.{sh,bash,zsh,fish}]
end_of_line = lf

[Makefile]
indent_style = tab
indent_size = 4

[*.{py,rb}]
indent_size = 4

[*.{go,java,scala,groovy,kotlin}]
indent_style = tab
indent_size = 4

[*.{cs,csx,cake,vb,vbx}]
# Default Severity for all .NET Code Style rules below
dotnet_analyzer_diagnostic.severity = warning
166 changes: 166 additions & 0 deletions module/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
Makefile
tags
TAGS
COMPILED_AT
*.o
*.o.c
*.orig
*.a
*.so
*.dll
*.bundle
*~
.*.sw?
\#*

/META-FAQ
/config.cache
/config.h
/config.log
/config.modules
/config.modules.sh
/config.status
/config.status.lineno
/cscope.out
/stamp-h
/autom4te.cache

Config/defs.mk

CVS
.#*

Doc/help
Doc/help.txt
Doc/help/[_a-zA-Z0-9]*

Doc/intro.pdf
Doc/intro.ps
Doc/intro.a4.pdf
Doc/intro.a4.ps
Doc/intro.us.pdf
Doc/intro.us.ps
Doc/version.yo
Doc/texi2html.conf
Doc/zsh*.1
Doc/zsh.texi
Doc/zsh.info*
Doc/*.html
Doc/zsh.aux
Doc/zsh.toc
Doc/zsh.cp
Doc/zsh.cps
Doc/zsh.fn
Doc/zsh.fns
Doc/zsh.ky
Doc/zsh.kys
Doc/zsh.pg
Doc/zsh.pgs
Doc/zsh.vr
Doc/zsh.vrs
Doc/zsh.log
Doc/zsh.dvi
Doc/zsh_a4.dvi
Doc/zsh_us.dvi
Doc/zsh.tp
Doc/zsh.tps
Doc/zsh.idx
Doc/zsh_*.ps
Doc/infodir
Doc/zsh.pdf
Doc/zsh_a4.pdf
Doc/zsh_us.pdf

Doc/Zsh/modlist.yo
Doc/Zsh/modmenu.yo
Doc/Zsh/manmodmenu.yo

Etc/FAQ
Etc/FAQ.html

Src/*.epro
Src/*.export
Src/*.mdh
Src/*.mdh.tmp
Src/*.mdhi
Src/*.mdhs
Src/*.syms
Src/Makemod.in
Src/Makemod
Src/[_a-zA-Z0-9]*.pro
Src/ansi2knr
Src/bltinmods.list
Src/cscope.out
Src/libzsh.so*
Src/modules-bltin
Src/modules.index
Src/modules.index.tmp
Src/modules.stamp
Src/patchlevel.h
Src/sigcount.h
Src/signames.c
Src/signames2.c
Src/stamp-modobjs
Src/stamp-modobjs.tmp
Src/tags
Src/TAGS
Src/version.h
Src/zsh
Src/zsh.exe
Src/zshcurses.h
Src/zshpaths.h
Src/zshterm.h
Src/zshxmods.h

Src/Builtins/Makefile.in
Src/Builtins/*.export
Src/Builtins/so_locations
Src/Builtins/*.pro
Src/Builtins/*.epro
Src/Builtins/*.syms
Src/Builtins/*.mdh
Src/Builtins/*.mdhi
Src/Builtins/*.mdhs
Src/Builtins/*.mdh.tmp
Src/Builtins/rlimits.h

Src/Modules/Makefile.in
Src/Modules/*.export
Src/Modules/so_locations
Src/Modules/*.pro
Src/Modules/*.epro
Src/Modules/*.syms
Src/Modules/*.mdh
Src/Modules/*.mdhi
Src/Modules/*.mdhs
Src/Modules/*.mdh.tmp
Src/Modules/errnames.c
Src/Modules/errcount.h
Src/Modules/curses_keys.h

Src/Zle/Makefile.in
Src/Zle/*.export
Src/Zle/so_locations
Src/Zle/*.pro
Src/Zle/*.epro
Src/Zle/*.syms
Src/Zle/*.mdh
Src/Zle/*.mdhi
Src/Zle/*.mdhs
Src/Zle/*.mdh.tmp
Src/Zle/thingies.list
Src/Zle/widgets.list
Src/Zle/zle_things.h
Src/Zle/zle_widget.h

Src/zi/Makefile.in
Src/zi/zpmod.epro
Src/zi/zpmod.export
Src/zi/zpmod.mdh
Src/zi/zpmod.mdhi
Src/zi/zpmod.mdhs
Src/zi/zpmod.pro
Src/zi/zpmod.syms

Test/*.tmp
/.project
7 changes: 7 additions & 0 deletions module/.preconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/sh

set -e

autoconf
autoheader
echo >stamp-h.in
2 changes: 2 additions & 0 deletions module/Config/.cvsignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
defs.mk
*.swp
2 changes: 2 additions & 0 deletions module/Config/.distfiles
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DISTFILES_SRC='
'
6 changes: 6 additions & 0 deletions module/Config/aczshoot.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
AC_DEFUN([zsh_OOT],
[
AC_CHECK_HEADERS(stdarg.h varargs.h termios.h termio.h)
AC_TYPE_SIGNAL
AC_DEFINE([ZSH_OOT_MODULE], [], [Out-of-tree module])
])
Loading

0 comments on commit 8249b34

Please sign in to comment.