~ruther/nixos-config

ref: 6904cf1761334d033556f106c82d79b48e6657f4 nixos-config/home/modules/profiles/development/emacs/doom.d/config.el -rw-r--r-- 8.6 KiB
6904cf17 — Frantisek Bohacek refactor: modularize the configuration 1 year, 1 day 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
;;; $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 evil-snipe-scope 'buffer)

(setq doom-localleader-key ",")

(add-hook 'nix-mode-hook #'lsp)

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

(map! :leader
      "!"
      #'+popup/other)

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

;; Downloaded binaries cannot be used on Nix.
(setq lsp-enable-suggest-server-download nil)

(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))

;; 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-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 vhdl-basic-offset 2)
)
  ;;(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)))))))))

(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)

;; 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 my-verilog-setup ()
  (setq verilog-indent-lists nil)
  (setq verilog-indent-level 2)
  (setq verilog-indent-level-behavioral 2)
  (setq verilog-indent-level-declaration 2)
  (setq verilog-indent-level-module 2)
  (setq verilog-case-indent 2)
  (setq verilog-cexp-indent 2)
  (setq verilog-align-ifelse t)
  (setq verilog-auto-delete-trailing-whitespace t)
  (setq verilog-auto-newline nil)
  (setq verilog-auto-save-policy nil)
  (setq verilog-auto-template-warn-unused t)
  (setq verilog-tab-to-comment t)
  (setq verilog-highlight-modules t)
  (setq verilog-highlight-grouping-keywords t)
)

(add-hook 'verilog-mode-hook 'my-verilog-setup)

(setq verilog-ext-feature-list
      '(font-lock
        xref
        capf
        hierarchy
        lsp
        navigation
        template
        formatter
        compilation
        imenu
        which-func
        hideshow
        typedefs
        time-stamp
        block-end-comments
        ports))
(verilog-ext-mode-setup)
(add-hook 'verilog-mode-hook #'verilog-ext-mode)

(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-to-list 'auto-mode-alist '("\\.m$" . matlab-mode))
(setq matlab-shell-command-switches (list "-nodesktop"))

;; topsy doesn't work well for some modes such as vhdl-mode :(
;; (add-hook 'prog-mode-hook #'topsy-mode)

(setq company-idle-delay nil)

(add-hook 'magit-mode-hook (lambda () (magit-delta-mode +1)))
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate)

(setq avy-all-windows t)

(remove-hook 'doom-first-buffer-hook #'smartparens-global-mode)

(add-hook 'write-file-functions 'delete-trailing-whitespace)
Do not follow this link