-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.el
323 lines (279 loc) · 9.38 KB
/
init.el
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
;;; init.el --- Emacs configuration file -*- lexical-binding: t -*-
;; No splash message
(setq inhibit-splash-screen t)
;; No backup files
(setq make-backup-files nil)
;; No toolbar
(progn (if (fboundp 'tool-bar-mode) (tool-bar-mode -1)))
;; Show column number
(column-number-mode 1)
;; Highlight current line
(global-hl-line-mode 1)
;; Store Customs in different place
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(load custom-file 'noerror)
;; Enable Which Function Mode
(which-function-mode 1)
;; Wrap lines
(global-visual-line-mode 1)
;; Calendar starts on Moday
(setq calendar-week-start-day 1)
;; Shortkey to comment region
(global-set-key (kbd "C-c C-c") 'comment-region)
;; Install use-package if not already installed
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(eval-when-compile
(require 'use-package)
(require 'use-package-ensure)
(setq use-package-always-ensure t))
;; Quelpa handler for use-package
(use-package quelpa-use-package
:init
(setq quelpa-update-melpa-p nil)
(setq quelpa-self-upgrade-p nil))
;; Diminished modes are minor modes with no modeline display
(use-package diminish)
;; Major-mode for editing CMake sources
(use-package cmake-mode
:mode "\\.cmake\\'")
;; Major mode for editing Docker's Dockerfiles
(use-package dockerfile-mode)
;; Incremental Vertical completYon
(use-package ivy
:diminish
:config
(ivy-mode 1))
;; Various completion functions using Ivy
(use-package counsel
:diminish
:after ivy
:config
(counsel-mode 1))
;; EditorConfig Emacs plugin
(use-package editorconfig
:diminish
:config
(editorconfig-mode 1))
;; Define and query search engines from within Emacs
(use-package engine-mode
:config
(engine-mode t)
(defengine github
"https://github.com/search?q=%s&type=code"
:keybinding "g")
(defengine duckduckgo
"https://duckduckgo.com/?q=%s"
:keybinding "d"))
;; Major mode for Markdown-formatted text
(use-package markdown-mode
:mode "\\.md\\'")
;; Major mode for the Meson build system files
(use-package meson-mode)
;; Outline-based notes management and organizer
(use-package org
:config
(setq org-directory "~/Misc/orgfiles")
(setq org-agenda-files (list org-directory))
(setq org-refile-use-outline-path 'file)
(setq org-refile-targets '((org-agenda-files :maxlevel . 1)))
(setq org-export-backends '(ascii html md odt))
(setq org-capture-templates
'(("t" "Todo [Inbox]" entry
(file "~/Misc/orgfiles/inbox.org")
"* TODO %i%?")))
(setq org-clock-persist t)
(setq org-clock-in-resume t)
(setq org-clock-persist-query-resume nil)
(setq org-clock-out-remove-zero-time-clocks t)
(org-clock-persistence-insinuate)
:bind
(("C-c c" . org-capture)))
;; A simple org-mode based journaling mode
(use-package org-journal
:after org
:config
(setq org-journal-dir "~/Misc/orgfiles/journal")
(setq org-journal-file-type 'weekly)
(setq org-journal-file-format "%Y/w%V.org")
(setq org-journal-date-format "%A (%d %b %Y)")
(setq org-journal-time-format "")
(setq org-journal-time-prefix "- ")
(setq org-journal-file-header
(concat
"#+Title: Week %V\n"
"#+OPTIONS: toc:nil tags:nil ^:{}\n"
"#+COLUMNS: %%ITEM(Task) %%CLOCKSUM(Clocked) %%EFFORT(Estimated)\n"
"\n"
"\n"))
(progn
(defun org-journal-aux/search-effort ()
(if (org-entry-get (point) "Effort")
(point)
(if (org-up-heading-safe)
(org-journal-aux/search-effort)
nil)))
(defun org-journal-aux/get-remaining-effort ()
(let ((actual-clocked (org-clock-sum-current-item)))
(save-excursion
(if (org-journal-aux/search-effort)
(org-minutes-to-clocksum-string
(- (org-hh:mm-string-to-minutes (org-entry-get (point) "Effort"))
(- (org-clock-sum-current-item) actual-clocked)))
nil))))
(defun org-journal/add-derived-effort ()
(if (not (org-entry-get (point) "Effort"))
(let ((remaining-effort (org-journal-aux/get-remaining-effort)))
(if remaining-effort
(progn
(org-entry-put (point) "Effort" remaining-effort)
(org-entry-put (point) "DerivedEffort" "true"))))))
(defun org-journal/remove-derived-effort ()
(if (org-entry-get (point) "DerivedEffort")
(progn
(org-entry-delete (point) "Effort")
(org-entry-delete (point) "DerivedEffort"))))
(defun org-journal/goto-head ()
(point-to-register 1)
(while (org-up-heading-safe) ()))
(defun org-journal/goto-back ()
(register-to-point 1)))
:hook
((org-clock-in-prepare . org-journal/goto-head)
(org-clock-in . org-journal/goto-back)))
;; Insert org-mode links from the clipboard
(use-package org-cliplink
:after org
:config
(progn
(defun org-cliplink-gh (&optional link)
(interactive)
(org-cliplink-insert-transformed-title
(or link (org-cliplink-clipboard-content))
(lambda (url title)
(let* ((parsed-url (url-generic-parse-url url))
(clean-title
(cond
((string-match "\\([^·]*\\) · Issue #\\([0-9]+\\) · " title) ; GitHub Issue
(concat "#" (match-string 2 title) " \"" (match-string 1 title) "\""))
((string-match "\\([^·]*\\) by [^·]+ · Pull Request #\\([0-9]+\\) · " title) ; GitHub Pull Request
(concat "!" (match-string 2 title) " \"" (match-string 1 title) "\""))
((string-match "\\([^·]*\\) · [^@]*@\\([^·]*\\) · " title) ; GitHub Commit
(concat (match-string 2 title) " (\"" (match-string 1 title) "\")"))
((string-match "\\([^(]*\\) (#\\([0-9a-z]+\\)) · Issues" title) ; GitLab Issue
(concat "#" (match-string 2 title) " \"" (match-string 1 title) "\""))
((string-match "\\(.*\\) (!\\([0-9a-z]+\\)) · Merge requests" title) ; GitLab Merge Request
(concat "!" (match-string 2 title) " \"" (match-string 1 title) "\""))
((string-match "\\([^(]*\\) (\\([0-9a-z]+\\)) · Commits" title) ; GitLab Commit
(concat (match-string 2 title) " (\"" (match-string 1 title) "\")"))
(t title)
)))
;; forward the title to the default org-cliplink transformer
(org-cliplink-org-mode-link-transformer url clean-title))))))
:bind
(("C-c C-x l" . org-cliplink-gh)))
;; Modern looks for Org
(use-package org-modern
:after org
:hook (org-mode . org-modern-mode))
;; Org Twiki and Foswiki export
;; Add function that fits better with the format we need for reports
(use-package ox-twiki
:after org
:config
(defun org-twiki-export-report ()
(interactive)
(org-twiki-export-as-twiki)
(goto-char (point-min))
(kill-whole-line)
(kill-whole-line)
(while (search-forward "---+" nil t)
(replace-match "--"))
(goto-char (point-min))))
;; A database abstraction layer for Org-mode
(use-package org-roam
:after org
:custom
(org-roam-directory (file-truename "~/Misc/orgfiles/org-roam"))
(org-roam-completion-everywhere t)
:config
(setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag)))
(org-roam-db-autosync-mode)
:bind
(("C-c n f" . org-roam-node-find)
("C-c n i" . org-roam-node-insert)
("C-c n c" . org-roam-capture)
:map org-mode-map
("C-M-i" . completion-at-point)))
;; Adds document titles to Markdown files generated with ox-md and derivatives
(use-package ox-md-title
:after org
:quelpa
(ox-md-title
:fetcher github
:repo "jeffkreeftmeijer/ox-md-title.el")
:config
(org-md-title-add)
(setq org-md-title t))
;; Manage and navigate projects in Emacs easily
(use-package projectile
:diminish
:config
(projectile-mode +1)
:custom
(projectile-indexing-method 'hybrid)
:bind-keymap
("C-c p" . projectile-command-map))
;; Ivy integration for Projectile
(use-package counsel-projectile
:config
(counsel-projectile-mode 1))
;; Automatic insertion, wrapping and paredit-like navigation with user
;; defined pairs
(use-package smartparens
:config
(require 'smartparens-config)
(smartparens-global-mode t)
(show-smartparens-global-mode t))
;; A tree style file explorer package
(use-package treemacs
:bind
(("<f8>" . treemacs)))
;;Projectile integration for treemacs
(use-package treemacs-projectile
:after projectile treemacs)
;; Major mode for editing Twiki pages
(use-package twiki
:quelpa
(twiki
:fetcher github
:repo "christopherjwhite/emacs-twiki-mode")
:mode ("\\.twiki\\'" . twiki-mode))
;; Major mode for editing YAML files
(use-package yaml-mode
:mode "\\.yml\\'")
(use-package yasnippet
:diminish
:config
(yas-global-mode t))
;; A low contrast color theme for Emacs
(use-package zenburn-theme
:config
(load-theme 'zenburn t))
;; Better experience with icons for ivy
(use-package all-the-icons-ivy-rich
:config
(all-the-icons-ivy-rich-mode 1))
;; More friendly display transformer for ivy
(use-package ivy-rich
:config
(ivy-rich-mode 1))
;; Better sorting and filtering
(use-package ivy-prescient
:config
(ivy-prescient-mode 1))