From c5f561b0c54f9adab1a133ed91d2f9cbd50eeda0 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 23 Nov 2023 16:32:04 -0500 Subject: [PATCH 01/41] bump: :core Fuco1/smartparens@79a338db115f -> Fuco1/smartparens@0778a8a84064 Wilfred/helpful@66ba816b26b6 -> Wilfred/helpful@a32a5b3d959a bbatsov/projectile@971cd5c4f25f -> bbatsov/projectile@9446ea92d284 emacs-compat/compat@ecf53005abf6 -> emacs-compat/compat@ea8de2ea18cf emacs-straight/project@ce140cdb7013 -> emacs-straight/project@f64bcf065c07 radian-software/straight.el@5e84c4e2cd8c -> radian-software/straight.el@b3760f5829db rainstormstudio/nerd-icons.el@619a0382d2e1 -> rainstormstudio/nerd-icons.el@e109d09b9570 Co-authored-by: LemonBreezes Close: #7527 --- lisp/packages.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lisp/packages.el b/lisp/packages.el index fcf692262..07c83ce38 100644 --- a/lisp/packages.el +++ b/lisp/packages.el @@ -17,11 +17,11 @@ :branch ,straight-repository-branch :local-repo "straight.el" :files ("straight*.el")) - :pin "5e84c4e2cd8ca79560477782ee4c9e5187725def") + :pin "b3760f5829dba37e855add7323304561eb57a3d4") ;; doom-ui.el (package! all-the-icons :pin "be9d5dcda9c892e8ca1535e288620eec075eb0be") -(package! nerd-icons :pin "619a0382d2e159f3142c4200fe4cfc2e89247ef1") +(package! nerd-icons :pin "e109d09b95706bb93c821b1229ca09cf00195690") (package! hide-mode-line :pin "bc5d293576c5e08c29e694078b96a5ed85631942") (package! highlight-numbers :pin "8b4744c7f46c72b1d3d599d4fb75ef8183dee307") (package! rainbow-delimiters :pin "f40ece58df8b2f0fb6c8576b527755a552a5e763") @@ -30,9 +30,9 @@ ;; doom-editor.el (package! better-jumper :pin "47622213783ece37d5337dc28d33b530540fc319") (package! dtrt-indent :pin "e0630f74f915c6cded05f76f66d66e540fcc37c3") -(package! helpful :pin "66ba816b26b68dd7df08e86f8b96eaae16c8d6a2") +(package! helpful :pin "a32a5b3d959a7fccf09a71d97b3d7c888ac31c69") (package! pcre2el :pin "018531ba0cf8e2b28d1108136a0e031b6a45f1c1") -(package! smartparens :pin "79a338db115f441cd47bb91e6f75816c5e78a772") +(package! smartparens :pin "0778a8a84064cf2bc3a9857bd0e7a4619cc1e5c3") (package! ws-butler ;; Use my fork of ws-butler, which has a few choice improvements and ;; optimizations (the original has been abandoned). @@ -40,8 +40,8 @@ :pin "572a10c11b6cb88293de48acbb59a059d36f9ba5") ;; doom-projects.el -(package! projectile :pin "971cd5c4f25ff1f84ab7e8337ffc7f89f67a1b52") -(package! project :pin "ce140cdb70138a4938c999d4606a52dbeced4676") +(package! projectile :pin "9446ea92d28462aeb37846a8be0a0c97a7bc0cee") +(package! project :pin "f64bcf065c0731caecbdcff5ca1c7f2d711b5b1e") ;; doom-keybinds.el (package! general :pin "833dea2c4a60e06fcd552b653dfc8960935c9fb4") @@ -49,4 +49,4 @@ (package! compat :recipe (:host github :repo "emacs-compat/compat") - :pin "ecf53005abf6f0325d14e0e024222e22e982c8dd") + :pin "ea8de2ea18cf7c348aadb6eb2aeb2a9d840bd064") From a180579d6f1343dac87a5794c05641b20b8eef19 Mon Sep 17 00:00:00 2001 From: LemonBreezes Date: Thu, 23 Nov 2023 17:08:14 -0500 Subject: [PATCH 02/41] bump: :term eshell Ambrevar/emacs-fish-completion@10384881817b -> Ambrevar/emacs-fish-completion@df42e1530829 akreisher/eshell-syntax-highlighting@8bf0494ca719 -> akreisher/eshell-syntax-highlighting@4ac27eec6595# Please enter the commit message for your changes. Lines starting - (#7529) Fix elisp code-completion in Eshell. Close: #7529 --- modules/term/eshell/config.el | 4 +++- modules/term/eshell/packages.el | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/term/eshell/config.el b/modules/term/eshell/config.el index 91db53186..358389add 100644 --- a/modules/term/eshell/config.el +++ b/modules/term/eshell/config.el @@ -230,7 +230,9 @@ Emacs versions < 29." (use-package eshell-syntax-highlighting - :hook (eshell-mode . eshell-syntax-highlighting-mode)) + :hook (eshell-mode . eshell-syntax-highlighting-mode) + :init + (add-hook 'eshell-syntax-highlighting-elisp-buffer-setup-hook #'highlight-quoted-mode)) (use-package! fish-completion diff --git a/modules/term/eshell/packages.el b/modules/term/eshell/packages.el index 128c16500..4bbff9fe5 100644 --- a/modules/term/eshell/packages.el +++ b/modules/term/eshell/packages.el @@ -6,8 +6,8 @@ (package! shrink-path :pin "c14882c8599aec79a6e8ef2d06454254bb3e1e41") (package! esh-help :pin "417673ed18a983930a66a6692dbfb288a995cb80") (package! eshell-did-you-mean :pin "80cd8c4b186a2fb29621cf634bcf2bcd914f1e3d") -(package! eshell-syntax-highlighting :pin "8bf0494ca71944b9d4bfb8ec3c93ea29d46bc2f9") +(package! eshell-syntax-highlighting :pin "4ac27eec6595ba116a6151dfaf0b0e0440101e10") (unless IS-WINDOWS - (package! fish-completion :pin "10384881817b5ae38cf6197a077a663420090d2c") + (package! fish-completion :pin "df42e153082927536763bdf408184152a7c938c3") (package! bash-completion :pin "f1daac0386c24cbe8a244a62c7588cc6847b07ae")) From 1bc5f441f00a06e61087e59e94e8ce1642ffeea6 Mon Sep 17 00:00:00 2001 From: LemonBreezes Date: Thu, 23 Nov 2023 17:34:57 -0500 Subject: [PATCH 03/41] tweak: helpful-set-variable-function: use setq! helpful-set-variable-function defaults to setopt if it's available, setq otherwise. `setopt` is superior for this use case because it uses custom.el's mechanism for setting variables (thus respecting custom.el's setters and type checks), however, it is unavailable in Emacs 28 and earlier (`setopt` was introduced in 29). Doom defines `setq!`, which is a drop-in replacement for setopt, and is functional in Emacs 28, so it is the better option here. Ref: #7527 --- lisp/doom-editor.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/doom-editor.el b/lisp/doom-editor.el index 9f79d7d57..2159b885c 100644 --- a/lisp/doom-editor.el +++ b/lisp/doom-editor.el @@ -584,7 +584,9 @@ current buffer." filename)) (prog1 (apply fn args) (when (buffer-live-p buf) - (with-current-buffer buf (goto-char pos))))))))) + (with-current-buffer buf (goto-char pos)))))))) + :config + (setq helpful-set-variable-function #'setq!)) (use-package! smartparens From 574cd321479ea66c0d1961da86a6969de06241a2 Mon Sep 17 00:00:00 2001 From: Zardoz <64504946+zardoz03@users.noreply.github.com> Date: Thu, 23 Nov 2023 22:55:13 +0000 Subject: [PATCH 04/41] tweak(doom-quit): make quit message OS-sensitive --- modules/ui/doom-quit/config.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/ui/doom-quit/config.el b/modules/ui/doom-quit/config.el index 89f54f7b8..3e6f69702 100644 --- a/modules/ui/doom-quit/config.el +++ b/modules/ui/doom-quit/config.el @@ -1,10 +1,13 @@ ;;; ui/doom-quit/config.el -*- lexical-binding: t; -*- (defvar +doom-quit-messages - '(;; from Doom 1 + `(;; from Doom 1 "Please don't leave, there's more demons to toast!" "Let's beat it -- This is turning into a bloodbath!" - "I wouldn't leave if I were you. DOS is much worse." + ,(format "I wouldn't leave if I were you. %s is much worse." + (if (member system-type '(ms-dos-windows-nt cygwin)) + "DOS" + "UNIX")) "Don't leave yet -- There's a demon around that corner!" "Ya know, next time you come in here I'm gonna toast ya." "Go ahead and leave. See if I care." From edd95854fd81f60a7132d830d07f4e4f22cbce89 Mon Sep 17 00:00:00 2001 From: Liam Hupfer Date: Thu, 23 Nov 2023 17:17:52 -0600 Subject: [PATCH 05/41] fix: premature use of emoji fontset in <=28.1 317cea5 assumed Emacs 28, but Doom still tries to support 27. Attempting to use the undefined emoji script on 27 results in an error. Prior to 28, emoji are part of the symbol script, which the following `set-fontset-font` call already handles. Amend: 317cea5eefda Ref: #7448 Fix: #7505 --- lisp/doom-ui.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/doom-ui.el b/lisp/doom-ui.el index 360998c66..ab5e116a3 100644 --- a/lisp/doom-ui.el +++ b/lisp/doom-ui.el @@ -546,7 +546,9 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original (dolist (script '(symbol mathematical)) (set-fontset-font t script symbol-font))) (when emoji-font - (set-fontset-font t 'emoji emoji-font) + ;; DEPRECATED: make unconditional when we drop 27 support + (when (version<= "28.1" emacs-version) + (set-fontset-font t 'emoji emoji-font)) ;; some characters in the Emacs symbol script are often covered by emoji ;; fonts (set-fontset-font t 'symbol emoji-font nil 'append))) From a00f03079ac0da2fe0af4193477d277132e3ae1e Mon Sep 17 00:00:00 2001 From: Chromium Date: Fri, 24 Nov 2023 00:32:04 +0100 Subject: [PATCH 06/41] bump: :app rss remyhonig/elfeed-org@7f3ad868f2fa -> remyhonig/elfeed-org@fe59a96969bd - fix elfeed-org-export-opml error - perf: use temporary buffers instead of find-file - replace outline-on-heading-p with org-at-heading-p - fix typo in last changes Ref: remyhonig/elfeed-org#88 --- modules/app/rss/packages.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/app/rss/packages.el b/modules/app/rss/packages.el index f78955804..f486b1729 100644 --- a/modules/app/rss/packages.el +++ b/modules/app/rss/packages.el @@ -4,4 +4,4 @@ (package! elfeed :pin "55fb162fa27e71b88effa59a83c57842e262b00f") (package! elfeed-goodies :pin "544ef42ead011d960a0ad1c1d34df5d222461a6b") (when (modulep! +org) - (package! elfeed-org :pin "7f3ad868f2fa3c17492340f7af84f208b9c25635")) + (package! elfeed-org :pin "fe59a96969bd321f5f9ec7317a4bc80943b94c86")) From 80f8b6b6802c38c3aa07bc4c428ca8fd7e9770dc Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 23 Nov 2023 18:05:01 -0500 Subject: [PATCH 07/41] bump: :editor fold emacs-tree-sitter/ts-fold@9d9e0c5cf7b5 -> emacs-tree-sitter/ts-fold@75e72c658ad8 - (#7480) Adds/enhances support for new languages. Co-authored-by: jperras Close: #7480 Ref: https://github.com/emacs-tree-sitter/ts-fold/releases/tag/0.2.0 --- modules/editor/fold/packages.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/editor/fold/packages.el b/modules/editor/fold/packages.el index 8676dbac8..032d3ed72 100644 --- a/modules/editor/fold/packages.el +++ b/modules/editor/fold/packages.el @@ -7,5 +7,5 @@ (when (modulep! :editor evil) (package! evil-vimish-fold :pin "b6e0e6b91b8cd047e80debef1a536d9d49eef31a")) (when (modulep! :tools tree-sitter) - (package! ts-fold :pin "9d9e0c5cf7b5397e06571bb6bf497598dc8796a8" + (package! ts-fold :pin "75e72c658ad8d8aac3af554a6b51b3c5c22dd0aa" :recipe (:host github :repo "emacs-tree-sitter/ts-fold"))) From 9be60fba435e41549d7e933293a25d9ede9a11c9 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 23 Nov 2023 18:06:12 -0500 Subject: [PATCH 08/41] bump: :lang scala emacs-lsp/lsp-metals@a2df7263ece6 -> emacs-lsp/lsp-metals@da7e54ed65f4 - (#7475) lsp-metals moved on from treemacs-extensions (obsolete) to treemacs-treelib. Co-authored-by: prashantvithani Close: #7475 --- modules/lang/scala/packages.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lang/scala/packages.el b/modules/lang/scala/packages.el index 8616e07ee..ba727aef4 100644 --- a/modules/lang/scala/packages.el +++ b/modules/lang/scala/packages.el @@ -6,4 +6,4 @@ (when (and (modulep! +lsp) (not (modulep! :tools lsp +eglot))) - (package! lsp-metals :pin "a2df7263ece6ac69214e41c52d66aab8d3f650eb")) + (package! lsp-metals :pin "da7e54ed65f4e153c94b9c54689908dce142ef37")) From 13fa55da8200e4482d5cb0d473762a3e08e21057 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 23 Nov 2023 18:23:08 -0500 Subject: [PATCH 09/41] bump: :lang java Groovy-Emacs-Modes/groovy-emacs-modes@c612ac1e9f74 -> Groovy-Emacs-Modes/groovy-emacs-modes@7b8520b2e2d3 emacs-lsp/lsp-java@dbe448a886e2 -> emacs-lsp/lsp-java@449673da7221 mopemope/meghanada-emacs@59c46cabb7ee -> mopemope/meghanada-emacs@fb29746e442e Co-authored-by: aveseli Close: #7554 --- modules/lang/java/packages.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/lang/java/packages.el b/modules/lang/java/packages.el index 8bbde7eaf..e9ec41e84 100644 --- a/modules/lang/java/packages.el +++ b/modules/lang/java/packages.el @@ -2,10 +2,10 @@ ;;; lang/java/packages.el (package! android-mode :pin "d5332e339a1f5e30559a53feffb8442ca79265d6") -(package! groovy-mode :pin "c612ac1e9f742856914ad6e8eb9e9dc169f489ab") +(package! groovy-mode :pin "7b8520b2e2d3ab1d62b35c426e17ac25ed0120bb") (when (modulep! +meghanada) - (package! meghanada :pin "59c46cabb7eee715fe810ce59424934a1286df84")) + (package! meghanada :pin "fb29746e442e3d7b903759d15977d142a4bf2131")) (when (modulep! +eclim) (package! eclim :pin "222ddd48fcf0ee01592dec77c58e0cf3f2ea1100") @@ -14,4 +14,4 @@ (when (modulep! +lsp) (unless (modulep! :tools lsp +eglot) - (package! lsp-java :pin "dbe448a886e2f4fb5d3a616f4499adbe643ba7a5"))) + (package! lsp-java :pin "449673da7221a30f1b1756cedcc48b9a2b52a51e"))) From c3b228fedd050d8d028aa3d4ec2c439ab4a19bad Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Sun, 15 Oct 2023 00:22:24 -0400 Subject: [PATCH 10/41] fix(treemacs): do not overwrite git mode when treemacs-python-executable is set --- modules/ui/treemacs/config.el | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/ui/treemacs/config.el b/modules/ui/treemacs/config.el index 0b8ab61ce..9f3febb6a 100644 --- a/modules/ui/treemacs/config.el +++ b/modules/ui/treemacs/config.el @@ -33,6 +33,7 @@ This must be set before `treemacs' has loaded.") (when +treemacs-git-mode ;; If they aren't supported, fall back to simpler methods (when (and (memq +treemacs-git-mode '(deferred extended)) + (not treemacs-python-executable) (not (executable-find "python3"))) (setq +treemacs-git-mode 'simple)) (treemacs-git-mode +treemacs-git-mode) From 31b2ad22fbf09d99f6c1492274e48b2ffbbf5873 Mon Sep 17 00:00:00 2001 From: Leo Okawa Ericson Date: Fri, 24 Nov 2023 02:21:08 +0000 Subject: [PATCH 11/41] fix(org): call org-reveal in correct buffer Sometimes, `org-reveal` is called in the wrong buffer which throws an error. For example, `org-link-open-from-string` creates an temporary org-mode buffer that gets killed very quickly which means that `org-reveal` gets called in a different buffer. I have also had issues with org-reveal getting called in the org-roam buffer, which is why this commit also saves the buffer it was called in. Co-authored-by: Leo Okawa Ericson --- modules/lang/org/autoload/org.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/lang/org/autoload/org.el b/modules/lang/org/autoload/org.el index 6ca2c2211..8690b1318 100644 --- a/modules/lang/org/autoload/org.el +++ b/modules/lang/org/autoload/org.el @@ -508,7 +508,11 @@ All my (performant) foldings needs are met between this and `org-show-subtree' ;; Must be done on a timer because `org-show-set-visibility' (used by ;; `org-reveal') relies on overlays that aren't immediately available ;; when `org-mode' first initializes. - (run-at-time 0.1 nil #'org-reveal '(4)))) + (let ((buf (current-buffer))) + (unless (doom-temp-buffer-p buf) + (run-at-time 0.1 nil (lambda () + (with-current-buffer buf + (org-reveal '(4))))))))) ;;;###autoload (defun +org-remove-occur-highlights-h () From cb3d01920c83904a8af0805346c460d2f4f5a698 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 23 Nov 2023 22:05:33 -0500 Subject: [PATCH 12/41] bump: :tools debugger lsp emacs-lsp/dap-mode@096070aacff8 -> emacs-lsp/dap-mode@755845ae053b emacs-lsp/lsp-mode@266945b3e470 -> emacs-lsp/lsp-mode@d441f3d268a3 emacs-straight/eglot@8ccec6532e70 -> emacs-straight/eglot@2b145778ba5e realgud/realgud@220ce2c348da -> realgud/realgud@365063ea8ce8 Fix: #7540 --- modules/tools/debugger/packages.el | 4 ++-- modules/tools/lsp/packages.el | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/tools/debugger/packages.el b/modules/tools/debugger/packages.el index b418d4d3a..208504513 100644 --- a/modules/tools/debugger/packages.el +++ b/modules/tools/debugger/packages.el @@ -1,10 +1,10 @@ ;; -*- no-byte-compile: t; -*- ;;; tools/debugger/packages.el -(when (package! realgud :pin "220ce2c348dab6cfc1cfa3c3f59644e777f9e8ff") +(when (package! realgud :pin "365063ea8ce8ec6a852cb388088d84147421c3c2") (when (modulep! :lang javascript) (package! realgud-trepan-ni :pin "0ec088ea343835e24ae73da09bea96bfb02a3130"))) (when (modulep! +lsp) - (package! dap-mode :pin "096070aacff875a09c13e596e5d60a55e0f07ab1") + (package! dap-mode :pin "755845ae053bbfdd3f7b3dca13efa4be480370b5") (package! posframe :pin "017deece88360c7297265680d78a0bb316470716")) diff --git a/modules/tools/lsp/packages.el b/modules/tools/lsp/packages.el index c4f76e1d6..8ca5f8cd5 100644 --- a/modules/tools/lsp/packages.el +++ b/modules/tools/lsp/packages.el @@ -3,13 +3,13 @@ (if (modulep! +eglot) (progn - (package! eglot :pin "8ccec6532e70f68289a06acc24437986a8a8a6c1") + (package! eglot :pin "2b145778ba5e57f393e50aea76b28e518c401828") (when (modulep! :completion vertico) (package! consult-eglot :pin "db9d41c9812a5a8a7b9a22fa7f3c314e37584d41")) (when (and (modulep! :checkers syntax) (not (modulep! :checkers syntax +flymake))) (package! flycheck-eglot :pin "9ff8d0068be59b1450964b390349d75a68af21ed"))) - (package! lsp-mode :pin "266945b3e470212305812581d24a938a96c47a3a") + (package! lsp-mode :pin "d441f3d268a31a4a514af2db506a5eec47ee617d") (package! lsp-ui :pin "0dd39900c8ed8145d207985cb2f65cedd1ffb410") (when (modulep! :completion ivy) (package! lsp-ivy :pin "9ecf4dd9b1207109802bd1882aa621eb1c385106")) From fba1d4005ee5c342cf1d974bc8700983a99f00e1 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 24 Nov 2023 10:01:45 -0500 Subject: [PATCH 13/41] bump: :tools tree-sitter emacs-tree-sitter/tree-sitter-langs@2f0f97abbd97 -> emacs-tree-sitter/tree-sitter-langs@3a3ad0527d5f meain/evil-textobj-tree-sitter@19979843f5fc -> meain/evil-textobj-tree-sitter@9a9edd42a2dc Close: #7560 Co-authored-by: l2dy --- modules/tools/tree-sitter/packages.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/tools/tree-sitter/packages.el b/modules/tools/tree-sitter/packages.el index 6b57fb998..c2f9a1ef5 100644 --- a/modules/tools/tree-sitter/packages.el +++ b/modules/tools/tree-sitter/packages.el @@ -2,9 +2,9 @@ ;;; tools/tree-sitter/packages.el (package! tree-sitter :pin "3cfab8a0e945db9b3df84437f27945746a43cc71") -(package! tree-sitter-langs :pin "2f0f97abbd97e17773a24eec3f329d262f81d020") +(package! tree-sitter-langs :pin "3a3ad0527d5f8c7768678878eb5cfe399bedf703") (package! tree-sitter-indent :pin "4ef246db3e4ff99f672fe5e4b416c890f885c09e") (when (modulep! :editor evil +everywhere) (package! evil-textobj-tree-sitter - :pin "19979843f5fc437917f9a4dae977f5e6d4793726")) + :pin "9a9edd42a2dca9dfd0bc6026d47f689fa117b90f")) From e4b1ed5a6aefb81f75a75a59f78f4b62dd2613b5 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 24 Nov 2023 10:25:34 -0500 Subject: [PATCH 14/41] refactor(eshell): eshell-prompt-regexp This new default makes eshell-prompt-regexp's consumers a little less susceptible to false positives in garbage/process output and a little more resistant to user changes to eshell-prompt-function. It's also closer to its default value (KISS). --- modules/term/eshell/config.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/term/eshell/config.el b/modules/term/eshell/config.el index 358389add..c3496ffe9 100644 --- a/modules/term/eshell/config.el +++ b/modules/term/eshell/config.el @@ -69,7 +69,7 @@ You should use `set-eshell-alias!' to change this.") ;; TODO Use `eshell-input-filter-initial-space' when Emacs 25 support is dropped eshell-input-filter (lambda (input) (not (string-match-p "\\`\\s-+" input))) ;; em-prompt - eshell-prompt-regexp "^.* λ " + eshell-prompt-regexp "^[^#$\n]* [#$λ] " eshell-prompt-function #'+eshell-default-prompt-fn ;; em-glob eshell-glob-case-insensitive t From dc16fe10e39f04ebb8e1bcf7f9befa19e9542fb6 Mon Sep 17 00:00:00 2001 From: StrawberryTea Date: Fri, 27 Oct 2023 23:23:39 -0500 Subject: [PATCH 15/41] feat(eshell): add imenu support --- modules/term/eshell/config.el | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/term/eshell/config.el b/modules/term/eshell/config.el index c3496ffe9..cf2beb9b2 100644 --- a/modules/term/eshell/config.el +++ b/modules/term/eshell/config.el @@ -105,6 +105,12 @@ You should use `set-eshell-alias!' to change this.") ;; cursor comes close to the left/right edges of the window. (setq-hook! 'eshell-mode-hook hscroll-margin 0) + ;; Recognize prompts as Imenu entries. + (setq-hook! 'eshell-mode-hook + imenu-generic-expression + `((,(propertize "λ" 'face 'eshell-prompt) + ,(concat eshell-prompt-regexp "\\(.*\\)") 1))) + ;; Don't auto-write our aliases! Let us manage our own `eshell-aliases-file' ;; or configure `+eshell-aliases' via elisp. (advice-add #'eshell-write-aliases-list :override #'ignore) From 6bea1f6a35d766dabb033b6eb461cc854df78297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20=27Vlk=27=20M=C5=BEourek?= Date: Thu, 26 Oct 2023 20:42:23 +0200 Subject: [PATCH 16/41] perf(lsp): turn off eglot events buffer The `eglot-events-buffer-size` setting disables the `eglot-events-buffer` when 0, enabling more consistent performance on long running emacs instance. Default is 2000000 lines. After each new event the events buffer is pretty printed as a whole, which causes steady performance decrease over time. Quite a bit of CPU is spent on pretty priting and Emacs GC is put under high pressure. --- modules/tools/lsp/+eglot.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/tools/lsp/+eglot.el b/modules/tools/lsp/+eglot.el index 95294f5eb..5b56b600e 100644 --- a/modules/tools/lsp/+eglot.el +++ b/modules/tools/lsp/+eglot.el @@ -16,6 +16,12 @@ (setq eglot-sync-connect 1 eglot-autoshutdown t eglot-send-changes-idle-time 0.5 + ;; NOTE This setting disable the eglot-events-buffer enabling more + ;; consistent performance on long running emacs instance. + ;; Default is 2000000 lines. After each new event the whole buffer + ;; is pretty printed which causes steady performance decrease over time. + ;; CPU is spent on pretty priting and Emacs GC is put under high pressure. + eglot-events-buffer-size 0 ;; NOTE We disable eglot-auto-display-help-buffer because :select t in ;; its popup rule causes eglot to steal focus too often. eglot-auto-display-help-buffer nil) @@ -32,7 +38,7 @@ :type-definition #'eglot-find-typeDefinition :documentation #'+eglot-lookup-documentation) - (add-to-list 'doom-debug-variables '(eglot-events-buffer-size . 0)) + (add-to-list 'doom-debug-variables '(eglot-events-buffer-size . 2000000)) (defadvice! +lsp--defer-server-shutdown-a (fn &optional server) "Defer server shutdown for a few seconds. From 5100ab121d7b3d6bee6bf06773443fe3581be308 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 24 Nov 2023 10:33:57 -0500 Subject: [PATCH 17/41] fix(upload): ssh-deploy-on-explicit-save: incorrect type According to upstream package emacs-ssh-deploy, the value 0 should disable the auto-save behavior. As the ssh-deploy-on-explicit-save is considered true if its value is 0, it triggers the after-save-hook anyway. This commit fixes the hook so it conforms to upstream definition: ssh-deploy-on-explicit-save Enabled automatic uploads on save (integer) Co-authored-by: visika Close: #7513 Fix: #7512 --- modules/tools/upload/README.org | 2 +- modules/tools/upload/config.el | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/tools/upload/README.org b/modules/tools/upload/README.org index 0cdff03e6..4b2445a61 100644 --- a/modules/tools/upload/README.org +++ b/modules/tools/upload/README.org @@ -47,7 +47,7 @@ to establish this mapping. E.g. #+begin_src emacs-lisp ((nil . ((ssh-deploy-root-local . "/local/path/to/project") (ssh-deploy-root-remote . "/ssh:user@server:/remote/project/") - (ssh-deploy-on-explicit-save . t)))) + (ssh-deploy-on-explicit-save . 1)))) #+end_src #+begin_quote diff --git a/modules/tools/upload/config.el b/modules/tools/upload/config.el index dadc824c7..25e2829be 100644 --- a/modules/tools/upload/config.el +++ b/modules/tools/upload/config.el @@ -37,7 +37,8 @@ (add-hook! 'after-save-hook (defun +upload-init-after-save-h () (when (and (bound-and-true-p ssh-deploy-root-remote) - ssh-deploy-on-explicit-save) + (integerp ssh-deploy-on-explicit-save) + (> ssh-deploy-on-explicit-save 0)) (ssh-deploy-upload-handler ssh-deploy-force-on-explicit-save)))) ;; Enable ssh-deploy if variables are set, and check for changes on open file From e133da7435eaa64ff8427fe4c60ad6cbf08298c8 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 24 Nov 2023 10:54:36 -0500 Subject: [PATCH 18/41] docs(upload): append slash to ssh-deploy-root-local Suffix ssh-deploy-root-local's path with a trailing slash (to be consistent with upstream documentation and the example value for ssh-deploy-root-remote right below it). Co-authored-by: visika Ref: #7513 --- modules/tools/upload/README.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/tools/upload/README.org b/modules/tools/upload/README.org index 4b2445a61..ecd373ca1 100644 --- a/modules/tools/upload/README.org +++ b/modules/tools/upload/README.org @@ -45,7 +45,7 @@ Uses ~ssh-deploy~ to map a local folder to a remote one. Set ~ssh-deploy-root-remote~ and ~ssh-deploy-root-local~ in a =.dir-locals.el= file to establish this mapping. E.g. #+begin_src emacs-lisp -((nil . ((ssh-deploy-root-local . "/local/path/to/project") +((nil . ((ssh-deploy-root-local . "/local/path/to/project/") (ssh-deploy-root-remote . "/ssh:user@server:/remote/project/") (ssh-deploy-on-explicit-save . 1)))) #+end_src @@ -66,7 +66,7 @@ Check out [[https://github.com/cjohansson/emacs-ssh-deploy#deployment-configurat ** ~root-local~ and ~root-remote~ must match The final directory names much match: #+begin_src emacs-lisp -((nil . ((ssh-deploy-root-local . "/local/path/to/example-project") +((nil . ((ssh-deploy-root-local . "/local/path/to/example-project/") (ssh-deploy-root-remote . "/ssh:user@server:/remote/example-project/") #+end_src From 2a875d9727f4b3b69db57a38ae2833acdc98ad96 Mon Sep 17 00:00:00 2001 From: StrawberryTea Date: Fri, 24 Nov 2023 10:00:52 -0600 Subject: [PATCH 19/41] refactor(evil): remove lisp prefix-function embrace pair A more generalized lisp prefix function was added upstream, so ours is no longer needed. Ref: cute-jumper/embrace.el#26 --- modules/editor/evil/config.el | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/modules/editor/evil/config.el b/modules/editor/evil/config.el index 3e56729ff..74d7b942c 100644 --- a/modules/editor/evil/config.el +++ b/modules/editor/evil/config.el @@ -245,8 +245,6 @@ directives. By default, this only recognizes C directives.") :hook (org-mode . embrace-org-mode-hook) :hook (ruby-mode . embrace-ruby-mode-hook) :hook (emacs-lisp-mode . embrace-emacs-lisp-mode-hook) - :hook ((lisp-mode emacs-lisp-mode clojure-mode racket-mode hy-mode) - . +evil-embrace-lisp-mode-hook-h) :hook ((c++-mode c++-ts-mode rustic-mode csharp-mode java-mode swift-mode typescript-mode) . +evil-embrace-angle-bracket-modes-hook-h) :hook (scala-mode . +evil-embrace-scala-mode-hook-h) @@ -284,16 +282,6 @@ directives. By default, this only recognizes C directives.") embrace--pairs-list)) (embrace-add-pair-regexp ?l "\\[a-z]+{" "}" #'+evil--embrace-latex)) - (defun +evil-embrace-lisp-mode-hook-h () - ;; Avoid `embrace-add-pair-regexp' because it would overwrite the default - ;; `f' rule, which we want for other modes - (push (cons ?f (make-embrace-pair-struct - :key ?f - :read-function #'+evil--embrace-elisp-fn - :left-regexp "([^ ]+ " - :right-regexp ")")) - embrace--pairs-list)) - (defun +evil-embrace-angle-bracket-modes-hook-h () (let ((var (make-local-variable 'evil-embrace-evil-surround-keys))) (set var (delq ?< evil-embrace-evil-surround-keys)) From d9a5b326b848f3b4fbbb24b6ef2d163da764f24c Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 30 Oct 2023 10:24:01 +1300 Subject: [PATCH 20/41] docs: replace single -> double semicolons --- templates/packages.example.el | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/templates/packages.example.el b/templates/packages.example.el index 839b83c58..364e6e9b7 100644 --- a/templates/packages.example.el +++ b/templates/packages.example.el @@ -7,44 +7,44 @@ ;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror: -;(package! some-package) +;; (package! some-package) ;; To install a package directly from a remote git repo, you must specify a ;; `:recipe'. You'll find documentation on what `:recipe' accepts here: ;; https://github.com/radian-software/straight.el#the-recipe-format -;(package! another-package -; :recipe (:host github :repo "username/repo")) +;; (package! another-package +;; :recipe (:host github :repo "username/repo")) ;; If the package you are trying to install does not contain a PACKAGENAME.el ;; file, or is located in a subdirectory of the repo, you'll need to specify ;; `:files' in the `:recipe': -;(package! this-package -; :recipe (:host github :repo "username/repo" -; :files ("some-file.el" "src/lisp/*.el"))) +;; (package! this-package +;; :recipe (:host github :repo "username/repo" +;; :files ("some-file.el" "src/lisp/*.el"))) ;; If you'd like to disable a package included with Doom, you can do so here ;; with the `:disable' property: -;(package! builtin-package :disable t) +;; (package! builtin-package :disable t) ;; You can override the recipe of a built in package without having to specify ;; all the properties for `:recipe'. These will inherit the rest of its recipe ;; from Doom or MELPA/ELPA/Emacsmirror: -;(package! builtin-package :recipe (:nonrecursive t)) -;(package! builtin-package-2 :recipe (:repo "myfork/package")) +;; (package! builtin-package :recipe (:nonrecursive t)) +;; (package! builtin-package-2 :recipe (:repo "myfork/package")) ;; Specify a `:branch' to install a package from a particular branch or tag. ;; This is required for some packages whose default branch isn't 'master' (which ;; our package manager can't deal with; see radian-software/straight.el#279) -;(package! builtin-package :recipe (:branch "develop")) +;; (package! builtin-package :recipe (:branch "develop")) ;; Use `:pin' to specify a particular commit to install. -;(package! builtin-package :pin "1a2b3c4d5e") +;; (package! builtin-package :pin "1a2b3c4d5e") ;; Doom's packages are pinned to a specific commit and updated from release to ;; release. The `unpin!' macro allows you to unpin single packages... -;(unpin! pinned-package) +;; (unpin! pinned-package) ;; ...or multiple packages -;(unpin! pinned-package another-pinned-package) +;; (unpin! pinned-package another-pinned-package) ;; ...Or *all* packages (NOT RECOMMENDED; will likely break things) -;(unpin! t) +;; (unpin! t) From 52be142e5cda428620b892daeefd9102afb1919f Mon Sep 17 00:00:00 2001 From: Eric Lim Date: Mon, 6 Nov 2023 11:20:55 +1300 Subject: [PATCH 21/41] docs(rss): add a missing double quote in README --- modules/app/rss/README.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/app/rss/README.org b/modules/app/rss/README.org index cd05ed240..f4a092151 100644 --- a/modules/app/rss/README.org +++ b/modules/app/rss/README.org @@ -78,7 +78,7 @@ configure feeds to follow: - You can "name" feeds as you please with ~org-mode~ ~org-insert-link~ ([[kbd:][C-c C-l]]) and put name as you want into ~description~. - If you don't want to use ~org-directory/elfeed.org~ file you can specify it - with ~(setq rmh-elfeed-org-files '("path/to/your/elfeed/file.org))~ + with ~(setq rmh-elfeed-org-files '("path/to/your/elfeed/file.org"))~ ** Keybindings + General From 7fb69fac64672dbd002b6a7b35fea6845447615a Mon Sep 17 00:00:00 2001 From: Jonas Jelten Date: Fri, 24 Nov 2023 17:05:30 +0100 Subject: [PATCH 22/41] bump: :lang markdown jrblevin/markdown-mode@c765b73b370f -> jrblevin/markdown-mode@b1a862f0165b - The workaround introduced aad7bc521f188 addressed an issue that was fixed upstream (jrblevin/markdown-mode@44f0e89534e6). Ref: jrblevin/markdown-mode#578 Revert: aad7bc521f18 --- modules/lang/markdown/config.el | 4 ---- modules/lang/markdown/packages.el | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/lang/markdown/config.el b/modules/lang/markdown/config.el index 6602d1339..6182d8eb1 100644 --- a/modules/lang/markdown/config.el +++ b/modules/lang/markdown/config.el @@ -26,10 +26,6 @@ capture, the end position, and the output buffer.") markdown-make-gfm-checkboxes-buttons t markdown-fontify-whole-heading-line t - ;; HACK Due to jrblevin/markdown-mode#578, invoking `imenu' throws a - ;; 'wrong-type-argument consp nil' error if you use native-comp. - markdown-nested-imenu-heading-index (not (ignore-errors (native-comp-available-p))) - ;; `+markdown-compile' offers support for many transpilers (see ;; `+markdown-compile-functions'), which it tries until one succeeds. markdown-command #'+markdown-compile diff --git a/modules/lang/markdown/packages.el b/modules/lang/markdown/packages.el index 1afd00040..cc59bb7fc 100644 --- a/modules/lang/markdown/packages.el +++ b/modules/lang/markdown/packages.el @@ -1,7 +1,7 @@ ;; -*- no-byte-compile: t; -*- ;;; lang/markdown/packages.el -(package! markdown-mode :pin "c765b73b370f0fcaaa3cee28b2be69652e2d2c39") +(package! markdown-mode :pin "b1a862f0165b7bafe0f874738a55be1b1720dd7d") (package! markdown-toc :pin "3d724e518a897343b5ede0b976d6fb46c46bcc01") (package! edit-indirect :pin "f80f63822ffae78de38dbe72cacaeb1aaa96c732") From 7d5ceff5ec9683b975d5a60c1a287b804ab5a4c3 Mon Sep 17 00:00:00 2001 From: Nikita Bloshchanevich Date: Tue, 14 Nov 2023 11:35:45 +0100 Subject: [PATCH 23/41] fix(plantuml): flycheck: executable support The flycheck-plantuml is by default configured to always run plantuml via "java". This only works with a downloaded plantuml. However, I would prefer to have plantuml installed via my package manager (fedora/dnf). A locally installed PlantUML executable is already detected by default for normal use (export/preview), we can also use it for flycheck. If plantuml is downloaded using plantuml-download-jar, this jar is still used by default (see setq plantuml-exec-mode), so this should not affect previous setups. --- modules/lang/plantuml/config.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/lang/plantuml/config.el b/modules/lang/plantuml/config.el index f55d45395..64ff4ed13 100644 --- a/modules/lang/plantuml/config.el +++ b/modules/lang/plantuml/config.el @@ -17,7 +17,11 @@ (use-package! flycheck-plantuml :when (modulep! :checkers syntax) :after plantuml-mode - :config (flycheck-plantuml-setup)) + :config + (flycheck-plantuml-setup) + (when (eq plantuml-default-exec-mode 'executable) + ;; Surprisingly, this works, even though flycheck-plantuml specifies -Djava.awt... + (setq-default flycheck-plantuml-executable plantuml-executable-path))) (after! ob-plantuml From 6a12331f8711e929c81b2546a726e5e3a0e692a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfonso=20Fernando=20=C3=81lvarez?= Date: Sun, 19 Nov 2023 19:21:28 +0000 Subject: [PATCH 24/41] docs(terraform): mention +lsp flag --- modules/tools/terraform/README.org | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/tools/terraform/README.org b/modules/tools/terraform/README.org index ade7f1820..36506eb99 100644 --- a/modules/tools/terraform/README.org +++ b/modules/tools/terraform/README.org @@ -12,7 +12,9 @@ run Terraform commands directly from Emacs. /This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] ** Module flags -/This module has no flags./ +- +lsp :: + Enable LSP support for ~terraform-mode~. Requires [[doom-module::tools lsp]] and a langserver + (supports terraform-ls or terraform-lsp). ** Packages - [[doom-package:company-terraform]] if [[doom-package::completion company]] From 45f86d945944781890a83ae661abf95bd7879b2e Mon Sep 17 00:00:00 2001 From: Ellis Kenyo Date: Fri, 24 Nov 2023 14:47:38 +0000 Subject: [PATCH 25/41] bump: :lang clojure babashka/neil@1dbac785cee4 -> babashka/neil@40993873bb4e clojure-emacs/cider@1ed5163433c9 -> clojure-emacs/cider@120fd885d37c clojure-emacs/clj-refactor.el@b5abe655e572 -> clojure-emacs/clj-refactor.el@0a2a6cbc2e29 clojure-emacs/clojure-mode@3453cd229b41 -> clojure-emacs/clojure-mode@25d713a67d8e clojure-emacs/parseclj@4d0e780e00f1 -> clojure-emacs/parseclj@74ff7d63fed9 clojure-emacs/parseedn@a09686fbb911 -> clojure-emacs/parseedn@c8f07926a688 ericdallo/jet.el@f007660c568e -> ericdallo/jet.el@7d5157aac692 Closes #7515 --- modules/lang/clojure/packages.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/lang/clojure/packages.el b/modules/lang/clojure/packages.el index 5603afe85..33c4f5fe9 100644 --- a/modules/lang/clojure/packages.el +++ b/modules/lang/clojure/packages.el @@ -10,17 +10,17 @@ ;; HACK Forward declare these clj-refactor/cider deps so that their deps are ;; byte-compiled first. -(package! parseclj :pin "4d0e780e00f1828b00c43099e6eebc6582998f72") -(package! parseedn :pin "a09686fbb9113b8b1b4f20c9e1dc0d6fea01a64f") +(package! parseclj :pin "74ff7d63fed92a3c859e474ae85f011e794b751a") +(package! parseedn :pin "c8f07926a688bfe995fde4460103915d401a1aff") ;;; Core packages -(package! clojure-mode :pin "3453cd229b412227aaffd1dc2870fa8fa213c5b1") -(package! clj-refactor :pin "b5abe655e572a6ecfed02bb8164b64716ef76b8e") -(package! cider :pin "1ed5163433c991c00ea83fdd4447e8daf4aeccbe") +(package! clojure-mode :pin "25d713a67d8e0209ee74bfc0153fdf677697b43f") +(package! clj-refactor :pin "0a2a6cbc2e29177f4f55730637a357433a03fa38") +(package! cider :pin "120fd885d37c07137f1c162e8d522ab3eed1ac3f") (when (and (modulep! :checkers syntax) (not (modulep! :checkers syntax +flymake))) (package! flycheck-clj-kondo :pin "ff7bed2315755cfe02ef471edf522e27b78cd5ca")) -(package! jet :pin "f007660c568e924e32d486a02aa4cd18203313cc") +(package! jet :pin "7d5157aac692fc761d8ed7a9f820fa6522136254") (package! neil :recipe (:host github :repo "babashka/neil" :files ("*.el")) - :pin "1dbac785cee4af8ad499839adbb83a8a297e7c70") + :pin "40993873bb4ef6d88af450e8a96d03275e266f6b") From fbf7e86b8e8372e460af5a283c05f8caf9cbd0c7 Mon Sep 17 00:00:00 2001 From: Ellis Kenyo Date: Fri, 24 Nov 2023 14:47:44 +0000 Subject: [PATCH 26/41] docs(clojure): clarify optional deps & add enrich-classpath note --- modules/lang/clojure/README.org | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/lang/clojure/README.org b/modules/lang/clojure/README.org index 36f57233a..d9d98d2e8 100644 --- a/modules/lang/clojure/README.org +++ b/modules/lang/clojure/README.org @@ -43,6 +43,8 @@ This module adds support for the Clojure(Script) language. This module requires: - [[https://clojure.org/][clojure]] + +This module optionally requires: - [[https://github.com/borkdude/clj-kondo][clj-kondo]], for linting code (if [[doom-module::checkers syntax]]) - [[https://clojure-lsp.github.io/clojure-lsp/][clojure-lsp]], for LSP support (if [[doom-module:+lsp]]) - [[https://github.com/babashka/neil][neil]] for the ability to add packages to your Clojure project from Emacs @@ -147,10 +149,17 @@ Several bindings used for viewing documentation for various functions, both insi | [[kbd:][K]] | ~+lookup/documentation~ | -* TODO Configuration -#+begin_quote - 󱌣 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote +* Configuration +** =enrich-classpath= +In recent versions, an option has been introduced that attempts to improve the experience of CIDER by accessing java source & javadocs, though this option is still currently considered beta. + +In order to opt into this, add the following to your =config.el= + +#+begin_src emacs-lisp +(setq cider-enrich-classpath t) +#+end_src + +See [[https://docs.cider.mx/cider/config/basic_config.html#use-enrich-classpath][the docs]] for more * Troubleshooting /There are no known problems with this module./ [[doom-report:][Report one?]] From dd856e4523f9c547d4a4a9ee21ad806c7bbae737 Mon Sep 17 00:00:00 2001 From: Luigi Sartor Piucco Date: Sat, 24 Sep 2022 17:33:32 -0300 Subject: [PATCH 27/41] module: add :completion corfu This commit's primary goal is allowing use of [minad/corfu](https://github.com/minad/corfu) as an alternative to [company](https://github.com/company-mode/company-mode). It introduces a module under :completion for this purpose, plus some conditionals on other relevant modules to toggle functionality like lsp back-ends and [minad/cape](https://github.com/minad/cape) capfs for certain modes. Other optional or miscellaneous features include: - Support for displaying the completion's documentation on a secondary popup; - Support for terminal display if :os tty; - Support for icons if +icons; - Support for tab-and-go completion if +tng; --- modules/completion/corfu/README.org | 139 +++++++++++++++++++ modules/completion/corfu/config.el | 192 +++++++++++++++++++++++++++ modules/completion/corfu/packages.el | 11 ++ modules/tools/lsp/+lsp.el | 5 +- 4 files changed, 346 insertions(+), 1 deletion(-) create mode 100644 modules/completion/corfu/README.org create mode 100644 modules/completion/corfu/config.el create mode 100644 modules/completion/corfu/packages.el diff --git a/modules/completion/corfu/README.org b/modules/completion/corfu/README.org new file mode 100644 index 000000000..f98c13675 --- /dev/null +++ b/modules/completion/corfu/README.org @@ -0,0 +1,139 @@ +#+title: :completion corfu +#+subtitle: Complete with cap(f), cape and a flying feather +#+created: September 9, 2022 +#+since: 3.0.0 (#7002) + +* Description :unfold: +This module provides code completion, powered by [[doom-package:corfu]]. + +It is recommended to enable either this or [[doom-module::completion company]], in case you +desire pre-configured auto-completion. Corfu is much lighter weight and focused, +plus it's built on native Emacs functionality, whereas company is heavy and +highly non-native, but has some extra features and more maturity. + +** Maintainers +- [[doom-user:][@LuigiPiucco]] + +[[doom-contrib-maintainer:][Become a maintainer?]] + +** Module flags +- +icons :: + Display icons beside completion suggestions. +- +tng :: + Invoke completion on [[kbd:][TAB]]. When corfu is active, [[kbd:][TAB]] and [[kbd:][S-TAB]] will navigate + the completion candidates. Arrow keys and evil-style movement are still + supported. +- +orderless :: + Pull in [[doom-package:orderless]] if necessary and apply multi-component + completion (still needed if [[doom-module::completion vertico]] is active). + +** Packages +- [[doom-package:corfu]] +- [[doom-package:cape]] +- [[doom-package:nerd-icons-completion]] if [[doom-module::completion corfu +icons]] +- [[doom-package:orderless]] if [[doom-module::completion corfu +orderless]] +- [[doom-package:corfu-terminal]] if [[doom-module::os tty]] + +** Hacks +/No hacks documented for this module./ + +** TODO Changelog +# This section will be machine generated. Don't edit it by hand. +/This module does not have a changelog yet./ + +* Installation +Enable this module in your ~doom!~ block. + +This module has no direct requirements, but some languages may have their own +requirements to fulfill before you get code completion in them (and some +languages may lack code completion support altogether). Run ~$ doom doctor~ to +find out if you're missing any dependencies. Note that corfu may have support +for completions in languages that have no development intelligence, since it +supports generic, context insensitive candidates such as file names or recurring +words. + +* TODO Usage +#+begin_quote + 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] +#+end_quote + +** Code completion +By default, completion gets triggered after typing 2 non-space consecutive +characters, or by means of the [[kbd:][C-SPC]] keybinding at any moment. While the popup +is visible, the following relevant keys are available: + +| Keybind | Description | +|----------+------------------------------------------------------| +| [[kbd:][]] | Go to next candidate | +| [[kbd:][]] | Go to previous candidate | +| [[kbd:][C-n]] | Go to next candidate | +| [[kbd:][C-p]] | Go to previous candidate | +| [[kbd:][C-j]] | (evil) Go to next candidate | +| [[kbd:][C-k]] | (evil) Go to previous candidate | +| [[kbd:][C-]] | Go to next doc line | +| [[kbd:][C-]] | Go to previous doc line | +| [[kbd:][C-S-n]] | Go to next doc line | +| [[kbd:][C-S-p]] | Go to previous doc line | +| [[kbd:][C-S-j]] | (evil) Go to next doc line | +| [[kbd:][C-S-k]] | (evil) Go to previous doc line | +| [[kbd:][C-h]] | Toggle documentation (if available) | +| [[kbd:][s-]] | Export to minibuffer (if [[doom-module::completion vertico]]) | +| [[kbd:][s-j]] | (evil) Export to minibuffer (if [[doom-module::completion vertico]]) | +| [[kbd:][RET]] | Insert candidate | +| [[kbd:][C-SPC]] | (when completing) Insert separator (see below) | +| [[kbd:][C-SPC]] | Complete (unless [[doom-module::completion corfu +tng]]) | + +If you prefer a [[kbd:][TAB]]-centric completion style, enable the [[doom-module::completion corfu +tng]] +flag so that, instead, you trigger completion with [[kbd:][TAB]], getting the following +additional binds: + +| Keybind | Description | +|---------+--------------------------------------------| +| [[kbd:][TAB]] | Complete | +| [[kbd:][TAB]] | (when completing) Go to next candidate | +| [[kbd:][S-TAB]] | (when completing) Go to previous candidate | + +** Searching with multiple keywords +If the [[doom-module::completion corfu +orderless]] flag is enabled, users can +perform code completion with multiple search keywords by use of space as +separator. More information can be found [[https://github.com/oantolin/orderless#company][here]]. Pressing [[kdb:][C-SPC]] again while +completing inserts a space as separator. This allows searching with +space-separated terms; each piece will match individually and in any order, with +smart casing. Pressing just [[kbd:][SPC]] acts as normal and restarts completion, so that +when typing sentences it doesn't try to complete the whole sentence instead of +just the word. + +** Exporting to the minibuffer (requires [[doom-module::completion vertico]]) +When using the [[doom-module::completion vertico]] module, which pulls in the +[[doom-package:consult]] package, the entries shown in the completion popup can be +exported to a consult minibuffer, giving access to all the manipulations the +vertico suite allows. For instance, one could use this to export with +[[doom-package:embark]] via [[kbd:][C-c C-l]] and get a buffer with all candidates. + +* Configuration +A few variables may be set to change behavior of this module: + +- [[var:corfu-auto-delay]] :: + Number of seconds till completion occurs automatically. Defaults to 0.1. +- [[var:corfu-auto-prefix]] :: + Number of characters till auto-completion starts to happen. Defaults to 2. +- [[var:corfu-on-exact-match]] :: + Configures behavior for exact matches. Its default is nil, and it's + recommended to leave it at that. Otherwise, single matches on snippet keys + expand immediately. +- [[var:+corfu-completion-styles]] :: + Used to override [[var:completion-styles]] for corfu invocations, such that it + 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. + +* Troubleshooting +[[doom-report:][Report an issue?]] + +* Frequently asked questions +/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] + +* TODO Appendix +#+begin_quote + 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] +#+end_quote diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el new file mode 100644 index 000000000..66d2ef12b --- /dev/null +++ b/modules/completion/corfu/config.el @@ -0,0 +1,192 @@ +;;; completion/corfu/config.el -*- lexical-binding: t; -*- + +(defvar +corfu-completion-styles '(basic partial-completion flex) + "Completion styles for corfu to use. + +If the user enables +orderless, `orderless' is automatically appended to this +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 +(use-package! corfu + :hook ((doom-first-buffer . global-corfu-mode) + (org-mode . corfu-mode)) + :init + ;; Auto-completion settings, must be set before calling `global-corfu-mode'. + ;; Due to lazy-loading, setting them in config.el works too. + (setq corfu-auto t + corfu-auto-delay 0.1 + corfu-auto-prefix 2 + corfu-excluded-modes '(erc-mode + circe-mode + help-mode + gud-mode + vterm-mode)) + :config + (setq corfu-cycle t + corfu-separator (when (modulep! +orderless) ?\s) + corfu-preselect t + corfu-count 16 + corfu-max-width 120 + corfu-preview-current 'insert + corfu-on-exact-match nil + corfu-quit-at-boundary (if (modulep! +orderless) 'separator t) + corfu-quit-no-match (if (modulep! +orderless) 'separator t) + ;; In the case of +tng, TAB should be smart regarding completion; + ;; However, it should otherwise behave like normal, whatever normal was. + tab-always-indent (if (modulep! +tng) 'complete tab-always-indent)) + + (when (modulep! +orderless) + (after! 'lsp-mode + (add-to-list 'completion-category-overrides + `(lsp-capf (styles ,@+corfu-completion-styles ,(when (modulep! +orderless) 'orderless))))) + (after! 'eglot + (add-to-list 'completion-category-overrides + `(eglot (styles ,@+corfu-completion-styles ,(when (modulep! +orderless) 'orderless)))))) + + ;; For the icons, we use a custom margin formatter, which simply reads the + ;; mapping in `+corfu-icon-mapping'. + (when (modulep! +icons) + (defun icon-margin-formatter (metadata) + (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 + ;; completion packages, such as vertico. That way, the user can leave the + ;; global value of the variable alone, say, to be used by the default + ;; front-end or consult. The vertico module also does something similar with + ;; `+vertico-company-completion-styles'. + (defadvice! +corfu--completion-styles (orig &rest args) + "Try default completion styles before orderless. + +Meant as :around advice for `corfu--recompute'." + :around #'corfu--recompute + (let ((completion-styles + (append +corfu-completion-styles (when (modulep! +orderless) + '(orderless)))) + completion-category-overrides completion-category-defaults) + (apply orig args))) + + (map! (:unless (modulep! +tng) + "C-SPC" #'completion-at-point) + (:map 'corfu-map + (:when (modulep! +orderless) + "C-SPC" #'corfu-insert-separator) + (:when (modulep! +tng) + [tab] #'corfu-next + [backtab] #'corfu-previous + "TAB" #'corfu-next + "S-TAB" #'corfu-previous))) + (after! evil-collection-corfu + (evil-collection-define-key 'insert 'corfu-map + (kbd "RET") #'corfu-insert + [return] #'corfu-insert)) + + (after! vertico + ;; Taken from corfu's README. + ;; TODO: extend this to other completion front-ends. + (defun corfu-move-to-minibuffer () + (interactive) + (let ((completion-extra-properties corfu--extra) + (completion-cycle-threshold completion-cycling)) + (apply #'consult-completion-in-region completion-in-region--data))) + (map! :map 'corfu-map "s-" #'corfu-move-to-minibuffer + (:when (modulep! :editor evil) "s-j" #'corfu-move-to-minibuffer)))) + +(defmacro +corfu--add-capf! (capf) + "Create sexp to add CAPF to the list of CAPFs." + `(add-to-list 'completion-at-point-functions ,capf)) +(use-package! cape + :after corfu + :config + (add-hook! prog-mode (+corfu--add-capf! #'cape-file)) + (add-hook! (org-mode markdown-mode) (+corfu--add-capf! #'cape-elisp-block)) + (advice-add #'lsp-completion-at-point :around #'cape-wrap-noninterruptible)) + +(use-package! corfu-terminal + :when (not (display-graphic-p)) + :hook (corfu-mode . corfu-terminal-mode)) + +;; +;;; Extensions +(use-package! corfu-history + :after savehist + :hook (corfu-mode . corfu-history-mode) + :config + (add-to-list 'savehist-additional-variables 'corfu-history)) +(use-package! corfu-popupinfo + :hook (corfu-mode . corfu-popupinfo-mode) + :config + (setq corfu-popupinfo-delay '(0.5 . 1.0)) + (map! (:map 'corfu-map + "C-" #'corfu-popupinfo-scroll-down + "C-" #'corfu-popupinfo-scroll-up + "C-S-p" #'corfu-popupinfo-scroll-down + "C-S-n" #'corfu-popupinfo-scroll-up + "C-h" #'corfu-popupinfo-toggle) + (:map 'corfu-popupinfo-map + :when (modulep! :editor evil) + ;; Reversed because popupinfo assumes opposite of what feels intuitive + ;; with evil. + "C-S-k" #'corfu-popupinfo-scroll-down + "C-S-j" #'corfu-popupinfo-scroll-up))) diff --git a/modules/completion/corfu/packages.el b/modules/completion/corfu/packages.el new file mode 100644 index 000000000..7111813ae --- /dev/null +++ b/modules/completion/corfu/packages.el @@ -0,0 +1,11 @@ +;; -*- no-byte-compile: t; -*- +;;; completion/corfu/packages.el + +(package! corfu :recipe (:files ("*.el" "extensions/*.el"))) +(package! cape) +(when (modulep! +icons) + (package! nerd-icons-completion)) +(when (modulep! +orderless) + (package! orderless)) +(when (modulep! :os tty) + (package! corfu-terminal)) diff --git a/modules/tools/lsp/+lsp.el b/modules/tools/lsp/+lsp.el index 5ae4a417d..96361aae4 100644 --- a/modules/tools/lsp/+lsp.el +++ b/modules/tools/lsp/+lsp.el @@ -138,8 +138,11 @@ server getting expensively restarted when reverting buffers." " ")) (add-to-list 'global-mode-string '(t (:eval lsp-modeline-icon)) - 'append)))))) + 'append))))) + (when (modulep! :completion corfu) + (setq lsp-completion-provider :none) + (add-hook 'lsp-mode-hook #'lsp-completion-mode))) (use-package! lsp-ui :hook (lsp-mode . lsp-ui-mode) From 8748084adf242c09217ebdfba26d47191cea7924 Mon Sep 17 00:00:00 2001 From: Luigi Sartor Piucco Date: Mon, 24 Jul 2023 21:55:32 -0300 Subject: [PATCH 28/41] fix(corfu): pin packages --- modules/completion/corfu/packages.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/completion/corfu/packages.el b/modules/completion/corfu/packages.el index 7111813ae..7363ae0f9 100644 --- a/modules/completion/corfu/packages.el +++ b/modules/completion/corfu/packages.el @@ -1,11 +1,11 @@ ;; -*- no-byte-compile: t; -*- ;;; completion/corfu/packages.el -(package! corfu :recipe (:files ("*.el" "extensions/*.el"))) -(package! cape) +(package! corfu :recipe (:files ("*.el" "extensions/*.el")) :pin "b2b9a2312f58117514724e729fda43efc4433ecd") +(package! cape :pin "116063b9ee912cbaa7318dbe6597ade4a62b3f59") (when (modulep! +icons) - (package! nerd-icons-completion)) + (package! nerd-icons-completion :pin "c2db8557a3c1a9588d111f8c8e91cae96ee85010")) (when (modulep! +orderless) - (package! orderless)) + (package! orderless :pin "d6b402a89e234d0e6166247ed6025f9acc8b4d9a")) (when (modulep! :os tty) - (package! corfu-terminal)) + (package! corfu-terminal :pin "501548c3d51f926c687e8cd838c5865ec45d03cc")) From a794f36e7ce139651356625bfb97b30535cb7e17 Mon Sep 17 00:00:00 2001 From: Luigi Sartor Piucco Date: Wed, 26 Jul 2023 19:57:21 -0300 Subject: [PATCH 29/41] feat(corfu): add snippets Yasnippet is now properly integrated! A previosly-unset default has now been given to `corfu-on-exact-match`. With snippets, it causes immediate expansion upon single match by default, so we set it to nil and recommend against changing it in the README. --- modules/completion/corfu/README.org | 3 ++- modules/completion/corfu/config.el | 6 ++++++ modules/completion/corfu/packages.el | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/completion/corfu/README.org b/modules/completion/corfu/README.org index f98c13675..689855e81 100644 --- a/modules/completion/corfu/README.org +++ b/modules/completion/corfu/README.org @@ -33,6 +33,7 @@ highly non-native, but has some extra features and more maturity. - [[doom-package:nerd-icons-completion]] if [[doom-module::completion corfu +icons]] - [[doom-package:orderless]] if [[doom-module::completion corfu +orderless]] - [[doom-package:corfu-terminal]] if [[doom-module::os tty]] +- [[doom-package:yasnippet-capf]] if [[doom-module::editor snippets]] ** Hacks /No hacks documented for this module./ @@ -50,7 +51,7 @@ languages may lack code completion support altogether). Run ~$ doom doctor~ to find out if you're missing any dependencies. Note that corfu may have support for completions in languages that have no development intelligence, since it supports generic, context insensitive candidates such as file names or recurring -words. +words. Snippets may also appear in the candidate list if available. * TODO Usage #+begin_quote diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el index 66d2ef12b..85c2c0585 100644 --- a/modules/completion/corfu/config.el +++ b/modules/completion/corfu/config.el @@ -163,6 +163,12 @@ Meant as :around advice for `corfu--recompute'." (add-hook! (org-mode markdown-mode) (+corfu--add-capf! #'cape-elisp-block)) (advice-add #'lsp-completion-at-point :around #'cape-wrap-noninterruptible)) +(use-package! yasnippet-capf + :after corfu + :config + (add-hook 'yas-minor-mode-hook + (lambda () (add-to-list 'completion-at-point-functions #'yasnippet-capf)))) + (use-package! corfu-terminal :when (not (display-graphic-p)) :hook (corfu-mode . corfu-terminal-mode)) diff --git a/modules/completion/corfu/packages.el b/modules/completion/corfu/packages.el index 7363ae0f9..b5a1b6bdb 100644 --- a/modules/completion/corfu/packages.el +++ b/modules/completion/corfu/packages.el @@ -9,3 +9,5 @@ (package! orderless :pin "d6b402a89e234d0e6166247ed6025f9acc8b4d9a")) (when (modulep! :os tty) (package! corfu-terminal :pin "501548c3d51f926c687e8cd838c5865ec45d03cc")) +(when (modulep! :editor snippets) + (package! yasnippet-capf :pin "40654214db7a44db3a99321447632b43a10fae57")) From 720e22a2520859306d910a0efd1098dd999f9492 Mon Sep 17 00:00:00 2001 From: Luigi Sartor Piucco Date: Wed, 20 Sep 2023 10:54:28 -0300 Subject: [PATCH 30/41] docs(corfu): simplify and show how to add capfs --- modules/completion/corfu/README.org | 13 +++++++++++++ modules/completion/corfu/config.el | 7 ++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/modules/completion/corfu/README.org b/modules/completion/corfu/README.org index 689855e81..fd964833a 100644 --- a/modules/completion/corfu/README.org +++ b/modules/completion/corfu/README.org @@ -128,6 +128,19 @@ A few variables may be set to change behavior of this module: - [[var:+corfu-icon-mapping]] :: Configures icons used for each completion. See its documentation for details. +** Adding CAPFs to a mode +To add other CAPFs on a mode-per-mode basis, put either of the following in your +~config.el~: + +#+begin_src emacs-lisp +(add-hook! some-mode (add-to-list 'completion-at-point-functions #'some-capf)) +;; OR, but note the different call signature +(add-hook 'some-mode-hook (lambda () (add-to-list 'completion-at-point-functions #'some-capf))) +#+end_src + +Also see ~add-hook!~'s documentation for additional ways to call it. +~add-hook~ only accepts the quoted arguments form above. + * Troubleshooting [[doom-report:][Report an issue?]] diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el index 85c2c0585..90c5caa38 100644 --- a/modules/completion/corfu/config.el +++ b/modules/completion/corfu/config.el @@ -153,14 +153,11 @@ Meant as :around advice for `corfu--recompute'." (map! :map 'corfu-map "s-" #'corfu-move-to-minibuffer (:when (modulep! :editor evil) "s-j" #'corfu-move-to-minibuffer)))) -(defmacro +corfu--add-capf! (capf) - "Create sexp to add CAPF to the list of CAPFs." - `(add-to-list 'completion-at-point-functions ,capf)) (use-package! cape :after corfu :config - (add-hook! prog-mode (+corfu--add-capf! #'cape-file)) - (add-hook! (org-mode markdown-mode) (+corfu--add-capf! #'cape-elisp-block)) + (add-hook! prog-mode (add-to-list 'completion-at-point-functions #'cape-file)) + (add-hook! (org-mode markdown-mode) (add-to-list 'completion-at-point-functions #'cape-elisp-block)) (advice-add #'lsp-completion-at-point :around #'cape-wrap-noninterruptible)) (use-package! yasnippet-capf From 8337dd19a64e3496267b38f3c6d2c894f1381c80 Mon Sep 17 00:00:00 2001 From: Liam Hupfer Date: Sun, 24 Sep 2023 15:28:45 -0500 Subject: [PATCH 31/41] perf(corfu): improve lazy loading `:after y` eagerly loads package x after y loads. Cape and `yasnippet-capf` define autoloads, so we can defer them until a capf is actually called. --- modules/completion/corfu/config.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el index 90c5caa38..93f5298de 100644 --- a/modules/completion/corfu/config.el +++ b/modules/completion/corfu/config.el @@ -61,7 +61,7 @@ must be present.") (org-mode . corfu-mode)) :init ;; Auto-completion settings, must be set before calling `global-corfu-mode'. - ;; Due to lazy-loading, setting them in config.el works too. + ;; Due to lazy-loading, overriding these in config.el works too. (setq corfu-auto t corfu-auto-delay 0.1 corfu-auto-prefix 2 @@ -154,17 +154,19 @@ Meant as :around advice for `corfu--recompute'." (:when (modulep! :editor evil) "s-j" #'corfu-move-to-minibuffer)))) (use-package! cape - :after corfu - :config + :defer t + :init (add-hook! prog-mode (add-to-list 'completion-at-point-functions #'cape-file)) (add-hook! (org-mode markdown-mode) (add-to-list 'completion-at-point-functions #'cape-elisp-block)) (advice-add #'lsp-completion-at-point :around #'cape-wrap-noninterruptible)) (use-package! yasnippet-capf - :after corfu - :config - (add-hook 'yas-minor-mode-hook - (lambda () (add-to-list 'completion-at-point-functions #'yasnippet-capf)))) + :when (modulep! :editor snippets) + :defer t + :init + (after! yasnippet + (add-hook! yas-minor-mode + (add-to-list 'completion-at-point-functions #'yasnippet-capf)))) (use-package! corfu-terminal :when (not (display-graphic-p)) From 2ede71b2aea84bc02e05905b39df90d5ed8d8c0c Mon Sep 17 00:00:00 2001 From: Liam Hupfer Date: Sun, 24 Sep 2023 15:29:06 -0500 Subject: [PATCH 32/41] tweak(corfu): allow corfu-history without savehist savehist is for persisting history across sessions, but users who disable savehist can still benefit from session-length Corfu history. --- modules/completion/corfu/config.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el index 93f5298de..cc256ab8f 100644 --- a/modules/completion/corfu/config.el +++ b/modules/completion/corfu/config.el @@ -172,13 +172,14 @@ Meant as :around advice for `corfu--recompute'." :when (not (display-graphic-p)) :hook (corfu-mode . corfu-terminal-mode)) -;; ;;; Extensions + (use-package! corfu-history - :after savehist :hook (corfu-mode . corfu-history-mode) :config - (add-to-list 'savehist-additional-variables 'corfu-history)) + (after! savehist (add-to-list 'savehist-additional-variables 'corfu-history))) + + (use-package! corfu-popupinfo :hook (corfu-mode . corfu-popupinfo-mode) :config From e52b613a69ef4fa8cd32f5a882fb4c54279f0072 Mon Sep 17 00:00:00 2001 From: Luigi Sartor Piucco Date: Mon, 2 Oct 2023 13:11:19 -0300 Subject: [PATCH 33/41] tweak(corfu): use better binding instead of S- --- modules/completion/corfu/config.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el index cc256ab8f..cd4be00c3 100644 --- a/modules/completion/corfu/config.el +++ b/modules/completion/corfu/config.el @@ -150,8 +150,8 @@ Meant as :around advice for `corfu--recompute'." (let ((completion-extra-properties corfu--extra) (completion-cycle-threshold completion-cycling)) (apply #'consult-completion-in-region completion-in-region--data))) - (map! :map 'corfu-map "s-" #'corfu-move-to-minibuffer - (:when (modulep! :editor evil) "s-j" #'corfu-move-to-minibuffer)))) + (map! :map 'corfu-map "M-m" #'corfu-move-to-minibuffer + (:when (modulep! :editor evil) :i "M-j" #'corfu-move-to-minibuffer)))) (use-package! cape :defer t From a47da9af716e528783639a028f886361ee25b13a Mon Sep 17 00:00:00 2001 From: Luigi Sartor Piucco Date: Mon, 2 Oct 2023 13:13:23 -0300 Subject: [PATCH 34/41] tweak(corfu): quit corfu on evil quit --- modules/completion/corfu/config.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el index cd4be00c3..15637143b 100644 --- a/modules/completion/corfu/config.el +++ b/modules/completion/corfu/config.el @@ -85,13 +85,16 @@ must be present.") tab-always-indent (if (modulep! +tng) 'complete tab-always-indent)) (when (modulep! +orderless) - (after! 'lsp-mode + (after! lsp-mode (add-to-list 'completion-category-overrides `(lsp-capf (styles ,@+corfu-completion-styles ,(when (modulep! +orderless) 'orderless))))) - (after! 'eglot + (after! eglot (add-to-list 'completion-category-overrides `(eglot (styles ,@+corfu-completion-styles ,(when (modulep! +orderless) 'orderless)))))) + (after! evil + (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) From a5eb58fcf3692caeccd74ad37338f76143b07bd7 Mon Sep 17 00:00:00 2001 From: Luigi Sartor Piucco Date: Sun, 15 Oct 2023 14:59:12 -0300 Subject: [PATCH 35/41] feat(corfu): switch to nerd-icons-corfu This removes the need to vendor the icon code. --- modules/completion/corfu/README.org | 3 +- modules/completion/corfu/config.el | 67 +--------------------------- modules/completion/corfu/packages.el | 3 +- 3 files changed, 5 insertions(+), 68 deletions(-) diff --git a/modules/completion/corfu/README.org b/modules/completion/corfu/README.org index fd964833a..1f071b638 100644 --- a/modules/completion/corfu/README.org +++ b/modules/completion/corfu/README.org @@ -31,6 +31,7 @@ highly non-native, but has some extra features and more maturity. - [[doom-package:corfu]] - [[doom-package:cape]] - [[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:corfu-terminal]] if [[doom-module::os tty]] - [[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]] :: Used to override [[var:completion-styles]] for corfu invocations, such that it 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 To add other CAPFs on a mode-per-mode basis, put either of the following in your diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el index 15637143b..16e7f2bbb 100644 --- a/modules/completion/corfu/config.el +++ b/modules/completion/corfu/config.el @@ -6,54 +6,6 @@ If the user enables +orderless, `orderless' is automatically appended to this 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 (use-package! corfu @@ -95,24 +47,8 @@ must be present.") (after! evil (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) - (defun icon-margin-formatter (metadata) - (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))) + (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter)) ;; 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 @@ -175,6 +111,7 @@ Meant as :around advice for `corfu--recompute'." :when (not (display-graphic-p)) :hook (corfu-mode . corfu-terminal-mode)) +;; ;;; Extensions (use-package! corfu-history diff --git a/modules/completion/corfu/packages.el b/modules/completion/corfu/packages.el index b5a1b6bdb..1d9f48f6c 100644 --- a/modules/completion/corfu/packages.el +++ b/modules/completion/corfu/packages.el @@ -4,7 +4,8 @@ (package! corfu :recipe (:files ("*.el" "extensions/*.el")) :pin "b2b9a2312f58117514724e729fda43efc4433ecd") (package! cape :pin "116063b9ee912cbaa7318dbe6597ade4a62b3f59") (when (modulep! +icons) - (package! nerd-icons-completion :pin "c2db8557a3c1a9588d111f8c8e91cae96ee85010")) + (package! nerd-icons-completion :pin "c2db8557a3c1a9588d111f8c8e91cae96ee85010") + (package! nerd-icons-corfu :pin "5082a22dfbdea092fcc475db3484cb3ff812b730")) (when (modulep! +orderless) (package! orderless :pin "d6b402a89e234d0e6166247ed6025f9acc8b4d9a")) (when (modulep! :os tty) From d526780aef14d3c4fdb5a95cacec73a2cb6b6824 Mon Sep 17 00:00:00 2001 From: StrawberryTea Date: Mon, 30 Oct 2023 14:36:19 -0400 Subject: [PATCH 36/41] feat(corfu): more CAPFs and ergonomy changes Add various CAPFs from cape: - `cape-line`; - `cape-dabbrev`; - `cape-emoji`; - `cape-dict`; Fixed some CAPFs via cape: - Make non-exclusive, purified and silent `pcomplete-completions-at-point`; - Make non-exclusive and non-interruptable `lsp-completion-at-point`; - Make non-exclusive `eglot-completion-at-point`; - Make non-exclusive `comint-completion-at-point`; Fix and improve keybindings: - Smart `backspace` for `+tng`; - Smart `DEL` for `+tng`; - Smart `SPC` which quits if after separator; - Smart `RET`; Add depth to CAPFs, allowing ordering to be adjustable. Remove the `+corfu-completion-styles` mechanism. Add `,` as additional separator. Enable in minibuffer. Bump `cape`. --- modules/completion/corfu/README.org | 101 ++++++---- modules/completion/corfu/autoload.el | 18 ++ modules/completion/corfu/config.el | 265 +++++++++++++++++++++------ modules/completion/corfu/packages.el | 2 +- 4 files changed, 291 insertions(+), 95 deletions(-) create mode 100644 modules/completion/corfu/autoload.el diff --git a/modules/completion/corfu/README.org b/modules/completion/corfu/README.org index 1f071b638..e74332d16 100644 --- a/modules/completion/corfu/README.org +++ b/modules/completion/corfu/README.org @@ -64,46 +64,51 @@ By default, completion gets triggered after typing 2 non-space consecutive characters, or by means of the [[kbd:][C-SPC]] keybinding at any moment. While the popup is visible, the following relevant keys are available: -| Keybind | Description | -|----------+------------------------------------------------------| -| [[kbd:][]] | Go to next candidate | -| [[kbd:][]] | Go to previous candidate | -| [[kbd:][C-n]] | Go to next candidate | -| [[kbd:][C-p]] | Go to previous candidate | -| [[kbd:][C-j]] | (evil) Go to next candidate | -| [[kbd:][C-k]] | (evil) Go to previous candidate | -| [[kbd:][C-]] | Go to next doc line | -| [[kbd:][C-]] | Go to previous doc line | -| [[kbd:][C-S-n]] | Go to next doc line | -| [[kbd:][C-S-p]] | Go to previous doc line | -| [[kbd:][C-S-j]] | (evil) Go to next doc line | -| [[kbd:][C-S-k]] | (evil) Go to previous doc line | -| [[kbd:][C-h]] | Toggle documentation (if available) | -| [[kbd:][s-]] | Export to minibuffer (if [[doom-module::completion vertico]]) | -| [[kbd:][s-j]] | (evil) Export to minibuffer (if [[doom-module::completion vertico]]) | -| [[kbd:][RET]] | Insert candidate | -| [[kbd:][C-SPC]] | (when completing) Insert separator (see below) | -| [[kbd:][C-SPC]] | Complete (unless [[doom-module::completion corfu +tng]]) | +| Keybind | Description | +|----------+---------------------------------------------------------| +| [[kbd:][]] | Go to next candidate | +| [[kbd:][]] | Go to previous candidate | +| [[kbd:][C-n]] | Go to next candidate | +| [[kbd:][C-p]] | Go to previous candidate | +| [[kbd:][C-j]] | (evil) Go to next candidate | +| [[kbd:][C-k]] | (evil) Go to previous candidate | +| [[kbd:][C-]] | Go to next doc line | +| [[kbd:][C-]] | Go to previous doc line | +| [[kbd:][C-S-n]] | Go to next doc line | +| [[kbd:][C-S-p]] | Go to previous doc line | +| [[kbd:][C-S-j]] | (evil) Go to next doc line | +| [[kbd:][C-S-k]] | (evil) Go to previous doc line | +| [[kbd:][C-h]] | Toggle documentation (if available) | +| [[kbd:][M-m]] | Export to minibuffer (if [[doom-module::completion vertico]]) | +| [[kbd:][M-j]] | (evil) Export to minibuffer (if [[doom-module::completion vertico]]) | +| [[kbd:][RET]] | Insert candidate | +| [[kbd:][SPC]] | Quit autocompletion after a wildcard or pass-through | +| [[kbd:][C-SPC]] | (when completing) Insert separator (see below) | +| [[kbd:][C-SPC]] | Complete (unless [[doom-module::completion corfu +tng]]) | If you prefer a [[kbd:][TAB]]-centric completion style, enable the [[doom-module::completion corfu +tng]] flag so that, instead, you trigger completion with [[kbd:][TAB]], getting the following additional binds: -| Keybind | Description | -|---------+--------------------------------------------| -| [[kbd:][TAB]] | Complete | -| [[kbd:][TAB]] | (when completing) Go to next candidate | -| [[kbd:][S-TAB]] | (when completing) Go to previous candidate | +| Keybind | Description | +|---------+-----------------------------------------------| +| [[kbd:][TAB]] | Complete | +| [[kbd:][TAB]] | (when completing) Go to next candidate | +| [[kbd:][S-TAB]] | (when completing) Go to previous candidate | +| [[kbd:][DEL]] | (when completing) Reset completion DWIM-style | ** Searching with multiple keywords -If the [[doom-module::completion corfu +orderless]] flag is enabled, users can -perform code completion with multiple search keywords by use of space as -separator. More information can be found [[https://github.com/oantolin/orderless#company][here]]. Pressing [[kdb:][C-SPC]] again while -completing inserts a space as separator. This allows searching with -space-separated terms; each piece will match individually and in any order, with -smart casing. Pressing just [[kbd:][SPC]] acts as normal and restarts completion, so that -when typing sentences it doesn't try to complete the whole sentence instead of -just the word. +If the [[doom-module::completion corfu +orderless]] flag is enabled, users can perform code +completion with multiple search keywords by use of space as the separator. More +information can be found [[https://github.com/oantolin/orderless#company][here]]. Pressing [[kdb:][C-SPC]] again while completing inserts a +space as separator. This allows searching with space-separated terms; each piece +will match individually and in any order, with smart casing. Pressing just [[kbd:][SPC]] +acts as normal and restarts completion, so that when typing sentences it doesn't +try to complete the whole sentence instead of just the word. + +Furthermore, if you also have [[var:+orderless-wildcard-character]] set (by default +it's the comma key), then that character acts as a wildcard when typed +mid-completion. ** Exporting to the minibuffer (requires [[doom-module::completion vertico]]) When using the [[doom-module::completion vertico]] module, which pulls in the @@ -123,26 +128,42 @@ A few variables may be set to change behavior of this module: Configures behavior for exact matches. Its default is nil, and it's recommended to leave it at that. Otherwise, single matches on snippet keys expand immediately. -- [[var:+corfu-completion-styles]] :: - Used to override [[var:completion-styles]] for corfu invocations, such that it - can have a value separate from, say, [[doom-package:consult]]. +- [[var:+orderless-wildcard-character]] :: + Used for fuzzy-matching corfu invocations as an escapable alternative to + ~corfu-separator~. Defaults to comma. +- [[var:+cape-buffer-scanning-size-limit:]] :: + Sets the maximum buffer size to be scanned by ~cape-dabbrev~ and + ~cape-lines~. Defaults to 1 MB. Set this if you are having performance + problems using ~cape-dabbrev~. ** Adding CAPFs to a mode To add other CAPFs on a mode-per-mode basis, put either of the following in your ~config.el~: #+begin_src emacs-lisp -(add-hook! some-mode (add-to-list 'completion-at-point-functions #'some-capf)) +(add-hook! some-mode (add-hook 'completion-at-point-functions #'some-capf depth t)) ;; OR, but note the different call signature -(add-hook 'some-mode-hook (lambda () (add-to-list 'completion-at-point-functions #'some-capf))) +(add-hook 'some-mode-hook (lambda () (add-hook 'completion-at-point-functions #'some-capf depth t))) #+end_src -Also see ~add-hook!~'s documentation for additional ways to call it. -~add-hook~ only accepts the quoted arguments form above. +DEPTH above is an integer between -100, 100, and defaults to 0 of ommited. Also +see ~add-hook!~'s documentation for additional ways to call it. ~add-hook~ only +accepts the quoted arguments form above. * Troubleshooting [[doom-report:][Report an issue?]] +If you have performance issues with ~cape-dabbrev~, the first thing I recommend +doing is looking at the list of buffers Dabbrev is scanning with: + +#+begin_src emacs-lisp +(dabbrev--select-buffers) ; => (# #> # ...) +(length (dabbrev--select-buffers)) ; => 37 +#+end_src + +and modifying ~dabbrev-ignored-buffer-regexps~ or ~dabbrev-ignored-buffer-modes~ +accordingly. + * Frequently asked questions /This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] diff --git a/modules/completion/corfu/autoload.el b/modules/completion/corfu/autoload.el new file mode 100644 index 000000000..215e5bd41 --- /dev/null +++ b/modules/completion/corfu/autoload.el @@ -0,0 +1,18 @@ +;;; completion/corfu/autoload/commands.el -*- lexical-binding: t; -*- + +;;;###autoload +(defun corfu-move-to-minibuffer () + ;; Taken from corfu's README. + ;; TODO: extend this to other completion front-ends. + (interactive) + (let ((completion-extra-properties corfu--extra) + (completion-cycle-threshold completion-cycling)) + (apply #'consult-completion-in-region completion-in-region--data))) + +;;;###autoload +(defun +corfu-insert-wildcard-separator () + ;; I had to rename this command so that it doesn't start with "corfu-". + ;; Otherwise, it does not insert the completion when +tng is enabled. + (interactive) + (setq this-command #'corfu-insert-separator) + (call-interactively #'corfu-insert-separator)) diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el index 16e7f2bbb..5bee3e0bf 100644 --- a/modules/completion/corfu/config.el +++ b/modules/completion/corfu/config.el @@ -1,10 +1,17 @@ ;;; completion/corfu/config.el -*- lexical-binding: t; -*- -(defvar +corfu-completion-styles '(basic partial-completion flex) - "Completion styles for corfu to use. +(defvar +cape-buffer-scanning-size-limit (* 1 1024 1024) ; 1 MB + "Size limit for a buffer to be scanned by `cape-line' or `cape-dabbrev'. -If the user enables +orderless, `orderless' is automatically appended to this -list before fowarding to `completion-styles'.") +As an exception, `cape-line' will also scan buffers with the same +major mode regardless of size.") + +(defvar +orderless-wildcard-character ?, + "A character used as a wildcard in Corfu for fuzzy autocompletion. If you +want to match the wildcard literally in completion, you can +escape it with forward slash. Do NOT set this to SPC. + +This variable needs to be set at the top-level before any `after!' blocks.") ;; ;;; Packages @@ -22,10 +29,12 @@ list before fowarding to `completion-styles'.") help-mode gud-mode vterm-mode)) + ;; `:g' is needed here to prevent `global-map' from overriding this with + ;; `set-mark-command'. + (map! :unless (modulep! +tng) :gi "C-SPC" #'completion-at-point) :config (setq corfu-cycle t - corfu-separator (when (modulep! +orderless) ?\s) - corfu-preselect t + corfu-preselect (if (modulep! :completion corfu +tng) 'prompt t) corfu-count 16 corfu-max-width 120 corfu-preview-current 'insert @@ -36,76 +45,224 @@ list before fowarding to `completion-styles'.") ;; However, it should otherwise behave like normal, whatever normal was. tab-always-indent (if (modulep! +tng) 'complete tab-always-indent)) - (when (modulep! +orderless) - (after! lsp-mode - (add-to-list 'completion-category-overrides - `(lsp-capf (styles ,@+corfu-completion-styles ,(when (modulep! +orderless) 'orderless))))) - (after! eglot - (add-to-list 'completion-category-overrides - `(eglot (styles ,@+corfu-completion-styles ,(when (modulep! +orderless) 'orderless)))))) + (defun corfu-disable-in-minibuffer-p () + (or (bound-and-true-p mct--active) + (bound-and-true-p vertico--input) + (and (featurep 'helm-core) (helm--alive-p)) + (eq (current-local-map) read-passwd-map))) - (after! evil - (add-hook 'evil-insert-state-exit-hook #'corfu-quit)) + (defun corfu-enable-in-minibuffer () + "Enable Corfu in the minibuffer if `completion-at-point' is bound." + (unless (corfu-disable-in-minibuffer-p) + (setq-local corfu-echo-delay nil ;; Disable automatic echo and popup + corfu-popupinfo-delay nil) + (corfu-mode 1))) + + (add-hook 'minibuffer-setup-hook #'corfu-enable-in-minibuffer) + + (defun corfu-visible-p () + (or (and (frame-live-p corfu--frame) + (frame-visible-p corfu--frame)) + (and (featurep 'corfu-terminal) + (popon-live-p corfu-terminal--popon)))) + + ;; If you want to update the visual hints after completing minibuffer commands + ;; with Corfu and exiting, you have to do it manually. + (defadvice! +corfu--insert-before-exit-minibuffer-a () + :before #'exit-minibuffer + (when (corfu-visible-p) + (when (member isearch-lazy-highlight-timer timer-idle-list) + (apply (timer--function isearch-lazy-highlight-timer) + (timer--args isearch-lazy-highlight-timer))) + (when (member (bound-and-true-p anzu--update-timer) timer-idle-list) + ;; Pending a PR I (@LemonBreezes) am making to expose `anzu--update-timer'. + (apply (timer--function anzu--update-timer) + (timer--args anzu--update-timer))) + (when (member (bound-and-true-p evil--ex-search-update-timer) + timer-idle-list) + (apply (timer--function evil--ex-search-update-timer) + (timer--args evil--ex-search-update-timer))))) + + ;; Do not make us type RET twice with Corfu. + (defun corfu--maybe-return-filter (cmd) + (if (eq corfu--index -1) (corfu-quit) cmd)) + (keymap-set corfu-map "RET" `(menu-item "corfu-maybe-return" corfu-insert + :filter corfu--maybe-return-filter)) + (keymap-set + corfu-map "" `(menu-item "corfu-maybe-return" corfu-insert + :filter corfu--maybe-return-filter)) + + ;; Allow completion after `:' in Lispy. + (add-to-list 'corfu-auto-commands #'lispy-colon) + + (when (and (modulep! +orderless) + +orderless-wildcard-character) + (defmacro +orderless-escapable-split-fn (char) + (let ((char-string (string (if (symbolp char) (symbol-value char) char)))) + `(defun +orderless-escapable-split-on-space-or-char (s) + (mapcar + (lambda (piece) + (replace-regexp-in-string + (string 1) ,char-string + (replace-regexp-in-string + (concat (string 0) "\\|" (string 1)) + (lambda (x) + (pcase x + ("\0" " ") + ("\1" ,char-string) + (_ x))) + piece + ;; These are arguments to `replace-regexp-in-string'. + 'fixedcase 'literal) + 'fixedcase 'literal)) + (split-string (replace-regexp-in-string + (concat "\\\\\\\\\\|\\\\ \\|\\\\" + ,char-string) + (lambda (x) + (pcase x + ("\\ " "\0") + (,(concat "\\" char-string) + "\1") + (_ x))) + s 'fixedcase 'literal) + ,(concat "[ " char-string "]+") + t))))) + (after! orderless + ;; Orderless splits the string into components and then determines the + ;; matching style for each component. This is all regexp stuff. + (setq orderless-component-separator + (+orderless-escapable-split-fn +orderless-wildcard-character)) + (setq corfu-separator +orderless-wildcard-character) + (keymap-set corfu-map (char-to-string +orderless-wildcard-character) + #'+corfu-insert-wildcard-separator) + ;; Quit completion after typing the wildcard followed by a space. + (keymap-set corfu-map "SPC" + `(menu-item "corfu-maybe-quit" nil + :filter + ,(lambda (_) + (when (and (> (point) (point-min)) + (eq (char-before) + +orderless-wildcard-character)) + (corfu-quit) + nil)))))) + + (add-hook! 'evil-insert-state-exit-hook + (defun +corfu-quit-on-evil-insert-state-exit-h () + ;; This predicate a workaround for unexpected calls to `corfu-quit' in + ;; :company-doc-buffer buffers. This was specifically happening when using + ;; `yasnippet-capf' and `company-yasnippet'. + (when (eq (current-buffer) (window-buffer (selected-window))) + (corfu-quit)))) (when (modulep! +icons) (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter)) - ;; 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 - ;; global value of the variable alone, say, to be used by the default - ;; front-end or consult. The vertico module also does something similar with - ;; `+vertico-company-completion-styles'. - (defadvice! +corfu--completion-styles (orig &rest args) - "Try default completion styles before orderless. + ;; Reset completion DWIM-style with backspace. + (when (modulep! +tng) + (defun corfu--maybe-reset-backspace-filter (cmd) + (when (and (> corfu--index -1) + (eq corfu-preview-current 'insert)) + cmd)) + (keymap-set corfu-map "DEL" `(menu-item "corfu-maybe-reset" corfu-reset + :filter corfu--maybe-reset-backspace-filter)) + (keymap-set + corfu-map "" `(menu-item "corfu-maybe-reset" corfu-reset + :filter corfu--maybe-reset-backspace-filter))) -Meant as :around advice for `corfu--recompute'." - :around #'corfu--recompute - (let ((completion-styles - (append +corfu-completion-styles (when (modulep! +orderless) - '(orderless)))) - completion-category-overrides completion-category-defaults) - (apply orig args))) - - (map! (:unless (modulep! +tng) - "C-SPC" #'completion-at-point) - (:map 'corfu-map - (:when (modulep! +orderless) - "C-SPC" #'corfu-insert-separator) - (:when (modulep! +tng) - [tab] #'corfu-next - [backtab] #'corfu-previous - "TAB" #'corfu-next - "S-TAB" #'corfu-previous))) + (map! (:map 'corfu-map + (:when (modulep! +orderless) + :gi "C-SPC" #'corfu-insert-separator) + (:when (modulep! +tng) + [tab] #'corfu-next + [backtab] #'corfu-previous + "TAB" #'corfu-next + "S-TAB" #'corfu-previous))) (after! evil-collection-corfu (evil-collection-define-key 'insert 'corfu-map (kbd "RET") #'corfu-insert [return] #'corfu-insert)) (after! vertico - ;; Taken from corfu's README. - ;; TODO: extend this to other completion front-ends. - (defun corfu-move-to-minibuffer () - (interactive) - (let ((completion-extra-properties corfu--extra) - (completion-cycle-threshold completion-cycling)) - (apply #'consult-completion-in-region completion-in-region--data))) - (map! :map 'corfu-map "M-m" #'corfu-move-to-minibuffer - (:when (modulep! :editor evil) :i "M-j" #'corfu-move-to-minibuffer)))) + (map! :map 'corfu-map "M-m" #'corfu-move-to-minibuffer) + (after! evil-collection-corfu + (evil-collection-define-key 'insert 'corfu-map + (kbd "M-j") #'corfu-move-to-minibuffer)))) (use-package! cape :defer t :init - (add-hook! prog-mode (add-to-list 'completion-at-point-functions #'cape-file)) - (add-hook! (org-mode markdown-mode) (add-to-list 'completion-at-point-functions #'cape-elisp-block)) + ;; Set up `cape-dabbrev' and `cape-line' options. + (defun +cape-line-buffers () + (cl-loop for buf in (buffer-list) + if (or (eq major-mode (buffer-local-value 'major-mode buf)) + (< (buffer-size buf) +cape-buffer-scanning-size-limit)) + collect buf)) + (defun +dabbrev-friend-buffer-p (other-buffer) + (< (buffer-size other-buffer) +cape-buffer-scanning-size-limit)) + (setq cape-dabbrev-check-other-buffers t + cape-line-buffer-function #'+cape-line-buffers + dabbrev-friend-buffer-function #'+dabbrev-friend-buffer-p + dabbrev-ignored-buffer-regexps + '("\\.\\(?:pdf\\|jpe?g\\|png\\|svg\\|eps\\)\\'" + "^ " + "\\(TAGS\\|tags\\|ETAGS\\|etags\\|GTAGS\\|GRTAGS\\|GPATH\\)\\(<[0-9]+>\\)?") + dabbrev-upcase-means-case-search t) + + (add-hook! prog-mode + (add-hook 'completion-at-point-functions #'cape-file -10 t)) + (add-hook! (org-mode markdown-mode) + (add-hook 'completion-at-point-functions #'cape-elisp-block 0 t)) + + ;; Enable Dabbrev completion basically everywhere as a fallback. + (add-hook! (prog-mode text-mode conf-mode comint-mode minibuffer-setup + eshell-mode) + (add-hook 'completion-at-point-functions #'cape-dabbrev 20 t)) + + ;; Complete emojis :). + (when (> emacs-major-version 28) + (add-hook! (prog-mode conf-mode) + (add-hook 'completion-at-point-functions + (cape-capf-inside-faces + (cape-capf-prefix-length #'cape-emoji 1) + ;; Only call inside comments and docstrings. + 'tree-sitter-hl-face:doc 'font-lock-doc-face + 'font-lock-comment-face 'tree-sitter-hl-face:comment) + 10 t)) + (add-hook! text-mode + (add-hook 'completion-at-point-functions + (cape-capf-prefix-length #'cape-emoji 1) 10 t))) + + ;; Enable dictionary-based autocompletion. + (add-hook! text-mode + (add-hook 'completion-at-point-functions #'cape-dict 40 t)) + (add-hook! (prog-mode conf-mode) + (add-hook 'completion-at-point-functions + (cape-capf-inside-faces + ;; Only call inside comments and docstrings. + #'cape-dict 'tree-sitter-hl-face:doc 'font-lock-doc-face + 'font-lock-comment-face 'tree-sitter-hl-face:comment) + 40 t)) + + ;; Make these capfs composable. + (advice-add #'comint-completion-at-point :around #'cape-wrap-nonexclusive) + (advice-add #'eglot-completion-at-point :around #'cape-wrap-nonexclusive) + (advice-add #'lsp-completion-at-point :around #'cape-wrap-nonexclusive) + (advice-add #'pcomplete-completions-at-point :around #'cape-wrap-nonexclusive) + + ;; From the `cape' readme. Without this, Eshell autocompletion is broken on + ;; Emacs28. + (when (< emacs-major-version 29) + (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent) + (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify)) + (advice-add #'lsp-completion-at-point :around #'cape-wrap-noninterruptible)) (use-package! yasnippet-capf :when (modulep! :editor snippets) :defer t :init - (after! yasnippet - (add-hook! yas-minor-mode - (add-to-list 'completion-at-point-functions #'yasnippet-capf)))) + (add-hook! yas-minor-mode + (add-hook 'completion-at-point-functions #'yasnippet-capf 30 t))) (use-package! corfu-terminal :when (not (display-graphic-p)) diff --git a/modules/completion/corfu/packages.el b/modules/completion/corfu/packages.el index 1d9f48f6c..b53626aab 100644 --- a/modules/completion/corfu/packages.el +++ b/modules/completion/corfu/packages.el @@ -2,7 +2,7 @@ ;;; completion/corfu/packages.el (package! corfu :recipe (:files ("*.el" "extensions/*.el")) :pin "b2b9a2312f58117514724e729fda43efc4433ecd") -(package! cape :pin "116063b9ee912cbaa7318dbe6597ade4a62b3f59") +(package! cape :pin "bee13e568d42ffec9010fbf795e8f942973da174") (when (modulep! +icons) (package! nerd-icons-completion :pin "c2db8557a3c1a9588d111f8c8e91cae96ee85010") (package! nerd-icons-corfu :pin "5082a22dfbdea092fcc475db3484cb3ff812b730")) From 747ecebd2492792c3c609b1aeee052d2e2def43a Mon Sep 17 00:00:00 2001 From: Luigi Sartor Piucco Date: Fri, 27 Oct 2023 16:00:03 -0300 Subject: [PATCH 37/41] fix(corfu): improve keybinding config --- modules/completion/corfu/README.org | 55 +++++++------- modules/completion/corfu/config.el | 109 ++++++++++++---------------- 2 files changed, 76 insertions(+), 88 deletions(-) diff --git a/modules/completion/corfu/README.org b/modules/completion/corfu/README.org index e74332d16..a72f336bc 100644 --- a/modules/completion/corfu/README.org +++ b/modules/completion/corfu/README.org @@ -64,27 +64,28 @@ By default, completion gets triggered after typing 2 non-space consecutive characters, or by means of the [[kbd:][C-SPC]] keybinding at any moment. While the popup is visible, the following relevant keys are available: -| Keybind | Description | -|----------+---------------------------------------------------------| -| [[kbd:][]] | Go to next candidate | -| [[kbd:][]] | Go to previous candidate | -| [[kbd:][C-n]] | Go to next candidate | -| [[kbd:][C-p]] | Go to previous candidate | -| [[kbd:][C-j]] | (evil) Go to next candidate | -| [[kbd:][C-k]] | (evil) Go to previous candidate | -| [[kbd:][C-]] | Go to next doc line | -| [[kbd:][C-]] | Go to previous doc line | -| [[kbd:][C-S-n]] | Go to next doc line | -| [[kbd:][C-S-p]] | Go to previous doc line | -| [[kbd:][C-S-j]] | (evil) Go to next doc line | -| [[kbd:][C-S-k]] | (evil) Go to previous doc line | -| [[kbd:][C-h]] | Toggle documentation (if available) | +| Keybind | Description | +|----------+------------------------------------------------------------------| +| [[kbd:][]] | Go to next candidate | +| [[kbd:][]] | Go to previous candidate | +| [[kbd:][C-n]] | Go to next candidate | +| [[kbd:][C-p]] | Go to previous candidate | +| [[kbd:][C-j]] | (evil) Go to next candidate | +| [[kbd:][C-k]] | (evil) Go to previous candidate | +| [[kbd:][C-]] | Go to next doc line | +| [[kbd:][C-]] | Go to previous doc line | +| [[kbd:][C-S-n]] | Go to next doc line | +| [[kbd:][C-S-p]] | Go to previous doc line | +| [[kbd:][C-S-j]] | (evil) Go to next doc line | +| [[kbd:][C-S-k]] | (evil) Go to previous doc line | +| [[kbd:][C-h]] | Toggle documentation (if available) | | [[kbd:][M-m]] | Export to minibuffer (if [[doom-module::completion vertico]]) | -| [[kbd:][M-j]] | (evil) Export to minibuffer (if [[doom-module::completion vertico]]) | -| [[kbd:][RET]] | Insert candidate | -| [[kbd:][SPC]] | Quit autocompletion after a wildcard or pass-through | -| [[kbd:][C-SPC]] | (when completing) Insert separator (see below) | +| [[kbd:][M-S-j]] | (evil) Export to minibuffer (if [[doom-module::completion vertico]]) | +| [[kbd:][RET]] | Insert candidate | +| [[kbd:][SPC]] | (after wildcard) Reset completion | +| [[kbd:][DEL]] | Reset completion | | [[kbd:][C-SPC]] | Complete (unless [[doom-module::completion corfu +tng]]) | +| [[kbd:][C-SPC]] | (when completing) Insert separator (see below) | If you prefer a [[kbd:][TAB]]-centric completion style, enable the [[doom-module::completion corfu +tng]] flag so that, instead, you trigger completion with [[kbd:][TAB]], getting the following @@ -95,16 +96,16 @@ additional binds: | [[kbd:][TAB]] | Complete | | [[kbd:][TAB]] | (when completing) Go to next candidate | | [[kbd:][S-TAB]] | (when completing) Go to previous candidate | -| [[kbd:][DEL]] | (when completing) Reset completion DWIM-style | ** Searching with multiple keywords -If the [[doom-module::completion corfu +orderless]] flag is enabled, users can perform code -completion with multiple search keywords by use of space as the separator. More -information can be found [[https://github.com/oantolin/orderless#company][here]]. Pressing [[kdb:][C-SPC]] again while completing inserts a -space as separator. This allows searching with space-separated terms; each piece -will match individually and in any order, with smart casing. Pressing just [[kbd:][SPC]] -acts as normal and restarts completion, so that when typing sentences it doesn't -try to complete the whole sentence instead of just the word. +If the [[doom-module::completion corfu +orderless]] flag is enabled, users can +perform code completion with multiple search keywords by use of space or ~,~ as +the separator. More information can be found [[https://github.com/oantolin/orderless#company][here]]. Pressing [[kdb:][C-SPC]] again while +completing inserts a space as separator. This allows searching with +space-separated terms; each piece will match individually and in any order, with +smart casing. Pressing just [[kbd:][SPC]] acts as normal and quits completion, so that +when typing sentences it doesn't try to complete the whole sentence instead of +just the word. Furthermore, if you also have [[var:+orderless-wildcard-character]] set (by default it's the comma key), then that character acts as a wildcard when typed diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el index 5bee3e0bf..6bcc6ac38 100644 --- a/modules/completion/corfu/config.el +++ b/modules/completion/corfu/config.el @@ -83,15 +83,6 @@ This variable needs to be set at the top-level before any `after!' blocks.") (apply (timer--function evil--ex-search-update-timer) (timer--args evil--ex-search-update-timer))))) - ;; Do not make us type RET twice with Corfu. - (defun corfu--maybe-return-filter (cmd) - (if (eq corfu--index -1) (corfu-quit) cmd)) - (keymap-set corfu-map "RET" `(menu-item "corfu-maybe-return" corfu-insert - :filter corfu--maybe-return-filter)) - (keymap-set - corfu-map "" `(menu-item "corfu-maybe-return" corfu-insert - :filter corfu--maybe-return-filter)) - ;; Allow completion after `:' in Lispy. (add-to-list 'corfu-auto-commands #'lispy-colon) @@ -133,18 +124,16 @@ This variable needs to be set at the top-level before any `after!' blocks.") (setq orderless-component-separator (+orderless-escapable-split-fn +orderless-wildcard-character)) (setq corfu-separator +orderless-wildcard-character) - (keymap-set corfu-map (char-to-string +orderless-wildcard-character) - #'+corfu-insert-wildcard-separator) - ;; Quit completion after typing the wildcard followed by a space. - (keymap-set corfu-map "SPC" - `(menu-item "corfu-maybe-quit" nil - :filter - ,(lambda (_) - (when (and (> (point) (point-min)) - (eq (char-before) - +orderless-wildcard-character)) - (corfu-quit) - nil)))))) + (defun +corfu--maybe-quit-spc-filter (cmd) + (when (and (> (point) (point-min)) + (eq (char-before) +orderless-wildcard-character)) + cmd)) + (let ((wildstr (char-to-string +orderless-wildcard-character)) + (mi-spc '(menu-item "corfu-maybe-quit" corfu-reset :filter +corfu--maybe-quit-spc-filter))) + (map! :map corfu-map + wildstr #'+corfu-insert-wildcard-separator + ;; Quit completion after typing the wildcard followed by a space. + "SPC" mi-spc)))) (add-hook! 'evil-insert-state-exit-hook (defun +corfu-quit-on-evil-insert-state-exit-h () @@ -157,36 +146,34 @@ This variable needs to be set at the top-level before any `after!' blocks.") (when (modulep! +icons) (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter)) - ;; Reset completion DWIM-style with backspace. - (when (modulep! +tng) - (defun corfu--maybe-reset-backspace-filter (cmd) - (when (and (> corfu--index -1) - (eq corfu-preview-current 'insert)) - cmd)) - (keymap-set corfu-map "DEL" `(menu-item "corfu-maybe-reset" corfu-reset - :filter corfu--maybe-reset-backspace-filter)) - (keymap-set - corfu-map "" `(menu-item "corfu-maybe-reset" corfu-reset - :filter corfu--maybe-reset-backspace-filter))) - - (map! (:map 'corfu-map - (:when (modulep! +orderless) - :gi "C-SPC" #'corfu-insert-separator) - (:when (modulep! +tng) - [tab] #'corfu-next - [backtab] #'corfu-previous - "TAB" #'corfu-next - "S-TAB" #'corfu-previous))) - (after! evil-collection-corfu - (evil-collection-define-key 'insert 'corfu-map - (kbd "RET") #'corfu-insert - [return] #'corfu-insert)) + (defun +corfu--maybe-reset-backspace-filter (cmd) + (when (and (modulep! +tng) + (> corfu--index -1) + (eq corfu-preview-current 'insert)) + cmd)) + (defun +corfu--maybe-quit-return-filter (cmd) + (let ((corfu--index (if (> corfu--index -1) corfu--index 0))) + (corfu-insert)) + cmd) + (let ((mi-del '(menu-item "corfu-maybe-reset-backspace-filter" corfu-reset + :filter +corfu--maybe-reset-backspace-filter))) + (map! :map corfu-map + [return] #'corfu-insert + "RET" #'corfu-insert + (:when (modulep! +orderless) + :gi "C-SPC" #'corfu-insert-separator) + (:when (modulep! +tng) + [tab] #'corfu-next + [backtab] #'corfu-previous + "TAB" #'corfu-next + "S-TAB" #'corfu-previous + [backspace] mi-del + "DEL" mi-del))) (after! vertico - (map! :map 'corfu-map "M-m" #'corfu-move-to-minibuffer) - (after! evil-collection-corfu - (evil-collection-define-key 'insert 'corfu-map - (kbd "M-j") #'corfu-move-to-minibuffer)))) + (map! :map corfu-map + "M-m" #'corfu-move-to-minibuffer + (:when (modulep! :editor evil) "M-J" #'corfu-move-to-minibuffer)))) (use-package! cape :defer t @@ -281,15 +268,15 @@ This variable needs to be set at the top-level before any `after!' blocks.") :hook (corfu-mode . corfu-popupinfo-mode) :config (setq corfu-popupinfo-delay '(0.5 . 1.0)) - (map! (:map 'corfu-map - "C-" #'corfu-popupinfo-scroll-down - "C-" #'corfu-popupinfo-scroll-up - "C-S-p" #'corfu-popupinfo-scroll-down - "C-S-n" #'corfu-popupinfo-scroll-up - "C-h" #'corfu-popupinfo-toggle) - (:map 'corfu-popupinfo-map - :when (modulep! :editor evil) - ;; Reversed because popupinfo assumes opposite of what feels intuitive - ;; with evil. - "C-S-k" #'corfu-popupinfo-scroll-down - "C-S-j" #'corfu-popupinfo-scroll-up))) + (map! :map corfu-map + "C-" #'corfu-popupinfo-scroll-down + "C-" #'corfu-popupinfo-scroll-up + "C-S-p" #'corfu-popupinfo-scroll-down + "C-S-n" #'corfu-popupinfo-scroll-up + "C-h" #'corfu-popupinfo-toggle) + (map! :when (modulep! :editor evil) + :map corfu-popupinfo-map + ;; Reversed because popupinfo assumes opposite of what feels intuitive + ;; with evil. + "C-S-k" #'corfu-popupinfo-scroll-down + "C-S-j" #'corfu-popupinfo-scroll-up)) From 14ea4b0b89c6f871e3956102d51f17b055c8af69 Mon Sep 17 00:00:00 2001 From: Luigi Sartor Piucco Date: Fri, 27 Oct 2023 16:09:14 -0300 Subject: [PATCH 38/41] tweak(corfu): place extra CAPFs behind flags --- modules/completion/corfu/README.org | 14 +++++-- modules/completion/corfu/config.el | 65 ++++++++++++++++------------- 2 files changed, 46 insertions(+), 33 deletions(-) diff --git a/modules/completion/corfu/README.org b/modules/completion/corfu/README.org index a72f336bc..224d6959c 100644 --- a/modules/completion/corfu/README.org +++ b/modules/completion/corfu/README.org @@ -20,12 +20,20 @@ highly non-native, but has some extra features and more maturity. - +icons :: Display icons beside completion suggestions. - +tng :: - Invoke completion on [[kbd:][TAB]]. When corfu is active, [[kbd:][TAB]] and [[kbd:][S-TAB]] will navigate - the completion candidates. Arrow keys and evil-style movement are still - supported. + Invoke completion on [[kbd:][TAB]]. When corfu is active, [[kbd:][TAB]] and + [[kbd:][S-TAB]] will navigate the completion candidates. Arrow keys and + evil-style movement are still supported. - +orderless :: Pull in [[doom-package:orderless]] if necessary and apply multi-component completion (still needed if [[doom-module::completion vertico]] is active). +- +dabbrev :: + Enable and configure [[doom-package:dabbrev]] as a nigh on everywhere CAPF + fallback. +- +dict :: + Enable and configure dictionary completion for text modes and related regions + in programming modes. +- +emoji :: + Enable and configure emoji completion via the emoji input method. ** Packages - [[doom-package:corfu]] diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el index 6bcc6ac38..632b61364 100644 --- a/modules/completion/corfu/config.el +++ b/modules/completion/corfu/config.el @@ -178,35 +178,39 @@ This variable needs to be set at the top-level before any `after!' blocks.") (use-package! cape :defer t :init - ;; Set up `cape-dabbrev' and `cape-line' options. - (defun +cape-line-buffers () - (cl-loop for buf in (buffer-list) - if (or (eq major-mode (buffer-local-value 'major-mode buf)) - (< (buffer-size buf) +cape-buffer-scanning-size-limit)) - collect buf)) - (defun +dabbrev-friend-buffer-p (other-buffer) - (< (buffer-size other-buffer) +cape-buffer-scanning-size-limit)) - (setq cape-dabbrev-check-other-buffers t - cape-line-buffer-function #'+cape-line-buffers - dabbrev-friend-buffer-function #'+dabbrev-friend-buffer-p - dabbrev-ignored-buffer-regexps - '("\\.\\(?:pdf\\|jpe?g\\|png\\|svg\\|eps\\)\\'" - "^ " - "\\(TAGS\\|tags\\|ETAGS\\|etags\\|GTAGS\\|GRTAGS\\|GPATH\\)\\(<[0-9]+>\\)?") - dabbrev-upcase-means-case-search t) - (add-hook! prog-mode (add-hook 'completion-at-point-functions #'cape-file -10 t)) (add-hook! (org-mode markdown-mode) (add-hook 'completion-at-point-functions #'cape-elisp-block 0 t)) ;; Enable Dabbrev completion basically everywhere as a fallback. - (add-hook! (prog-mode text-mode conf-mode comint-mode minibuffer-setup - eshell-mode) - (add-hook 'completion-at-point-functions #'cape-dabbrev 20 t)) + (when (modulep! +dabbrev) + ;; Set up `cape-dabbrev' options. + (defun +dabbrev-friend-buffer-p (other-buffer) + (< (buffer-size other-buffer) +cape-buffer-scanning-size-limit)) + (setq cape-dabbrev-check-other-buffers t + dabbrev-friend-buffer-function #'+dabbrev-friend-buffer-p + dabbrev-ignored-buffer-regexps + '("\\.\\(?:pdf\\|jpe?g\\|png\\|svg\\|eps\\)\\'" + "^ " + "\\(TAGS\\|tags\\|ETAGS\\|etags\\|GTAGS\\|GRTAGS\\|GPATH\\)\\(<[0-9]+>\\)?") + dabbrev-upcase-means-case-search t) + (add-hook! (prog-mode text-mode conf-mode comint-mode minibuffer-setup + eshell-mode) + (add-hook 'completion-at-point-functions #'cape-dabbrev 20 t))) + (when (modulep! +line) + ;; Set up `cape-line' options. + (defun +cape-line-buffers () + (cl-loop for buf in (buffer-list) + if (or (eq major-mode (buffer-local-value 'major-mode buf)) + (< (buffer-size buf) +cape-buffer-scanning-size-limit)) + collect buf)) + (setq cape-line-buffer-function #'+cape-line-buffers) + (add-hook! (text-mode comint-mode minibuffer-setup) + (add-hook 'completion-at-point-functions #'cape-line 20 t))) ;; Complete emojis :). - (when (> emacs-major-version 28) + (when (and (modulep! +emoji) (> emacs-major-version 28)) (add-hook! (prog-mode conf-mode) (add-hook 'completion-at-point-functions (cape-capf-inside-faces @@ -220,15 +224,16 @@ This variable needs to be set at the top-level before any `after!' blocks.") (cape-capf-prefix-length #'cape-emoji 1) 10 t))) ;; Enable dictionary-based autocompletion. - (add-hook! text-mode - (add-hook 'completion-at-point-functions #'cape-dict 40 t)) - (add-hook! (prog-mode conf-mode) - (add-hook 'completion-at-point-functions - (cape-capf-inside-faces - ;; Only call inside comments and docstrings. - #'cape-dict 'tree-sitter-hl-face:doc 'font-lock-doc-face - 'font-lock-comment-face 'tree-sitter-hl-face:comment) - 40 t)) + (when (modulep! +dict) + (add-hook! text-mode + (add-hook 'completion-at-point-functions #'cape-dict 40 t)) + (add-hook! (prog-mode conf-mode) + (add-hook 'completion-at-point-functions + (cape-capf-inside-faces + ;; Only call inside comments and docstrings. + #'cape-dict 'tree-sitter-hl-face:doc 'font-lock-doc-face + 'font-lock-comment-face 'tree-sitter-hl-face:comment) + 40 t))) ;; Make these capfs composable. (advice-add #'comint-completion-at-point :around #'cape-wrap-nonexclusive) From 369bf397d7f65612de60d7cdf43d8b04f1a184c2 Mon Sep 17 00:00:00 2001 From: Luigi Sartor Piucco Date: Fri, 27 Oct 2023 16:21:58 -0300 Subject: [PATCH 39/41] tweak(corfu): expand autoload command triggers --- modules/completion/corfu/config.el | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el index 632b61364..b42adc2e4 100644 --- a/modules/completion/corfu/config.el +++ b/modules/completion/corfu/config.el @@ -177,6 +177,50 @@ This variable needs to be set at the top-level before any `after!' blocks.") (use-package! cape :defer t + :commands + cape-abbrev + cape-dabbrev + cape-dict + cape-elisp-block + cape-elisp-symbol + cape-emoji + cape-file + cape-history + cape-keyword + cape-line + cape-rfc1345 + cape-sgml + cape-tex + cape-company-to-capf + cape-capf-super + cape-capf-buster + cape-capf-accept-all + cape-capf-debug + cape-capf-silent + cape-capf-purify + cape-capf-nonexclusive + cape-capf-noninterruptable + cape-capf-properties + cape-capf-predicate + cape-capf-prefix-length + cape-capf-inside-comment + cape-capf-inside-string + cape-capf-inside-faces + cape-capf-interactive + cape-wrap-buster + cape-wrap-accept-all + cape-wrap-debug + cape-wrap-silent + cape-wrap-purify + cape-wrap-nonexclusive + cape-wrap-noninterruptable + cape-wrap-properties + cape-wrap-predicate + cape-wrap-prefix-length + cape-wrap-inside-comment + cape-wrap-inside-string + cape-wrap-inside-faces + cape-interactive :init (add-hook! prog-mode (add-hook 'completion-at-point-functions #'cape-file -10 t)) From aff7254ad507ecfefde9f70922cfbff1fe347b9f Mon Sep 17 00:00:00 2001 From: Luigi Sartor Piucco Date: Sun, 29 Oct 2023 14:31:13 -0300 Subject: [PATCH 40/41] feat(corfu, vertico): use equal orderless config This removes the old `&` separator for Vertico (does anyone use that instead of just space?) in favor of escapable space and unifies orderless config with Corfu. Also implements smart separator insert/escape/reset on `C-SPC` --- modules/completion/corfu/config.el | 90 ++++++++-------------------- modules/completion/vertico/config.el | 3 +- 2 files changed, 27 insertions(+), 66 deletions(-) diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el index b42adc2e4..05b281987 100644 --- a/modules/completion/corfu/config.el +++ b/modules/completion/corfu/config.el @@ -6,13 +6,6 @@ As an exception, `cape-line' will also scan buffers with the same major mode regardless of size.") -(defvar +orderless-wildcard-character ?, - "A character used as a wildcard in Corfu for fuzzy autocompletion. If you -want to match the wildcard literally in completion, you can -escape it with forward slash. Do NOT set this to SPC. - -This variable needs to be set at the top-level before any `after!' blocks.") - ;; ;;; Packages (use-package! corfu @@ -24,6 +17,7 @@ This variable needs to be set at the top-level before any `after!' blocks.") (setq corfu-auto t corfu-auto-delay 0.1 corfu-auto-prefix 2 + corfu-separator ?\s corfu-excluded-modes '(erc-mode circe-mode help-mode @@ -39,7 +33,7 @@ This variable needs to be set at the top-level before any `after!' blocks.") corfu-max-width 120 corfu-preview-current 'insert corfu-on-exact-match nil - corfu-quit-at-boundary (if (modulep! +orderless) 'separator t) + corfu-quit-at-boundary t corfu-quit-no-match (if (modulep! +orderless) 'separator t) ;; In the case of +tng, TAB should be smart regarding completion; ;; However, it should otherwise behave like normal, whatever normal was. @@ -56,7 +50,7 @@ This variable needs to be set at the top-level before any `after!' blocks.") (unless (corfu-disable-in-minibuffer-p) (setq-local corfu-echo-delay nil ;; Disable automatic echo and popup corfu-popupinfo-delay nil) - (corfu-mode 1))) + (corfu-mode +1))) (add-hook 'minibuffer-setup-hook #'corfu-enable-in-minibuffer) @@ -86,54 +80,9 @@ This variable needs to be set at the top-level before any `after!' blocks.") ;; Allow completion after `:' in Lispy. (add-to-list 'corfu-auto-commands #'lispy-colon) - (when (and (modulep! +orderless) - +orderless-wildcard-character) - (defmacro +orderless-escapable-split-fn (char) - (let ((char-string (string (if (symbolp char) (symbol-value char) char)))) - `(defun +orderless-escapable-split-on-space-or-char (s) - (mapcar - (lambda (piece) - (replace-regexp-in-string - (string 1) ,char-string - (replace-regexp-in-string - (concat (string 0) "\\|" (string 1)) - (lambda (x) - (pcase x - ("\0" " ") - ("\1" ,char-string) - (_ x))) - piece - ;; These are arguments to `replace-regexp-in-string'. - 'fixedcase 'literal) - 'fixedcase 'literal)) - (split-string (replace-regexp-in-string - (concat "\\\\\\\\\\|\\\\ \\|\\\\" - ,char-string) - (lambda (x) - (pcase x - ("\\ " "\0") - (,(concat "\\" char-string) - "\1") - (_ x))) - s 'fixedcase 'literal) - ,(concat "[ " char-string "]+") - t))))) + (when (modulep! +orderless) (after! orderless - ;; Orderless splits the string into components and then determines the - ;; matching style for each component. This is all regexp stuff. - (setq orderless-component-separator - (+orderless-escapable-split-fn +orderless-wildcard-character)) - (setq corfu-separator +orderless-wildcard-character) - (defun +corfu--maybe-quit-spc-filter (cmd) - (when (and (> (point) (point-min)) - (eq (char-before) +orderless-wildcard-character)) - cmd)) - (let ((wildstr (char-to-string +orderless-wildcard-character)) - (mi-spc '(menu-item "corfu-maybe-quit" corfu-reset :filter +corfu--maybe-quit-spc-filter))) - (map! :map corfu-map - wildstr #'+corfu-insert-wildcard-separator - ;; Quit completion after typing the wildcard followed by a space. - "SPC" mi-spc)))) + (setq orderless-component-separator #'orderless-escapable-split-on-space))) (add-hook! 'evil-insert-state-exit-hook (defun +corfu-quit-on-evil-insert-state-exit-h () @@ -146,22 +95,34 @@ This variable needs to be set at the top-level before any `after!' blocks.") (when (modulep! +icons) (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter)) - (defun +corfu--maybe-reset-backspace-filter (cmd) + (defun +corfu--reset-or-passthrough (cmd) (when (and (modulep! +tng) (> corfu--index -1) (eq corfu-preview-current 'insert)) cmd)) - (defun +corfu--maybe-quit-return-filter (cmd) - (let ((corfu--index (if (> corfu--index -1) corfu--index 0))) - (corfu-insert)) - cmd) - (let ((mi-del '(menu-item "corfu-maybe-reset-backspace-filter" corfu-reset - :filter +corfu--maybe-reset-backspace-filter))) + (defun +corfu--backward-toggle-escape-sep (cmd) + (save-excursion + (backward-char 1) + (if (looking-back "\\\\" -1) + #'corfu-reset + (lambda () + (interactive) + (save-excursion + (backward-char 1) + (insert-char ?\\)))))) + (defun +corfu--insert-separator-or-toggle-escape (cmd) + (if (char-equal (char-before) corfu-separator) + (+corfu--backward-toggle-escape-sep cmd) + cmd)) + (let ((mi-del '(menu-item "corfu-reset-or-passthrough" corfu-reset + :filter +corfu--maybe-reset-backspace-filter)) + (mi-c-spc '(menu-item "corfu-insert-separator-or-toggle-escape" corfu-insert-separator + :filter +corfu--insert-separator-or-toggle-escape))) (map! :map corfu-map [return] #'corfu-insert "RET" #'corfu-insert (:when (modulep! +orderless) - :gi "C-SPC" #'corfu-insert-separator) + :gi "C-SPC" mi-c-spc) (:when (modulep! +tng) [tab] #'corfu-next [backtab] #'corfu-previous @@ -176,7 +137,6 @@ This variable needs to be set at the top-level before any `after!' blocks.") (:when (modulep! :editor evil) "M-J" #'corfu-move-to-minibuffer)))) (use-package! cape - :defer t :commands cape-abbrev cape-dabbrev diff --git a/modules/completion/vertico/config.el b/modules/completion/vertico/config.el index a4efa7c4e..ac4bbad05 100644 --- a/modules/completion/vertico/config.el +++ b/modules/completion/vertico/config.el @@ -98,6 +98,7 @@ orderless." ;; Flex matching ((string-prefix-p "~" pattern) `(orderless-flex . ,(substring pattern 1))) ((string-suffix-p "~" pattern) `(orderless-flex . ,(substring pattern 0 -1))))) + ;; TODO: Find a way to deduplicate this code from the corfu module. (add-to-list 'completion-styles-alist '(+vertico-basic-remote @@ -110,7 +111,7 @@ orderless." ;; find-file etc. completion-category-overrides '((file (styles +vertico-basic-remote orderless partial-completion))) orderless-style-dispatchers '(+vertico-orderless-dispatch) - orderless-component-separator "[ &]") + orderless-component-separator #'orderless-escapable-split-on-space) ;; ...otherwise find-file gets different highlighting than other commands (set-face-attribute 'completions-first-difference nil :inherit nil)) From 232c25589f2ea8202c62c0dde43efbf2b3038f17 Mon Sep 17 00:00:00 2001 From: Luigi Sartor Piucco Date: Tue, 31 Oct 2023 21:54:50 -0300 Subject: [PATCH 41/41] bump: :completion corfu --- modules/completion/corfu/packages.el | 10 +++++----- modules/completion/vertico/packages.el | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/completion/corfu/packages.el b/modules/completion/corfu/packages.el index b53626aab..0107b7278 100644 --- a/modules/completion/corfu/packages.el +++ b/modules/completion/corfu/packages.el @@ -1,14 +1,14 @@ ;; -*- no-byte-compile: t; -*- ;;; completion/corfu/packages.el -(package! corfu :recipe (:files ("*.el" "extensions/*.el")) :pin "b2b9a2312f58117514724e729fda43efc4433ecd") -(package! cape :pin "bee13e568d42ffec9010fbf795e8f942973da174") +(package! corfu :recipe (:files ("*.el" "extensions/*.el")) :pin "457042d486e7542b9a6a832e47e6833d217ffd47") +(package! cape :pin "abacb231157e0c90e29bdda6d15b4b448e48ffbd") (when (modulep! +icons) (package! nerd-icons-completion :pin "c2db8557a3c1a9588d111f8c8e91cae96ee85010") - (package! nerd-icons-corfu :pin "5082a22dfbdea092fcc475db3484cb3ff812b730")) + (package! nerd-icons-corfu :pin "7077bb76fefc15aed967476406a19dc5c2500b3c")) (when (modulep! +orderless) - (package! orderless :pin "d6b402a89e234d0e6166247ed6025f9acc8b4d9a")) + (package! orderless :pin "89eb3775daa53cfb52ad03015410c23f28c72d30")) (when (modulep! :os tty) (package! corfu-terminal :pin "501548c3d51f926c687e8cd838c5865ec45d03cc")) (when (modulep! :editor snippets) - (package! yasnippet-capf :pin "40654214db7a44db3a99321447632b43a10fae57")) + (package! yasnippet-capf :pin "a0a6b1c2bb6decdad5cf9b74202f0042f494a6ab")) diff --git a/modules/completion/vertico/packages.el b/modules/completion/vertico/packages.el index 68f1b73e9..947c8b7a5 100644 --- a/modules/completion/vertico/packages.el +++ b/modules/completion/vertico/packages.el @@ -6,7 +6,7 @@ :files ("*.el" "extensions/*.el")) :pin "a28370d07f35c5387c7a9ec2e5b67f0d4598058d") -(package! orderless :pin "e6784026717a8a6a7dcd0bf31fd3414f148c542e") +(package! orderless :pin "89eb3775daa53cfb52ad03015410c23f28c72d30") (package! consult :pin "fe49dedd71802ff97be7b89f1ec4bd61b98c2b13") (package! consult-dir :pin "ed8f0874d26f10f5c5b181ab9f2cf4107df8a0eb")