aboutsummaryrefslogtreecommitdiff
path: root/Emacs/.config/emacs/config.org
blob: c99bbe766bb85e52afb54dd7178d96e5ae5ef8a9 (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
#+TITLE: Config for Emacs
#+AUTHOR: Oreodave
#+DESCRIPTION: My bespoke config for Emacs
#+PROPERTY: header-args :tangle yes

* Notes
  This setup uses emacs 27, with use-package and melpa.
  Code structure is pretty simple: 
  - parent packages or packages that other packages leverage greatly are configured first.
  I use =:after= as a depdence generator: in most circumstances.

* Init
** Set some details
   Some basic details set for the purposes of Emacs
    #+BEGIN_SRC emacs-lisp
      (setq user-emacs-directory (expand-file-name "~/.config/emacs/")
	    ring-bell-function 'ignore
	    inhibit-startup-screen t)
    #+END_SRC

** Turn off those annoying bars
   Annoying menu bars, tool bars, etc
   #+BEGIN_SRC emacs-lisp
     (tool-bar-mode -1)
     (scroll-bar-mode -1)
     (tab-bar-mode -1)
     (menu-bar-mode -1)
   #+END_SRC

** Set fonts and alpha
   Make two constants that hold the values for font and alpha, then set them in Emacs.
   #+BEGIN_SRC emacs-lisp
     (defconst dx:font "IBM Plex Mono-12" "Default font for Emacs")
     (defconst dx:alpha 0.9 "Default alpha transparency for Emacs")

     (add-to-list 'default-frame-alist (cons 'font dx:font))
     (add-to-list 'default-frame-alist (cons 'alpha dx:alpha))
     (set-face-attribute 'default t :font dx:font)

     (add-hook 'prog-mode-hook #'hs-minor-mode)
     (add-hook 'prog-mode-hook #'display-line-numbers-mode)
   #+END_SRC
** Set some useful variables
   Truncate lines, display number lines and stop making backup files (for now).
   #+BEGIN_SRC emacs-lisp
    (setq completion-ignore-case t
	  truncate-lines t
	  display-line-numbers-type t
	  make-backup-files nil)
    #+END_SRC
** ido mode
   Setup ido mode, easy to use completion framework.
   #+BEGIN_SRC emacs-lisp
   (ido-mode +1)
   #+END_SRC
* Keybindings
** Keychord
   Setup key chord, pretty basic config.
   #+BEGIN_SRC emacs-lisp
     (use-package key-chord
       :ensure t
       :config
       (key-chord-mode +1))
   #+END_SRC
** General
   Setup for general, keybinding library.
   I use the function =general-evil-setup= to use the =*map= family of keymapping functions.
   In this case I setup two defines: =gmap= and =lmap=. 
   =gmap= is for all global maps while lmap is for local, mode based keybindings
   I also have a good bit of bindings setup here, such that any default emacs functions that I use regularly is setup here.
   #+BEGIN_SRC emacs-lisp
     (use-package general
       :ensure t
       :init
       ;; Definers
       (general-def :states 'normal
	 "SPC" nil)
       (general-create-definer gmap :prefix "SPC") 
       (general-create-definer lmap :prefix "SPC m")
       (general-evil-setup t)
)
   #+END_SRC
* Which key
#+BEGIN_SRC emacs-lisp
(use-package which-key
  :ensure t
  :config
  (which-key-mode +1))
#+END_SRC

* Evil
  Basic evil configuration with some keychords.
  #+BEGIN_SRC emacs-lisp
(use-package evil
  :ensure t
  :after key-chord general
  :config
  (evil-mode +1)
  (key-chord-define evil-insert-state-map "jk" #'evil-normal-state)
       ;; Keybindgs
       (gmap "SPC" #'execute-extended-command)
       ;; Files
       (gmap
	 :infix "f" 
	 "f" #'find-file
	 "p" #'(lambda () (interactive) (find-file "~/.config/emacs/init.el"))
	 "-" #'dired
	 "s" #'save-buffer)
       ;; Buffers
       (gmap
	 :infix "b"
	 "b" #'switch-to-buffer
	 "d" #'kill-buffer
	 "n" #'next-buffer
	 "p" #'previous-buffer
	 "i" #'ibuffer)
       ;; Other
       (gmap
	 "c" #'compile)
       (vmap
	 :keymaps 'emacs-lisp-mode-map
	 "gr" #'eval-region)
)
  #+END_SRC
** Evil surround
#+BEGIN_SRC emacs-lisp
(use-package evil-surround
  :ensure t
  :after evil 
  :config
  (global-evil-surround-mode +1))
#+END_SRC

* Helpful
  #+BEGIN_SRC emacs-lisp
  (use-package helpful
  :after general
  :ensure t
  :config
  (gmap
    :infix "h"
    "f" #'helpful-callable
    "v" #'helpful-variable
    "k" #'helpful-key))
  #+END_SRC

* Yasnippet
#+BEGIN_SRC emacs-lisp
(use-package yasnippet
  :ensure t
  :after general
  :config
  (add-hook 'prog-mode-hook #'yas-minor-mode)
  (gmap
    "is" #'yas-insert-snippet))

(use-package yasnippet-snippets
  :ensure t
  :after yasnippet)
#+END_SRC

* Doom-themes 
  Setup for doom themes.
  Allow bold themes but not italic (italic is harder to read).
  Allow doom themes to configure org mode to fix fonts on headers, etc.
  Define a function that does the same thing as =counsel-load-function-action= without the dependency on counsel.
  Load a theme using said function, in this case =doom-monokai-classic=.
  #+BEGIN_SRC emacs-lisp
  (use-package doom-themes
    :ensure t
    :config
    (setq doom-themes-enable-bold t
	  doom-themes-enable-italic nil)
    (doom-themes-org-config)
    (defun dx:load-theme (theme)
      "Load a given theme into Emacs, while unloading the rest"
      (mapc #'disable-theme custom-enabled-themes)
      (load-theme theme t))
    (dx:load-theme 'doom-monokai-classic))
    #+END_SRC

* Org-mode
** Vanilla org mode
  #+BEGIN_SRC emacs-lisp
    (use-package org
      :ensure t
      :config
      (load (concat user-emacs-directory "+org.el"))
      (nmap
	:keymaps 'org-mode-map
	"M-j"   #'org-metadown
	"M-k"   #'org-metaup
	"C-RET" #'dx:org-insert-item-below))
  #+END_SRC
** Evil org mode
Setup evil org mode, which allows for some nicer abstractions of the interace.
#+BEGIN_SRC emacs-lisp
  (use-package evil-org
    :ensure t
    :after org
    :config
    (add-hook 'org-mode-hook 'evil-org-mode)
    (add-hook 'evil-org-mode-hook
	      (lambda ()
		(evil-org-set-key-theme)))
    (require 'evil-org-agenda)
    (evil-org-agenda-set-keys))
#+END_SRC
* Magit
  #+BEGIN_SRC emacs-lisp
  (use-package magit
  :ensure t
  :after general
  :config
  (gmap
    "g" #'magit-status))


  #+END_SRC
* Ace window
#+BEGIN_SRC emacs-lisp
(use-package ace-window
  :ensure t
  :after general
  :config
  (gmap "o" #'ace-window)
  (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)
	aw-dispatch-always t))


#+END_SRC
* Counsel
#+BEGIN_SRC emacs-lisp
(use-package counsel
  :ensure t
  :after general
  :config
  (gmap
    :infix "s" 
    "s" #'swiper
    "r" #'counsel-rg)
  (general-def
    :keymaps 'ivy-minibuffer-map
    "C-j" #'ivy-next-line-or-history
    "C-k" #'ivy-previous-line-or-history))
#+END_SRC