summaryrefslogtreecommitdiff
path: root/.emacs.d/init.el
blob: 882287d94ee908af40d0e6b3f72222e134c1c227 (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
;;; init.el --- Coast's ~/.emacs.d/init.el
;;
;;; Commentary:
;; This is my GNU/Emacs configuration --
;; It has:
;; - (TEMPORARY) Evil mode; as I've gotten used to Vim binds when I was away from GNU/Emacs for a bit.
;; - Automatic syntax-highlighting.
;; - Has a minimap.
;; - Bad theme; it's fine on my eyes, though -- I like the 'solarized' theme >:3
;; - It's also gay.
;;
;;; Code:
;;
(require 'package)
(setq package-archives
      '(("gnu" . "https://elpa.gnu.org/packages/")
        ("melpa" . "https://melpa.org/packages/")))
(package-initialize)
(unless package-archive-contents
  (package-refresh-contents))
(require 'use-package)

;;; Message:
;; "run" command (M-x / evil)
(defun coast/run-current-file ()
  (interactive)
  (let ((file (buffer-file-name)))
    (cond
     ((not file)
      (message "No file to run!"))
     ((string-match "\\.py\\'" file)
      (compile (format "python3 %s" file)))
     ((string-match "\\.c\\'" file)
      (let* ((out (concat (file-name-sans-extension file) ".out")))
        (compile (format "gcc %s -o %s && %s" file out out))))
     ((string-match "\\.sh\\'" file)
      (compile (format "bash %s" file)))
     ((string-match "\\.rs\\'" file)
      (let* ((out (file-name-sans-extension file)))
        (compile (format "rustc %s && %s" file out))))
     ((string-match "\\.lua\\'" file)
      (compile (format "lua %s" file)))
     ((string-match "\\.js\\'" file)
      (compile (format "node %s" file)))
     ((coast/file-has-shebang-p file)
      (compile (format "%s" file)))
     (t (message "Not sure how to run this.")))))

(defun coast/file-has-shebang-p (file)
  (when (and file (file-readable-p file))
    (with-temp-buffer
      (insert-file-contents-literally file nil 0 128)
      (goto-char (point-min))
      (looking-at "^#!"))))

(defalias 'run #'coast/run-current-file)

(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(global-display-line-numbers-mode 1)
(global-hl-line-mode 1)
(electric-pair-mode 1)

(setq-default electric-pair-pairs
              '((?\" . ?\")
                (?\{ . ?\})
                (?\( . ?\))
                (?\[ . ?\])
                (?\< . ?\>)))

(setq-default electric-pair-text-pairs electric-pair-pairs)

(set-frame-parameter (selected-frame) 'alpha '(95 . 95))
(add-to-list 'default-frame-alist '(alpha . (95 . 95)))

(set-face-attribute 'default nil :family "Inconsolata" :height 180)

(setq backup-directory-alist `((".*" . "~/.local/tmp/emacsbackup/")))
(setq make-backup-files t)
(setq backup-by-copying t)

(use-package solarized-theme :ensure t)
(load-theme 'solarized-selenized-dark t)

(use-package all-the-icons :ensure t :if (display-graphic-p))
(use-package rainbow-mode :ensure t :hook (prog-mode . rainbow-mode))
(use-package elcord :ensure t :config (elcord-mode 1))

(use-package neotree :ensure t :bind ("<f9>" . neotree-toggle))

(use-package vertico :ensure t :config (vertico-mode 1))
(use-package marginalia :ensure t :hook (vertico-mode . marginalia-mode))
(use-package consult
  :ensure t
  :bind (("C-x b" . consult-buffer)
         ("C-s" . consult-line)))

(use-package which-key :ensure t :config (which-key-mode 1))

(use-package company :ensure t :hook (prog-mode . company-mode))
(use-package yasnippet :ensure t :hook (prog-mode . yas-minor-mode))
(use-package flycheck :ensure t :hook (prog-mode . flycheck-mode))

(global-set-key (kbd "C-c t") 'ansi-term)

(use-package web-mode
  :ensure t
  :mode "\\.html?\\'"
  :config
  (setq web-mode-enable-auto-pairing t
        web-mode-enable-auto-closing t
        web-mode-enable-auto-expanding t))

(use-package emmet-mode
  :ensure t
  :hook ((web-mode html-mode css-mode) . emmet-mode)
  :config
  (setq emmet-expand-jsx-className? t))

(use-package python :mode "\\.py\\'")
(use-package sh-script :mode "\\.sh\\'")
(use-package cc-mode)
(use-package markdown-mode :ensure t :mode "\\.md\\'")
(use-package yaml-mode :ensure t :mode "\\.ya?ml\\'")
(use-package macrostep :ensure t)

;;; Message:
;; Language-setup.
(use-package python
  :mode ("\\.py\\'" . python-mode)
  :interpreter ("python" . python-mode))

(use-package rust-mode
  :ensure t
  :mode ("\\.rs\\'" . rust-mode))

(use-package sh-script
  :mode (("\\.sh\\'" . sh-mode)
         ("\\.bash\\'" . sh-mode)
         ("\\.zsh\\'" . sh-mode))
  :interpreter (("bash" . sh-mode)
                ("sh" . sh-mode)
                ("zsh" . sh-mode)))

(use-package lua-mode
  :ensure t
  :mode ("\\.lua\\'" . lua-mode))

(use-package cc-mode
  :mode (("\\.c\\'" . c-mode)
         ("\\.h\\'" . c-mode)
         ("\\.cpp\\'" . c++-mode)
         ("\\.hpp\\'" . c++-mode))
  :interpreter (("c" . c-mode)
                ("cpp" . c++-mode)))

(use-package markdown-mode
  :ensure t
  :mode ("\\.md\\'" . markdown-mode))

(use-package yaml-mode
  :ensure t
  :mode ("\\.ya?ml\\'" . yaml-mode))

;;; Message
;; -- Set window title --
(setq frame-title-format '("%b —— GNU/Emacs"))

;;; Message:
;; -- The below may have been temporarily added --

(use-package doom-modeline
  :ensure t
  :init
  (setq doom-modeline-height 25
        doom-modeline-bar-width 3
        doom-modeline-buffer-file-name-style 'truncate-with-project
        doom-modeline-icon t
        doom-modeline-major-mode-icon t
        doom-modeline-enable-word-count t
        doom-modeline-vcs-max-length 12
        doom-modeline-minor-modes nil)
  :config
  (doom-modeline-mode 1))

(setq evil-want-keybinding nil)

(use-package evil
  :ensure t
  :init (setq evil-want-integration t
              evil-want-C-u-scroll t)
  :config (evil-mode 1))

(use-package evil-collection
  :after evil
  :ensure t
  :config (evil-collection-init))

(use-package evil-leader
  :ensure t
  :config
  (global-evil-leader-mode)
  (evil-leader/set-leader "<SPC>")
  (evil-leader/set-key
    "f" 'find-file
    "b" 'switch-to-buffer
    "k" 'kill-buffer
    "t" 'ansi-term
    "e" 'eval-buffer
    "r" 'coast/run-current-file))

(use-package evil-surround :ensure t :config (global-evil-surround-mode 1))
(use-package evil-commentary :ensure t :config (evil-commentary-mode 1))

(use-package corfu
  :ensure t
  :custom
  (corfu-auto t)
  (corfu-cycle t)
  (corfu-quit-no-match nil)
  :init
  (global-corfu-mode))

(use-package cape
  :ensure t)

(defun my/evil-ex-corfu-setup ()
  (setq-local completion-at-point-functions
              (list (cape-super-capf #'completion-at-point))))

(add-hook 'evil-ex-completion-hook #'my/evil-ex-corfu-setup)

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(warning-suppress-log-types '((use-package))))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

(provide 'init)
;;; init.el ends here