求助evil evil-leader which-key的小问题

我安装了evil ,evil-leader和which-key插件,把evil-leader的leader-key设置为SPC了,现在我有两个事情不知怎么设置: 1,在insert模式下如何设置 C-, 达到和normal模式按SPC一样的弹出which-key的效果 2,which-key弹出的一级菜单、二级菜单、三级菜单怎么改一下名字啊,如下图:

:joy: 第二个没需求

:tropical_fish: 第一个,你可以查看

1 个赞

另一种方案是使用 general.el 代替 evil-leader,您说的需求都可以满足:

  1. 请参考 README 的示例
    (general-create-definer my-leader-def
      :states '(normal insert visual emacs)
      :prefix "SPC"
      :non-normal-prefix "C-,"
    
    这样就指定了 normal state 下的 leader 键是 SPC、其余的 insert / visual /emacs state 下是 C-,。之后用这个新创建的 definer 分配键位就好:
    (my-leader-def "/" 'swiper)
    
  2. 定义键位时,可以用 :which-key 或简写 :wk 来指定 which-key 所显示的文字:
    (my-leader-def
     "y" '(:wk "youdao")
     "yv" '(youdao-dictionary-play-voice :wk "pronounce")
     "yy" '(youdao-dictionary-search-at-point :wk "search-this"))
    
8 个赞

做个标记。以后有兴趣再试一下evil。

doom-emacs那里抄过来的

;; 把 `<SPC>' 变成 `SPC'
(defvar leader-key
  (string-trim (default-value 'evil-leader/leader) "[<]+" "[>]+"))

(with-eval-after-load 'which-key
  (let ((prefix-re (regexp-opt (list leader-key))))
    (cl-pushnew `((,(format "\\`%s a\\'" prefix-re))
                  nil . "apps")
                which-key-replacement-alist)
    (cl-pushnew `((,(format "\\`%s b\\'" prefix-re))
                  nil . "buffmark")
                which-key-replacement-alist)
    (cl-pushnew `((,(format "\\`%s f\\'" prefix-re))
                  nil . "files")
                which-key-replacement-alist)
    (cl-pushnew `((,(format "\\`%s o\\'" prefix-re))
                  nil . "open")
                which-key-replacement-alist)
    (cl-pushnew `((,(format "\\`%s p\\'" prefix-re))
                  nil . "project")
                which-key-replacement-alist))
  )