summaryrefslogtreecommitdiff
path: root/emacs.d/init.el
blob: 5400784306d7040e5f13e0fe8468acc06856b712 (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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Lars Wirzenius Emacs config. I have no idea what I'm doing, I've
;; cobbled this up from snippets on the net.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Set up packaging system.

(require 'package)

(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))

;; Uncomment this to force Emacs to update its package lists.
;; Keep it commented to make startup faster.	
;(package-refresh-contents)

(unless (package-installed-p 'use-package)
  (package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)

;; I don't want Emacs modifying my config file, so I tell it to save
;; custom options elsewhere.

(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Some UI / behavior customizations.

(setq inhibit-startup-screen t)

(tab-bar-mode t)
(setq tab-bar-new-tab-to 'rightmost)

(tool-bar-mode 0)

(column-number-mode t)
(setq column-number-indicator-zero-based nil)

(global-display-line-numbers-mode)
(set-face-attribute 'line-number nil
		    :height 0.8)
(set-face-attribute 'line-number-current-line nil
		    :foreground "#ff0000")

(setq select-enable-clipboard t)

(setq buffers-menu-show-directories t)

(set-default 'truncate-lines t)

(add-hook 'text-mode-hook 'hl-line-mode)
(add-hook 'prog-mode-hook 'hl-line-mode)

(global-set-key (kbd "<f5>") 'compile)
(global-set-key (kbd "C-<f5>") 'recompile)
(global-unset-key "\C-x\C-b")

(when (display-graphic-p)
  (global-unset-key "\C-x\C-c")
  (global-unset-key "\C-z")
  (global-unset-key "\C-_")
  (global-unset-key (kbd "\C-x\C-z"))
  (global-unset-key (kbd "<insert>"))
  (global-set-key (kbd "C-=") 'text-scale-adjust)
  (global-set-key (kbd "C-+") 'text-scale-adjust)
  (global-set-key (kbd "C--") 'text-scale-adjust)
  (global-set-key (kbd "C-0") 'text-scale-adjust)
)

(setq-default indent-tabs-mode nil)

(setq make-backup-files nil)

(setq text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify)))

(setq sentence-end-double-space nil)

(set-face-attribute 'default nil
		    :height 130
		    :family "Hack")

(setq ispell-dictionary "en_US")

(add-hook 'text-mode-hook 'show-paren-mode)
(add-hook 'prog-mode-hook 'show-paren-mode)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Packages I like, with their configuration.

(use-package magit
  :config
  (global-set-key (kbd "C-x g") 'magit-status))
(setq vc-handled-backends nil)

(use-package blacken)
(use-package python-mode
  :config
  (py-underscore-word-syntax-p-off)
  (add-hook 'python-mode-hook 'blacken-mode))

(use-package yaml-mode
  :config
  (add-to-list 'auto-mode-alist '("\\.ick\\'" . yaml-mode))
  (add-to-list 'auto-mode-alist '("\\.subplot\\'" . yaml-mode))
  (add-to-list 'auto-mode-alist '("\\.vmdb\\'" . yaml-mode))
  (add-to-list 'auto-mode-alist '("\\.yaml\\'" . yaml-mode))
  (add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode)))

(use-package markdown-mode
  :config
  (add-to-list 'auto-mode-alist '("NEWS" . markdown-mode))
  (add-to-list 'auto-mode-alist '("README" . markdown-mode))
  (add-to-list 'auto-mode-alist '("\\.mdwn\\'" . markdown-mode)))

(use-package shfmt
  :config
  (add-hook 'sh-mode-hook 'shfmt-on-save-mode))

(use-package rustic
  :config
  (setq rustic-format-trigger 'on-save))

(use-package lsp-mode
  :commands lsp
  :custom
  (lsp-rust-analyzer-cargo-watch-command "clippy")
  (lsp-eldoc-render-all t)
  (lsp-idle-delay 0.6)
  :config
  (add-hook 'lsp-mode-hook 'lsp-ui-mode))

(use-package lsp-ui
  :commands lsp-ui-mode
  :custom
  (lsp-ui-peek-always-show t)
  (lsp-ui-sideline-show-hover t)
  (lsp-ui-doc-enable nil))

(use-package company
  :config
  (setq company-tooltip-align-annotations t))

(use-package flycheck
  :config
  (setq-default flycheck-disabled-checkers '(python-pylint)))

(use-package flycheck-rust)

(use-package flycheck-color-mode-line)
(eval-after-load 'flycheck
  '(add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode))

(add-hook 'prog-mode-hook 'flycheck-mode)
(add-hook 'yaml-mode-hook 'flycheck-mode)
(add-hook 'markdown-mode-hook 'flycheck-mode)
(set-face-attribute 'flycheck-error nil
		    :weight 'bold
		    :underline "#ff0000"
		    :foreground "#ff0000")

(require 'flyspell)
(add-hook 'text-mode-hook 'flyspell-mode)
(add-hook 'prog-mode-hook 'flyspell-prog-mode)
(set-face-attribute 'flyspell-incorrect nil
		    :foreground "#ff0000")


(provide 'init)