aboutsummaryrefslogtreecommitdiff
path: root/.emacs.d/lisp/init-eglot.el
blob: 311c5d31062e07a853c82aa83fe858d25026b940 (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
(when (gx/maybe-require-package 'eglot)
  (autoload #'eglot-ensure "eglot" nil t))

(defun gx/eglot-format-before-save ()
  (add-hook 'before-save-hook #'eglot-format nil t))

(defun gx/eglot-code-action-organize-imports-before-save ()
  (add-hook 'before-save-hook #'eglot-code-action-organize-imports nil t))

(with-eval-after-load 'evil
  (evil-define-key 'normal 'eglot--managed-mode
    (kbd "gd") 'xref-find-definitions
    (kbd "gr") 'xref-find-references
    (kbd "gt") 'eglot-find-typeDefinition
    (kbd "K") 'eldoc-doc-buffer
    (kbd "gi") 'eglot-find-implementation
    (kbd "C-t") 'xref-pop-marker-stack))

(setq eglot-autoreconnect t)

(with-eval-after-load 'eglot
  (setq completion-category-defaults nil))

(provide 'init-eglot)