~tobtobxx/.config

.config/emacs/init.el -rw-r--r-- 5.6 KiB
6ed4bc0f — TobTobXX [git] Set conflictstyle to zdiff3 28 days ago
                                                                                
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
; Disable welcome buffer
(setq inhibit-startup-message t)

; Not yet ready to disable menubar
(menu-bar-mode -1)
; Disable the toolbar (icons)
(tool-bar-mode -1)

;; Disable auto saves (managed via hook in evil-normal-state-entry
(setq auto-save-default nil)

; Enable (absolute) line numbers
(global-linum-mode)
;; Fixed number width => no horizontal jumps
(setq linum-format "%5d")
; Show column somewhere in the bottom bar
(column-number-mode)
; cursorline
(global-hl-line-mode)
; Show matching paren
(show-paren-mode)
;; Disable backup files (ie. foo.txt~)
(setq make-backup-files nil)
;; TODO visible whitespace

;; Set JetBrains font
(set-face-attribute 'default nil :font "JetBrainsMono")

; Bootstrap straight.el
; TODO look into freezing packages
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

; Install use-package
(straight-use-package 'use-package)
; Use straight by default
(setq straight-use-package-by-default t)


;; Evil mode
(use-package evil
  :init
  (setq evil-want-C-u-scroll t)
  (setq evil-want-C-w-in-emacs-state t)
  ;; TODO doesn't seem to work?
  (setq evil-undo-system 'undo-redo)
  ;; Save buffer on entering normal mode (but only if the buffer actually
  ;; represents a file).
  :hook ((evil-normal-state-entry . (lambda () (when buffer-file-name (save-buffer)))))
  :config
  (evil-mode))


;; Convenience wrapper around different keymapping functions
(use-package general)
;; Space as leader key
(general-create-definer leader-def
  :states 'normal
  :prefix "SPC")


;; Which keys shows possible options for key chords
(use-package which-key
  :config
  (which-key-mode)
  (setq which-key-idle-delay 0.7)
  (setq which-key-idle-secondary-delay 0))


;; Color theme
(use-package doom-themes)
(use-package atom-one-dark-theme)
(use-package base16-theme
  :custom
  ;; linum-mode different background? Nope.
  (base16-distinct-fringe-background nil)
  :config
  (load-theme 'base16-material-darker t))


;; A dashboard which shows recents, bookmarks and projects
;(use-package all-the-icons)
(use-package dashboard
  ;:after all-the-icons
  :config
  (dashboard-setup-startup-hook)
  ;; Maybe I'll someday come up with a great title
  (setq dashboard-banner-logo-title nil)
  (setq dashboard-center-content t)
  ;; own image?
  (setq dashboard-startup-banner 'logo)
  (setq dashboard-items '((recents  . 7)
			  (bookmarks . 5)
			  (projects . 10)))
  ;(setq dashboard-set-heading-icons t)
  ;(setq dashboard-set-file-icons t)
  ;; TODO: come up with bearable footer messages
  (setq dashboard-set-footer nil))

;; Show dashboard also when connecting with emacsclient
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
;; TODO: Override r and p ni dashboard-mode over evil-mode


;; Helpful is a better *Help* buffer
(use-package helpful)
;; Help mappings
(leader-def
  "h h" 'helpful-at-point
  "h k" 'helpful-key
  "h c" 'helpful-command
  "h f" 'helpful-callable
  "h v" 'helpful-variable)
;; Remap default commands
(general-define-key
 [remap describe-key] 'helpful-key
 [remap describe-function] 'helpful-callable)


;; Helm as a universal chooser
(use-package helm
  :config
  (helm-mode)
  (helm-autoresize-mode t))

;; Use helm-M-x.
;; And also I like M-SPC more than M-x.
(general-define-key
  [remap execute-extended-command] 'helm-M-x
  "M-SPC" 'helm-M-x)
;; Improve navigation inside a helm buffer
;; TODO doesn't work AT ALL
;(general-define-key
  ;:keymaps 'helm-map
  ;"ESC" 'keyboard-escape-quit
  ;"<tab>" 'helm-next-line
  ;"<backtab>" 'helm-previous-line)


;; TODO: project management using projectile
;; TODO: Install fd, ag
(use-package projectile
  :custom
  (projectile-project-search-path '(("~/projects/" . 2)))
  (projectile-known-projects-file (expand-file-name "~/.cache/emacs/projectile-bookmarks.eld"))
  :config
  (projectile-global-mode))
  
(leader-def
  "p" '(:keymap projectile-command-map :package projectile))


;; TODO: Setup for programming: HUGE WIP
(use-package lsp-ui)
(use-package lsp-mode
  :config
  (setq lsp-session-file (expand-file-name "~/.cache/emacs/.lsp-session-v1"))
  (lsp-enable-which-key-integration t)
  :hook ((rust-mode . lsp)
	 ;; TODO: Doesn't work
	 (lsp-mode . (lambda () (lsp-enable-which-key-integration t)))))


(use-package rustic)

(leader-def
  "l" '(:keymap lsp-command-map :package lsp-mode))


;; Buffer and file navigation
(leader-def
  "b" 'helm-buffers-list ;; manage (b)uffers
  "o" 'helm-find-files ;; (o)pen arbitrary files
  ;; TODO replace with helm?
  "f" 'fzf-projectile) ;; (f)ile in project


;; TODO company mode gives autocompletion
(use-package company
  :after lsp-mode
  :hook (lsp-mode . company-mode)
  :custom ((company-idle-delay 0)
	   (company-tooltip-idle-delay 0))
  ;; TODO use general?
  :bind (:map company-active-map
	    ("<tab>" . company-select-next-if-tooltip-visible-or-complete-selection)
	    ("<backtab>" . company-select-previous)
	    :map lsp-mode-map
	    ("<tab>" . company-indent-or-complete-common)))
;; TODO: company-box?


;; TODO
;; - evil-org
;; - postframe

;; ivy-rich displays some short descriptions for commands etc
;; TODO find something similar to ivy-rich

;; TODO: Why can't anyone get autocompletion right???
;; I want: Writing as normal and RET won't do anything.
;;         <tab> will select the 0th entry and THEN, RET will apply it.