blob: 0c5e3dd1b1cad8570622630a3c2bf184a900cdf4 (
plain) (
blame)
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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
|
;;; init.el --- This is where all emacs start. -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(defconst emacs-start-time (current-time))
(defun report-time-since-load ()
"Report how long it takes to load my Emacs configuration."
(message "[after-init ]Loading init...done (%.3fs)"
(float-time (time-subtract (current-time) emacs-start-time))))
(add-hook 'after-init-hook #'(lambda () (report-time-since-load)) t)
(setq sentence-end-double-space nil ;; it matters for filling
create-lockfiles nil ;; don't use a lock file
initial-major-mode 'fundamental-mode ;; default mode for the scratch buffer
initial-scratch-message "" ;; makes the scratch buffer empty
confirm-kill-emacs #'yes-or-no-p ;; ask before killing emacs
use-short-answers t ;; use y-or-n
ring-bell-function 'ignore ;; really no bell
visible-bell nil ;; no bell
delete-by-moving-to-trash t ;; delete files by moving them to the trash
history-delete-duplicates t ;; delete duplicate from history
require-final-newline t ;; ensure a new line is present at the bottom of files
auto-save-default nil ;; no auto save
backup-inhibited t ;; no backups
)
;; Use UTF-8 everywhere
(set-default-coding-systems 'utf-8)
(use-package recentf
:custom
(recentf-max-saved-items 2000)
(recentf-max-menu-items 200)
(recentf-exclude
'("~\\'" "\\`out\\'" "\\.log\\'" "^/[^/]*:" "\\.el\\.gz\\'" "\\.gz\\'"))
:config
(recentf-mode t))
(use-package savehist
:hook (after-init . savehist-mode)
:config
(setq history-length 100)
(setq history-delete-duplicates t)
(setq savehist-save-minibuffer-history t)
(savehist-mode t))
(use-package saveplace
:config
(save-place-mode t))
(use-package autorevert
:custom
(auto-revert-use-notify nil)
:config
(global-auto-revert-mode t))
(global-set-key (kbd "M-j") 'join-line)
(use-package which-key
:diminish
:hook (after-init . which-key-mode))
(use-package imenu
:config
(setq imenu-auto-rescan t))
(use-package exec-path-from-shell
:config
(exec-path-from-shell-initialize)
:custom
(exec-path-from-shell-variables '("ASPELL_CONF")))
(use-package ibuffer
:bind ("C-x C-b" . ibuffer)
:custom
(ibuffer-expert t)
(ibuffer-show-empty-filter-groups nil)
(ibuffer-jump-offer-only-visible-buffers t)
(ibuffer-maybe-show-predicates '("^\\*.*\\*$"))
(ibuffer-never-show-predicates '("^ "))
(ibuffer-use-other-window t))
(use-package midnight
:custom
;; every 6 hours
(midnight-period (* 3600 6)))
(use-package dired
:hook (dired-mode . dired-omit-mode)
:bind (:map dired-mode-map
( "." . dired-omit-mode))
:custom
(dired-omit-files (rx (seq bol ".")))
(dired-use-ls-dired t)
(insert-directory-program "/etc/profiles/per-user/fcuny/bin/ls")
(dired-clean-up-buffers-too nil)
(dired-dwim-target t)
(dired-hide-details-hide-information-lines nil)
(dired-hide-details-hide-symlink-targets nil)
(dired-recursive-copies 'always)
(dired-recursive-deletes 'always)
(dired-no-confirm
'(byte-compile chgrp chmod chown copy hardlink symlink touch)))
(defun my/rename-this-buffer-and-file ()
"Renames current buffer and file it is visiting."
(interactive)
(let ((name (buffer-name))
(filename (buffer-file-name))
(read-file-name-function 'read-file-name-default))
(if (not (and filename (file-exists-p filename)))
(error "Buffer '%s' is not visiting a file!" name)
(let ((new-name (read-file-name "New name: " filename)))
(cond ((get-buffer new-name)
(error "A buffer named '%s' already exists!" new-name))
(t
(rename-file filename new-name 1)
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil)
(message "File '%s' successfully renamed to '%s'" name (file-name-nondirectory new-name))))))))
;; Don't say anything on mode-line mouseover.
(setq mode-line-default-help-echo nil)
;; Keep cursors and highlights in current window only.
(setq cursor-in-non-selected-windows nil)
;; Don't highlight inactive windows.
(setq highlight-nonselected-windows nil)
(use-package fringe
:config
;; no fringe on the right side
(fringe-mode '(8 . 0)))
;; Disable bidirectional text support for slight performance bonus.
(setq bidi-display-reordering nil)
;; show column number in the mode line
(setq column-number-mode t)
(require 'time)
(setq display-time-24hr-format t
display-time-interval 60
display-time-mode t
display-time-format "%H:%M %d.%m"
display-time-day-and-date t
display-time-default-load-average nil)
(setq world-clock-list t
world-clock-timer-enable t
world-clock-timer-second 60
world-clock-time-format "%R %z %A %d %B")
;; UTC => 02:42 +0000 Wednesday 20 April
;; Berkeley => 19:42 -0700 Tuesday 19 April
(setq zoneinfo-style-world-list '(("UTC" "UTC")
("America/Los_Angeles" "Berkeley")
("America/Denver" "Mountain Time")
("America/Chicago" "Central Time")
("America/New_York" "New York")
("Europe/London" "London")
("Europe/Paris" "Paris")))
(use-package ef-themes
:custom
(ef-themes-region '(intense no-extend neutral))
(ef-themes-disable-other-themes t)
(ef-themes-to-toggle '(ef-melissa-light ef-maris-light))
:init
(ef-themes-select 'ef-maris-light))
(use-package magit
:bind ("C-x g" . magit-status)
:custom
(magit-diff-refine-hunk t)
(magit-repository-directories
'(("~/workspace" . 1)))
(magit-repolist-column-flag-alist
'((magit-untracked-files . "N")
(magit-unstaged-files . "U")
(magit-staged-files . "S")))
(magit-repolist-columns
'(("Name" 25 magit-repolist-column-ident nil)
("" 3 magit-repolist-column-flag)
("Version" 25 magit-repolist-column-version
((:sort magit-repolist-version<)))
("B<U" 3 magit-repolist-column-unpulled-from-upstream
((:right-align t)
(:sort <)))
("B>U" 3 magit-repolist-column-unpushed-to-upstream
((:right-align t)
(:sort <)))
("Path" 99 magit-repolist-column-path nil)))
(magit-clone-default-directory "~/workspace/")
:config
;; show ANSI colors in the process buffer, so it's easier to read what's going on
;; for some reasons if it's in the `:custom' section it does not get set
(setq magit-process-finish-apply-ansi-colors t))
(use-package git-link
:defines git-link-remote-alist
:bind ("C-c Y" . git-link)
:commands (git-link git-link-commit git-link-homepage)
:custom
(git-link-open-in-browser t)
:config
;; sets up roblox git enterprise as a git-link handler
(add-to-list 'git-link-remote-alist '("github\\.rblx\\.com" git-link-github))
(add-to-list 'git-link-commit-remote-alist '("github\\.rblx\\.com" git-link-commit-github)))
(use-package rg
:custom
(rg-group-result t)
(rg-show-columns t)
(rg-align-line-number-field-length 3)
(rg-align-column-number-field-length 3)
(rg-align-line-column-separator "#")
(rg-align-position-content-separator "|")
(rg-hide-command nil)
(rg-align-position-numbers t)
(rg-command-line-flags '("--follow")))
(use-package project
:config
(setq project-mode-line t
project-switch-commands
'((project-find-file "Find file" f)
(project-dired "Dired" d)
(project-eshell "Eshell" e)
(magit-project-status "Magit" ?m))))
;; `elec-pair' is a built-in minor-mode that enables auto-pairing of parens (or
;; similar delimiters).
(use-package elec-pair
:hook (prog-mode . electric-pair-mode))
(use-package compile
:hook (compilation-filter . ansi-color-compilation-filter)
:custom
(compilation-always-kill t)
(compilation-context-lines 10)
(compilation-disable-input t)
(compilation-scroll-output 'first-error)
(compilation-scroll-output t)
(compilation-skip-threshold 2)
;; Save all buffers on M-x `compile'
(compilation-ask-about-save nil))
(use-package eldoc
:diminish
:hook ((emacs-lisp-mode) . eldoc-mode)
:custom
(eldoc-idle-delay 1)
(eldoc-documentation-strategy #'eldoc-documentation-default)
;; Don't resize the echo area if the documentation is longer. This is very
;; distracting when combined with Eglot's highlight functionality.
(eldoc-echo-area-use-multiline-p nil))
(use-package tree-sitter
:config
(global-tree-sitter-mode))
(use-package tree-sitter-langs
:after tree-sitter)
(use-package direnv
:custom
(direnv-always-show-summary nil)
:config
(direnv-mode))
(use-package emacs-lisp-mode
:bind (:map emacs-lisp-mode-map
("C-c C-r" . eval-region)
("C-c C-d" . eval-defun)
("C-c C-b" . eval-buffer))
:hook ((emacs-lisp-mode . flymake-mode)))
(use-package eglot
:after yasnippet
:bind (:map eglot-mode-map
("C-c l a" . eglot-code-actions)
("C-c l r" . eglot-rename)
("C-c l f" . eglot-format-buffer))
:hook ((go-mode . eglot-ensure)
(python-mode . eglot-ensure)
(nix-mode . eglot-ensure))
:custom
(eglot-send-changes-idle-time 0.1)
:config
(setq eglot-autoshutdown t
;; Disable logging of events.
eglot-events-buffer-size 0)
(setq-default eglot-workspace-configuration
'(:pylsp (:plugins (:ruff (:enabled t)))
:nil (:formatting (:command ["nixfmt"]))
:gopls (:usePlaceholders t
:staticcheck t
:completeUnimported t
:matcher "CaseSensitive")))
;; uses https://github.com/nix-community/nixd for the LSP server instead of rnix
(add-to-list 'eglot-server-programs '(nix-mode . ("nil"))))
;;; go related configuration
(use-package go-mode
:hook ((go-mode . tree-sitter-hl-mode)
(go-mode . (lambda () (setq tab-width 4)))
(go-mode . (lambda () (add-hook 'before-save-hook 'eglot-format-buffer nil t))))
:bind (:map go-mode-map
("C-c C-c" . compile)))
(use-package gotest
:after go-mode
:custom
(go-test-verbose t))
;;; nix related configuration
(use-package nix-mode
:hook ((nix-mode . (lambda () (add-hook 'before-save-hook 'eglot-format-buffer nil t))))
:custom
(nix-indent-function 'nix-indent-line))
;;; python related configuration
(use-package python-mode
:hook ((python-mode . tree-sitter-hl-mode)))
(use-package ruby-mode)
;;; flymake related configuration
(use-package flymake
:bind (:prefix "C-c !"
:prefix-map flymake-prefix-map
("l" . consult-flymake)
("b" . flymake-show-project-diagnostics)
("n" . flymake-goto-next-error)
("p" . flymake-goto-prev-error))
:hook
(prog-mode . flymake-mode)
:custom
(flymake-start-on-save-buffer t)
(flymake-fringe-indicator-position 'left-fringe)
(flymake-suppress-zero-counters t)
(flymake-proc-compilation-prevents-syntax-check t)
(flymake-no-changes-timeout 9999)
(elisp-flymake-byte-compile-load-path load-path))
;;; JSON related modules
(use-package json-mode
:mode "\\.json\\'")
(use-package json-reformat
:after json-mode)
(use-package jq-mode
:mode "\\.jq\\'")
;;; hashicorp related modules
(use-package terraform-mode
:mode "\.tf\\'")
(use-package hcl-mode
:mode "\.nomad\\'")
;;; TOML related modules
(use-package toml-mode)
;;; YAML related modules
(use-package yaml-mode)
;;; docker related modules
(use-package docker
:bind ("C-c d" . docker)
:diminish
:init
(use-package docker-image :commands docker-images)
(use-package docker-volume :commands docker-volumes)
(use-package docker-network :commands docker-containers)
(use-package docker-compose :commands docker-compose)
(use-package docker-container
:commands docker-containers
:custom
(docker-containers-shell-file-name "/bin/bash")
(docker-containers-show-all nil)))
(use-package docker-compose-mode
:mode "docker-compose.*\.yml\\'")
(use-package dockerfile-mode
:mode "Dockerfile[a-zA-Z.-]*\\'")
(use-package protobuf-mode
:mode "\\.proto\\'")
;;; css related configuration
(use-package css-mode
:custom
(css-indent-offset 2)
(cssm-indent-level 1))
(use-package consult
:commands (consult-ripgrep consult-buffer consult-imenu)
:bind (("C-c m" . consult-mode-command)
("C-x b" . consult-buffer)
("C-x r b" . consult-bookmark)
("C-x p b" . consult-project-buffer)
("C-c i" . consult-imenu)
("M-g e" . consult-compile-error)
("M-g M-g" . consult-goto-line)
("M-g m" . consult-mark)
("M-g k" . consult-global-mark)))
(use-package corfu
:custom
(corfu-auto t)
:bind ("M-/" . completion-at-point)
:hook ((after-init . global-corfu-mode)
(global-corfu-mode . corfu-popupinfo-mode)))
(use-package cape
:ensure t)
(use-package marginalia
:ensure t
:hook (after-init . marginalia-mode))
(use-package orderless
:demand t
:custom
(completion-styles '(orderless basic))
(completion-category-defaults nil))
(use-package vertico
:hook ((after-init . vertico-mode)))
(use-package eshell
:commands (eshell eshell-command)
:bind (("C-r" . consult-history))
:custom
(eshell-hist-ignoredups t)
(eshell-history-size 50000)
(eshell-ls-dired-initial-args '("-h"))
(eshell-ls-initial-args "-h")
(eshell-ls-exclude-regexp "~\\'")
(eshell-save-history-on-exit t)
(eshell-stringify-t nil)
(eshell-term-name "ansi"))
(use-package yasnippet
:hook (after-init . yas-global-mode))
;; Yasnippet Completion At Point Function
(use-package yasnippet-capf
:init (add-to-list 'completion-at-point-functions #'yasnippet-capf))
(report-time-since-load)
;;; early-init.el ends here
;; byte-compile-warnings: (not docstrings lexical noruntime)
;; End:
|