refactor(corfu): settings and keybinding overhaul
Previously, a distinction was made only between "regular" style (assumed to be for people who prefer to cycle directionally and commit with RET) and +tng (assumed to be for people who prefer TAB and auto-commit). This made composing further variations harder on the user, as they would have to work around our bindings. Now we provide a flag per feature, and the user can compose to their liking. Some variable options were turned into flags and the global CAPF list was pruned, suggesting to use individual keys for those functions if required.
This commit is contained in:
parent
2bb5f29a01
commit
03f065df9f
5 changed files with 149 additions and 171 deletions
|
@ -460,56 +460,65 @@ Continues comments if executed from a commented line. Consults
|
|||
|
||||
(map! :when (modulep! :completion corfu)
|
||||
:after corfu
|
||||
(:map corfu-mode-map
|
||||
:when (modulep! :completion corfu +individual)
|
||||
:prefix "C-x"
|
||||
:gi "C-l" #'cape-line
|
||||
:gi "C-k" #'cape-keyword
|
||||
:gi "C-f" #'cape-file
|
||||
:gi "s" #'cape-dict
|
||||
:gi "C-s" #'yasnippet-capf
|
||||
:gi "C-n" #'cape-dabbrev
|
||||
:gi "C-p" #'cape-history)
|
||||
(:map corfu-map
|
||||
"C-S-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)
|
||||
(:when (modulep! :completion corfu +tab)
|
||||
:gi [tab] #'corfu-next
|
||||
:gi "TAB" #'corfu-next
|
||||
:gi [backtab] #'corfu-previous
|
||||
:gi "S-TAB" #'corfu-previous))
|
||||
(:after corfu-popupinfo
|
||||
:map corfu-popupinfo-map
|
||||
"C-<up>" #'corfu-popupinfo-scroll-down
|
||||
"C-<down>" #'corfu-popupinfo-scroll-up
|
||||
(:when (modulep! :completion corfu +direction)
|
||||
"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 (not (modulep! :completion corfu +tng))
|
||||
(:map corfu-map
|
||||
"C-<return>" `(menu-item "Conclude the minibuffer" exit-minibuffer
|
||||
:filter ,(lambda (cmd) (when (minibufferp nil t) cmd)))
|
||||
"S-<return>" `(menu-item "Insert completion and conclude"
|
||||
+corfu-complete-and-exit-minibuffer
|
||||
:filter ,(lambda (cmd) (when (minibufferp nil t) cmd))))))
|
||||
(when-let ((cmds-del (and (modulep! :completion corfu +tng)
|
||||
`(menu-item "Reset completion" corfu-reset
|
||||
:filter ,(lambda (cmd)
|
||||
(when (and (>= corfu--index 0)
|
||||
(eq corfu-preview-current 'insert))
|
||||
cmd)))))
|
||||
(cmds-ret `(menu-item "Insert completion" corfu-insert
|
||||
:filter ,(lambda (cmd)
|
||||
(cond ((eq corfu--index -1)
|
||||
(corfu-quit))
|
||||
((and (modulep! :completion corfu +tng)
|
||||
(eq corfu-preview-current 'insert)
|
||||
(minibufferp nil t))
|
||||
(corfu-insert)
|
||||
nil)
|
||||
(t
|
||||
cmd))))))
|
||||
"C-S-d" (cmd! (funcall-interactively #'corfu-popupinfo-scroll-up corfu-popupinfo-min-height))))
|
||||
(when-let ((cmds-del
|
||||
`(menu-item "Reset completion" corfu-reset
|
||||
:filter ,(lambda (cmd)
|
||||
(interactive)
|
||||
(when (and (>= corfu--index 0)
|
||||
(eq corfu-preview-current 'insert))
|
||||
cmd))))
|
||||
(cmds-ret-pt
|
||||
`(menu-item "Insert completion or pass-through" corfu-insert
|
||||
:filter ,(lambda (cmd)
|
||||
(interactive)
|
||||
(if (>= corfu--index 0)
|
||||
cmd
|
||||
(corfu-quit))))))
|
||||
(map! :when (modulep! :completion corfu)
|
||||
:after corfu
|
||||
:map corfu-map
|
||||
[backspace] cmds-del
|
||||
"DEL" cmds-del
|
||||
:ig [return] cmds-ret
|
||||
:ig "RET" cmds-ret))
|
||||
(:when (modulep! :completion corfu +on-ret)
|
||||
:gi [return] #'corfu-insert
|
||||
:gi "RET" #'corfu-insert)
|
||||
(:when (modulep! :completion corfu +on-ret-pt)
|
||||
:gi [return] cmds-ret-pt
|
||||
:gi "RET" cmds-ret-pt)
|
||||
(:unless (or (modulep! :completion corfu +on-ret)
|
||||
(modulep! :completion corfu +on-ret-pt))
|
||||
[return] nil
|
||||
"RET" nil)))
|
||||
|
||||
;; 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue