doomemacs/modules/input/chinese/config.el
Henrik Lissner 051c31109f
feat(chinese): search anything with pinyin
- Advise orderless to use pyim-cregexp-build when using vertico
- Add it to ivy-re-builders-alist when using ivy

Close: #6482
Co-authored-by: merrickluo <merrickluo@users.noreply.github.com>
2023-02-23 02:28:38 -05:00

68 lines
1.9 KiB
EmacsLisp

;;; input/chinese/config.el -*- lexical-binding: t; -*-
(use-package! pyim
:after-call after-find-file pre-command-hook
:init
(setq pyim-dcache-directory (concat doom-cache-dir "pyim/"))
:config
(setq pyim-page-tooltip t
default-input-method "pyim")
;; allow vertico/selectrum search with pinyin
(cond ((modulep! :completion vertico)
(advice-add #'orderless-regexp :filter-return #'pyim-cregexp-build-regexp-string))
((modulep! :completion ivy)
(setq ivy-re-builders-alist '((t . pyim-cregexp-ivy))))))
(use-package! liberime
:when (modulep! +rime)
:init
(setq liberime-auto-build t
liberime-user-data-dir (file-name-concat doom-cache-dir "rime")))
(use-package! pyim-liberime
:when (modulep! +rime)
:after liberime
:config
(setq pyim-default-scheme 'rime))
(use-package! pangu-spacing
:hook (text-mode . pangu-spacing-mode)
:config
;; Always insert `real' space in org-mode.
(setq-hook! 'org-mode-hook pangu-spacing-real-insert-separtor t))
(use-package! fcitx
:after evil
:config
(when (setq fcitx-remote-command
(or (executable-find "fcitx5-remote")
(executable-find "fcitx-remote")))
(fcitx-evil-turn-on)))
(use-package! ace-pinyin
:after avy
:init (setq ace-pinyin-use-avy t)
:config (ace-pinyin-global-mode t))
;;
;;; Hacks
(defadvice! +chinese--org-html-paragraph-a (args)
"Join consecutive Chinese lines into a single long line without unwanted space
when exporting org-mode to html."
:filter-args #'org-html-paragraph
(cl-destructuring-bind (paragraph contents info) args
(let* ((fix-regexp "[[:multibyte:]]")
(fixed-contents
(replace-regexp-in-string
(concat "\\(" fix-regexp "\\) *\n *\\(" fix-regexp "\\)")
"\\1\\2"
contents)))
(list paragraph fixed-contents info))))