summaryrefslogtreecommitdiffstats
path: root/.config/emacs/init.el
diff options
context:
space:
mode:
authorjdlugosz963 <jdlugosz963@gmail.com>2022-08-12 17:48:25 +0200
committerjdlugosz963 <jdlugosz963@gmail.com>2022-08-12 17:48:25 +0200
commit060362883a088f4779e247d232455b80f41f2f65 (patch)
treead719f07ff8f5d27f127603f7e36713e1b451ecb /.config/emacs/init.el
parent9ff9098d793c4f05b77a7deb2f40c0470e9fe8ae (diff)
downloaddotfiles-060362883a088f4779e247d232455b80f41f2f65.tar.gz
dotfiles-060362883a088f4779e247d232455b80f41f2f65.zip
Add emacs config
Diffstat (limited to '.config/emacs/init.el')
-rw-r--r--.config/emacs/init.el289
1 files changed, 289 insertions, 0 deletions
diff --git a/.config/emacs/init.el b/.config/emacs/init.el
new file mode 100644
index 0000000..ffcd1bb
--- /dev/null
+++ b/.config/emacs/init.el
@@ -0,0 +1,289 @@
1(setq user-full-name "Jakub Dlugosz"
2 user-mail-address "jdlugosz963@gmail.com")
3
4(setq gc-cons-threshold (* 50 1000 1000))
5
6(defun jd/display-startup-time ()
7 (message "Emacs loaded in %s with %d garbage collections."
8 (format "%.2f seconds"
9 (float-time
10 (time-subtract after-init-time before-init-time)))
11 gcs-done))
12
13(add-hook 'emacs-startup-hook #'jd/display-startup-time)
14
15(require 'package)
16(setq package-archives '(("melpa" . "https://melpa.org/packages/")
17 ("org" . "https://orgmode.org/elpa/")
18 ("gnu-devel" . "https://elpa.gnu.org/devel/")
19 ("elpa" . "https://elpa.gnu.org/packages/")))
20(package-initialize)
21
22(unless package-archive-contents
23 (package-refresh-contents))
24
25(unless (package-installed-p 'use-package)
26 (package-install 'use-package))
27
28(setq use-package-always-ensure t)
29
30(require 'use-package)
31
32(use-package general
33 :config
34 (general-create-definer jd/leader-key-def
35 :keymaps '(normal insert visual emacs)
36 :prefix "SPC"
37 :global-prefix "C-SPC")
38
39 (general-create-definer jd/ctrl-c-keys
40 :prefix "C-c"))
41
42(use-package undo-tree
43 :config
44 (setq undo-tree-auto-save-history nil)
45 (global-undo-tree-mode 1))
46
47(use-package evil
48 :init
49 (setq evil-want-integration t)
50 (setq evil-want-keybinding nil)
51 (setq evil-want-C-u-scroll t)
52 (setq evil-want-C-i-jump nil)
53 (setq evil-undo-system 'undo-tree)
54 :config
55 (evil-mode 1))
56
57(use-package evil-collection
58 :after evil
59 :config
60 (evil-collection-init))
61
62(jd/leader-key-def
63 "w" 'evil-window-map
64 "wd" '(evil-window-delete :which-key "Window delete"))
65
66(jd/leader-key-def
67 "ou" '(undo-tree-visualize :which-key "Open"))
68
69;; remove . key
70(define-key evil-normal-state-map (kbd ".") '())
71
72(setq inhibit-startup-message t)
73(scroll-bar-mode -1)
74(tool-bar-mode -1)
75(tooltip-mode -1)
76(menu-bar-mode -1)
77(set-fringe-mode 10)
78
79(set-face-attribute 'default nil :font "Hack" :height 100)
80
81 ; (load-theme 'wombat)
82
83(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
84
85(use-package monokai-theme
86 :config
87 (load-theme 'monokai t))
88
89(use-package diminish)
90
91(use-package counsel)
92(use-package ivy
93 :diminish
94 :bind
95 (("C-s" . swiper)
96 :map ivy-minibuffer-map
97 ("C-k" . ivy-previous-line)
98 ("C-j" . ivy-next-line)
99 :map ivy-switch-buffer-map
100 ("C-k" . ivy-previous-line))
101 :config
102 (ivy-mode 1))
103
104(jd/leader-key-def
105 "t" '(:ignore t :which-key "Toogle")
106 "tt" '(counsel-load-theme :which-key "Choose theme"))
107
108(jd/leader-key-def
109 "bb" '(counsel-switch-buffer :which-key "Buffer switch")
110 "b" '(:ignore t :which-key "Buffer")
111 "," '(counsel-switch-buffer :which-key "Buffer switch"))
112
113(use-package which-key
114 :diminish
115 :config
116 (which-key-mode)
117 (setq which-key-idle-delay 0.3))
118
119(use-package all-the-icons)
120
121(use-package doom-modeline
122 :init (doom-modeline-mode 1)
123 :custom ((doom-modeline-height 15)))
124
125(jd/leader-key-def
126 "f" '(:ignore t :which-key "Files")
127 "fs" '(save-buffer :which-key "File save")
128 "." '(find-file :which-key "Find file")
129 "ff" '(find-file :which-key "Find file"))
130
131(jd/leader-key-def
132 "e" '(:ignore t :which-key "Eval")
133 "eb" '(eval-buffer :which-key "Eval buffer"))
134
135(jd/leader-key-def
136 :keymaps '(visual)
137 "er" '(eval-region :which-key "Eval region"))
138
139(jd/leader-key-def
140 "bk" '(kill-this-buffer :which-key "Buffer kill"))
141
142(defun jd/org-mode-setup ()
143 (org-indent-mode)
144 (variable-pitch-mode 1)
145 (visual-line-mode 1))
146
147(use-package org
148 :pin org
149 :commands (org-capture org-agenda)
150 :hook (org-mode . jd/org-mode-setup)
151 :config
152 (setq org-ellipsis " ▾")
153
154 (setq org-agenda-start-with-log-mode t)
155 (setq org-log-done 'time)
156 (setq org-log-into-drawer t)
157 (require 'org-tempo))
158
159(jd/leader-key-def
160 "o" '(:ignore t :which-key "Open")
161 "oa" '(org-agenda :which-key "Open org-agenda"))
162
163(use-package org-make-toc)
164
165(add-hook 'org-mode-hook #'org-make-toc-mode)
166; (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'org-make-toc)))
167
168(defun jd/org-font-setup ()
169 ;; Replace list hyphen with dot
170 (font-lock-add-keywords 'org-mode
171 '(("^ *\\([-]\\) "
172 (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•-"))))))
173
174 ;; Set faces for heading levels
175 (dolist (face '((org-level-1 . 1.3)
176 (org-level-2 . 1.2)
177 (org-level-3 . 1.1)
178 (org-level-4 . 1.0)
179 (org-level-5 . 1.1)
180 (org-level-6 . 1.1)
181 (org-level-7 . 1.1)
182 (org-level-8 . 1.1)))
183 (set-face-attribute (car face) nil :font "Monospace" :weight 'Bold :height (cdr face)))
184
185 ;; Ensure that anything that should be fixed-pitch in Org files appears that way
186 (set-face-attribute 'org-block nil :font "mononoki Nerd Font" :inherit 'fixed-pitch)
187 (set-face-attribute 'org-table nil :inherit 'fixed-pitch)
188 (set-face-attribute 'org-formula nil :inherit 'fixed-pitch)
189 (set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch))
190 (set-face-attribute 'org-table nil :inherit '(shadow fixed-pitch))
191 (set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch))
192 (set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch))
193 (set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch))
194 (set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch)
195 (set-face-attribute 'line-number nil :inherit 'fixed-pitch)
196 (set-face-attribute 'line-number-current-line nil :inherit 'fixed-pitch))
197
198(with-eval-after-load 'org-faces (jd/org-font-setup))
199
200(defun jd/org-tempo-setup ()
201 (add-to-list 'org-structure-template-alist '("sh" . "src sh"))
202 (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
203 (add-to-list 'org-structure-template-alist '("li" . "src lisp"))
204 (add-to-list 'org-structure-template-alist '("sc" . "src scheme"))
205 (add-to-list 'org-structure-template-alist '("ts" . "src typescript"))
206 (add-to-list 'org-structure-template-alist '("py" . "src python"))
207 (add-to-list 'org-structure-template-alist '("go" . "src go"))
208 (add-to-list 'org-structure-template-alist '("yaml" . "src yaml")))
209
210(with-eval-after-load 'org-tempo (jd/org-tempo-setup))
211
212(defun jd/org-babel-tangle-config ()
213 (when (string-equal (file-name-directory (buffer-file-name))
214 (expand-file-name user-emacs-directory))
215 ;; Dynamic scoping to the rescue
216 (let ((org-confirm-babel-evaluate nil))
217 (org-babel-tangle))))
218
219(add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'jd/org-babel-tangle-config)))
220
221(defun jd/org-mode-visual-fill ()
222 (setq visual-fill-column-width 100
223 visual-fill-column-center-text t)
224 (visual-fill-column-mode 1))
225
226(use-package visual-fill-column
227 :hook (org-mode . jd/org-mode-visual-fill))
228
229(use-package org-superstar
230 :hook (org-mode . org-superstar-mode)
231 :config
232 (setq org-superstar-special-todo-items t)
233 (setq org-superstar-remove-leading-stars t)
234 (setq org-superstar-headline-bullets-list '("◉" "○" "●" "○" "●" "○" "●")))
235
236(use-package projectile
237 :diminish projectile-mode
238 :init
239 (when (file-directory-p "~/Documents/code")
240 (setq projectile-project-search-path '("~/Documents/code/")))
241 :config (projectile-mode)
242 :custom ((projectile-Completion-system 'ivy)))
243
244(jd/leader-key-def
245 "p" '(projectile-command-map :which-key "Project")
246 "p <ESC>" '()
247 "SPC" '(projectile-find-file :which-key "Find file in project"))
248
249(use-package magit
250 :custom
251 (magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1))
252
253(jd/leader-key-def
254 "g" '(:ignore t :which-key "Git")
255 "gg" '(magit-status-here :which-key "Magit status"))
256
257(use-package vterm)
258(use-package vterm-toggle
259 :init
260 (setq vterm-toggle-fullscreen-p nil)
261 :config
262 (add-to-list 'display-buffer-alist
263 '((lambda (buffer-or-name _)
264 (let ((buffer (get-buffer buffer-or-name)))
265 (with-current-buffer buffer
266 (or (equal major-mode 'vterm-mode)
267 (string-prefix-p vterm-buffer-name (buffer-name buffer))))))
268 (display-buffer-reuse-window display-buffer-at-bottom)
269 (reusable-frames . visible)
270 (window-height . 0.3))))
271
272(jd/leader-key-def
273 "oT" '(vterm :which-key "Open terminal in current window")
274 "ot" '(vterm-toggle :which-key "Toggle terminal"))
275
276(use-package all-the-icons-dired
277 :hook (dired-mode . all-the-icons-dired-mode))
278
279(use-package dired-ranger)
280
281(use-package dired
282 :ensure nil
283 :commands (dired dired-jump)
284 :bind (("C-x C-j" . dired-jump))
285 :custom ((dired-listing-switches "-agho --group-directories-first"))
286 :config
287 (evil-collection-define-key 'normal 'dired-mode-map
288 "h" 'dired-up-directory
289 "l" 'dired-single-buffer))