feat(corfu): switch to nerd-icons-corfu
This removes the need to vendor the icon code.
This commit is contained in:
parent
a47da9af71
commit
a5eb58fcf3
3 changed files with 5 additions and 68 deletions
|
@ -31,6 +31,7 @@ highly non-native, but has some extra features and more maturity.
|
||||||
- [[doom-package:corfu]]
|
- [[doom-package:corfu]]
|
||||||
- [[doom-package:cape]]
|
- [[doom-package:cape]]
|
||||||
- [[doom-package:nerd-icons-completion]] if [[doom-module::completion corfu +icons]]
|
- [[doom-package:nerd-icons-completion]] if [[doom-module::completion corfu +icons]]
|
||||||
|
- [[doom-package:nerd-icons-corfu]] if [[doom-module::completion corfu +icons]]
|
||||||
- [[doom-package:orderless]] if [[doom-module::completion corfu +orderless]]
|
- [[doom-package:orderless]] if [[doom-module::completion corfu +orderless]]
|
||||||
- [[doom-package:corfu-terminal]] if [[doom-module::os tty]]
|
- [[doom-package:corfu-terminal]] if [[doom-module::os tty]]
|
||||||
- [[doom-package:yasnippet-capf]] if [[doom-module::editor snippets]]
|
- [[doom-package:yasnippet-capf]] if [[doom-module::editor snippets]]
|
||||||
|
@ -125,8 +126,6 @@ A few variables may be set to change behavior of this module:
|
||||||
- [[var:+corfu-completion-styles]] ::
|
- [[var:+corfu-completion-styles]] ::
|
||||||
Used to override [[var:completion-styles]] for corfu invocations, such that it
|
Used to override [[var:completion-styles]] for corfu invocations, such that it
|
||||||
can have a value separate from, say, [[doom-package:consult]].
|
can have a value separate from, say, [[doom-package:consult]].
|
||||||
- [[var:+corfu-icon-mapping]] ::
|
|
||||||
Configures icons used for each completion. See its documentation for details.
|
|
||||||
|
|
||||||
** Adding CAPFs to a mode
|
** Adding CAPFs to a mode
|
||||||
To add other CAPFs on a mode-per-mode basis, put either of the following in your
|
To add other CAPFs on a mode-per-mode basis, put either of the following in your
|
||||||
|
|
|
@ -6,54 +6,6 @@
|
||||||
If the user enables +orderless, `orderless' is automatically appended to this
|
If the user enables +orderless, `orderless' is automatically appended to this
|
||||||
list before fowarding to `completion-styles'.")
|
list before fowarding to `completion-styles'.")
|
||||||
|
|
||||||
(defvar +corfu-icon-mapping
|
|
||||||
`((array ,(nerd-icons-codicon "nf-cod-symbol_array") :face font-lock-type-face)
|
|
||||||
(boolean ,(nerd-icons-codicon "nf-cod-symbol_boolean") :face font-lock-builtin-face)
|
|
||||||
(class ,(nerd-icons-codicon "nf-cod-symbol_class") :face font-lock-type-face)
|
|
||||||
(color ,(nerd-icons-codicon "nf-cod-symbol_color") :face success)
|
|
||||||
(command ,(nerd-icons-codicon "nf-cod-terminal") :face default)
|
|
||||||
(constant ,(nerd-icons-codicon "nf-cod-symbol_constant") :face font-lock-constant-face)
|
|
||||||
(constructor ,(nerd-icons-codicon "nf-cod-triangle_right") :face font-lock-function-name-face)
|
|
||||||
(enummember ,(nerd-icons-codicon "nf-cod-symbol_enum_member") :face font-lock-builtin-face)
|
|
||||||
(enum-member ,(nerd-icons-codicon "nf-cod-symbol_enum_member") :face font-lock-builtin-face)
|
|
||||||
(enum ,(nerd-icons-codicon "nf-cod-symbol_enum") :face font-lock-builtin-face)
|
|
||||||
(event ,(nerd-icons-codicon "nf-cod-symbol_event") :face font-lock-warning-face)
|
|
||||||
(field ,(nerd-icons-codicon "nf-cod-symbol_field") :face font-lock-variable-name-face)
|
|
||||||
(file ,(nerd-icons-codicon "nf-cod-symbol_file") :face font-lock-string-face)
|
|
||||||
(folder ,(nerd-icons-codicon "nf-cod-folder") :face font-lock-doc-face)
|
|
||||||
(interface ,(nerd-icons-codicon "nf-cod-symbol_interface") :face font-lock-type-face)
|
|
||||||
(keyword ,(nerd-icons-codicon "nf-cod-symbol_keyword") :face font-lock-keyword-face)
|
|
||||||
(macro ,(nerd-icons-codicon "nf-cod-symbol_misc") :face font-lock-keyword-face)
|
|
||||||
(magic ,(nerd-icons-codicon "nf-cod-wand") :face font-lock-builtin-face)
|
|
||||||
(method ,(nerd-icons-codicon "nf-cod-symbol_method") :face font-lock-function-name-face)
|
|
||||||
(function ,(nerd-icons-codicon "nf-cod-symbol_method") :face font-lock-function-name-face)
|
|
||||||
(module ,(nerd-icons-codicon "nf-cod-file_submodule") :face font-lock-preprocessor-face)
|
|
||||||
(numeric ,(nerd-icons-codicon "nf-cod-symbol_numeric") :face font-lock-builtin-face)
|
|
||||||
(operator ,(nerd-icons-codicon "nf-cod-symbol_operator") :face font-lock-comment-delimiter-face)
|
|
||||||
(param ,(nerd-icons-codicon "nf-cod-symbol_parameter") :face default)
|
|
||||||
(property ,(nerd-icons-codicon "nf-cod-symbol_property") :face font-lock-variable-name-face)
|
|
||||||
(reference ,(nerd-icons-codicon "nf-cod-references") :face font-lock-variable-name-face)
|
|
||||||
(snippet ,(nerd-icons-codicon "nf-cod-symbol_snippet") :face font-lock-string-face)
|
|
||||||
(string ,(nerd-icons-codicon "nf-cod-symbol_string") :face font-lock-string-face)
|
|
||||||
(struct ,(nerd-icons-codicon "nf-cod-symbol_structure") :face font-lock-variable-name-face)
|
|
||||||
(text ,(nerd-icons-codicon "nf-cod-text_size") :face font-lock-doc-face)
|
|
||||||
(typeparameter ,(nerd-icons-codicon "nf-cod-list_unordered") :face font-lock-type-face)
|
|
||||||
(type-parameter ,(nerd-icons-codicon "nf-cod-list_unordered") :face font-lock-type-face)
|
|
||||||
(unit ,(nerd-icons-codicon "nf-cod-symbol_ruler") :face font-lock-constant-face)
|
|
||||||
(value ,(nerd-icons-codicon "nf-cod-symbol_field") :face font-lock-builtin-face)
|
|
||||||
(variable ,(nerd-icons-codicon "nf-cod-symbol_variable") :face font-lock-variable-name-face)
|
|
||||||
(t ,(nerd-icons-codicon "nf-cod-code") :face font-lock-warning-face))
|
|
||||||
"Mapping of completion kinds to icons.
|
|
||||||
|
|
||||||
It should be a list of elements with the form (KIND ICON-TXT [:face FACE]).
|
|
||||||
KIND is a symbol determining what the completion is, and comes from calling the
|
|
||||||
`:company-kind' property of the completion. ICON-TXT is a string with the icon
|
|
||||||
to use, usually as a character from the `nerd-icons' symbol font. See that
|
|
||||||
package for how to get these. Note that it can be simple text if that is
|
|
||||||
preferred. FACE, if present, is applied to the icon, mainly for its color. The
|
|
||||||
special `t' symbol should be used for KIND to represent the default icon, and
|
|
||||||
must be present.")
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;;; Packages
|
;;; Packages
|
||||||
(use-package! corfu
|
(use-package! corfu
|
||||||
|
@ -95,24 +47,8 @@ must be present.")
|
||||||
(after! evil
|
(after! evil
|
||||||
(add-hook 'evil-insert-state-exit-hook #'corfu-quit))
|
(add-hook 'evil-insert-state-exit-hook #'corfu-quit))
|
||||||
|
|
||||||
;; For the icons, we use a custom margin formatter, which simply reads the
|
|
||||||
;; mapping in `+corfu-icon-mapping'.
|
|
||||||
(when (modulep! +icons)
|
(when (modulep! +icons)
|
||||||
(defun icon-margin-formatter (metadata)
|
(add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))
|
||||||
(when-let ((kindfunc (or (plist-get completion-extra-properties :company-kind)
|
|
||||||
(assq 'company-kind metadata))))
|
|
||||||
(lambda (cand)
|
|
||||||
(let* ((kind (funcall kindfunc cand))
|
|
||||||
(icon-entry (assq (or kind t) +corfu-icon-mapping))
|
|
||||||
(str (cadr icon-entry))
|
|
||||||
(props (cddr icon-entry))
|
|
||||||
(extra-face (plist-get props :face))
|
|
||||||
(space (propertize " " 'display '(space :width 1)))
|
|
||||||
(str (concat " " str space)))
|
|
||||||
(when extra-face
|
|
||||||
(put-text-property 0 3 'face extra-face str))
|
|
||||||
str))))
|
|
||||||
(setq corfu-margin-formatters '(icon-margin-formatter)))
|
|
||||||
|
|
||||||
;; This is to decouple the use of `completion-styles' in corfu from other
|
;; This is to decouple the use of `completion-styles' in corfu from other
|
||||||
;; completion packages, such as vertico. That way, the user can leave the
|
;; completion packages, such as vertico. That way, the user can leave the
|
||||||
|
@ -175,6 +111,7 @@ Meant as :around advice for `corfu--recompute'."
|
||||||
:when (not (display-graphic-p))
|
:when (not (display-graphic-p))
|
||||||
:hook (corfu-mode . corfu-terminal-mode))
|
:hook (corfu-mode . corfu-terminal-mode))
|
||||||
|
|
||||||
|
;;
|
||||||
;;; Extensions
|
;;; Extensions
|
||||||
|
|
||||||
(use-package! corfu-history
|
(use-package! corfu-history
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
(package! corfu :recipe (:files ("*.el" "extensions/*.el")) :pin "b2b9a2312f58117514724e729fda43efc4433ecd")
|
(package! corfu :recipe (:files ("*.el" "extensions/*.el")) :pin "b2b9a2312f58117514724e729fda43efc4433ecd")
|
||||||
(package! cape :pin "116063b9ee912cbaa7318dbe6597ade4a62b3f59")
|
(package! cape :pin "116063b9ee912cbaa7318dbe6597ade4a62b3f59")
|
||||||
(when (modulep! +icons)
|
(when (modulep! +icons)
|
||||||
(package! nerd-icons-completion :pin "c2db8557a3c1a9588d111f8c8e91cae96ee85010"))
|
(package! nerd-icons-completion :pin "c2db8557a3c1a9588d111f8c8e91cae96ee85010")
|
||||||
|
(package! nerd-icons-corfu :pin "5082a22dfbdea092fcc475db3484cb3ff812b730"))
|
||||||
(when (modulep! +orderless)
|
(when (modulep! +orderless)
|
||||||
(package! orderless :pin "d6b402a89e234d0e6166247ed6025f9acc8b4d9a"))
|
(package! orderless :pin "d6b402a89e234d0e6166247ed6025f9acc8b4d9a"))
|
||||||
(when (modulep! :os tty)
|
(when (modulep! :os tty)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue