summary refs log tree commit diff
path: root/emacs/custom/my-completion.el
blob: a8629c82672bba51f80421fd0cc032e3451f4939 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
;;; my-completion.el --- Configure parts related to completion -*- lexical-binding: t -*-

;;; Commentary:

;;; Code:

(require 'cape)
(require 'consult)
(require 'corfu)
(require 'corfu-doc)
(require 'orderless)
(require 'marginalia)
(require 'savehist)
(require 'vertico)

;;; settings
;; save the mini buffer's history
(savehist-mode t)
(setq savehist-file (expand-file-name "var/history" user-emacs-directory))

(setq completion-styles '(orderless basic))
(setq completion-category-defaults nil)

(setq corfu-cycle t)       ;; Enable cycling for `corfu-next/previous'
(setq corfu-auto t)        ;; Enable auto completion
(setq corfu-max-width 80)  ;; Default is 100 and is too wide

(vertico-mode t)           ;; Enable vertico globally
(marginalia-mode t)        ;; Enable marginalia globally
(global-corfu-mode)        ;; Enable corfu globally

(add-to-list 'completion-at-point-functions #'cape-file)
(add-to-list 'completion-at-point-functions #'cape-abbrev)
(add-to-list 'completion-at-point-functions #'cape-ispell)

;;; bindings
(global-set-key (kbd "C-c m") 'consult-mode-command)
(global-set-key (kbd "C-x b") 'consult-buffer)
(global-set-key (kbd "C-x 4 b") 'consult-buffer-other-window)
(global-set-key (kbd "C-x r b") 'consult-bookmark)
(global-set-key (kbd "C-x p b") 'consult-project-buffer)
(global-set-key (kbd "C-c i") 'consult-imenu)
(global-set-key (kbd "C-c f") 'consult-git-grep)
(global-set-key (kbd "C-c /") 'consult-ripgrep)
(global-set-key (kbd "C-c r") 'consult-recent-file)
(global-set-key (kbd "M-y") 'consult-yank-pop)
(global-set-key (kbd "M-g e") 'consult-compile-error)
(global-set-key (kbd "M-g f") 'consult-flymake)
(global-set-key (kbd "M-g M-g") 'consult-goto-line)
(global-set-key (kbd "M-g O") 'consult-outline)
(global-set-key (kbd "M-g o") 'consult-org-heading)
(global-set-key (kbd "M-g m") 'consult-mark)
(global-set-key (kbd "M-g k") 'consult-global-mark)
(global-set-key (kbd "M-s l") 'consult-line)
(global-set-key (kbd "M-s L") 'consult-line-multi)

;;; hooks
;; display a documentation popup for completion candidate when using
;; corfu
(add-hook 'corfu-mode-hook #'corfu-doc-mode)

(provide 'my-completion)

;;; my-completion.el ends here