~ruther/nixos-config

ref: 8f7cf4252cd26266296a6bff299b3e4ae7709c37 nixos-config/modules/editors/emacs/doom.d/config.el -rw-r--r-- 10.4 KiB
8f7cf425 — Frantisek Bohacek feat: add sequence detector for headphones 1 year, 6 months ago
                                                                                
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
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-

;; Place your private configuration here! Remember, you do not need to run 'doom
;; sync' after modifying this file!


;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets. It is optional.
(setq user-full-name "Frantisek Bohacek"
      user-mail-address "rutherther@protonmail.com")

;; Doom exposes five (optional) variables for controlling fonts in Doom:
;;
;; - `doom-font' -- the primary font to use
;; - `doom-variable-pitch-font' -- a non-monospace font (where applicable)
;; - `doom-big-font' -- used for `doom-big-font-mode'; use this for
;;   presentations or streaming.
;; - `doom-unicode-font' -- for unicode glyphs
;; - `doom-serif-font' -- for the `fixed-pitch-serif' face
;;
;; See 'C-h v doom-font' for documentation and more examples of what they
;; accept. For example:
;;
;;(setq doom-font (font-spec :family "Fira Code" :size 12 :weight 'semi-light)
;;      doom-variable-pitch-font (font-spec :family "Fira Sans" :size 13))
;;
;; If you or Emacs can't find your font, use 'M-x describe-font' to look them
;; up, `M-x eval-region' to execute elisp code, and 'M-x doom/reload-font' to
;; refresh your font settings. If Emacs still can't find your font, it likely
;; wasn't installed correctly. Font issues are rarely Doom issues!

;; There are two ways to load a theme. Both assume the theme is installed and
;; available. You can either set `doom-theme' or manually load a theme with the
;; `load-theme' function. This is the default:
(setq doom-theme 'doom-one)

;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
(setq display-line-numbers-type 'relative)

;; If you use `org' and don't want your org files in the default location below,
;; change `org-directory'. It must be set before org loads!
(setq org-directory "~/org/")


;; Whenever you reconfigure a package, make sure to wrap your config in an
;; `after!' block, otherwise Doom's defaults may override your settings. E.g.
;;
;;   (after! PACKAGE
;;     (setq x y))
;;
;; The exceptions to this rule:
;;
;;   - Setting file/directory variables (like `org-directory')
;;   - Setting variables which explicitly tell you to set them before their
;;     package is loaded (see 'C-h v VARIABLE' to look up their documentation).
;;   - Setting doom variables (which start with 'doom-' or '+').
;;
;; Here are some additional functions/macros that will help you configure Doom.
;;
;; - `load!' for loading external *.el files relative to this one
;; - `use-package!' for configuring packages
;; - `after!' for running code after a package has loaded
;; - `add-load-path!' for adding directories to the `load-path', relative to
;;   this file. Emacs searches the `load-path' when you load packages with
;;   `require' or `use-package'.
;; - `map!' for binding new keys
;;
;; To get information about any of these functions/macros, move the cursor over
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
;; This will open documentation for it, including demos of how they are used.
;; Alternatively, use `C-h o' to look up a symbol (functions, variables, faces,
;; etc).
;;
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
;; they are implemented.


(setq doom-localleader-key ",")

(map! :leader
      "c d" 'lsp-ui-doc-show
      "c m" #'+make/run)

(map! :map cdlatex-mode-map
   :i "TAB" #'cdlatex-tab)

(use-package! lsp-mode
        :custom
        (lsp-rust-analyzer-server-display-inlay-hints t)
        (lsp-rust-analyzer-display-lifetime-elision-hints-enable "skip_trivial")
        (lsp-rust-analyzer-display-chaining-hints t)
        (lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names nil)
        (lsp-rust-analyzer-display-closure-return-type-hints t)
        (lsp-rust-analyzer-display-parameter-hints nil)
        (lsp-rust-analyzer-diagnostics-enable-experimental t)
        (lsp-rust-analyzer-display-reborrow-hints nil))
(use-package! lsp-ui
  :ensure
  :commands lsp-ui-mode
  :custom
  (lsp-ui-peek-always-show t)
  (lsp-ui-sideline-show-hover t)
  (lsp-ui-doc-enable nil))

(require 'dap-cpptools)

(with-eval-after-load 'dap-cpptools
;; Add a template specific for debugging Rust programs.
;; It is used for new projects, where I can M-x dap-edit-debug-template
(dap-register-debug-template "Rust::CppTools Run Configuration"
                                (list :type "cppdbg"
                                :request "launch"
                                :name "Rust::Run"
                                :MIMode "gdb"
                                :miDebuggerPath "rust-gdb"
                                :environment []
                                :program "${workspaceFolder}/target/debug/hello / replace with binary"
                                :cwd "${workspaceFolder}"
                                :console "external"
                                :dap-compilation "cargo build"
                                :dap-compilation-dir "${workspaceFolder}")))

(with-eval-after-load 'dap-mode
        (setq dap-default-terminal-kind "integrated") ;; Make sure that terminal programs open a term for I/O in an Emacs buffer
        (dap-auto-configure-mode +1))

;(add-to-list 'org-latex-classes
;'("ctuslides" "\\documentclass[presentation]{ctuslides}"
;  ("\\section{%s}" . "\\section*{%s}")
;  ("\\subsection{%s}" . "\\subsection*{%s}")
;  ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))

(remove-hook 'doom-first-input-hook #'evil-snipe-mode)

(setq lsp-julia-default-environment "~/.julia/environments/v1.8")

;; latex

(defun run-latexmk ()
  (interactive)
  (let ((TeX-save-query nil)
        (TeX-process-asynchronous nil)
        (master-file (TeX-master-file)))
    (TeX-save-document "")
    (TeX-run-TeX "latexmk"
                 (TeX-command-expand "latexmk -pdf %O %S" 'TeX-master-file)
                 master-file))
    (if (plist-get TeX-error-report-switches (intern master-file))
        (TeX-next-error t)
      (progn
        (demolish-tex-help)
        (minibuffer-message "latexmk: done."))))

(after! centaur-tabs (centaur-tabs-group-by-projectile-project))

;; imenu

(setq imenu-list-focus-after-activation t)
(map! :leader
      (:prefix ("t" . "Toggle")
       :desc "Toggle imenu shown in a sidebar"
      "i"
      #'imenu-list-smart-toggle))

;; vhdl

(add-hook 'vhdl-mode-hook #'lsp!)
(add-hook 'vhdl-ts-mode-hook #'lsp!)

(defvar-local my/flycheck-local-cache nil)

(defun my/flycheck-checker-get (fn checker property)
  (or (alist-get property (alist-get checker my/flycheck-local-cache))
      (funcall fn checker property)))

(advice-add 'flycheck-checker-get :around 'my/flycheck-checker-get)

(add-hook 'vhdl-ts-mode-hook #'vhdl-electric-mode)
(add-hook 'vhdl-ts-mode-hook #'vhdl-stutter-mode)
(add-hook 'vhdl-mode-hook #'vhdl-electric-mode)
(add-hook 'vhdl-mode-hook #'vhdl-stutter-mode)

(defun my-vhdl-setup ()
  (setq vhdl-clock-edge-condition 'function)
  (setq vhdl-clock-name "clk_i")
  (setq vhdl-reset-kind 'sync)
  (setq vhdl-reset-name "rst_in")
  ;;(setq lsp-vhdl--params '(server-path "/home/ruther/Documents/git_cloned/rust_hdl/target/debug/vhdl_ls" server-args nil))
  ;;(setq lsp-vhdl-server-path "/home/ruther/Documents/git_cloned/rust_hdl/target/debug/vhdl_ls"))
(setq lsp-vhdl-server 'vhdl-ls)

(add-hook 'vhdl-mode-hook 'my-vhdl-setup)
(add-hook 'vhdl-ts-mode-hook 'my-vhdl-setup)

;;(add-hook 'lsp-managed-mode-hook
;;          (lambda ()
;;            (when (derived-mode-p 'vhdl-mode)
;;              (setq my/flycheck-local-cache '((lsp . ((next-checkers . (vhdl-ghdl)))))))))

(use-package! vhdl-ext
  :after vhdl-mode
  :demand
  :mode (("\\.vhd\\'"  . vhdl-mode)
         ("\\.vhdl\\'" . vhdl-mode))
  :init
  (setq vhdl-ext-feature-list
        '(font-lock
          ;;eglot
          lsp
          ;;flycheck
          beautify
          navigation
          template
          compilation
          imenu
          which-func
          hideshow
          time-stamp
          company-keywords
          ports))
  :hook ((vhdl-mode . vhdl-ext-mode))
  :config
  (vhdl-ext-mode-setup))

(flycheck-define-checker vhdl-ghdl
"A VHDL syntax checker using ghdl."
:command ("ghdl"
        "--std=08"
        "-s"
        "--std=08"
        "--ieee=synopsys"
        (eval (concat "--workdir=" (projectile-project-root) "/work"))
        "-fexplicit"
        "-fno-color-diagnostics"
        source)
:error-patterns
((error line-start (file-name) ":" line ":" column
                ": " (message) line-end))
:modes vhdl-mode)

;; org-mdoe
(setq rmh-elfeed-org-files (list "~/doc/notes/org/elfeed.org"))

;; tree sitter and navigation
;;(setq treesit-language-source-alist
;;      '((rust "https://github.com/tree-sitter/tree-sitter-rust")
;;        (vhdl "https://github.com/alemuller/tree-sitter-vhdl")
;;        (python "https://github.com/tree-sitter/tree-sitter-python")))

;;(use-package! combobulate
;;  :preface (setq combobulate-key-prefix "SPC k"))

;;(setq major-mode-remap-alist
;; '((yaml-mode . yaml-ts-mode)
;;   ;;(rust-mode . rust-ts-mode)
;;   ;;(rustic-mode . rust-ts-mode)
;;   (c-mode . c-ts-mode)
;;   ;;(vhdl-mode . vhdl-ts-mode)
;;   (bash-mode . bash-ts-mode)
;;   (js2-mode . js-ts-mode)
;;   (typescript-mode . typescript-ts-mode)
;;   (json-mode . json-ts-mode)
;;   (css-mode . css-ts-mode)
;;   (python-mode . python-ts-mode)))

;;(add-hook 'lsp-ui-mode
;;  (lambda ()
;;  ))
;;

(defun my-lsp-ui-setup ()
  (setq lsp-ui-doc-position 'top)
  (setq lsp-ui-doc-max-height 30))
(add-hook 'lsp-mode-hook 'my-lsp-ui-setup)

(defun ~/magit-process-environment (env)
  "Add GIT_DIR and GIT_WORK_TREE to ENV when in a special directory.
https://github.com/magit/magit/issues/460 (@cpitclaudel)."
  (let ((default (file-name-as-directory (expand-file-name default-directory)))
        (home (expand-file-name "~/")))
    (when (string= default home)
      (let ((gitdir (expand-file-name "~/.dotFiles/")))
        (push (format "GIT_WORK_TREE=%s" home) env)
        (push (format "GIT_DIR=%s" gitdir) env))))
  env)

(advice-add 'magit-process-environment
            :filter-return #'~/magit-process-environment)

(use-package org-roam
  :ensure t
  :custom
  (org-roam-directory "~/doc/notes/org-roam")
  (org-roam-dailies-directory "journals/")
  (org-roam-capture-templates
   '(("d" "default" plain
      "%?" :target
      (file+head "pages/${slug}.org" "#+title: ${title}\n")
      :unnarrowed t)))
  :config (org-roam-db-autosync-enable))

(add-hook 'python-mode-hook #'lsp)
Do not follow this link