···11+;;; early-init -- Early emacs initialization
22+;;; Commentary:
33+;;; Code:
44+55+(defvar nesv/tiling-window-manager-regexp "bspwm\\|herbstluftwm\\|i3\\|hyprland"
66+ "Regexp to match the name of tiling window managers.")
77+88+(defmacro nesv/with-desktop-session (&rest body)
99+ "Expand BODY if desktop is *not* a tiling window manager."
1010+ (declare (indent 0))
1111+ `(when-let ((session (getenv "DESKTOP_SESSION"))
1212+ ((not (string-match-p session nesv/tiling-window-manager-regexp))))
1313+ ,@body))
1414+1515+(defun nesv/add-to-list (list element)
1616+ "Add ELEMENT to LIST. A simplified version of ADD-TO-LIST."
1717+ (set list (cons element (symbol-value list))))
1818+1919+;; Set the window size on non-tiling window managers.
2020+;;
2121+;; INITIAL-FRAME-ALIST is the first frame that is produced when starting emacs.
2222+;; DEFAULT-FRAME-ALIST is all other frames.
2323+(nesv/with-desktop-session
2424+ (mapc
2525+ (lambda (var)
2626+ (nesv/add-to-list var '(width . (text-pixels . 800)))
2727+ (nesv/add-to-list var '(height . (text-pixels . 900)))
2828+ (nesv/add-to-list var '(scroll-bar-width . 10)))
2929+ '(default-frame-alist initial-frame-alist)))
3030+3131+(setq frame-resize-pixelwise t
3232+ frame-inhibit-implied-resize t
3333+ frame-title-format '("%b")
3434+ ring-bell-function 'ignore
3535+ use-dialog-box t
3636+ use-file-dialog nil
3737+ use-short-answers t
3838+ inhibit-splash-screen t
3939+ inhibit-startup-screen t
4040+ inhibit-x-resources t
4141+ inhibit-startup-echo-area-message user-login-name
4242+ inhibit-startup-buffer-menu t)
4343+4444+;; Disable useless graphical elements like the menu bar, the scroll bar, and
4545+;; the tool bar.
4646+(menu-bar-mode -1)
4747+(scroll-bar-mode -1)
4848+(tool-bar-mode -1)
4949+5050+;; Temporarily increase the garbage collection threshold.
5151+;; This should shave about 0.5s off startup time.
5252+(setq gc-cons-threshold most-positive-fixnum
5353+ gc-cons-percentage 0.5)
5454+5555+;; More startup optimizations.
5656+(defvar nesv/file-name-handler-alist file-name-handler-alist)
5757+(defvar nesv/vc-handled-backends vc-handled-backends)
5858+5959+(setq file-name-handler-alist nil
6060+ vc-handled-backends nil)
6161+6262+(add-hook 'emacs-startup-hook
6363+ (lambda ()
6464+ (setq gc-cons-threshold (* 1000 1000 8)
6565+ gc-cons-percentage 0.1
6666+ file-name-handler-alist nesv/file-name-handler-alist
6767+ vc-handled-backends nesv/vc-handled-backends)))
6868+6969+;; Name the default frame.
7070+(add-hook 'after-init-hook (lambda () (set-frame-name "nesv")))
7171+7272+;; Inititalize install packages early.
7373+(setq package-enable-at-startup t)
7474+7575+(provide 'early-init)
7676+;;; early-init.el ends here
+92-229
init.el
···22;;; Commentary:
33;;; Code:
4455+;; Define a new group for customizations.
66+;; This will basically allow someone else to use this configuration,
77+;; but tweak it to their own liking by setting custom vars.
88+(defgroup nesv-emacs nil
99+ "User options for nesv's Emacs.
1010+Put the customizations in a file called ~/.emacs.d/nesv-emacs-pre-custom.el."
1111+ :group 'file)
1212+1313+;; Load extras for minibuffer completion.
1414+(defcustom nesv-emacs-completion-extras t
1515+ "When non-nil, load extras for minibuffer completion (e.g. `consult', `embark')."
1616+ :group 'nesv-emacs
1717+ :type 'boolean)
1818+1919+;; User option to load extra stuff for tree-sitter.
2020+(defcustom nesv-emacs-tree-sitter-extras t
2121+ "When non-nil, load extras for tree-sitter integration (e.g. `expreg')."
2222+ :group 'nesv-emacs
2323+ :type 'boolean)
2424+2525+(defcustom nesv-emacs-load-which-key nil
2626+ "When non-nil, display keybinding hints after a short delay."
2727+ :group 'nesv-emacs
2828+ :type 'boolean)
2929+3030+(defcustom nesv-emacs-load-nerd-icons nil
3131+ "When non-nil, enable nerd icons."
3232+ :group 'nesv-emacs
3333+ :type 'boolean)
3434+3535+(defcustom nesv-emacs-load-theme 'ef
3636+ "Load the specified colour theme."
3737+ :group 'nesv-emacs
3838+ :type '(choice :tag "Theme to load" :value ef
3939+ (const :tag "`ef-themes'" ef)
4040+ (const :tag "`modus-themes'" modus)
4141+ (const :tag "Jonathan Blow style" naysayer)
4242+ (const :tag "Do not load a theme" nil)))
4343+4444+(defcustom nesv-emacs-font "Source Code Pro"
4545+ "Set the specific font face when loading Emacs in GUI mode."
4646+ :group 'nesv-emacs
4747+ :type '(choice :tag "Font to use" :value "Source Code Pro"
4848+ (const :tag "MonoLisa" "MonoLisa")
4949+ (const :tag "Berkeley Mono" "Berkeley Mono")))
5050+551;; ░█▀█░█▀█░█▀▀░█░█░█▀█░█▀▀░█▀▀░█▀▀
652;; ░█▀▀░█▀█░█░░░█▀▄░█▀█░█░█░█▀▀░▀▀█
753;; ░▀░░░▀░▀░▀▀▀░▀░▀░▀░▀░▀▀▀░▀▀▀░▀▀▀
···60106 :config
61107 (direnv-mode))
621086363-;; ░█▀▀░█▀█░█░░░█▀█░█░█░█▀▄░░░▀█▀░█░█░█▀▀░█▄█░█▀▀░█▀▀
6464-;; ░█░░░█░█░█░░░█░█░█░█░█▀▄░░░░█░░█▀█░█▀▀░█░█░█▀▀░▀▀█
6565-;; ░▀▀▀░▀▀▀░▀▀▀░▀▀▀░▀▀▀░▀░▀░░░░▀░░▀░▀░▀▀▀░▀░▀░▀▀▀░▀▀▀
6666-;; A recreation of Jonathan Blow's emacs theme.
6767-(use-package naysayer-theme
6868- :ensure t)
6969-7070-;; EF-THEMES
7171-;;
7272-;; https://protesilaos.com/emacs/ef-themes
7373-(use-package ef-themes
7474- :ensure t)
7575-7676-;; MODUS THEMES
7777-;;
7878-;; https://protesilaos.com/emacs/modus-themes
7979-(use-package modus-themes
8080- :ensure t)
8181-8282-(load-theme 'ef-bio t)
8383-84109;; ░█▀▀░█▀█░█░░░█▀█░▀█▀░█▀▄░█▀▀░░░░░█▄█░█▀█░█▀▄░█▀▀
85110;; ░▀▀█░█░█░█░░░█▀█░░█░░█▀▄░█▀▀░▄▄▄░█░█░█░█░█░█░█▀▀
86111;; ░▀▀▀░▀▀▀░▀▀▀░▀░▀░▀▀▀░▀░▀░▀▀▀░░░░░▀░▀░▀▀▀░▀▀░░▀▀▀
···96121(menu-bar-mode -1) ; Disable the menubar.
97122(tool-bar-mode -1) ; Disable the toolbar.
98123(setq ring-bell-function 'ignore) ; Disable the damn bell.
9999-(setq make-backup-files nil) ; Do not create backup files.
100124(setq auto-save-default nil) ; Disable auto save.
101125(global-auto-revert-mode t) ; Auto-reload buffers when the backing file on disk changes.
102126(global-hl-line-mode t) ; Highlight the current line.
···104128(setq column-number-mode t) ; Display column numbers.
105129(set-default 'truncate-lines t) ; Let long lines flow off-screen.
106130131131+;; Disable backup files, and lock files.
132132+(setq make-backup-files nil)
133133+(setq backup-inhibited nil)
134134+(setq create-lockfiles nil)
135135+136136+;; Silence native compilation (`nativecomp').
137137+(when (native-comp-available-p)
138138+ (setq native-comp-async-report-warnings-errors 'silent)
139139+ (setq native-compile-prune-cache t))
140140+141141+;; By default, Emacs writes persistent customizations to the end of the user's
142142+;; init.el.
143143+;; Disable it.
144144+(setq custom-file (make-temp-file "emacs-custom-"))
145145+107146;; Draw a ruler at the 80-character column.
108147(add-hook 'prog-mode-hook #'display-fill-column-indicator-mode)
109148(add-hook 'text-mode-hook #'display-fill-column-indicator-mode)
···112151(setq-default fill-column 80)
113152(add-hook 'text-mode-hook #'auto-fill-mode)
114153154154+;; Enable these commands.
155155+(mapc
156156+ (lambda (command) (put command 'disabled nil))
157157+ '(list-timers narrow-to-region narrow-to-page upcase-region downcase-region))
158158+159159+;; Disable these commands.
160160+(mapc
161161+ (lambda (command) (put command 'disabled t))
162162+ '(eshell project-eshell overwrite-mode iconify-frame diary))
163163+164164+;; Always start with the *scratch* buffer.
165165+(setq initial-buffer-choice t)
166166+115167;; ░█▀▀░█░█░▀█▀░░░█▄█░█▀█░█▀▄░█▀▀
116168;; ░█░█░█░█░░█░░░░█░█░█░█░█░█░█▀▀
117169;; ░▀▀▀░▀▀▀░▀▀▀░░░▀░▀░▀▀▀░▀▀░░▀▀▀
···123175 (add-to-list 'default-frame-alist '(width . 120))
124176 (add-to-list 'default-frame-alist '(height . 60)))
125177126126-(use-package fontaine
127127- :ensure t
128128- :config
129129- (setq fontaine-presets
130130- '((tiny
131131- :default-family "Iosevka Comfy Wide Fixed"
132132- :default-height 70)
133133- (small
134134- :default-family "Iosevka Comfy Fixed"
135135- :default-height 90)
136136- (regular
137137- :default-height 100)
138138- (medium
139139- :default-height 110)
140140- (medium-large
141141- :default-height 120)
142142- (large
143143- :default-weight semilight
144144- :default-height 140
145145- :bold-weight extrabold)
146146- (presentation
147147- :default-weight semlight
148148- :default-height 170
149149- :bold-weight extrabold)
150150- (t
151151- :default-family "Iosevka Comfy Wide"
152152- :default-weight regular
153153- :default-height 100
154154- :fixed-pitch-family nil ; Falls back to :default-family
155155- :fixed-pitch-weight nil ; Falls back to :default-weight
156156- :fixed-pitch-height 1.0
157157- ;;:variable-pitch-family "Iosevka Comfy Wide Duo"
158158- :variable-pitch-family "Atkinson Hyperlegible"
159159- :variable-pitch-weight nil
160160- :variable-pitch-height 1.0
161161- :bold-family nil ; Whatever the underlying face has
162162- :bold-weight bold
163163- :italic-family nil
164164- :italic-slant italic
165165- :line-spacing nil)))
166166- (when (display-graphic-p)
167167- (fontaine-set-preset 'medium-large)))
178178+;; By default, Emacs inserts tabs in place of multiple spaces when formatting
179179+;; a region.
180180+;; Turn this off.
181181+(setq-default indent-tabs-mode nil)
182182+168183169184(use-package cursory
170185 :ensure t
···210225(use-package nerd-icons
211226 :ensure t)
212227213213-;; ░█▀▀░█▀█░█▀█░▀█▀░░░█░░░▀█▀░█▀▀░█▀█░▀█▀░█░█░█▀▄░█▀▀░█▀▀
214214-;; ░█▀▀░█░█░█░█░░█░░░░█░░░░█░░█░█░█▀█░░█░░█░█░█▀▄░█▀▀░▀▀█
215215-;; ░▀░░░▀▀▀░▀░▀░░▀░░░░▀▀▀░▀▀▀░▀▀▀░▀░▀░░▀░░▀▀▀░▀░▀░▀▀▀░▀▀▀
216216-;; (setq-default mono-lisa-v2-ligatures '(;; coding ligatures
217217-;; "<!---" "--->" "|||>" "<!--" "<|||" "<==>" "-->" "->>" "-<<" "..=" "!=="
218218-;; "#_(" "/==" "||>" "||=" "|->" "===" "==>" "=>>" "=<<" "=/=" ">->" ">=>"
219219-;; ">>-" ">>=" "<--" "<->" "<-<" "<||" "<|>" "<=" "<==" "<=>" "<=<" "<<-"
220220-;; "<<=" "<~>" "<~~" "~~>" ">&-" "<&-" "&>>" "&>" "->" "-<" "-~" ".=" "!="
221221-;; "#_" "/=" "|=" "|>" "==" "=>" ">-" ">=" "<-" "<|" "<~" "~-" "~@" "~="
222222-;; "~>" "~~"
223223-;; ;; whitespace ligatures
224224-;; "---" "'''" "\"\"\"" "..." "..<" "{|" "[|" ".?" "::" ":::" "::=" ":="
225225-;; ":>" ":<" "\;\;" "!!" "!!." "!!!" "?." "?:" "??" "?=" "**" "***" "*>"
226226-;; "*/" "--" "#:" "#!" "#?" "##" "###" "####" "#=" "/*" "/>" "//" "/**"
227227-;; "///" "$(" ">&" "<&" "&&" "|}" "|]" "$>" ".." "++" "+++" "+>" "=:="
228228-;; "=!=" ">:" ">>" ">>>" "<:" "<*" "<*>" "<$" "<$>" "<+" "<+>" "<>" "<<"
229229-;; "<<<" "</" "</>" "^=" "%%")
230230-;; berkeley-mono-ligatures '(;; Group A
231231-;; ".." ".=" "..." "..<" "::" ":::" ":=" "::=" ";;" ";;;" "??" "???"
232232-;; ".?" "?." ":?" "?:" "?=" "**" "***" "/*" "*/" "/**"
233233-;; ;; Group B
234234-;; "<-" "->" "-<" ">-" "<--" "-->" "<<-" "->>" "-<<" ">>-" "<-<" ">->"
235235-;; "<-|" "|->" "-|" "|-" "||-" "<!--" "<#--" "<=" "=>" ">=" "<==" "==>"
236236-;; "<<=" "=>>" "=<<" ">>=" "<=<" ">=>" "<=|" "|=>" "<=>" "<==>" "||="
237237-;; "|=" "//=" "/="
238238-;; ;; Group C
239239-;; "<<" ">>" "<<<" ">>>" "<>" "<$" "$>" "<$>" "<+" "+>" "<+>" "<:" ":<"
240240-;; "<:<" ">:" ":>" "<~" "~>" "<~>" "<<~" "<~~" "~~>" "~~" "<|" "|>"
241241-;; "<|>" "<||" "||>" "<|||" "|||>" "</" "/>" "</>" "<*" "*>" "<*>" ":?>"
242242-;; ;; Group D
243243-;; "#(" "#{" "#[" "]#" "#!" "#?" "#=" "#_" "#_(" "##" "###" "####"
244244-;; ;; Group E
245245-;; "[|" "|]" "[<" ">]" "{!!" "!!}" "{|" "|}" "{{" "}}" "{{--" "--}}"
246246-;; "{!--" "//" "///" "!!"
247247-;; ;; Group F
248248-;; "www" "@_" "&&" "&&&" "&=" "~@" "++" "+++" "/\\" "\\/" "_|_" "||"
249249-;; ;; Group G
250250-;; "=:" "=:=" "=!=" "==" "===" "=/=" "=~" "~-" "^=" "__" "!=" "!==" "-~"
251251-;; "--" "---"))
252252-253253-;; (when (display-graphic-p)
254254-;; (use-package ligature
255255-;; :ensure t
256256-;; :config
257257-;; (ligature-set-ligatures 'prog-mode mono-lisa-v2-ligatures)
258258-;; (global-ligature-mode t)))
259259-260260-;; ░█▀▀░▀█▀░▀█▀░░░█░█▄█░█▀█░█▀▀░▀█▀░▀█▀
261261-;; ░█░█░░█░░░█░░▄▀░░█░█░█▀█░█░█░░█░░░█░
262262-;; ░▀▀▀░▀▀▀░░▀░░▀░░░▀░▀░▀░▀░▀▀▀░▀▀▀░░▀░
263263-(use-package magit
264264- :ensure t
265265- :hook (after-save-hook . magit-after-save-refresh-status))
266266-267267-;; Git Gutter -- Shows git status in the sidebar
268268-(use-package git-gutter
269269- :ensure t
270270- :hook (prog-mode . git-gutter-mode)
271271- :config
272272- (setq git-gutter:update-interval 0.2))
273273-(use-package git-gutter-fringe
274274- :ensure t
275275- :config
276276- (define-fringe-bitmap 'git-gutter-fr:added [224] nil nil '(center repeated))
277277- (define-fringe-bitmap 'git-gutter-fr:modified [224] nil nil '(center repeated))
278278- (define-fringe-bitmap 'git-gutter-fr:deleted [128 192 224 240] nil nil 'bottom))
279279-280280-;; ░▀█▀░█▀▄░█▀▀░█▀▀░░░░░█▀▀░▀█▀░▀█▀░▀█▀░█▀▀░█▀▄
281281-;; ░░█░░█▀▄░█▀▀░█▀▀░▄▄▄░▀▀█░░█░░░█░░░█░░█▀▀░█▀▄
282282-;; ░░▀░░▀░▀░▀▀▀░▀▀▀░░░░░▀▀▀░▀▀▀░░▀░░░▀░░▀▀▀░▀░▀
283283-;; ...because it's pretty cool.
284284-(use-package tree-sitter
285285- :ensure t)
286286-(use-package tree-sitter-langs
287287- :ensure t
288288- :hook (tree-sitter-after-on-hook . tree-sitter-hl-mode)
289289- :config
290290- (global-tree-sitter-mode))
291228292229;; indent-mode helps with indenting, moving around, and acting on
293230;; whitespace-sensitive code, like YAML and Python.
294231(use-package indent-tools
295232 :ensure t)
296233297297-;; ░█░░░█▀█░█▀█░█▀▀░█░█░█▀█░█▀▀░█▀▀░█▀▀
298298-;; ░█░░░█▀█░█░█░█░█░█░█░█▀█░█░█░█▀▀░▀▀█
299299-;; ░▀▀▀░▀░▀░▀░▀░▀▀▀░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀▀▀
300300-(use-package adoc-mode
301301- :ensure t)
302302-303303-;; Bazel, Starlark, Tilt, etc.
304304-(use-package bazel :ensure t
305305- :mode ("Tiltfile.\\'" . bazel-mode))
306306-307307-;; CUE -- https://cuelang.org
308308-(use-package cue-mode :ensure t)
309309-310310-(use-package dockerfile-mode :ensure t)
311311-312312-(use-package go-mode
313313- :ensure t
314314- :hook (before-save . gofmt-before-save))
315315-316316-;; HashiCorp Configuration Language
317317-(use-package hcl-mode :ensure t)
318318-(use-package terraform-mode
319319- :ensure t
320320- :hook (terraform-mode . outline-minor-mode))
321321-322322-;; Just -- https://just.systems
323323-(use-package just-mode :ensure t)
324324-325325-(use-package markdown-mode
326326- :ensure t
327327- :mode ("README\\.md\\'" . gfm-mode)
328328- :hook (markdown-mode . auto-fill-mode)
329329- :init (setq markdown-command "multimarkdown"))
330330-331331-(use-package protobuf-mode :ensure t)
332332-333333-;; (use-package rust-mode
334334-;; :ensure t
335335-;; :hook (rust-mode-hook . eglot-ensure)
336336-;; :init
337337-;; (add-hook 'rust-mode-hook (lambda () (setq indent-tabs-mode nil)))
338338-;; :config
339339-;; (setq rust-format-on-save t))
340340-341341-(use-package rustic
342342- :ensure t
343343- :config
344344- (setq rustic-lsp-client 'eglot)
345345- (setq lsp-eldoc-hook nil)
346346- (setq lsp-enable-symbol-highlighting nil)
347347- (setq lsp-signature-auto-activate nil)
348348- (setq rustic-format-on-save t)
349349- (add-hook 'rustic-mode-hook 'nesv/rustic-mode-hook))
350350-351351-(defun nesv/rustic-mode-hook ()
352352- (when buffer-file-name
353353- (setq-local buffer-save-without-query t))
354354- (add-hook 'before-save-hook 'lsp-format-buffer nil t))
355355-356356-(use-package yaml-mode :ensure t)
357357-(use-package flycheck-yamllint :ensure t)
234234+;; Add directories containing my custom `.el' files to Emacs' load-path.
235235+(mapc
236236+ (lambda (string) (add-to-list 'load-path (locate-user-emacs-file string)))
237237+ '("nesv"))
358238359359-;; Zig -- https://ziglang.org
360360-(use-package zig-mode :ensure t)
239239+(require 'nesv-theme)
240240+(require 'nesv-fonts)
241241+(require 'nesv-which-key)
242242+(require 'nesv-tree-sitter)
243243+(require 'nesv-programming)
244244+(when nesv-emacs-load-nerd-icons
245245+ (require 'nesv-icons))
246246+(require 'nesv-slime)
247247+(require 'nesv-gnus)
361248362249;; ░█░█░█▀▀░█░█░█▄█░█▀█░█▀█░█▀▀
363250;; ░█▀▄░█▀▀░░█░░█░█░█▀█░█▀▀░▀▀█
···380267;; (which-key-add-keymap-based-replacements nesv-prefix-map
381268;; "b" `("Buffer" . ,nesv-buffer-prefix-map))
382269383383-;; ░█▀▀░█░░░▀█▀░█▄█░█▀▀
384384-;; ░▀▀█░█░░░░█░░█░█░█▀▀
385385-;; ░▀▀▀░▀▀▀░▀▀▀░▀░▀░▀▀▀
386386-(setq inferior-lisp-program "sbcl")
387387-388388-;; ░█▀▀░█▀█░█░█░█▀▀
389389-;; ░█░█░█░█░█░█░▀▀█
390390-;; ░▀▀▀░▀░▀░▀▀▀░▀▀▀
391391-(setq gnus-select-method '(nntp "news.newshosting.com"))
392392-393270(provide 'init)
394271;;; init.el ends here
395395-396396-(custom-set-variables
397397- ;; custom-set-variables was added by Custom.
398398- ;; If you edit it by hand, you could mess it up, so be careful.
399399- ;; Your init file should contain only one such instance.
400400- ;; If there is more than one, they won't work right.
401401- '(package-selected-packages
402402- '(ef-theme ef-themes mu4e flycheck-yamllint bazel indent-tools solaire-mode direnv neotree all-the-icons just-mode naysayer-theme zig-mode zig-mod doom-modeline yasnippet yaml-mode use-package tree-sitter-langs telephone-line sexy-monochrome-theme rustic protobuf-mode projectile powerline modus-operandi-theme magit lua-mode lsp-mode gruvbox-theme go-mode git-gutter-fringe flymake-pest flymake-lua flycheck erlang dracula-theme doom-themes dockerfile-mode cyberpunk-theme cyberpunk-2019-theme cue-mode cql-mode company-terraform cargo auto-complete apparmor-mode apache-mode ansible)))
403403-(custom-set-faces
404404- ;; custom-set-faces was added by Custom.
405405- ;; If you edit it by hand, you could mess it up, so be careful.
406406- ;; Your init file should contain only one such instance.
407407- ;; If there is more than one, they won't work right.
408408- )