| git.druid.rocks | index | druid520 | radium | radium-completion.el |
radium-completion.el
;;; radium-completion.el, completion without lsp: vertico/orderless/corfu/cape/embark -*- lexical-binding: t; -*-
;;
;; minibuffer completion (M-x, switch-buffer, find-file, ...):
;; vertico + orderless + marginalia + consult
;; in-buffer completion (the actual "advanced completion" ask):
;; corfu (popup, works on a tty via corfu-terminal) + cape (backends:
;; dabbrev, file, keyword, history). ggtags contributes its own
;; completion-at-point backend from radium-tags.el once loaded.
;; actions on whatever i completed: embark (C-.).
;; manual fallback: hippie-expand on M-/, tries everything above plus more.
(use-package vertico
:init (vertico-mode 1)
:custom (vertico-cycle t))
(use-package orderless
:custom
(completion-styles '(orderless basic))
(completion-category-overrides '((file (styles basic partial-completion)))))
(use-package marginalia
:init (marginalia-mode 1))
(use-package consult
:bind (("C-c f" . consult-find)
("C-c g" . consult-grep)
("C-c r" . consult-recent-file)
("C-c i" . consult-imenu)
("C-x b" . consult-buffer)
("M-y" . consult-yank-pop)))
(use-package corfu
:init (global-corfu-mode 1)
:custom
(corfu-auto t)
(corfu-auto-delay 0.15)
(corfu-auto-prefix 2)
(corfu-cycle t)
(corfu-preselect 'prompt)
:config
;; corfu's popup binds TAB to accept/complete while it's showing,
;; which - since corfu-auto pops it up after just 2 characters - means
;; TAB silently stops indenting mid-typing far more often than it
;; looks like it should. RET already accepts (corfu-insert) and C-g
;; still quits, so TAB is free to always mean "indent", everywhere,
;; no exceptions.
(define-key corfu-map (kbd "TAB") nil)
(define-key corfu-map (kbd "<tab>") nil))
(use-package corfu-terminal
:after corfu
:init (unless (display-graphic-p) (corfu-terminal-mode 1)))
(use-package cape
:init
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
(add-to-list 'completion-at-point-functions #'cape-file)
(add-to-list 'completion-at-point-functions #'cape-keyword)
(add-to-list 'completion-at-point-functions #'cape-history))
;; embark: a menu of actions for whatever is at point or selected in
;; the minibuffer (C-.) - rename files from the file list, eval the
;; symbol under point, kill/insert the candidate, etc. the companion
;; package wires it into consult's preview-capable results.
(use-package embark
:bind ("C-." . embark-act))
;; geiser also claims C-. in scheme buffers (module completion) - it
;; keeps M-` for that, and C-. stays embark everywhere, one key one
;; meaning.
(defvar geiser-mode-map)
(with-eval-after-load 'geiser-mode
(define-key geiser-mode-map (kbd "C-.") nil))
(use-package embark-consult
:after (embark consult)
:hook (embark-collect-mode . consult-preview-at-point-mode))
(setq hippie-expand-try-functions-list
'(try-expand-dabbrev
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-list
try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))
(global-set-key (kbd "M-/") #'hippie-expand)
(provide 'radium-completion)