Skip to content
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

Conflict with ivy-rich #7

Open
rememberYou opened this issue Mar 4, 2019 · 14 comments
Open

Conflict with ivy-rich #7

rememberYou opened this issue Mar 4, 2019 · 14 comments

Comments

@rememberYou
Copy link

rememberYou commented Mar 4, 2019

First of all, I would like to thank you for your work for the community.

Recently I tested your package and I found that when I use it, then I lose all the other information that ivy-rich can provide me. Indeed, on the left side of the image, we can see that the buffer language and other information have disappeared in favour of the icon.

2019-03-04_16 02 21

If it can help, this is how I configure ivy-rich and all-the-icons-ivy packages:

(use-package ivy-rich
  :after ivy
  :custom
  (ivy-virtual-abbreviate 'full
                          ivy-rich-switch-buffer-align-virtual-buffer t
                          ivy-rich-path-style 'abbrev)
  :config (ivy-rich-mode 1))

(use-package all-the-icons-ivy
  :after (all-the-icons ivy)
  :custom (all-the-icons-ivy-buffer-commands '(ivy-switch-buffer-other-window))
  :config
  (add-to-list 'all-the-icons-ivy-file-commands 'counsel-dired-jump)
  (add-to-list 'all-the-icons-ivy-file-commands 'counsel-find-library)
  (all-the-icons-ivy-setup))

Do you have any idea how to fix this issue?

@asok
Copy link
Owner

asok commented Apr 16, 2019

First of all, I would like to thank you for your work for the community.

Thanks for the kind words, and excuse me for responding so late.

Do you have any idea how to fix this issue?

I've quickly eyed ivy-rich package and it seems that it is also using all the icons for buffer switcher. Does it lack something from all-the-icons-ivy that you'd like to use both?

@rememberYou
Copy link
Author

rememberYou commented Apr 16, 2019

I found a way to get ride of this issue.

To keep it short, I defined a function (ivy-rich-switch-buffer-icon) that allowed me to provide the icon corresponding to the candidate concerned, and I sent it to ivy-rich-display-transformers-list for ivy-switch-buffer:

(use-package all-the-icons :defer 0.5)

(use-package ivy
  :delight
  :after ivy-rich
  :config (ivy-mode))

(use-package ivy-rich
  :defer 0.1
  :preface
  (defun ivy-rich-switch-buffer-icon (candidate)
    "Returns an icon for the candidate out of `all-the-icons'."
    (with-current-buffer
        (get-buffer candidate)
      (let ((icon (all-the-icons-icon-for-mode major-mode :height 0.9)))
        (if (symbolp icon)
            (all-the-icons-icon-for-mode 'fundamental-mode :height 0.9)
          icon))))
  :config
  (plist-put ivy-rich-display-transformers-list
             'ivy-switch-buffer
             '(:columns
               ((ivy-rich-switch-buffer-icon (:width 2))
                (ivy-rich-candidate (:width 40))
                (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 20 :face warning)))
               :predicate (lambda (cand) (get-buffer cand))))
  (ivy-rich-mode 1))

(use-package all-the-icons-ivy
  :after (all-the-icons ivy)
  :custom (all-the-icons-ivy-buffer-commands '(ivy-switch-buffer-other-window))
  :config
  (add-to-list 'all-the-icons-ivy-file-commands 'counsel-dired-jump)
  (add-to-list 'all-the-icons-ivy-file-commands 'counsel-find-library)
  (all-the-icons-ivy-setup))

However, I think that all-the-icons-ivy should prevent users from implementing the code provided above. Indeed, the purpose of this package is to provide all-the-icons for ivy.

To be honest, I didn't look at fixing this issue with all-the-icons-ivy, but I'd be happy to make a pull request if I have an idea.

Thank you again for your answer.

@hisnawi
Copy link

hisnawi commented Feb 3, 2020

Is there a resolution on this? When I installed ivy-rich I also lost the icons from all-the-icons-ivy-rich

@rememberYou
Copy link
Author

@hisnawi have you tried my solution above?

@hisnawi
Copy link

hisnawi commented Feb 3, 2020

@rememberYou I did, and it actually did work!
The problem I have though is that some files/modes reference icons from (all-the-icons-alltheicon or all-the-icons-fileicon) but those show up as "fundamental-mode" icon.
I see from your implementation that it is expected behavior?

@rememberYou
Copy link
Author

By default it will have the fundamental-mode icon, but you can make a pull request to add your mode in the repository of all-the-icon with a nice icon 🙂

Source: https://github.com/domtronn/all-the-icons.el/blob/1416f37984486a44c6c0cbe0a2c985e82f965b6b/all-the-icons.el#L518

@hisnawi
Copy link

hisnawi commented Feb 3, 2020

I am confused.
Couldn't the code you posted be modified to pull the correct icon from the corresponding package?
all-the-icons comes with these other repos for icons ((all-the-icons-alltheicon or all-the-icons-fileicon). Why limiting the icons to "all-the-icons" ones only?

@hisnawi
Copy link

hisnawi commented Feb 3, 2020

Something like this (in principle) should work but with my limited lisp knowledge I cant get it to work.
Although changing this one line in the original function to:

(let ((icon (all-the-icons-icon-for-file candidate :height 0.9)))
works on it's own.

But I want to have a function that covers both cases.
No luck so far:

  (defun ivy-rich-switch-buffer-icon (candidate)
    "Returns an icon for the candidate out of `all-the-icons'."
    (with-current-buffer
        (get-buffer candidate)
      (let ((icon (all-the-icons-icon-for-file candidate :height 0.9)))
        (if (not (symbolp icon)) icon
      (let ((icon2 (all-the-icons-icon-for-mode major-mode :height 0.9)))
        (if (symbolp icon2)
            (all-the-icons-icon-for-mode 'fundamental-mode :height 0.9)
          icon2))))))

@asok
Copy link
Owner

asok commented Feb 3, 2020

First of all I've never used ivy-rich. But isn't that a more full blown version of all-the-icons-ivy? Is there really a benefit in running both of them?

@hisnawi
Copy link

hisnawi commented Feb 3, 2020

@asok, I am not sure I understand.
all-the-icons-ivy doesn't provide the extra information when you open an Ivy buffer.
Just like @rememberYou posted in his first message from the pictures, ivy-rich provide more information about the files like (size, mode, project, path).
Are you saying all-the-icons-ivy provide that as well?
Is there an option to enable that feature?

On the other hand, I don't think ivy-rich shows icons in ivy buffers like all-the-icons-ivy does.

@hisnawi
Copy link

hisnawi commented Feb 4, 2020

Ok. this did it for me:
I know it might not be optimized, but it works.

  (defun ivy-rich-switch-buffer-icon (candidate)
    "Returns an icon for the candidate out of `all-the-icons'."
    (with-current-buffer
        (get-buffer candidate)
      (let ((icon2 (all-the-icons-icon-for-file candidate :height 0.9))
            (icon (all-the-icons-icon-for-mode major-mode :height 0.9)))
        (if (not (symbolp icon)) icon
        (if (symbolp icon2) (all-the-icons-icon-for-mode 'fundamental-mode :height 0.9)
          icon2)))))

@asok
Copy link
Owner

asok commented Feb 4, 2020

Just like @rememberYou posted in his first message from the pictures, ivy-rich provide more information about the files like (size, mode, project, path).
Are you saying all-the-icons-ivy provide that as well?

No, all-the-icons-ivy only adds the icon next to the candidates. But I see that you can add icons to ivy-rich via: https://github.com/Yevgnen/ivy-rich#1312-add-icons-for-ivy-switch-buffer

But I guess you would like the same for file switching commands?

@hisnawi
Copy link

hisnawi commented Feb 4, 2020

Correct

@hisnawi
Copy link

hisnawi commented Feb 5, 2020

With many buffers open I am seeing sluggish scrolling between buffers in the list:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants