Giter Site home page Giter Site logo

all-the-icons-completion's People

Contributors

fredericgiquel avatar iyefrat avatar protesilaos avatar roshanshariff avatar stebalien avatar yilin-zhang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

all-the-icons-completion's Issues

Add corfu-margin-formatters support

It would be quite easy to add icon support for Corfu to all-the-icons-completion, in particular for the :company-kind metadata. Maybe there is interest in this? Could also be a separate package of course. See also https://github.com/jdtsmith/kind-icon.

Example:

(add-hook 'corfu-margin-formatters #'kind-example)
(add-hook 'corfu-margin-formatters #'file-example)

;; works in prog-mode buffers, if `:company-kind` metadata is available.
(defun kind-example (_metadata)
  (when-let (kind (plist-get completion-extra-properties :company-kind))
    (lambda (cand)
      (format "<%s> " (funcall kind cand)))))

;; works in eshell
(defun file-example (metadata)
  (when (eq (completion-metadata-get metadata 'category) 'file)
    (lambda (cand)
      (format "<%s> " (file-name-extension cand)))))

Probably it makes sense to add a function all-the-icons-icon-for-kind to the all-the-icons package which maps from company/lsp kinds to the icons. Or the mapping could take place here since it is a completion feature.

"Lisp nesting exceeds ‘max-lisp-eval-depth’"

Hi, after the recent updates, using all-the-icons-completions together with selectrum and marginalia gives me the following error problem when I try certain commands:

Error in post-command-hook (selectrum--update): (error "Lisp nesting exceeds ‘max-lisp-eval-depth’")

This happens e.g., when I open info and type m to select a menu item, but not with find-file or consult-buffer.

The problem appears to be caused by this commit: 055b386. If I undo it, everything starts working again.

The cases where the problem occurs all seem to involve completion candidates that do not have any associated icons: Like I said, find-file and consult-buffer are fine, and they both show icons. Commands that I've found so far trigger the error are Info-menu, projectile-find-file and consult-yank-pop, and these don't show any icons if I undo the problematic commit.

(For reference, I already posted issues to selectrum here and marginalia here, but those packages don't seem to have anything to do with the issue.)

Tags please!

Sometimes it is quite unstable to update Emacs package in a rolling way. So I usually use Melpa-Stable, nongnu, and gnu elpa repositories. If there were stable releases, I won't anymore worry about the occurrence of incompatibility after the update. Thanks.

Emacs hangs in `projectile-switch-project` when remote project not reachable

Hey,

I am using Doom Emacs with (vertico +icons) enabled. I have a projectile project that I access remotely over SSH through a (company) VPN (/sshx:VPN:/some/path). If the VPN is not enabled, I experience that Emacs hangs (i.e. no response, but C-g aborts) when I call projectile-switch-project.

If I disable +icons (or remove projectile-switch-project from marginalia-command-categories), these hangs do not occur, which brought me to your package.
Additionally, if I am connected to the VPN and call projectile-switch-project, I get first asked for a password for authinfo and then I can type and select one of the projects. Without +icons, I have to enter the passphrase only after I have selected the remote project.

Could it be that icon-fetching fails when the remote path cannot be accessed?

conflict with bibtex-actions

This is to cross-reference issuse #166 I filed in bibtex-actions. That issue is closed but I'm still unable to get icons working in that package when all-the-icons-completion is in use. It's not clear to me whether this is best filed here or there but I figured I'd check.

Allow easy customization of all-the-icons-completion-get-icon

It'd be nice if it was easier to add categories without having to fully override all-the-icons-completion-get-icon. For instance, let's assume I define a new category via marginalia like:

(add-to-list 'marginalia-command-categories
               '(eradio-play . radiostation))

If I wanted to add a custom icon for candidates of this type I'd have to:

  • Create a function spitting out the icon, something like:
(defun all-the-icons-completion-get-radiostation-icon (cand)
  "Return the icon for the candidate CAND of completion category radiostation."
  (concat (all-the-icons-octicon "megaphone" :face 'all-the-icons-completion-dir-face) " "))
  • Patch all-the-icons-completion-get-icon
@@ -55,6 +55,7 @@ defun all-the-icons-completion-get-icon
     (project-file (all-the-icons-completion-get-file-icon cand))
     (buffer (all-the-icons-completion-get-buffer-icon cand))
     (bookmark (all-the-icons-completion-get-bookmark-icon cand))
+    (radiostation (all-the-icons-completion-get-radiostation-icon cand))
     (t "")))
 
 (defun all-the-icons-completion-get-file-icon (cand)

I think it'd make things easier for users if all-the-icons-completion-get-icon consumed an alist defined as defcustom and mapping categories to functions.

Would that make sense? Happy to send a patch myself.

Thanks.

Small patches for the directory check and directory icon

Hello @iyefrat!

I have prepared two minor patches and would like to share them with you.
I copy them below. If you prefer a pull request, I will make it happen.

Use file-directory-p

From e794669fe55718d5d7346a925a5a7f4f1afa31ce Mon Sep 17 00:00:00 2001
Message-Id: <e794669fe55718d5d7346a925a5a7f4f1afa31ce.1642752720.git.info@protesilaos.com>
From: Protesilaos Stavrou <[email protected]>
Date: Fri, 21 Jan 2022 10:02:25 +0200
Subject: [PATCH] Use file-directory-p instead of string checking

---
 all-the-icons-completion.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/all-the-icons-completion.el b/all-the-icons-completion.el
index 878bc37..56bde66 100644
--- a/all-the-icons-completion.el
+++ b/all-the-icons-completion.el
@@ -53,7 +53,7 @@ (defun all-the-icons-completion-get-icon (cand cat)
 
 (defun all-the-icons-completion-get-file-icon (cand)
   "Return the icon for the candidate CAND of completion category file."
-  (cond ((string-match-p "\\/$" cand) (concat (all-the-icons-icon-for-dir cand) " "))
+  (cond ((file-directory-p cand) (concat (all-the-icons-icon-for-dir cand) " "))
         (t (concat (all-the-icons-icon-for-file cand) " "))))
 
 (defun all-the-icons-completion-get-buffer-icon (cand)
-- 
2.34.1

Add face for dir icon

From c0628787c3e5616cc29c745d6aba2900c4f28d36 Mon Sep 17 00:00:00 2001
Message-Id: <c0628787c3e5616cc29c745d6aba2900c4f28d36.1642752725.git.info@protesilaos.com>
From: Protesilaos Stavrou <[email protected]>
Date: Fri, 21 Jan 2022 10:04:59 +0200
Subject: [PATCH] Add face for directory icon

The current face definition inherits from the 'default', meaning that it
should look the same it did before.

This allows users/themes to apply the same style between
all-the-icons-completion.el, all-the-icons-dired.el, and
all-the-icons-ibuffer.el.
---
 all-the-icons-completion.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/all-the-icons-completion.el b/all-the-icons-completion.el
index 56bde66..609e147 100644
--- a/all-the-icons-completion.el
+++ b/all-the-icons-completion.el
@@ -43,6 +43,11 @@ (defgroup all-the-icons-completion nil
   :group 'convenience
   :prefix "all-the-icons-completion")
 
+(defface all-the-icons-completion-dir-face
+  '((t :inherit default))
+  "Face for the directory icon."
+  :group 'all-the-icons-faces)
+
 (defun all-the-icons-completion-get-icon (cand cat)
   "Return the icon for the candidate CAND of completion category CAT."
   (cl-case cat
@@ -53,7 +58,10 @@ (defun all-the-icons-completion-get-icon (cand cat)
 
 (defun all-the-icons-completion-get-file-icon (cand)
   "Return the icon for the candidate CAND of completion category file."
-  (cond ((file-directory-p cand) (concat (all-the-icons-icon-for-dir cand) " "))
+  (cond ((file-directory-p cand)
+         (concat
+          (all-the-icons-icon-for-dir cand :face 'all-the-icons-completion-dir-face)
+          " "))
         (t (concat (all-the-icons-icon-for-file cand) " "))))
 
 (defun all-the-icons-completion-get-buffer-icon (cand)
-- 
2.34.1

Native compiler warning

Many thanks for providing this package. When installing and native compiling with Emacs 29, the compiler nags with:

In all-the-icons-completion-completion-metadata-get:
all-the-icons-completion.el:103:33: Warning: Unused lexical variable `orig'

which is this line:

(let ((orig (get-text-property 0 'multi-category cand)))

I'm not really familiar with the code but orig isn't used in the (and cat aff) clause. Maybe the let-binding can be dropped?

Vertico-buffer extension breaks line-wrapping

Following up from my comment here, when vertico +icons is enabled in the Doom Vertico PR along with the vertico-buffer, the line spacing is broken, with each entry spanning multiple display lines.

Per @minad's comment, I tried his latest commit of vertico by unpinning the package in doom, but the issue persists.

Step by step instructions:

  1. Start from the latest commit on the vertico PR (at time of writing, this is b5cf7aa (#4664))
  2. Enable the vertico-buffer extension:
(after! vertico
  (vertico-buffer-mode))
  1. Invoke a vertico session. You should see something similar to the below screenshot.

See screenshot:
image

not show PDF icon correctly

I'm using doom-emacs with vertico +icons. When I switch buffer, the PDF icon for PDFView is not set correctly.
Screen Shot 2021-09-24 at 10 19 42 PM
However, when I invoke the find-file command, the PDF icon is displayed correctly.
Screen Shot 2021-09-24 at 10 20 13 PM

Is this issue relevant to this project? I don't even find the "pdf" text in this project.

Error: "all-the-icons-completion.elc failed to define function all-the-icons-marginalia-setup"

I just setup marginalia and all-the-icons-completion to work together, and during the load process I am recieving this error:

'apply: Autoloading file /home/user/.emacs.d/straight/build/all-the-icons-completion/all-the-icons-completion.elc failed to define function all-the-icons-marginalia-setup'

I added the icon-setup function, not sure if that is needed anymore, from here --> minad/marginalia#59 (comment)_

My configuration looks like below:

(use-package all-the-icons-completion
  :after (marginalia all-the-icons)
  :hook (marginalia-mode . all-the-icons-marginalia-setup)
  :init
  (all-the-icons-completion-mode))
(use-package marginalia
  :after all-the-icons
  :general
  (:keymaps 'minibuffer-local-map
   "M-A" 'marginalia-cycle)
  :custom
  (marginalia-max-relative-age 0)
  (marginalia-align 'right)
  :init
  (defun icon-setup ()
    (if marginalia-mode
	(advice-add 'completion-metadata-get :around 'icon-completion-metadata-get)
      (advice-remove 'completion-metadata-get 'icon-completion-metadata-get)))

  (add-hook 'marginalia-mode-hook 'icon-setup)
  (marginalia-mode))

Is there some critical step I am missing?

Missing parens in readme example

The example in the readme is missing parens. Also it would be nice if that lambda was provided as an autoloaded function in this package.

Adding image thumbnails

Hi,

I managed to get a proof of concept for adding thumbnails instead of icons when a file is an image.

I just added a clause to all-the-icons-completion-get-file-icon:

((string-match-p "png$" cand)
		 (concat (file-image-string (f-join (minibuffer-contents) cand))  " "))

with some utils to get a string with an image as a display text property:

(defun image-string (image string)
  (with-temp-buffer
	(insert-image image string)
	(buffer-string)))

(defun file-image-string (path)
  (image-string (create-image path 'png) "image"))

The result with a small image:
22-12-14_13h03_55-select

I think a proper implementation of this with image resizing and caching (a bit like dired-image does) would require it's own package. But it seems like I could reuse most of the code here. So I was wondering if you or @minad could help me get started here? I must say I am quite afraid by the all-the-icons-completion-completion-metadata-get monster function !

Cheers,

Théo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.