-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ivy-rich--switch-buffer-root-and-filename is broken (report with probable fix) #53
Comments
Hi, sorry for the late reply. I'm not sure whether the original purpose of @styx00 About the columns widths, I personally prefer percentages like ivy-switch-buffer
(:columns ((ivy-rich-switch-buffer-candidate (:width 0.25))
(ivy-rich-switch-buffer-size (:width 0.05))
(ivy-rich-switch-buffer-indicators (:width 0.05 :face error :align right))
(ivy-rich-switch-buffer-major-mode (:width 0.1 :face warning))
(ivy-rich-switch-buffer-project (:width 0.15 :face success))
(ivy-rich-switch-buffer-path (:width (lambda (x)
(ivy-rich-switch-buffer-shorten-path x (ivy-rich-minibuffer-width 0.4))))))
:predicate
(lambda (cand)
(get-buffer cand)))
|
I'm not a user of (defun ivy-rich--switch-buffer-root-and-filename (candidate)
(when-let (;; (root (ivy-rich-switch-buffer-root candidate))
(dir (ivy-rich--switch-buffer-directory candidate)))
(when (bound-and-true-p projectile-mode)
(setq dir (or (file-name-directory
(or (ivy-rich--local-values
candidate 'buffer-file-truename)
""))
(file-truename dir))))
(cons ;; (expand-file-name root)
""
(expand-file-name dir)))) |
My home-baked fallback when there's no project root. (defadvice! ivy-rich-no-project-fallback (orig-fn candidate)
:around #'ivy-rich--switch-buffer-root-and-filename
(if-let ((result (funcall orig-fn candidate)))
result
(cons ""
(expand-file-name (ivy-rich--switch-buffer-directory candidate))))) |
Or like this ? (defun ivy-rich-no-project-fallback (orig-fn candidate)
(if-let ((result (funcall orig-fn candidate)))
result
(cons ""
(expand-file-name (ivy-rich--switch-buffer-directory candidate)))))
(advice-add #'ivy-rich--switch-buffer-root-and-filename
:around #'ivy-rich-no-project-fallback) |
Oh yes indeed. I am using doom emacs and |
function
ivy-rich--switch-buffer-root-and-filename
is broken. It returns alwaysnil
if the file is not part of a project (or projectile is not installed).How to reproduce: open a file like "/tmp/foo.txt" and then switch buffers with
ivy-switch-buffer
, whileivy-rich
is activated. You will see, that there is no path listed at candidatefoo.txt
.Folowing code is a try to fix this function:
The text was updated successfully, but these errors were encountered: