summaryrefslogtreecommitdiff
path: root/dot_config/emacs/lisp/lsp-mode-config.el
blob: cc26d9ca05f26e49a45a796478b184cd7257fdca (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
;; (use-package lsp-mode
;;   :init
;;   ;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
;;   (setq lsp-keymap-prefix "C-c l")
;;   :hook
;;   ((lsp-mode . lsp-enable-which-key-integration)
;;    (prog-mode . lsp-deferred))
;;   :commands lsp
;;   :custom
;;   (lsp-keymap-prefix "C-c l")                                ;; Set the prefix for LSP commands.
;;   (lsp-inlay-hint-enable t)                                  ;; Usage of inlay hints.
;;   (lsp-session-file (locate-user-emacs-file ".lsp-session")) ;; Specify session file location.
;;   (lsp-log-io nil)                                           ;; Disable IO logging for speed.
;;   (lsp-idle-delay 0.5)                                       ;; Set the delay for LSP to 0 (debouncing).
;;   (lsp-keep-workspace-alive nil)                             ;; Disable keeping the workspace alive.
;;   ;; Core settings
;;   (lsp-enable-xref t)                                        ;; Enable cross-references.
;;   (lsp-auto-configure t)                                     ;; Automatically configure LSP.
;;   (lsp-enable-links nil)                                     ;; Disable links.
;;   (lsp-eldoc-enable-hover t)                                 ;; Enable ElDoc hover.
;;   (lsp-enable-file-watchers nil)                             ;; Disable file watchers.
;;   (lsp-enable-folding nil)                                   ;; Disable folding.
;;   (lsp-enable-imenu t)                                       ;; Enable Imenu support.
;;   (lsp-enable-indentation nil)                               ;; Disable indentation.
;;   (lsp-enable-on-type-formatting nil)                        ;; Disable on-type formatting.
;;   (lsp-enable-suggest-server-download t)                     ;; Enable server download suggestion.
;;   (lsp-enable-symbol-highlighting t)                         ;; Enable symbol highlighting.
;;   (lsp-enable-text-document-color t)                         ;; Enable text document color.
;;   (lsp-warn-no-matched-clients nil)                          ;; Disable warning when there are no supported clients.
;;   ;; Modeline settings
;;   (lsp-modeline-code-actions-enable nil)                     ;; Keep modeline clean.
;;   (lsp-modeline-diagnostics-enable nil)                      ;; Use `flymake' instead.
;;   (lsp-modeline-workspace-status-enable t)                   ;; Display "LSP" in the modeline when enabled.
;;   (lsp-signature-doc-lines 1)                                ;; Limit echo area to one line.
;;   (lsp-eldoc-render-all t)                                   ;; Render all ElDoc messages.
;;   ;; Completion settings
;;   (lsp-completion-enable t)                                  ;; Enable completion.
;;   (lsp-completion-enable-additional-text-edit t)             ;; Enable additional text edits for completions.
;;   (lsp-enable-snippet t)                                     ;; Disable snippets
;;   (lsp-completion-show-kind t)                               ;; Show kind in completions.
;;   ;; Lens settings
;;   (lsp-lens-enable t)                                        ;; Enable lens support.
;;   ;; Headerline settings
;;   (lsp-headerline-breadcrumb-enable-symbol-numbers t)        ;; Enable symbol numbers in the headerline.
;;   (lsp-headerline-arrow "▶")                                 ;; Set arrow for headerline.
;;   (lsp-headerline-breadcrumb-enable-diagnostics nil)         ;; Disable diagnostics in headerline.
;;   (lsp-headerline-breadcrumb-icons-enable nil)               ;; Disable icons in breadcrumb.
;;   ;; Semantic settings
;;   (lsp-semantic-tokens-enable nil)
;;   :config
;;   (define-key lsp-mode-map (kbd "C-c l") lsp-command-map)
;;   )

(use-package eldoc-box)

(use-package eglot
  :hook
  ;; Automatically start Eglot for specific programming modes
  ((prog-mode . eglot-ensure))
  :bind
  ("C-c l a" . eglot-code-actions)
  ("C-c l r" . eglot-rename)
  ("C-c l h" . eldoc-box-help-at-point)
  ("C-c l f" . eglot-format)
  ("C-c l F" . eglot-format-buffer)
  ("C-c l d" . xref-find-definitions)
  ("C-c l R" . xref-find-references)
  ("C-c l i" . eglot-find-implementation)
  :custom
  (eglot-autoshutdown t)
  :config
  ;; Configure rust-analyzer to use Clippy instead of Cargo Check
  (setq-default eglot-workspace-configuration
                '(:rust-analyzer
                  (:check
                   (:command "clippy")))))

(use-package corfu
  :ensure t
  :defer t
  :custom
  (corfu-auto nil)                       ;; Only completes when hitting TAB
  (corfu-auto-delay 0)                ;; Delay before popup (enable if corfu-auto is t)
  (corfu-auto-prefix 1)                  ;; Trigger completion after typing 1 character
  (corfu-quit-no-match t)                ;; Quit popup if no match
  (corfu-scroll-margin 5)                ;; Margin when scrolling completions
  (corfu-max-width 50)                   ;; Maximum width of completion popup
  (corfu-min-width 50)                   ;; Minimum width of completion popup
  (corfu-popupinfo-delay 0.5)            ;; Delay before showing documentation popup
  :init
  (global-corfu-mode)
  (corfu-popupinfo-mode t))


(use-package yasnippet
  :ensure t)
  ;; :hook ((text-mode
  ;;         prog-mode
  ;;         conf-mode
;;         snippet-mode) . yas-minor-mode))

(use-package yasnippet-capf
  :after cape
  :config
  (add-to-list 'completion-at-point-functions #'yasnippet-capf)
  (defun mi/eglot-capf-with-yasnippet ()
  (setq-local completion-at-point-functions
              (list
	       (cape-capf-super
		#'eglot-completion-at-point
		#'yasnippet-capf))))
(with-eval-after-load 'eglot
  (add-hook 'eglot-managed-mode-hook #'mi/eglot-capf-with-yasnippet)))

(use-package yasnippet-snippets)

;; (use-package flycheck
;;   :ensure t
;;   :custom
;;   (flycheck-display-errors-delay 0))

;; (use-package flycheck-inline
;;   :hook
;;   (flycheck-mode . flycheck-inline-mode))

(use-package rustic
  :ensure t
  :defer t
  :init (setq rust-mode-treesitter-derive t)
  :config
  (setq rustic-lsp-client 'eglot)
  (setq rustic-format-on-save t)
  (setq rustic-rustfmt-args "--edition 2024") ;; should be a temporary fix
  :custom
  (rustic-cargo-use-last-stored-arguments t)
  (rustic-babel-display-error-popup nil)
  (rustic-lsp-setup-p nil)
  (lsp-rust-analyzer-cargo-watch-command "clippy"))

(use-package cape
  :demand t
  :init
  ;; Add `completion-at-point-functions', used by `completion-at-point'.
  (setq-default completion-at-point-functions
                (append (default-value 'completion-at-point-functions)
                        (list #'cape-dabbrev #'cape-file #'cape-abbrev #'cape-emoji #'cape-history #'cape-tex))))

(use-package fennel-mode
  :config
  (with-eval-after-load 'org
    (require 'ob-fennel)))

;; DAP Mode
;; (use-package exec-path-from-shell
;;   :ensure
;;   :init (exec-path-from-shell-initialize))

;; (use-package dap-mode
;;   :defer t
;;   :ensure
;;   :config
;;   (dap-ui-mode)
;;   (dap-ui-controls-mode 1)

;;   (require 'dap-lldb)
;;   (require 'dap-gdb-lldb)
;;   (dap-gdb-lldb-setup))

(provide 'lsp-mode-config)