yuequ
1
我希望 ivy-switch-buffer
不要显示 buffer size,于是把 Yevgnen/ivy-rich: More friendly interface for ivy 里的例子微改:
(setq ivy-rich--display-transformers-list
'(ivy-switch-buffer
(:columns
(
(ivy-rich-candidate (:width 30))
;; (ivy-rich-switch-buffer-size (:width 7))
(ivy-rich-switch-buffer-indicators (:width 4 :face error :align right))
(ivy-rich-switch-buffer-major-mode (:width 12 :face warning))
(ivy-rich-switch-buffer-project (:width 15 :face success))
(ivy-rich-switch-buffer-path (:width (lambda (x) (ivy-rich-switch-buffer-shorten-path x (ivy-rich-minibuffer-width 0.3))))))
:predicate
(lambda (cand) (get-buffer cand)))))
放在 dotspacemacs/user-config
里,但是不起作用。
请问可能是哪里有问题?谢谢
文档说了
Note that you may need to disable and enable the ‘ivy-rich-mode’
again to make this variable take effect.
你大概是改的时候太晚了,ivy-rich-mode已经生效了吧。
yuequ
3
我后来去抄了spacemacs ivy-rich的部分,然后把上面改过的部分放到 :init
里,也不起作用。
是不是放错地方了…?
yuequ
5
后来在某种错误下试成功了…
(defun yuequ-dofile/init-ivy-rich ()
(use-package ivy-rich
;; if `counsel' loads after `ivy-rich', it overrides some of `ivy-rich''s
;; transformers
:after counsel
:init
(progn
(setq ivy-rich-path-style 'abbrev
ivy-virtual-abbreviate 'full)
(setq ivy-rich-display-transformers-list
'(ivy-switch-buffer
(:columns
((ivy-rich-candidate (:width 30))
;; (ivy-rich-switch-buffer-size (:width 7))
;; (ivy-rich-switch-buffer-indicators (:width 4 :face error :align right))
;; (ivy-rich-switch-buffer-major-mode (:width 12 :face warning))
;; (ivy-rich-switch-buffer-project (:width 15 :face success))
(ivy-rich-switch-buffer-path (:width (lambda (x) (ivy-rich-switch-buffer-shorten-path x (ivy-rich-minibuffer-width 0.3))))))
:predicate
(lambda (cand) (get-buffer cand)))))
)
:config
(progn
(ivy-rich-mode))))
一是要用 init-ivy-rich
,post-init-ivy-rich
不行;另一是要用 ivy-rich-display-transformers-list
而不能用 ivy-rich--display-transformers-list
。
但是这样会有 warning:
More than one init function found for package ivy-rich. Previous owner was ivy,
replacing it with layer yuequ-dofile.
yuequ
6
果然放错地方了,丢到 config.el
里就可以了