dev: merge branch 'pr7739' into emenel
This commit is contained in:
commit
c5fb8007b0
5 changed files with 135 additions and 59 deletions
|
@ -202,6 +202,15 @@ A few variables may be set to change behavior of this module:
|
||||||
- [[var:+corfu-want-minibuffer-completion]] ::
|
- [[var:+corfu-want-minibuffer-completion]] ::
|
||||||
Whether to enable Corfu in the minibuffer. See its documentation for
|
Whether to enable Corfu in the minibuffer. See its documentation for
|
||||||
additional tweaks.
|
additional tweaks.
|
||||||
|
- [[var:+corfu-want-tab-prefer-expand-snippets]] ::
|
||||||
|
Whether to prefer expanding snippets over cycling candidates when pressing
|
||||||
|
[[kbd:][TAB]].
|
||||||
|
- [[var:+corfu-want-tab-prefer-navigating-snippets]] ::
|
||||||
|
Whether to prefer navigating snippets over cycling candidates when pressing
|
||||||
|
[[kbd:][TAB]] and [[kbd:][S-TAB]].
|
||||||
|
- [[var:+corfu-want-tab-prefer-navigating-org-tables]] ::
|
||||||
|
Whether to prefer navigating org tables over cycling candidates when pressing
|
||||||
|
[[kbd:][TAB]] and [[kbd:][S-TAB]].
|
||||||
|
|
||||||
** Adding CAPFs to a mode
|
** Adding CAPFs to a mode
|
||||||
To add other CAPFs on a mode-per-mode basis, put either of the following in your
|
To add other CAPFs on a mode-per-mode basis, put either of the following in your
|
||||||
|
|
|
@ -16,6 +16,18 @@ Possible values are:
|
||||||
Setting this to `aggressive' will enable Corfu in more commands which
|
Setting this to `aggressive' will enable Corfu in more commands which
|
||||||
use the minibuffer such as `query-replace'.")
|
use the minibuffer such as `query-replace'.")
|
||||||
|
|
||||||
|
(defvar +corfu-want-tab-prefer-expand-snippets nil
|
||||||
|
"If non-nil, prefer expanding snippets over cycling candidates with
|
||||||
|
TAB.")
|
||||||
|
|
||||||
|
(defvar +corfu-want-tab-prefer-navigating-snippets nil
|
||||||
|
"If non-nil, prefer navigating snippets over cycling candidates with
|
||||||
|
TAB/S-TAB.")
|
||||||
|
|
||||||
|
(defvar +corfu-want-tab-prefer-navigating-org-tables nil
|
||||||
|
"If non-nil, prefer navigating org tables over cycling candidates with
|
||||||
|
TAB/S-TAB.")
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;;; Packages
|
;;; Packages
|
||||||
(use-package! corfu
|
(use-package! corfu
|
||||||
|
|
|
@ -38,38 +38,64 @@
|
||||||
;;; Global keybindings
|
;;; Global keybindings
|
||||||
|
|
||||||
;; Smart tab, these will only work in GUI Emacs
|
;; Smart tab, these will only work in GUI Emacs
|
||||||
(map! :i [tab] (cmds! (and (modulep! :editor snippets)
|
(map! :i [tab]
|
||||||
(yas-maybe-expand-abbrev-key-filter 'yas-expand))
|
`(menu-item "Evil insert smart tab" nil :filter
|
||||||
#'yas-expand
|
(lambda (cmd)
|
||||||
(and (bound-and-true-p company-mode)
|
(cond
|
||||||
(modulep! :completion company +tng))
|
((or (doom-lookup-key [tab] overriding-terminal-local-map)
|
||||||
#'company-indent-or-complete-common
|
(doom-lookup-key (kbd "TAB") overriding-terminal-local-map))
|
||||||
(and (bound-and-true-p corfu-mode)
|
cmd)
|
||||||
(modulep! :completion corfu))
|
,@(when (modulep! :editor snippets)
|
||||||
#'completion-at-point)
|
'(((+yas-active-p)
|
||||||
:m [tab] (cmds! (and (modulep! :editor snippets)
|
#'yas-next-field-or-maybe-expand)
|
||||||
(evil-visual-state-p)
|
((yas-maybe-expand-abbrev-key-filter 'yas-expand)
|
||||||
|
#'yas-expand)))
|
||||||
|
,@(when (modulep! :completion company +tng)
|
||||||
|
'(((bound-and-true-p company-mode)
|
||||||
|
#'company-indent-or-complete-common)))
|
||||||
|
,@(when (modulep! :completion corfu)
|
||||||
|
'(((bound-and-true-p corfu-mode)
|
||||||
|
#'indent-for-tab-command))))))
|
||||||
|
:m [tab]
|
||||||
|
`(menu-item "Evil motion smart tab" nil :filter
|
||||||
|
(lambda (cmd)
|
||||||
|
(cond
|
||||||
|
((or (doom-lookup-key [tab] overriding-terminal-local-map)
|
||||||
|
(doom-lookup-key (kbd "TAB") overriding-terminal-local-map))
|
||||||
|
cmd)
|
||||||
|
,@(when (modulep! :editor snippets)
|
||||||
|
'(((and (evil-visual-state-p)
|
||||||
(or (eq evil-visual-selection 'line)
|
(or (eq evil-visual-selection 'line)
|
||||||
(not (memq (char-after) (list ?\( ?\[ ?\{ ?\} ?\] ?\))))))
|
(not (memq (char-after)
|
||||||
#'yas-insert-snippet
|
(list ?\( ?\[ ?\{ ?\} ?\] ?\))))))
|
||||||
(and (modulep! :editor fold)
|
#'yas-insert-snippet)))
|
||||||
(save-excursion (end-of-line) (invisible-p (point))))
|
,@(when (modulep! :editor fold)
|
||||||
#'+fold/toggle
|
'(((save-excursion (end-of-line) (invisible-p (point)))
|
||||||
|
#'+fold/toggle)))
|
||||||
;; Fixes #4548: without this, this tab keybind overrides
|
;; Fixes #4548: without this, this tab keybind overrides
|
||||||
;; mode-local ones for modes that don't have an evil
|
;; mode-local ones for modes that don't have an evil
|
||||||
;; keybinding scheme or users who don't have :editor (evil
|
;; keybinding scheme or users who don't have :editor (evil
|
||||||
;; +everywhere) enabled.
|
;; +everywhere) enabled.
|
||||||
(or (doom-lookup-key
|
((or (doom-lookup-key
|
||||||
[tab]
|
[tab]
|
||||||
(list (evil-get-auxiliary-keymap (current-local-map) evil-state)
|
(list (evil-get-auxiliary-keymap (current-local-map)
|
||||||
|
evil-state)
|
||||||
(current-local-map)))
|
(current-local-map)))
|
||||||
(doom-lookup-key
|
(doom-lookup-key
|
||||||
(kbd "TAB")
|
(kbd "TAB")
|
||||||
(list (evil-get-auxiliary-keymap (current-local-map) evil-state)))
|
(list (evil-get-auxiliary-keymap (current-local-map)
|
||||||
|
evil-state)))
|
||||||
(doom-lookup-key (kbd "TAB") (list (current-local-map))))
|
(doom-lookup-key (kbd "TAB") (list (current-local-map))))
|
||||||
it
|
cmd)
|
||||||
(fboundp 'evil-jump-item)
|
((fboundp 'evil-jump-item)
|
||||||
#'evil-jump-item)
|
#'evil-jump-item))))
|
||||||
|
;; Extend smart tab for specific modes. This way, we process the entire
|
||||||
|
;; smart tab logic and only fall back to these commands at the end.
|
||||||
|
(:when (modulep! :lang org)
|
||||||
|
(:after org :map org-mode-map
|
||||||
|
[remap indent-for-tab-command]
|
||||||
|
`(menu-item "Go to the next field" org-table-next-field
|
||||||
|
:filter ,(lambda (cmd) (when (org-at-table-p) cmd)))))
|
||||||
|
|
||||||
(:after help :map help-mode-map
|
(:after help :map help-mode-map
|
||||||
:n "o" #'link-hint-open-link)
|
:n "o" #'link-hint-open-link)
|
||||||
|
|
7
modules/config/default/autoload/filters.el
Normal file
7
modules/config/default/autoload/filters.el
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
;;; config/default/autoload/filters.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +yas-active-p ()
|
||||||
|
"Return t if we are in a YASnippet field."
|
||||||
|
(memq (bound-and-true-p yas--active-field-overlay)
|
||||||
|
(overlays-in (1- (point)) (1+ (point)))))
|
|
@ -464,11 +464,7 @@ Continues comments if executed from a commented line. Consults
|
||||||
[remap corfu-insert-separator] #'+corfu-smart-sep-toggle-escape
|
[remap corfu-insert-separator] #'+corfu-smart-sep-toggle-escape
|
||||||
"C-S-s" #'+corfu-move-to-minibuffer
|
"C-S-s" #'+corfu-move-to-minibuffer
|
||||||
"C-p" #'corfu-previous
|
"C-p" #'corfu-previous
|
||||||
"C-n" #'corfu-next
|
"C-n" #'corfu-next))
|
||||||
"S-TAB" #'corfu-previous
|
|
||||||
[backtab] #'corfu-previous
|
|
||||||
"TAB" #'corfu-next
|
|
||||||
[tab] #'corfu-next))
|
|
||||||
(let ((cmds-del
|
(let ((cmds-del
|
||||||
`(menu-item "Reset completion" corfu-reset
|
`(menu-item "Reset completion" corfu-reset
|
||||||
:filter ,(lambda (cmd)
|
:filter ,(lambda (cmd)
|
||||||
|
@ -478,27 +474,53 @@ Continues comments if executed from a commented line. Consults
|
||||||
(cmds-ret
|
(cmds-ret
|
||||||
`(menu-item "Insert completion DWIM" corfu-insert
|
`(menu-item "Insert completion DWIM" corfu-insert
|
||||||
:filter ,(lambda (cmd)
|
:filter ,(lambda (cmd)
|
||||||
(interactive)
|
|
||||||
(cond ((null +corfu-want-ret-to-confirm)
|
(cond ((null +corfu-want-ret-to-confirm)
|
||||||
(corfu-quit)
|
(corfu-quit))
|
||||||
nil)
|
((or (not (minibufferp nil t))
|
||||||
|
(eq +corfu-want-ret-to-confirm t))
|
||||||
|
(when (>= corfu--index 0) cmd))
|
||||||
((eq +corfu-want-ret-to-confirm 'minibuffer)
|
((eq +corfu-want-ret-to-confirm 'minibuffer)
|
||||||
(funcall-interactively cmd)
|
(funcall-interactively cmd)
|
||||||
nil)
|
nil)
|
||||||
((and (or (not (minibufferp nil t))
|
(t cmd)))))
|
||||||
(eq +corfu-want-ret-to-confirm t))
|
(cmds-tab
|
||||||
(>= corfu--index 0))
|
`(menu-item "Select next candidate or expand/traverse snippet" corfu-next
|
||||||
cmd)
|
:filter (lambda (cmd)
|
||||||
((or (not (minibufferp nil t))
|
(cond ,@(when (modulep! :editor snippets)
|
||||||
(eq +corfu-want-ret-to-confirm t))
|
'(((and +corfu-want-tab-prefer-navigating-snippets
|
||||||
nil)
|
(+yas-active-p))
|
||||||
|
#'yas-next-field-or-maybe-expand)
|
||||||
|
((and +corfu-want-tab-prefer-expand-snippets
|
||||||
|
(yas-maybe-expand-abbrev-key-filter 'yas-expand))
|
||||||
|
#'yas-expand)))
|
||||||
|
,@(when (modulep! :lang org)
|
||||||
|
'(((and +corfu-want-tab-prefer-navigating-org-tables
|
||||||
|
(org-at-table-p))
|
||||||
|
#'org-table-next-field)))
|
||||||
|
(t cmd)))) )
|
||||||
|
(cmds-s-tab
|
||||||
|
`(menu-item "Select previous candidate or expand/traverse snippet"
|
||||||
|
corfu-previous
|
||||||
|
:filter (lambda (cmd)
|
||||||
|
(cond ,@(when (modulep! :editor snippets)
|
||||||
|
'(((and +corfu-want-tab-prefer-navigating-snippets
|
||||||
|
(+yas-active-p))
|
||||||
|
#'yas-prev-field)))
|
||||||
|
,@(when (modulep! :lang org)
|
||||||
|
'(((and +corfu-want-tab-prefer-navigating-org-tables
|
||||||
|
(org-at-table-p))
|
||||||
|
#'org-table-previous-field)))
|
||||||
(t cmd))))))
|
(t cmd))))))
|
||||||
(map! :when (modulep! :completion corfu)
|
(map! :when (modulep! :completion corfu)
|
||||||
:map corfu-map
|
:map corfu-map
|
||||||
[backspace] cmds-del
|
[backspace] cmds-del
|
||||||
"DEL" cmds-del
|
"DEL" cmds-del
|
||||||
:gi [return] cmds-ret
|
:gi [return] cmds-ret
|
||||||
:gi "RET" cmds-ret))
|
:gi "RET" cmds-ret
|
||||||
|
"S-TAB" cmds-s-tab
|
||||||
|
[backtab] cmds-s-tab
|
||||||
|
:gi "TAB" cmds-tab
|
||||||
|
:gi [tab] cmds-tab))
|
||||||
|
|
||||||
;; 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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue