aboutsummaryrefslogtreecommitdiff
path: root/.config/emacs/ide.el
blob: 24a4d7ed59917ed2492ee3e916601d1e72a22b37 (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
;; == eglot
(use-package eglot
  :ensure nil
  :bind
  (("C-c l a" . eglot-code-actions))
  (("C-c l r" . eglot-rename))
  :hook
  (eglot-managed-mode . (lambda () (setq-local eldoc-documentation-function 'eldoc-documentation-enthusiast)))
  (eglot-mode-hook . flymake-mode)
  :config
  (add-to-list 'eglot-ignored-server-capabilities ':inlayHintProvider)
  (add-to-list 'eglot-ignored-server-capabilities ':documentOnTypeFormattingProvider)
  (add-to-list 'eglot-ignored-server-capabilities ':documentHighlightProvider)
  (add-to-list 'eglot-server-programs
			   '((c-ts-mode c++-ts-mode c-mode c++-mode)
				 . ("clangd"
					"-j=8"
					"--log=error"
					"--malloc-trim"
					"--background-index"
					"--completion-style=detailed"
					"--pch-storage=memory"
					"--header-insertion=never"
					"--header-insertion-decorators=0")))
  :custom
  (eglot-send-changes-idle-time 0.1))

(use-package eldoc
  :ensure nil
  :config
  (setq-default eldoc-documentation-strategy 'eldoc-documentation-enthusiast)
  (setq-default eldoc-minor-mode-string ""))

(use-package sideline-flymake
  :ensure nil)
(use-package sideline
  :ensure nil
  :diminish
  :hook
  ((flymake-mode . sideline-mode))
  :init
  (setq sideline-backends-right '(sideline-flymake)
		sideline-backends-right-skip-current-line nil
		sideline-order-right 'up
		sideline-priority 100))

;; == dumb jump
(use-package dumb-jump
  :ensure nil
  :init
  (add-hook 'xref-backend-functions #'dumb-jump-xref-activate)
  (setq xref-show-definitions-function #'xref-show-definitions-completing-read))

;; == text completion
(use-package corfu
  :ensure nil
  :demand t
  :bind
  (:map corfu-map
		("C-g" . corfu-quit))
  :config
  (add-hook 'corfu-mode-hook
			(lambda ()
			  ;; disable orderless
			  (setq-local completion-styles '(basic)
						  completion-category-overrides nil
						  completion-category-defaults nil)))
  (global-corfu-mode))

(use-package corfu-history
  :ensure nil
  :demand t
  :config
  (corfu-history-mode))

(use-package cape
  :ensure nil
  :demand t
  :init
  (add-hook 'completion-at-point-functions #'cape-dabbrev)
  (add-hook 'completion-at-point-functions #'cape-file)
  :config
  (advice-add 'eglot-completion-at-point :around  #'cape-wrap-buster))
  ;; (defun my/lsp-capf-busted ()
  ;;   "Return an uncached LSP completion function."
  ;;   (cape-capf-buster #'lsp-completion-at-point))
  ;; (add-hook 'lsp-completion-mode-hook
  ;;           (lambda ()
  ;;             (setq-local completion-at-point-functions
  ;;                         (list (my/lsp-capf-busted))))))

(use-package completion-preview
  :ensure nil
  :demand t
  :diminish
  :config
  (global-completion-preview-mode)
  (global-set-key (kbd "M-n") 'completion-preview-next-candidate)
  (global-set-key (kbd "M-p") 'completion-preview-prev-candidate))

;; == snippets
(use-package yasnippet
  :ensure nil
  :diminish yas-minor-mode yas-global-mode
  :config
  (yas-reload-all)
  :hook
  (prog-mode . yas-minor-mode)
  :bind
  (:map yas-keymap
		("M-n" . yas-next-field)
		("M-p" . yas-prev-field)
		([(tab)] . nil)
		("TAB" . nil)
		("M-I" . nil))
  (:map yas-minor-mode-map
		("C-'". yas-expand)
		([(tab)] . nil)
		("TAB" . nil)
		("M-I" . nil)))

;; (use-package yasnippet
;;   :bind
;;   (:map yas-minor-mode-map
;;         ("C-'". yas-expand)
;;         ([(tab)] . nil)
;;         ("TAB" . nil))
;;   :config
;;   (yas-reload-all)
;;   (yas-global-mode t))

(use-package yasnippet-snippets
  :ensure nil
  :after yasnippet)