dev: merging latest changes from pr7002

This commit is contained in:
Matt Nish-Lapidus 2023-12-11 17:33:17 -05:00
commit 35e7bd2711
4 changed files with 92 additions and 99 deletions

View file

@ -37,47 +37,18 @@ major mode regardless of size.")
tab-always-indent (if (modulep! +tng) 'complete tab-always-indent)) tab-always-indent (if (modulep! +tng) 'complete tab-always-indent))
(add-to-list 'completion-category-overrides `(lsp-capf (styles ,@completion-styles))) (add-to-list 'completion-category-overrides `(lsp-capf (styles ,@completion-styles)))
(map! :map corfu-mode-map
:e "C-M-i" #'completion-at-point
:i "C-SPC" #'completion-at-point
:n "C-SPC" (cmd! (call-interactively #'evil-insert-state)
(call-interactively #'completion-at-point))
:v "C-SPC" (cmd! (call-interactively #'evil-change)
(call-interactively #'completion-at-point)))
(map! :unless (modulep! :editor evil)
:map corfu-mode-map
"C-M-i" #'completion-at-point)
(add-hook! corfu-mode (add-hook! corfu-mode
(defun +corfu-mode-binds () (defun +corfu-mode-unbinds ()
;; In `corfu-mode', unbind C-SPC from `global-map', so Emacs keeps searching. ;; In `corfu-mode', unbind C-SPC from `global-map', so Emacs keeps searching.
(make-local-variable 'global-map) (make-local-variable 'global-map)
(unbind-key "C-SPC" 'global-map))) (unbind-key "C-SPC" 'global-map)))
(add-hook! 'minibuffer-setup-hook
(defun +corfu-enable-in-minibuffer () (defun +corfu-enable-in-minibuffer ()
"Enable Corfu in the minibuffer if `completion-at-point' is bound." "Enable Corfu in the minibuffer if `completion-at-point' is bound."
(when (where-is-internal #'completion-at-point (list (current-local-map))) (when (where-is-internal #'completion-at-point (list (current-local-map)))
(setq-local corfu-echo-delay nil) (setq-local corfu-echo-delay nil)
(corfu-mode +1))) (corfu-mode +1))))
(add-hook 'minibuffer-setup-hook #'+corfu-enable-in-minibuffer)
;; 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 (or (and (frame-live-p corfu--frame)
(frame-visible-p corfu--frame))
(and (featurep 'corfu-terminal)
(popon-live-p corfu-terminal--popon)))
(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)
(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)))))
(after! evil (after! evil
(add-hook 'evil-insert-state-exit-hook #'corfu-quit)) (add-hook 'evil-insert-state-exit-hook #'corfu-quit))
@ -85,32 +56,9 @@ major mode regardless of size.")
(when (modulep! +icons) (when (modulep! +icons)
(add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter)) (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))
(let ((cmds-del (cmds! (and (modulep! +tng)
(> corfu--index -1)
(eq corfu-preview-current 'insert))
#'corfu-reset)))
(map! :map corfu-map
[return] #'corfu-insert
"RET" #'corfu-insert
(:when (modulep! +orderless)
"<remap> <completion-at-point>" #'+corfu-smart-sep-toggle-escape)
(:when (modulep! +tng)
[tab] #'corfu-next
[backtab] #'corfu-previous
"TAB" #'corfu-next
"S-TAB" #'corfu-previous
[backspace] cmds-del
"DEL" cmds-del)))
(when (modulep! +orderless) (when (modulep! +orderless)
(after! orderless (after! orderless
(setq orderless-component-separator #'orderless-escapable-split-on-space))) (setq orderless-component-separator #'orderless-escapable-split-on-space))))
(after! vertico
(map! :map corfu-map
"M-m" #'+corfu-move-to-minibuffer
(:when (modulep! :editor evil)
"M-J" #'+corfu-move-to-minibuffer))))
(use-package! cape (use-package! cape
:defer t :defer t
@ -139,17 +87,6 @@ major mode regardless of size.")
eshell-mode) eshell-mode)
(defun +corfu-add-cape-dabbrev-h () (defun +corfu-add-cape-dabbrev-h ()
(add-hook 'completion-at-point-functions #'cape-dabbrev 20 t))))) (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) +corfu-buffer-scanning-size-limit))
collect buf))
(setq cape-line-buffer-function #'+cape-line-buffers)
(add-hook! (text-mode comint-mode minibuffer-setup)
(defun +corfu-add-cape-line-h ()
(add-hook 'completion-at-point-functions #'cape-line 20 t))))
;; Complete emojis :). ;; Complete emojis :).
(when (and (modulep! +emoji) (> emacs-major-version 28)) (when (and (modulep! +emoji) (> emacs-major-version 28))
(add-hook! (prog-mode conf-mode) (add-hook! (prog-mode conf-mode)
@ -215,16 +152,4 @@ major mode regardless of size.")
(use-package! corfu-popupinfo (use-package! corfu-popupinfo
:hook ((corfu-mode . corfu-popupinfo-mode)) :hook ((corfu-mode . corfu-popupinfo-mode))
:config :config
(setq corfu-popupinfo-delay '(0.5 . 1.0)) (setq corfu-popupinfo-delay '(0.5 . 1.0)))
(map! :map corfu-map
"C-<up>" #'corfu-popupinfo-scroll-down
"C-<down>" #'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))

View file

@ -511,7 +511,7 @@
"C-x C-b" #'ibuffer "C-x C-b" #'ibuffer
"C-x K" #'doom/kill-this-buffer-in-all-windows "C-x K" #'doom/kill-this-buffer-in-all-windows
;;; company-mode ;;; completion (in-buffer)
(:when (modulep! :completion company) (:when (modulep! :completion company)
"C-;" #'+company/complete "C-;" #'+company/complete
(:after company (:after company
@ -537,6 +537,13 @@
"C-p" #'company-search-repeat-backward "C-p" #'company-search-repeat-backward
"C-s" (cmd! (company-search-abort) (company-filter-candidates)))) "C-s" (cmd! (company-search-abort) (company-filter-candidates))))
(:when (modulep! :completion corfu)
:after corfu
(:map corfu-mode-map
"C-M-i" #'completion-at-point)
(:map corfu-popupinfo-map
"C-S-h" #'corfu-popupinfo-toggle))
;;; ein notebooks ;;; ein notebooks
(:after ein:notebook-multilang (:after ein:notebook-multilang
:map ein:notebook-multilang-mode-map :map ein:notebook-multilang-mode-map

View file

@ -43,7 +43,10 @@
#'yas-expand #'yas-expand
(and (bound-and-true-p company-mode) (and (bound-and-true-p company-mode)
(modulep! :completion company +tng)) (modulep! :completion company +tng))
#'company-indent-or-complete-common) #'company-indent-or-complete-common
(and (bound-and-true-p corfu-mode)
(modulep! :completion corfu +tng))
#'completion-at-point)
:m [tab] (cmds! (and (modulep! :editor snippets) :m [tab] (cmds! (and (modulep! :editor snippets)
(evil-visual-state-p) (evil-visual-state-p)
(or (eq evil-visual-selection 'line) (or (eq evil-visual-selection 'line)
@ -127,7 +130,7 @@
;; ;;
;;; Module keybinds ;;; Module keybinds
;;; :completion ;;; :completion (in-buffer)
(map! (:when (modulep! :completion company) (map! (:when (modulep! :completion company)
:i "C-@" (cmds! (not (minibufferp)) #'company-complete-common) :i "C-@" (cmds! (not (minibufferp)) #'company-complete-common)
:i "C-SPC" (cmds! (not (minibufferp)) #'company-complete-common) :i "C-SPC" (cmds! (not (minibufferp)) #'company-complete-common)
@ -156,7 +159,31 @@
"C-s" #'company-filter-candidates "C-s" #'company-filter-candidates
[escape] #'company-search-abort))) [escape] #'company-search-abort)))
(:when (modulep! :completion ivy) (:when (modulep! :completion corfu)
(:after corfu
(:map corfu-mode-map
:e "C-M-i" #'completion-at-point
(:unless (modulep! :completion corfu +tng)
:i "C-SPC" #'completion-at-point
:n "C-SPC" (cmd! (call-interactively #'evil-insert-state)
(call-interactively #'completion-at-point))
:v "C-SPC" (cmd! (call-interactively #'evil-change)
(call-interactively #'completion-at-point))))
(:map corfu-map
"C-u" (cmd! (let ((corfu-cycle nil))
(funcall-interactively #'corfu-next (- corfu-count))))
"C-d" (cmd! (let ((corfu-cycle nil))
(funcall-interactively #'corfu-next corfu-count)))))
(:after corfu-popupinfo
: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
"C-h" #'corfu-popupinfo-toggle)))
;;; :completion (separate)
(map! (:when (modulep! :completion ivy)
(:after ivy (:after ivy
:map ivy-minibuffer-map :map ivy-minibuffer-map
"C-SPC" #'ivy-call-and-recenter ; preview file "C-SPC" #'ivy-call-and-recenter ; preview file
@ -169,7 +196,8 @@
[C-return] #'+ivy/git-grep-other-window-action)) [C-return] #'+ivy/git-grep-other-window-action))
(:when (modulep! :completion helm) (:when (modulep! :completion helm)
(:after helm :map helm-map (:after helm
:map helm-map
[remap next-line] #'helm-next-line [remap next-line] #'helm-next-line
[remap previous-line] #'helm-previous-line [remap previous-line] #'helm-previous-line
[left] #'left-char [left] #'left-char
@ -371,8 +399,10 @@
;;; <leader> c --- code ;;; <leader> c --- code
(:prefix-map ("c" . "code") (:prefix-map ("c" . "code")
(:when (and (modulep! :tools lsp) (not (modulep! :tools lsp +eglot))) (:when (and (modulep! :tools lsp) (not (modulep! :tools lsp +eglot)))
:desc "LSP" "l" #'+default/lsp-command-map
:desc "LSP Execute code action" "a" #'lsp-execute-code-action :desc "LSP Execute code action" "a" #'lsp-execute-code-action
:desc "LSP Organize imports" "o" #'lsp-organize-imports :desc "LSP Organize imports" "o" #'lsp-organize-imports
:desc "LSP Rename" "r" #'lsp-rename
(:when (modulep! :completion ivy) (:when (modulep! :completion ivy)
:desc "Jump to symbol in current workspace" "j" #'lsp-ivy-workspace-symbol :desc "Jump to symbol in current workspace" "j" #'lsp-ivy-workspace-symbol
:desc "Jump to symbol in any workspace" "J" #'lsp-ivy-global-workspace-symbol) :desc "Jump to symbol in any workspace" "J" #'lsp-ivy-global-workspace-symbol)
@ -387,9 +417,7 @@
:desc "Incoming call hierarchy" "y" #'lsp-treemacs-call-hierarchy :desc "Incoming call hierarchy" "y" #'lsp-treemacs-call-hierarchy
:desc "Outgoing call hierarchy" "Y" (cmd!! #'lsp-treemacs-call-hierarchy t) :desc "Outgoing call hierarchy" "Y" (cmd!! #'lsp-treemacs-call-hierarchy t)
:desc "References tree" "R" (cmd!! #'lsp-treemacs-references t) :desc "References tree" "R" (cmd!! #'lsp-treemacs-references t)
:desc "Symbols" "S" #'lsp-treemacs-symbols) :desc "Symbols" "S" #'lsp-treemacs-symbols))
:desc "LSP" "l" #'+default/lsp-command-map
:desc "LSP Rename" "r" #'lsp-rename)
(:when (modulep! :tools lsp +eglot) (:when (modulep! :tools lsp +eglot)
:desc "LSP Execute code action" "a" #'eglot-code-actions :desc "LSP Execute code action" "a" #'eglot-code-actions
:desc "LSP Rename" "r" #'eglot-rename :desc "LSP Rename" "r" #'eglot-rename

View file

@ -165,7 +165,7 @@
(and (sp-in-code-p id action context) (and (sp-in-code-p id action context)
(save-excursion (save-excursion
(goto-char (line-beginning-position)) (goto-char (line-beginning-position))
(looking-at-p "[ ]*#include[^<]+")))) (looking-at-p "[ \t]*#include[^<]+"))))
;; ...and leave it to smartparens ;; ...and leave it to smartparens
(sp-local-pair '(c++-mode objc-mode) (sp-local-pair '(c++-mode objc-mode)
@ -453,6 +453,39 @@ Continues comments if executed from a commented line. Consults
'(evil-ex-completion-map))) '(evil-ex-completion-map)))
"C-s" command)) "C-s" command))
(map! :when (modulep! :completion corfu)
:after corfu
(:map corfu-map
[return] #'corfu-insert
"RET" #'corfu-insert
"C-s" #'+corfu-move-to-minibuffer
"C-p" #'corfu-previous
"C-n" #'corfu-next
(:when (modulep! :completion corfu +orderless)
"<remap> <completion-at-point>" #'+corfu-smart-sep-toggle-escape)
(:when (modulep! :completion corfu +tng)
[tab] #'corfu-next
"TAB" #'corfu-next
[backtab] #'corfu-previous
"S-TAB" #'corfu-previous))
(:after corfu-popupinfo
:map corfu-popupinfo-map
"C-<up>" #'corfu-popupinfo-scroll-down
"C-<down>" #'corfu-popupinfo-scroll-up
"C-S-p" #'corfu-popupinfo-scroll-down
"C-S-n" #'corfu-popupinfo-scroll-up
"C-S-u" (cmd! (funcall-interactively #'corfu-popupinfo-scroll-down corfu-popupinfo-min-height))
"C-S-d" (cmd! (funcall-interactively #'corfu-popupinfo-scroll-up corfu-popupinfo-min-height))))
(when-let ((cmds-del (and (modulep! :completion corfu +tng)
(cmds! (and (> corfu--index -1)
(eq corfu-preview-current 'insert))
#'corfu-reset))))
(map! :after corfu
:map corfu-map
[backspace] cmds-del
"DEL" cmds-del))
;; Smarter C-a/C-e for both Emacs and Evil. C-a will jump to indentation. ;; Smarter C-a/C-e for both Emacs and Evil. C-a will jump to indentation.
;; Pressing it again will send you to the true bol. Same goes for C-e, except ;; Pressing it again will send you to the true bol. Same goes for C-e, except
;; it will ignore comments+trailing whitespace before jumping to eol. ;; it will ignore comments+trailing whitespace before jumping to eol.