summaryrefslogtreecommitdiff
path: root/config.el
blob: f9736bdaae9ac2fd3659f8b87d54da993d65cc80 (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
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
;;; -*- lexical-binding: t; -*-

;; (setq doom-font (font-spec :family "Hasklig" :size 15))
(load-theme 'doom-palenight t)

(when (version<= "26.0.50" emacs-version )
  (global-display-line-numbers-mode))

;; company-mode auto-completion, to turn off use :company-complete
(require 'company)
(setq company-idle-delay 0.2
      company-minimum-prefix-length 3)

;; hooks to turn on lsp when entering haskell mode
(add-hook 'haskell-mode-hook #'lsp)
(add-hook 'haskell-literate-mode-hook #'lsp)

(setq org-agenda-files '("~/org" "~/org/roam"))
(setq org-roam-directory "~/org/roam")
(setq org-roam-v2-ack t)

(setq org-todo-keywords
      '((sequence "TODO" "IDEA" "IDLE" "DONE"))
        org-todo-keyword-faces
        '(("[-]"  . +org-todo-active)
          ("[?]"  . +org-todo-onhold)
          ("KILL" . +org-todo-cancel)))

(add-to-list 'load-path "~/.nix-profile/share/emacs/site-lisp/mu4e/")

(after! mu4e
  (set-email-account! "hacc"
                      '( (user-mail-address . "stuebinm@hacc.space")
                         (user-full-name . "stuebinm")
                         (m4u-maildir . "~/Maildir/hacc")
                         (mu4e-sent-folder . "/hacc/Sent")
                         (mu4e-trash-folder . "/hacc/Trash") )
                      t))

(after! helm-dictionary
  (setq helm-dictionary-database
        '(("de-en" . "~/org/dict/de-en.txt")
          ("es-de" . "~/org/dict/es-de.txt")
          ("en-it" . "~/org/dict/en-it-enwiktionary.txt")
          ("it-en" . "~/org/dict/it-en-enwiktionary.txt"))))



;; Use carp-mode for .carp files
;(add-to-list 'auto-mode-alist '("\\.carp\\'" . carp-mode))


;; carp-mode and stuff
(add-to-list 'load-path "~/.config/nixpkgs/doom.d/carp-emacs")

;; (require 'carp-mode)
;; (require 'inf-carp-mode)
;; (require 'carp-flycheck)
;; ;; Use carp-mode for .carp files
;; (add-to-list 'auto-mode-alist '("\\.carp\\'" . carp-mode))
;; ;; flycheck mode for better type errors
;; (add-hook 'carp-mode-hook
;;           (lambda ()
;;             (flycheck-mode 1)))

;; hide all these annoying popups that clutter the view
(setq lsp-ui-doc-enable nil)
(setq lsp-ui-sideline-show-code-actions nil)
(setq lsp-signature-render-documentation nil)

(after! (lsp-ui helm-lsp)
  (lsp-signature-activate)
  ;; custom version which will not blindly apply a single code action
  ;; if only one is available without asking about it first.
  ;; Source taken from https://github.com/emacs-lsp/helm-lsp/blob/master/helm-lsp.el
  (lsp-make-interactive-code-action wingman-fill-hole "refactor.wingman.fillHole")
  (lsp-make-interactive-code-action wingman-case-split "refactor.wingman.caseSplit")
  (lsp-make-interactive-code-action wingman-refine "refactor.wingman.refine")
  (lsp-make-interactive-code-action wingman-split-func-args "refactor.wingman.spltFuncArgs")
  (lsp-make-interactive-code-action wingman-use-constructor "refactor.wingman.useConstructor")
  (map! :map haskell-mode-map
        "C-c s" #'lsp-wingman-split
        "C-c h" #'lsp-wingman-fillhole)
  (defun helm-lsp-code-actions-custom()
    "Show lsp code actions using helm."
    (interactive)
    (let ((actions (lsp-code-actions-at-point)))
      (cond
       ((seq-empty-p actions) (signal 'lsp-no-code-actions nil))
       (t (helm :sources
                (helm-build-sync-source
                    "Code Actions"
                  :candidates actions
                  :candidate-transformer
                  (lambda (candidates)
                    (-map
                     (-lambda ((candidate &as
                                          &CodeAction :title))
                       (list title :data candidate))
                     candidates))
                  :action '(("Execute code action" . (lambda(candidate)
                                                       (print "selected code action")
                                                       (print (plist-get candidate :data))
                                                       (lsp-execute-code-action (plist-get candidate :data)))))))))))

  (map! :map doom-leader-code-map
        "a" #'helm-lsp-code-actions-custom))





(use-package! isar-mode
  :mode "\\.thy\\'"
  :config
  ;; (add-hook 'isar-mode-hook 'turn-on-highlight-indentation-mode)
  ;; (add-hook 'isar-mode-hook 'flycheck-mode)
  (add-hook 'isar-mode-hook 'company-mode)
  (add-hook 'isar-mode-hook
            (lambda ()
              (set (make-local-variable 'company-backends)
                   '((company-dabbrev-code company-yasnippet)))))
  (add-hook 'isar-mode-hook
            (lambda ()
              (set (make-local-variable 'indent-tabs-mode) nil)))
  (add-hook 'isar-mode-hook
            (lambda ()
              (yas-minor-mode))))

(use-package! lsp-isar-parse-args
  :custom
  (lsp-isar-parse-args-nollvm nil))

(use-package! lsp-isar
  :commands lsp-isar-define-client-and-start
  :custom
  (lsp-isar-output-use-async t)
  (lsp-isar-output-time-before-printing-goal nil)
  (lsp-isar-experimental t)
  (lsp-isar-split-pattern 'lsp-isar-split-pattern-three-columns)
  (lsp-isar-decorations-delayed-printing t)
  :init
  (add-hook 'lsp-isar-init-hook 'lsp-isar-open-output-and-progress-right-spacemacs)
  (add-hook 'isar-mode-hook #'lsp-isar-define-client-and-start)

  (push (concat "/home/stuebinm/clones/isabelle-emacs/src/Tools/emacs-lsp/yasnippet")
   yas-snippet-dirs)
  (setq lsp-isar-path-to-isabelle "/home/stuebinm/clones/isabelle-emacs"))















(require 'exwm)
;; (if (boundp 'inexwm)
;;     (progn



(defvar desktop-environment-mode-map
  (let ((desktop-environment--keybindings
         `(;; Brightness
           (,(kbd "<XF86MonBrightnessUp>") . ,(function desktop-environment-brightness-increment))
           (,(kbd "<XF86MonBrightnessDown>") . ,(function desktop-environment-brightness-decrement))
           (,(kbd "S-<XF86MonBrightnessUp>") . ,(function desktop-environment-brightness-increment-slowly))
           (,(kbd "S-<XF86MonBrightnessDown>") . ,(function desktop-environment-brightness-decrement-slowly))
           ;; Volume
           (,(kbd "<XF86AudioRaiseVolume>") . ,(function desktop-environment-volume-increment))
           (,(kbd "<XF86AudioLowerVolume>") . ,(function desktop-environment-volume-decrement))
           (,(kbd "S-<XF86AudioRaiseVolume>") . ,(function desktop-environment-volume-increment-slowly))
           (,(kbd "S-<XF86AudioLowerVolume>") . ,(function desktop-environment-volume-decrement-slowly))
           (,(kbd "<XF86AudioMute>") . ,(function desktop-environment-toggle-mute))
           (,(kbd "<XF86AudioMicMute>") . ,(function desktop-environment-toggle-microphone-mute))
           ;; Screenshot
           (,(kbd "S-<print>") . ,(function desktop-environment-screenshot-part))
           (,(kbd "<print>") . ,(function desktop-environment-screenshot))
           ;; Screen locking
           (,(kbd "s-c") . ,(function desktop-environment-lock-screen))
           (,(kbd "<XF86ScreenSaver>") . ,(function desktop-environment-lock-screen))
           ;; Wifi controls
           (,(kbd "<XF86WLAN>") . ,(function desktop-environment-toggle-wifi))
           ;; Bluetooth controls
           (,(kbd "<XF86Bluetooth>") . ,(function desktop-environment-toggle-bluetooth))
           ;; Music controls
           (,(kbd "<XF86AudioPlay>") . ,(function desktop-environment-toggle-music))
           (,(kbd "<XF86AudioPrev>") . ,(function desktop-environment-music-previous))
           (,(kbd "<XF86AudioNext>") . ,(function desktop-environment-music-next))
           (,(kbd "<XF86AudioStop>") . ,(function desktop-environment-music-stop))))
        (map (make-sparse-keymap)))
    (dolist (keybinding desktop-environment--keybindings)
      (define-key map (car keybinding) (cdr keybinding)))
    map)
  "Keymap for `desktop-environment-mode'.")

(defun desktop-environment-exwm-set-global-keybindings (enable)
  (when (featurep 'exwm-input)
      (when enable
        (map-keymap (lambda (event definition)
                      (exwm-input-set-key (vector event) definition))
                    desktop-environment-mode-map))))


;; set up desktop env keybindings with exwm
;(setq desktop-environment-update-global-keys :global)
;(desktop-environment-mode)
(desktop-environment-exwm-set-global-keybindings t)

;; keybindings for exwm
(exwm-input-set-key (kbd "s-l") 'evil-window-right)
(exwm-input-set-key (kbd "s-k") 'evil-window-up)
(exwm-input-set-key (kbd "s-j") 'evil-window-down)
(exwm-input-set-key (kbd "s-h") 'evil-window-left)
(exwm-input-set-key (kbd "s-L") '+evil/window-move-right)
(exwm-input-set-key (kbd "s-K") '+evil/window-move-up)
(exwm-input-set-key (kbd "s-J") '+evil/window-move-down)
(exwm-input-set-key (kbd "s-H") '+evil/window-move-left)
(exwm-input-set-key (kbd "s-q") 'evil-quit)
(exwm-input-set-key (kbd "s-o") 'delete-other-windows)
(exwm-input-set-key (kbd "s-SPC") 'switch-to-buffer)
(exwm-input-set-key (kbd "s-v") 'evil-window-vsplit)
(exwm-input-set-key (kbd "s-b") 'evil-window-split)
(exwm-input-set-key (kbd "s-V") '+evil/window-vsplit-and-follow)
(exwm-input-set-key (kbd "s-B") '+evil/window-split-and-follow)

(exwm-input-set-key (kbd "<XF86AudioLowerVolume>")
                    'pulseaudio-control-decrease-volume)
(exwm-input-set-key (kbd "<XF86AudioRaiseVolume>")
                    'pulseaudio-control-increase-volume)
(exwm-input-set-key (kbd "<XF86AudioMute>")
                    'pulseaudio-control-toggle-current-sink-mute)
(exwm-input-set-key (kbd "<s-XF86AudioMute>")
                    'pulseaudio-control-select-sink-by-name)

(exwm-input-set-key (kbd "s-c") 'desktop-environment-lock-screen)
(exwm-input-set-key (kbd "s-x") 'counsel-M-x)

(exwm-input-set-key (kbd "<XF86MonBrightnessDown>")
                    'desktop-environment-brightness-decrement)
(exwm-input-set-key (kbd "<XF86MonBrightnessUp>")
                    'desktop-environment-brightness-increment)
(exwm-input-set-key (kbd "<M-XF86MonBrightnessDown>")
                    'desktop-environment-brightness-decrement-slowly)
(exwm-input-set-key (kbd "<M-XF86MonBrightnessUp>")
                    'desktop-environment-brightness-increment-slowly)


;; icons in the tray
      (setq display-time-24hr-format 1)
      (display-time-mode)
      (display-battery-mode)
      ;; ))


      ;; stuff for executing other programs
      (require 'simple)

      (defvar execute-command-alist '()
        "An association list of (command-call . process-object) for all commands executed.")

      (defconst execute-list-buffer "*Execute Cmd List*"
        "Name of the execute listing buffer.")

      (defun execute-program (command)
        "Execute the COMMAND asynchronously and track it so later can be listed using `execute-list'."
        (interactive (list (read-shell-command "execute command:")))
        (let* ((proc-obj
                (start-process-shell-command "execute-process" "execute-process-buffer" command)))
          (when proc-obj ; Add to the alist
            (setq execute-command-alist
                  (cons (cons command proc-obj) execute-command-alist))
            (display-buffer (process-buffer proc-obj)))))

      (defun execute-list ()
        "List all the commands executed."
        (interactive)
        (with-current-buffer (get-buffer-create execute-list-buffer)
          (delete-region (point-min) (point-max))
          (switch-to-buffer (current-buffer))
          (dolist (e execute-command-alist)
            (when (process-status (cdr e))
              (insert (format "%d: '%s' - %s - %s\n"
                              (process-id (cdr e))
                              (car e)
                              (process-status (cdr e))
                              (process-buffer (cdr e))))))))


      (substitute-key-definition 'shell-command 'execute-program (current-global-map))
      (exwm-input-set-key (kbd "s-s") 'execute-program)
      (exwm-input-set-key (kbd "s-t") '(lambda ()
                                         "open a kitty terminal"
                                         (interactive)
                                         (execute-program "kitty")))