aboutsummaryrefslogtreecommitdiff
path: root/Doom/.doom.d/org/config.org
blob: e0bf129c9b4fe946118c74fa79a76b27455f7365 (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
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
#+TITLE: Oreodave's Emacs configuration
#+AUTHOR: Oreodave
#+DESCRIPTION: My Doom Emacs configuration!

* Preclude
- This is my [[https://github.com/hlissner/doom-emacs][Doom Emacs]] configuration.
- Use it for most of my code editing and development needs.
- Incredibly versatile tool in my inventory.
* Initial setup
** Doom Variables
- Set the doom local-leader to "SPC ," because it's faster
- Good font choices:
  - Hack
  - Source Code Pro/Variable
  - IBM Plex Mono
  - Space Mono
  - Z003 if I'm feeling fancy (▀̿Ĺ̯▀̿̿)
#+BEGIN_SRC elisp
(after! core-keybinds
  (map! :leader "," nil)
  (setq doom-localleader-key "SPC ,")
  (setq doom-themes-enable-italic nil)
  (setq doom-themes-enable-bold t)
  (setq doom-theme 'doom-monokai-classic)
  (setq doom-font (font-spec :family "Source Code Pro" :size 15)))
#+END_SRC
** Other variables
Some quality of life things and others that I couldn't really put in one category
- Using line-numbers that are relative now instead of nothing.
- Set org directory
- Add libgen to search providers
#+BEGIN_SRC elisp
(setq completion-ignore-case t
  truncate-lines t
  display-line-numbers-type t
  bookmark-default-file (expand-file-name (concat doom-private-dir "bookmarks")))
(setq-default frame-title-format '("%b - Emacs"))
(add-to-list 'default-frame-alist '(alpha . 90))
(cl-pushnew '("Libgen" "http://gen.lib.rus.ec/search.php?req=%s") +lookup-provider-url-alist :key #'car :test 'string=)
#+END_SRC
** HACK: Load org mode again?
#+BEGIN_SRC elisp
(load (expand-file-name (concat user-emacs-directory "modules/lang/org/config.el")))
#+END_SRC
* Package Configuration
Configuration for or based heavily around specific packages that I find very important
** Ido
Just add vimish keybindings to ido completion
#+BEGIN_SRC elisp
(map!
 :map (ido-common-completion-map ido-file-completion-map ido-buffer-completion-map)
 "C-k" #'ido-prev-match
 "C-j" #'ido-next-match)

(setq ido-ignore-buffers '("\\` " "^\\*ESS\\*" "^\\*[Hh]elp" "^\\*.*Completions\\*$" "^\\*tramp" "^\\*cvs-" "^*Ido"))
#+END_SRC
** DAP
*** Function
First to setup is a routine for setting up all the dap-panes for debugging.
Easier to do than just running all those functions manually
- Routine sets up the panes that I like to use, instead of M-x'ing it
- *<SPC>cD* starts up the routine
#+BEGIN_SRC elisp
(after! dap-mode
  (defun dx:debug ()
    (interactive)
    (dap-ui-mode)
    (dap-ui-locals)
    (dap-ui-sessions)))
#+END_SRC
*** Keybind
#+BEGIN_SRC elisp
(map!
 :after dap-mode
 :leader
 :desc "Start debugging setup" "cD" #'dx:debug)
#+END_SRC
** Spelling checker
Keybinds to org-mode for flyspell package
#+BEGIN_SRC elisp
(map!
 :after (flyspell org)
 :localleader
 :map org-mode-map
 :prefix "w"
 :desc "Correct current word" "c" #'flyspell-correct-at-point
 :desc "Autocorrect word"     "a" #'flyspell-auto-correct-word
 :desc "Goto next error"      "w" #'flyspell-goto-next-error)
#+END_SRC
** Projectile
Add CMakeLists.txt to projectile-project-roots.
#+BEGIN_SRC elisp
(after! projectile
  (cl-pushnew "CMakeLists.txt" projectile-project-root-files :test 'string=)
  (setq projectile-tags-command
        "ctags -e -R --exclude=dist --exclude=.ccls --exclude=.ccls-cache"))
#+END_SRC
** Prettify symbols
Configuration for the module (pretty-code).
*** Setup symbols
Some symbols aren't present in the current doom version, or my fonts are screwing up, so I wrote them here.
Maybe a bit of a bandage over broken glass, but at least it's something.
#+BEGIN_SRC elisp
(setq +pretty-code-symbols
      '(:name "»"
        :src_block "»"
        :src_block_end "«"
        :quote "“"
        :quote_end "”"
        :lambda "λ"
        :def "ƒ"
        :composition "∘"
        :map "↦"
        :null "∅"
        :true "𝕋"
        :false "𝔽"
        :int "ℤ"
        :float "ℝ"
        :str "𝕊"
        :bool "𝔹"
        :not "¬"
        :in "∈"
        :not-in "∉"
        :and "∧"
        :or "∨"
        :for "∀"
        :some "∃"
        :return "⟼"
        :yield "⟻"
        :tuple "⨂"
        :pipe "|"
        :dot "•"))
#+END_SRC

The 'x' symbol in the =+pretty-code-fira-code-font-ligatures= is annoying, and unneeded.
So I remove it.
#+BEGIN_SRC elisp
(assoc-delete-all "x" +pretty-code-fira-code-font-ligatures #'string=)
#+END_SRC
*** Pretty symbols
Setup pretty symbols specifically for C++.
I import the string type via `using std::string` which isn't supported in standard doom so I added support for it as well.
#+BEGIN_SRC elisp
(after! cc-mode
  (set-pretty-symbols!
    '(c-mode c++-mode)
    :return "return"
    :or "||"
    :and "&&"
    :not "!"
    :bool "bool"
    :str "string"
    :str "std::string"
    :float "float"
    :int "int"
    :false "false"
    :true "true"
    :null "nullptr"))
#+END_SRC
** Calc
*** Configuration
#+BEGIN_SRC elisp
(use-package! calc
  :config
  (setq calc-angle-mode 'rad)
  (map!
   :leader
   :desc "Calc" ":" #'calc))
#+END_SRC
** Dired and ranger
I like doing shell comamnds from dired, but I don't want Emacs to hang when doing them.
So, as '!' is a common use command and "&" is the async comamnd, I'll just switcheroo the "!" and "&" for their designated commands.
#+BEGIN_SRC elisp
(map!
 :map dired-mode-map
 :n "!" #'dired-do-async-shell-command
 :n "&" #'dired-do-shell-command)
#+END_SRC
** Compilation
Add keybind to recompile (inside the buffer)
#+BEGIN_SRC elisp
(map!
 (:map 'compilation-mode-map
  :n "u" #'recompile))
#+END_SRC
** Company
#+BEGIN_SRC elisp
(add-hook
 'company-mode-hook
 #'(lambda () (setq company-frontends '(company-preview-frontend company-pseudo-tooltip-frontend))))
#+END_SRC
* Language Configuration
Configuration for various languages which I feel can be useful
** C-style languages
Configuration for C and C++.
Emacs doesn't have the full range of styles that I want, so lemme just do it myself.
#+BEGIN_SRC elisp
(after! cc-mode
  (c-add-style
   "user"
   '((c-basic-offset . 2)
     (c-comment-only-line-offset . 0)
     (c-hanging-braces-alist (brace-list-open)
                             (brace-entry-open)
                             (substatement-open after)
                             (block-close . c-snug-do-while)
                             (arglist-cont-nonempty))
     (c-cleanup-list brace-else-brace)
     (c-offsets-alist
      (statement-block-intro . +)
      (knr-argdecl-intro . 0)
      (substatement-open . 0)
      (substatement-label . 0)
      (access-label . 0)
      (label . 0)
      (statement-cont . +))))
  (setq c-default-style "user"))
#+END_SRC
** Python
Configuration for the Python language in doom
*** Set interpreter and flycheck to Python 3
I do python development for Python3 so I need to set the flycheck python checker, as well as the interpreter, to be Python3
#+BEGIN_SRC elisp
(after! python
  (setq python-version-checked t)
  (setq python-python-command "python3")
  (setq python-shell-interpreter "python3")
  (setq flycheck-python-pycompile-executable "python3"))
#+END_SRC
*** Map to python-mode-map
Most of my python work is in scripts or ideas, so I don't need extensive testing utilities or anything like that
I adhere greatly to the REPL in python, so I need access to it often.
#+BEGIN_SRC elisp
(after! python
  (map! ; Python keybinds
   :map python-mode-map
   :localleader
   :desc "Start python minor" "c" #'run-python
   :desc "Format buffer"      "=" #'py-yapf-buffer
   (:prefix "s"
    :desc "Send region REPL" "r" #'python-shell-send-region
    :desc "Send buffer"      "b" #'python-shell-send-buffer
    :desc "Send function"    "f" #'python-shell-send-defun)))
#+END_SRC
** Typescript
- Typescript (in my opinion) should be indented by 2
- Setup the LSP server on the lsp-language-id-config in case it hasn't already
#+BEGIN_SRC elisp
(after! typescript-mode
  (setq typescript-indent-level 2)
  (setq tide-format-options '(:indentSize 2 :tabSize 2))
  (after! lsp
    (cl-pushnew '(typescript-mode . "typescript") lsp-language-id-configuration :key #'car)
    (lsp-register-client
     (make-lsp-client
      :new-connection (lsp-stdio-connection "typescript-language-server --stdio")
      :major-modes '(typescript-mode)
      :server-id 'typescript))))
#+END_SRC
** Org
Org configuration to maximise org workflow.
*** Org variables
Setup the agenda-files and the org-directory.
#+BEGIN_SRC elisp
(after! org
  (add-hook 'org-mode-hook #'visual-line-mode)
  (add-hook 'org-mode-hook #'org-toggle-latex-fragment)
  (setq org-directory "~/Text"
        org-agenda-files '("~/Text/")
        org-src-window-setup 'split-window-right
        org-superstar-headline-bullets-list '("◉" "‣" "⧈" "⬠")
        org-log-repeat 'note))
#+END_SRC
*** Fragtog
#+BEGIN_SRC elisp
(use-package! org-fragtog
  :config
  (add-hook 'org-mode-hook #'org-fragtog-mode))
#+END_SRC
*** Thesaurus
Powerthesaurus installation, added a keybind in org-mode for looking up words.
#+BEGIN_SRC elisp
(use-package! powerthesaurus
  :after-call (org-mode)
  :defer-incrementally (org)
  :config
  (map!
   :localleader
   :map org-mode-map
   :prefix "w"
   :desc "Thesaurus" "t" #'powerthesaurus-lookup-word-at-point))
#+END_SRC
Powerthesaurus for thesaurus on writer files
*** Org keymap
- I like using org-export often, so bind it to a primary bind.
- Loading latex fragments is nice
#+BEGIN_SRC elisp
(map! ; Org keybinds
 :after org
 :map org-mode-map
 :localleader
 :desc "Org dispatch"        "e" #'org-export-dispatch
 :desc "Org LaTeX"           "E" #'org-latex-export-as-latex)
#+END_SRC
** Haskell
Setup repl binds for Haskell
#+BEGIN_SRC elisp
(map!
 :after haskell-mode
 :map haskell-mode-map
 :localleader
 "l" #'haskell-process-load-file
 "r" #'haskell-process-reload
 "o" #'haskell-process-start)
#+END_SRC
** Sxhkd
Define a major-mode for sxhkd config files.
#+BEGIN_SRC elisp
(define-generic-mode sxhkd-mode
  '(?#)
  '("alt" "Escape" "super" "bspc" "ctrl" "space" "shift" "hyper" "XF86*")
  '("{" "}")
  '("sxhkdrc")
  nil
  "Simple mode for sxhkdrc files.")
#+END_SRC
* Key-map
General keymap
** Personal
- Prefix "SPC m" (rebound from local-leader) that will hold personal keybinds for functions that I like using
- Mostly opening directories I use a lot or doing custom stuff that I can't really put in anything in particular
#+BEGIN_SRC elisp
(map!
 :leader
 :prefix ("m" . "personal") ; Personal
 :desc   "Open books"         "b"  #'(lambda () (interactive) (dired (concat org-directory "/Books"))); I like my books
 :desc   "Convert auto-fill"  "f"  #'dx:org/fill-to-long-lines
 :desc   "Change theme"       "t"  #'dx:themes/set-new-theme ; From my own collection
 :desc   "Generate template"  "g"  #'+gentemplate/generate-template) ; From my own collection
#+END_SRC
** Remaps
Adding a new configuration option.
Remapping functions that other modules set to default functions.
#+BEGIN_SRC elisp
(define-key!
  [remap compile]           #'compile)
#+END_SRC
** Non-leader
Non-leader bindings for text-based commands.
#+BEGIN_SRC elisp
(map!
 "M-v" #'dx:newline
 "M-V" #'(lambda () (interactive) (dx:newline 1)))
#+END_SRC