aboutsummaryrefslogtreecommitdiff
path: root/doom.d/config.org
blob: cc546f30c88ac299489891b63b4885af305e274c (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
#+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, which I try to use for as many things as
possibe. It is currently my main C# and Python editor but hopefully it will
become my C one soon!
* Notes and keybinds
|-------------+----------------------------------------------------------------------------------------------------------+-----------------|
| Bind        | Use                                                                                                      | Context         |
|-------------+----------------------------------------------------------------------------------------------------------+-----------------|
| *<C-c '>*   | To edit a src block                                                                                      | Org             |
| *<C-c C-o>* | To read the buffer results into a traversible buffer, so you can read it and do normal vim stuff with it | Counsel         |
| *<C-c C-p>* | To edit results buffer. You can edit specific items or the entire thing using a regex. Incredibly useful | Counsel results |
| *<C-o>*     | When you've gone to some line or definiton, go back to previous place                                    | Normal          |
| *<C-x h>*   | Mark whole buffer for copying                                                                            | Normal          |
|-------------+----------------------------------------------------------------------------------------------------------+-----------------|
* Global variables
#+BEGIN_SRC emacs-lisp
(setq doom-localleader-key ",")
(setq warning-minimum-level :emergency)
(setq completion-ignore-case t)
#+END_SRC
- '<SPC>m' is right next to ',', so may as well use one tap instead of two
- Projectile tags commands

* Theming
#+BEGIN_SRC emacs-lisp
(load-theme 'doom-molokai t)
#+END_SRC
I like monokai :)

* General keymap
#+BEGIN_SRC emacs-lisp
(map!
 :leader
 :desc   "M-x"                "<SPC>" 'counsel-M-x
 :desc   "Indent"             "j"     'indent-region
 :desc   "Reload emacs"       "r"     'oreodave/reload
 :desc   "Open project files" "pf"    'projectile-find-file
 :desc   "Compile via make"   "cC"    '+make/run
                                        ; Redefine <SPC><SPC> as M-x rather than find-file because of my muscle memory with spacemacs
                                        ; General maps like <SPC>j for indenting because I don't know what else to bind them to
                                        ; <SPC>pf => project -> find file
 (:prefix "/" ; Search
   :desc "Ag!"                "a"     '+ivy/ag
   :desc "FZF!"               "f"     'counsel-fzf
   :desc "RipGrep!"           "r"     'counsel-rg
   :desc "Search Tags"        "t"     'counsel-etags-list-tag
   :desc "Search buffer"      "/"     'swiper
   )
                                        ; I like using <SPC>/ in comparison to <SPC>s: it's closer together (thus quicker, I do searches a lot so this is noticeable) and makes more sense
                                        ; Ripgrep is faster than Ag in most cases and makes me feel cool
                                        ; <SPC>// is quicker to do than <SPC>/b, for something that is done so often

 (:prefix "w" ; Windows
   :desc "Close window"       "d"     '+workspace/close-window-or-workspace
   :desc "Switch window"      "W"     'ace-window
   :desc "Swap windows"       "S"     'ace-swap-window
   )
                                        ; <SPC>wd is slightly closer together than <SPC>wc
                                        ; <SPC>wd is also used in spacemacs so I'd rather use this
                                        ; <SPC>wW allows me to switch windows more efficiently than before, better than just motions

 (:prefix "b"
   :desc "Close buffer"       "d"     'doom/kill-this-buffer-in-all-windows
   )
                                        ; <SPC>bd is used for the same reasons as above

 (:prefix "p"
   :desc "Regen tags"         "g"     'projectile-regenerate-tags
   )
 )
; <SPC>pg for regenning tags is useful when searching them
#+END_SRC
* Custom
** Packages and functionality
*** Projectile
#+BEGIN_SRC emacs-lisp
(after! projectile
  (setq oreodave-tags-alist '("Makefile" "node_modules" "bin" "dist" "obj" "'*.json'"))
  (defun oreodave/config/construct-tags ()
    (setq projectile-tags-command (reduce (lambda (x y) (concat x y)) (mapcar (lambda (i) (concat " --exclude=" i)) oreodave-tags-alist)
            :initial-value "exctags -Re "))
    )
  (setq projectile-tags-command (oreodave/config/construct-tags))
  )
#+END_SRC
Really simple, just want to set projectile-tags-command when projectile has loaded
*** Wakatime
#+BEGIN_SRC emacs-lisp
(setq wakatime-api-key (shell-command-to-string "pass Keys/Wakatime"))
#+END_SRC
Using new password holder (pass) to help with secure transactions.
*** Dash
#+BEGIN_SRC emacs-lisp
(setq dash-docs-docsets-path "~/.docsets")
#+END_SRC
My docsets are stored in .docsets for ease of use
*** Frame management
#+BEGIN_SRC emacs-lisp
(map!
 :leader
 ; TODO think of a new prefix or leave and justfiy this one
 :prefix ("m" . "Frame") ; Literally the first free prefix I could think of
 :desc "Kill frame"                  "d" 'delete-frame
 :desc "Make current buffer frame"   "m" 'make-frame
 :desc "Choose buffer to make frame" "n" 'display-buffer-other-frame
 :desc "Switch frames"               "o" 'other-frame
 )
#+END_SRC
- This is my config for handling new frames
- I've only recently found out about them, they're incredibly powerful tools
  that I should've put in my toolbox a LONG time ago
*** Font size
#+BEGIN_SRC emacs-lisp
(map!
 :leader
 :prefix ("z" . "Font") ; using this prefix due to spacemacs
 :desc "Increase font"  "+" 'doom/increase-font-size
 :desc "Decreease font" "-" 'doom/decrease-font-size
 :desc "Adjust font"    "z" 'text-scale-adjust
 )
#+END_SRC
*** Custom functions
#+BEGIN_SRC emacs-lisp
(defun oreodave/reload ()
  (interactive)
  (load-file (concat doom-private-dir "config.el"))
  )
#+END_SRC
** Languages
*** C#
#+BEGIN_SRC emacs-lisp
(after! csharp-mode
  (defun oreodave/csharp/unit-test ()
    (interactive)
    (omnisharp--cs-inspect-buffer
     (lambda (elements)
       (let* ((test-methods (omnisharp--cs-filter-resursively
                             'omnisharp--cs-unit-test-method-p
                             elements))) ;; Get set of elements through omnisharp

         (ivy-read "Choose test: " ;; Start ivy to get nice menu
                   (mapcar (lambda (els) (cdr (nth 1 els))) test-methods) ;; Get names of any unit test methods
                   :require-match t
                   :keymap counsel-describe-map
                   :sort t
                   :unwind (lambda ()
                             (counsel-delete-process)
                             (swiper--cleanup))
  (setq omnisharp-server-executable-path "~/bin/omnisharp/run")
  (add-hook 'csharp-mode-hook '(lambda() (setq c-basic-offset 4))) ; Hook for csharp setting variables

  (map! ; CSharp Keybinds
   :map csharp-mode-map
   :localleader
   :desc   "Format buffer"  "="    'omnisharp-code-format-entire-file
   (:prefix "t"
     :desc "Unit Test This" "t"   'omnisharp-unit-test-at-point
     :desc "Unit Test Last" "l"   'omnisharp-unit-test-last
     :desc "Unit Test All"  "b"   'omnisharp-unit-test-buffer
     )
   )
  )
     #+END_SRC
- I have custom installed the omnisharp roslyn executable, so I'd rather use that
- C# code is better at 4 space indents, but I indent most of my C code at 2 space indents because it looks nicer :)
- Currently the Doom Emacs keybinds are not working for C# Unit-tests so I had to do them myself
- I find these keybinds to be more mnemonic (,mtt => Test -> This)
*** Python
#+BEGIN_SRC emacs-lisp
(after! python
  (setq python-version-checked t)
  (setq python-python-command "python3")
  (setq python-shell-interpreter "python3")
  (setq flycheck-python-pycompile-executable "python3")

  (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
- I do python development for Python3 (who doesn't?), so I need to set the flycheck python checker, as well as the interpreter, to be Python3
- Python keybinds
- Most of my python work is in scripts or ideas, so I don't need extensive testing utilities or anything like that
- I run my python code a LOT and thus need commands for sending bits or whole scripts into the REPL
*** JavaScript/TypeScript
#+BEGIN_SRC emacs-lisp
(after! typescript-mode
  (setq typescript-indent-level 2)
  (setq tide-format-options '(:indentSize 2 :tabSize 2))
  (map!
   :localleader
   :map typescript-mode-map
   :desc "Format code" "=" 'tide-format
   )
  )
#+END_SRC
- Typescript (in my opinion) should be indented by 2
- I like having one keybind to format a file, thus need to rebind
*** Org
#+BEGIN_SRC emacs-lisp
(after! org
  (map! ; Org keybinds
   :map org-mode-map
   :localleader
   :desc "Org dispatch" "ee" 'org-export-dispatch
   )
  )
#+END_SRC
I like using the org dispatch facilities more than the default export keybinds
in Doom, so I need this binding