emacs: Autocomplete tweaks

This commit is contained in:
Charlotte Van Petegem 2023-08-02 14:49:32 +02:00
parent 51aa54d32a
commit 4da5d5718f
No known key found for this signature in database
GPG key ID: 019E764B7184435A
2 changed files with 30 additions and 3 deletions

View file

@ -24,6 +24,8 @@
:global-prefix "C-SPC" :global-prefix "C-SPC"
) )
;; Overwrite evil's evil-complete-next
(imap "C-n" 'completion-at-point)
(nmap "<escape>" 'save-buffer) (nmap "<escape>" 'save-buffer)
(lmap (lmap
"" nil ;; Unbind SPC, I don't use it for navigation anyway. "" nil ;; Unbind SPC, I don't use it for navigation anyway.
@ -101,12 +103,26 @@
:config (ido-mode nil) :config (ido-mode nil)
) )
;; Handy completion-at-point-functions
(use-package cape
:hook
(prog-mode . chvp--setup-capfs)
(text-mode . chvp--setup-capfs)
:config
(defun chvp--setup-capfs ()
(add-hook 'completion-at-point-functions #'tempel-complete -50 t)
(add-hook 'completion-at-point-functions #'cape-file 10 t)
(add-hook 'completion-at-point-functions #'dabbrev-capf 15 t)
(add-hook 'completion-at-point-functions #'cape-line 20 t)
)
)
;; Autocomplete ;; Autocomplete
(use-package corfu (use-package corfu
:diminish (corfu-mode) :diminish (corfu-mode)
:custom :custom
(corfu-cycle t "Enable cycling through completions") (corfu-cycle t "Enable cycling through completions")
(corfu-auto t "Auto completion") (corfu-auto t "Show completion preview by default")
(corfu-auto-prefix 2 "Show completion after two characters") (corfu-auto-prefix 2 "Show completion after two characters")
:config :config
(global-corfu-mode) (global-corfu-mode)
@ -263,14 +279,14 @@
;; Tempel (snippet expansion) ;; Tempel (snippet expansion)
(use-package tempel (use-package tempel
:demand t
:after cape
;; This is not very nice, but let's just assume that development machines have my nixos-config checked out ;; This is not very nice, but let's just assume that development machines have my nixos-config checked out
:custom (tempel-path "/home/charlotte/repos/nixos-config/modules/base/emacs/snippets/*.eld") :custom (tempel-path "/home/charlotte/repos/nixos-config/modules/base/emacs/snippets/*.eld")
:general :general
(lmap (lmap
"t i" '(tempel-insert :which-key "Insert template") "t i" '(tempel-insert :which-key "Insert template")
) )
:config
(setq completion-at-point-functions (cons #'tempel-complete completion-at-point-functions))
) )
;; List item selection interface ;; List item selection interface

View file

@ -44,6 +44,17 @@
"SPC n" '(flymake-goto-next-error :which-key "Next error") "SPC n" '(flymake-goto-next-error :which-key "Next error")
"SPC p" '(flymake-goto-prev-error :which-key "Previous error") "SPC p" '(flymake-goto-prev-error :which-key "Previous error")
) )
:hook (eglot-managed-mode . chvp--eglot-capf)
:config
(advice-add 'eglot-completion-at-point :around #'cape-wrap-buster)
(defun chvp--eglot-capf ()
(setq-local completion-at-point-functions
(list (cape-super-capf
#'eglot-completion-at-point
#'tempel-complete)
#'cape-file
#'dabbrev-capf
#'cape-line)))
) )
;; Forth syntax support ;; Forth syntax support