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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
|
(use-package yasnippet
:straight t)
(use-package flycheck
:straight t
;; :custom (flycheck-check-syntax-automatically '(save mode-enable))
)
(use-package lsp-mode
:straight t
:hook ((lsp-mode . lsp-lens-mode)
;; Solves F# buffer out of sync
;; (lsp-mode . (lambda () (lsp-treemacs-sync-mode -1))
(lsp-mode . (flymake-mode-off))))
(use-package dap-mode
:straight t
:after lsp-mode
:bind (("C-c M-n" . dap-next)
("C-c M-s" . dap-step-in)
("C-c M-a" . dap-step-out)
("C-c M-w" . dap-continue)))
(require 'dap-netcore)
(use-package lsp-ui
:straight t
:init
(setq lsp-ui-doc-enable t
lsp-ui-sideline-diagnostic-max-lines 7
lsp-ui-sideline-diagnostic-max-line-length 40
lsp-lens-enable nil)
(defun magemacs/lsp-ui-doc-toggle ()
"For some reason it is required to do at least once a call to lsp-ui-doc-show in order for this to work. Probably the problem resides on the frame created requiring some preparation before actually being used, so `frame-live-p` doesn't return nil."
(interactive)
(let ((frame (lsp-ui-doc--get-frame)))
(if (frame-live-p frame)
(cond ((frame-visible-p frame) (lsp-ui-doc-hide))
(t (lsp-ui-doc-show)))
(message "Hover with the mouse or call `lsp-ui-doc-show` over some obect first. For why, read doc string."))))
:bind
(("s-?" . 'magemacs/lsp-ui-doc-toggle)))
(use-package nix-mode
:straight t
:hook
(nix-mode . lsp-deferred)
(nix-repl-mode . corfu-mode)
:config
(add-to-list 'lsp-language-id-configuration '(nix-mode . "nix"))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection '("nil"))
:major-modes '(nix-mode)
:server-id 'nix)))
(use-package swiper
:straight t
:bind
("\C-s" . swiper))
(use-package display-line-numbers
:straight t
:hook ((prog-mode . (lambda ()
(display-line-numbers-mode)
(setq display-line-numbers 'relative)))))
(use-package windmove
:straight t
:bind
("C-c <right>" . windmove-right)
("C-c <left>" . windmove-left)
("C-c <up>" . windmove-up)
("C-c <down>" . windmove-down))
(use-package perspective
:straight t
:bind (("C-x k" . persp-kill-buffer*))
:init
(persp-mode)
:custom (persp-suppress-no-prefix-key-warning t))
(use-package move-text
:straight t
:bind
("M-<up>" . move-text-up)
("M-<down>" . move-text-down))
(use-package corfu
:straight t
:custom ((corfu-auto t)
(corfu-auto-defer 0.25)
(corfu-min-width 15)
(corfu-max-width 70)
(corfu-auto-prefix 1)
(corfu-popupinfo-defer corfu-auto-defer))
:hook ((prog-mode . (lambda ()
(corfu-mode)
(unless window-system (corfu-terminal-mode))))
(sql-mode . (lambda ()
(corfu-mode)
(unless window-system (corfu-terminal-mode))))
(corfu-mode . corfu-popupinfo-mode)
(eshell-mode . corfu-mode)))
(use-package corfu-terminal
:straight t)
(use-package fsharp-mode
:straight t
;; :after lsp-mode
:mode (("\\.fs$" . fsharp-mode)
("\\.fsx$" . fsharp-mode)
("\\.fsi$" . fsharp-mode))
:hook ((fsharp-mode . eglot-ensure))
:bind
(("C-c C-," . 'fsharp-shift-region-left)
("C-c C-." . 'fsharp-shift-region-right)
("C-o" . 'fsharp-newline-and-indent)
("C-c C-i" . 'run-fsharp)
("C-c C-a" . 'fsharp-find-alternate-file)
("M-h" . 'fsharp-mark-phrase))
:config
;; (setq lsp-fsharp-server-install-dir "/Users/mmagueta/.dotnet/tools/fsautocomplete")
(setq compile-command "dotnet build")
(setq inferior-fsharp-program "dotnet fsi --readline-"))
(use-package magit
:straight t
:bind
("C-x g" . magit-status)
:config
(use-package diff-hl
:straight t))
(use-package helm
:straight t
:init
(helm-mode t)
(if (seq-find (lambda (x) (or (eq 'marquardt x)
(eq 'feng-shui x))) custom-enabled-themes)
(set-face-attribute 'helm-selection nil
:background (color-lighten-name (face-attribute 'default :foreground) 50)
:foreground (color-darken-name (face-attribute 'default :background) 40))
(set-face-attribute 'helm-selection nil
:background (color-lighten-name (face-attribute 'default :foreground) 50)
:foreground (color-darken-name (face-attribute 'default :background) 100)))
:bind
("M-x" . helm-M-x)
("M-i" . helm-imenu)
("C-x b" . helm-buffers-list))
(use-package multiple-cursors
:straight t
:bind
("C-c m c" . mc/edit-lines)
("C-<" . mc/mark-previous-like-this)
("C->" . mc/mark-next-like-this))
(use-package projectile
:straight t
:init
(projectile-mode t)
:bind-keymap
("C-c p" . projectile-command-map))
(use-package dashboard
:after projectile
:straight t
:after all-the-icons
;; :diminish dashboard-mode
:config
(dashboard-setup-startup-hook)
(setq dashboard-center-content t)
;; (setq dashboard-set-file-icons t)
;; (setq dashboard-startup-banner "~/.emacs.d/sources/emacs.svg")
(setq dashboard-startup-banner "~/.emacs.d/sources/magemacs.png")
(setq dashboard-image-banner-max-height 300)
(setq dashboard-image-banner-max-width 500)
(setq dashboard-banner-logo-title "Welcome to MageMacs, a magic GNU Emacs customization")
(setq dashboard-items '((recents . 5)
(bookmarks . 5)
(projects . 5)))
(setq dashboard-center-content t)
(setq dashboard-footer-messages '("Quod oculus non vidit, nec auris audivit - I Corinthios II,IX")))
(use-package transpose-frame
:straight t)
(use-package copilot
:straight (:host github :repo "copilot-emacs/copilot.el" :files ("dist" "*.el"))
:bind (:map copilot-mode-map
("C-q <tab>" . copilot-accept-completion)
("C-q <right>" . copilot-next-completion)
("C-q <left>" . copilot-previous-completion)))
(use-package candle-mode
:after lsp-mode
:straight (:host github :repo "PerplexSystems/candle-mode" :files ("dist" "*.el"))
:hook ((candle-mode . lsp-deferred))
:config
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)
(add-to-list 'lsp-language-id-configuration
'(candle-mode . "candle"))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection "millet-ls")
:activation-fn (lsp-activate-on "candle")
:server-id 'millet)))
(use-package erlang
:straight t
:hook
(erlang-mode . lsp-deferred)
(erlang-mode . yas-minor-mode)
(erlang-mode . erlang-set-project-root)
:config
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection '("elp" "server"))
:major-modes '(erlang-mode)
:priority 0
:server-id 'erlang-language-platform))
(setq inferior-erlang-machine "rebar3")
(setq inferior-erlang-machine-options '("shell"))
(setq inferior-erlang-shell-type nil)
(defun erlang-set-project-root ()
"Set `default-directory` to the parent dir containing `rebar.config` or `rebar.config.script`, if found."
(when (derived-mode-p 'erlang-mode)
(let* ((start (or (buffer-file-name) default-directory))
(proj-root
(locate-dominating-file
start
(lambda (dir)
(or (file-exists-p (expand-file-name "rebar.config" dir))
(file-exists-p (expand-file-name "rebar.config.script" dir)))))))
(when proj-root
(setq-local default-directory proj-root))))))
;; (use-package eglot
;; :bind (:map eglot-mode-map
;; ("C-c C-d" . eglot-help-at-point)
;; ("C-c C-r" . eglot-code-actions)))
;; (use-package eglot-fsharp
;; :straight t)
(use-package eldoc
:straight t
:hook (eglot-mode . eldoc-mode)
:config
(eldoc-add-command 'corfu-insert))
(use-package eldoc-box
:straight t
:hook (eldoc-mode . eldoc-box-hover-mode))
(use-package lfe-mode
:straight t
:mode ("\\.lfe$" . lfe-mode)
:hook
(lfe-mode . display-line-numbers-mode)
(lfe-mode . corfu-mode)
(lfe-mode . eglot-ensure)
(lfe-mode . yas-minor-mode)
:init
(defvar lfe-mode-syntax-table
(let ((table (copy-syntax-table lisp-mode-syntax-table)))
;; Like scheme we allow [ ... ] as alternate parentheses.
(modify-syntax-entry ?\[ "(] " table)
(modify-syntax-entry ?\] ")[ " table)
;; ":" character should be used as punctuation to separate symbols
(modify-syntax-entry ?: "." table)
table)
"Syntax table in use in Lisp Flavoured Erlang mode buffers.")
(defun find-rebar-config-root ()
"Find the nearest parent directory containing 'rebar.config'.
Starts from `default-directory`. Returns the path or nil if not found."
(let ((dir (file-name-as-directory default-directory)))
(catch 'found
(while dir
(if (file-exists-p (expand-file-name "rebar.config" dir))
(throw 'found dir)
(let ((parent (file-name-directory (directory-file-name dir))))
(if (or (null parent) (equal parent dir))
(setq dir nil) ;; reached root
(setq dir parent)))))
nil)))
(defvar inferior-lfe-program
;; (concat "rebar3 --config " (find-rebar-config-root) "rebar.config lfe repl")
;; (setenv "REBAR_CONFIG" (concat (find-rebar-config-root)
;; "rebar.config"))
;; "rebar3 lfe repl")
;; "rebar3 --config /home/mmagueta/Projects/Nekoma/mahjong/server/rebar.config lfe repl"
"rebar3")
(defvar inferior-lfe-program-options '("lfe" "repl"))
(defun inferior-lfe ()
"Run an inferior LFE process, input and output via a buffer `*inferior-lfe*'.
Start the shell `inferior-lfe-program' `inferior-lfe-program-options' -env TERM vt100.
If a rebar project is found you are prompted (see `inferior-lfe-check-if-rebar-project')
and can choose to run lfe using rebar3."
(interactive)
(let ((prog inferior-lfe-program)
(opts inferior-lfe-program-options)
(rebar-project-root (inferior-lfe--is-rebar-project))
(mix-project-root (inferior-lfe--is-mix-project)))
(cond
((and inferior-lfe-check-if-rebar-project
rebar-project-root
(inferior-lfe--start-rebar-lfe))
(setq prog "sh"
opts (list "-i" "-c" (concat "TERM=\"vt100\";"
(format "cd %s" rebar-project-root)
"; rebar3 lfe repl"))))
((and inferior-lfe-check-if-mix-project
mix-project-root
(inferior-lfe--start-mix-lfe))
(setq prog "sh"
opts (list "-i" "-c" (concat "TERM=\"vt100\";"
(format "cd %s" mix-project-root)
"; mix lfe repl")))))
(unless (comint-check-proc "*inferior-lfe*")
(set-buffer (apply (function make-comint)
"inferior-lfe" prog nil opts))
(inferior-lfe-mode))
(setq inferior-lfe-buffer "*inferior-lfe*")
(pop-to-buffer "*inferior-lfe*"))))
(with-eval-after-load 'eglot
(add-to-list
'eglot-server-programs
`(lfe-mode . (,(concat (getenv "HOME") "/Binary/lfe-ls/_build/prod/bin/lfe-ls")
"--transport" "tcp" "--port" :autoport))))
;; (with-eval-after-load 'eglot
;; (add-to-list
;; 'eglot-server-programs
;; `(fsharp-mode . (,(concat (getenv "HOME") "/.dotnet/tools/fsautocomplete")
;; ))))
;; (use-package eglot-fsharp
;; :after fsharp-mode
;; :config
;; (add-hook 'fsharp-mode-hook #'eglot-ensure))
(use-package org-drill
:straight t)
(use-package sly
:straight t
:hook ((sly-mode . corfu-mode)
(sly-mode . smartparens-mode))
:init
;; (setq sly-lisp-implementations
;; '((sbcl ("/etc/profiles/per-user/mmagueta/bin/sbcl"))
;; (ecl ("/etc/profiles/per-user/mmagueta/bin/ecl"))))
(defun sly-eval-last-expression-eros ()
(interactive)
(cl-destructuring-bind (output value)
(sly-eval `(swank:eval-and-grab-output ,(sly-last-expression)))
(eros--make-result-overlay (concat output value)
:where (point)
:duration eros-eval-result-duration)))
:bind (:map sly-mode-map
("C-x C-e" . sly-eval-last-expression-eros)))
(use-package cider
:straight t
:hook (cider-mode . corfu-mode))
(use-package clojure-mode
:straight t
:after cider
:hook ((clojure-mode . lsp-deferred)))
(use-package rainbow-delimiters
:straight t
:hook
(lisp-mode . rainbow-delimiters-mode)
(emacs-lisp-mode . rainbow-delimiters-mode)
(lfe-mode . rainbow-delimiters-mode)
(clojure-mode . rainbow-delimiters-mode))
(use-package smartparens
:straight t
:hook ((lisp-mode . smartparens-mode)
(emacs-lisp-mode . smartparens-mode)
(lfe-mode . smartparens-mode)
(clojure-mode . smartparens-mode)
(cider-mode . smartparens-mode))
:bind (:map smartparens-mode-map
("C-M-<right>" . 'sp-forward-sexp)
("C-M-<left>" . 'sp-backward-sexp)
("C-M-<down>" . 'sp-down-sexp)
("C-M-<up>" . 'sp-up-sexp)
("C-k" . 'sp-kill-sexp)
("M-r" . 'sp-copy-sexp)
("C-M-s" . 'sp-forward-slurp-sexp)
("C-S-s" . 'sp-backward-slurp-sexp)
("C-M-b" . 'sp-forward-barf-sexp)
("C-S-b" . 'sp-backward-barf-sexp)))
;; (use-package protobuf-mode
;; :straight t)
(let ((secrets (concat (getenv "HOME") "/.emacs.d/secrets.el")))
(when (file-exists-p secrets)
(load-file secrets)))
(use-package sqlformat
:straight t
:ensure t
:custom
(sqlformat-command 'pgformatter)
(sqlformat-args '("-s2" "-g")))
(lsp-register-client
(make-lsp-client
:new-connection
(lsp-stdio-connection (list "swipl"
"-g" "use_module(library(lsp_server))."
"-g" "lsp_server:main"
"-t" "halt"
"--" "stdio"))
:major-modes '(prolog-mode)
:priority 1
:multi-root t
:server-id 'prolog-ls))
(use-package c++-mode
:after lsp-mode
:hook (c++-mode . lsp-deferred))
(use-package tuareg
:straight t
:after dap-mode
:hook (tuareg-mode . lsp-deferred)
:config
(require 'dap-mode)
(require 'dap-codelldb)
(require 'dap-ocaml))
(use-package eros
:straight t
:hook (emacs-lisp-mode . eros-mode))
;; (use-package pgmacs
;; :straight (:host github :repo "MMagueta/pgmacs" :branch "add-script-support" :files ("dist" "*.el")))
(use-package envrc
:straight t
:hook (after-init . envrc-global-mode))
(use-package direnv
:straight t)
(use-package projectile-direnv
:straight t)
(use-package org-super-agenda
:straight t
:after org
:custom
(org-agenda-custom-commands
'(("c" "Super Agenda"
((agenda "" ((org-super-agenda-groups
'((:name "Today"
:time-grid t
:date today
:todo "TODAY")
(:name "Due soon"
:deadline future)
(:name "Overdue"
:deadline past)
(:name "Important"
:priority "A")))))))))
(org-agenda-files `(,(concat (getenv "HOME") "/.emacs.d/agenda.org")))
:config
(org-super-agenda-mode))
(defun c-mode-compile-bind ()
"Bind C-c C-c to `compile' in C mode."
(local-set-key (kbd "C-c C-c") #'compile))
(add-hook 'c-mode-hook #'c-mode-compile-bind)
(add-hook 'c-mode-hook #'lsp-deferred)
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection '("denon" "lsp"))
:activation-fn (lsp-activate-on "typescript")
:priority -1
:server-id 'ts-ls))
(provide 'configuration)
;;; configuration.el ends here
|