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
|
(use-package emacs
:ensure nil
:custom
(user-mail-address "me@sakamoto.network")
(user-full-name "Sakamoto")
(mml-secure-openpgp-sign-with-sender t)
(message-sendmail-envelope-from 'header)
(auto-save-default nil) ;; Disable automatic saving of buffers.
(column-number-mode t) ;; Display the column number in the mode line.
(create-lockfiles nil) ;; Prevent the creation of lock files when editing.
(delete-by-moving-to-trash t) ;; Move deleted files to the trash instead of permanently deleting them.
(delete-selection-mode 1) ;; Enable replacing selected text with typed text.
(display-line-numbers-type 'relative) ;; Use relative line numbering in programming modes.
(global-auto-revert-non-file-buffers t) ;; Automatically refresh non-file buffers.
(history-length 100) ;; Set the length of the command history.
(indent-tabs-mode nil) ;; Disable the use of tabs for indentation (use spaces instead).
(inhibit-startup-message t) ;; Disable the startup message when Emacs launches.
(initial-scratch-message "") ;; Clear the initial message in the *scratch* buffer.
(ispell-program-name "hunspell")
(ispell-dictionary "en_US")
(shr-use-colors nil)
(blink-cursor-mode nil)
(make-backup-files nil) ;; Disable creation of backup files.
(pixel-scroll-precision-mode t) ;; Enable precise pixel scrolling.
(pixel-scroll-precision-use-momentum nil) ;; Disable momentum scrolling for pixel precision.
(fill-column 80) ;; Set column fill
(ring-bell-function 'ignore) ;; Disable the audible bell.
(split-width-threshold 300) ;; Prevent automatic window splitting if the window width exceeds 300 pixels.
(switch-to-buffer-obey-display-actions t) ;; Make buffer switching respect display actions.
(tab-always-indent 'complete) ;; Make the TAB key complete text instead of just indenting.
(tab-width 4) ;; Set the tab width to 4 spaces.
(treesit-font-lock-level 4) ;; Use advanced font locking for Treesit mode.
(truncate-lines t) ;; Enable line truncation to avoid wrapping long lines.
(global-visual-line-mode 1) ;; Soft wrap text
(global-visual-wrap-prefix-mode t)
(use-dialog-box nil) ;; Disable dialog boxes in favor of minibuffer prompts.
(use-short-answers t) ;; Use short answers in prompts for quicker responses (y instead of yes)
(warning-minimum-level :emergency) ;; Set the minimum level of warnings to display.
(help-window-select t)
(repeat-mode 1)
(scroll-conservatively 101)
(epg-pinentry-mode 'loopback)
(view-read-only t) ;; Enter view mode on read-only files
(imenu-auto-rescan t) ;; Automatically update imenu entries based on current buffer/file
(minibuffer-visible-completions t) ;; Use arrow keys to select completion candidates
:hook ;; Add hooks to enable specific features in certain modes.
(prog-mode . display-line-numbers-mode) ;; Enable line numbers in programming modes.
(text-mode . display-line-numbers-mode)
:config
;; By default emacs gives you access to a lot of *special* buffers, while navigating with [b and ]b,
;; this might be confusing for newcomers. This settings make sure ]b and [b will always load a
;; file buffer. To see all buffers use <leader> SPC, <leader> b l, or <leader> b i.
(defun skip-these-buffers (_window buffer _bury-or-kill)
"Function for `switch-to-prev-buffer-skip'."
(string-match "\\*[^*]+\\*" (buffer-name buffer)))
(setq switch-to-prev-buffer-skip 'skip-these-buffers)
(set-face-attribute 'default nil :family "Departure Mono" :height 120)
;; Save manual customizations to a separate file instead of cluttering `init.el'.
;; You can M-x customize, M-x customize-group, or M-x customize-themes, etc.
;; The saves you do manually using the Emacs interface would overwrite this file.
;; The following makes sure those customizations are in a separate file.
(setq custom-file (locate-user-emacs-file "custom-vars.el")) ;; Specify the custom file path.
(load custom-file 'noerror 'nomessage) ;; Load the custom file quietly, ignoring errors.
;; Makes Emacs vertical divisor the symbol │ instead of |.
(set-display-table-slot standard-display-table 'vertical-border (make-glyph-code ?│))
:init ;; Initialization settings that apply before the package is loaded.
(tool-bar-mode -1) ;; Disable the tool bar for a cleaner interface.
(menu-bar-mode -1) ;; Disable the menu bar for a more streamlined look.
(when scroll-bar-mode
(scroll-bar-mode -1)) ;; Disable the scroll bar if it is active.
(global-auto-revert-mode 1) ;; Enable global auto-revert mode to keep buffers up to date with their corresponding files.
(recentf-mode 1) ;; Enable tracking of recently opened files.
(setq history-delete-duplicates t)
(savehist-mode 1) ;; Enable saving of command history.
(save-place-mode 1) ;; Enable saving the place in files for easier return.
(winner-mode 1) ;; Enable winner mode to easily undo window configuration changes.
(xterm-mouse-mode 1) ;; Enable mouse support in terminal mode.
(file-name-shadow-mode 1) ;; Enable shadowing of filenames for clarity.
(auth-source-pass-enable) ;; Use password-store instead of authinfo
(midnight-mode 1) ;; Cleanup every 3 days
;; Set the default coding system for files to UTF-8.
(modify-coding-system-alist 'file "" 'utf-8))
(use-package windmove
:ensure nil
:init
(windmove-default-keybindings 'meta))
(use-package window
:ensure nil ;; This is built-in, no need to fetch it.
:custom
(display-buffer-alist
'(
;; ("\\*.*e?shell\\*"
;; (display-buffer-in-side-window)
;; (window-height . 0.25)
;; (side . bottom)
;; (slot . -1))
("\\*\\(Backtrace\\|Warnings\\|Compile-Log\\|[Hh]elp\\|Messages\\|Bookmark List\\|Ibuffer\\|Occur\\|eldoc.*\\)\\*"
(display-buffer-in-side-window)
(window-height . 0.25)
(side . bottom)
(slot . 0))
;; Example configuration for the LSP help buffer,
;; keeps it always on bottom using 25% of the available space:
("\\*\\(lsp-help\\)\\*"
(display-buffer-in-side-window)
(window-height . 0.25)
(side . bottom)
(slot . 0))
;; Configuration for displaying various diagnostic buffers on
;; bottom 25%:
("\\*\\(Flymake diagnostics\\|xref\\|ivy\\|Swiper\\|Completions\\)"
(display-buffer-in-side-window)
(window-height . 0.25)
(side . bottom)
(slot . 1))
)))
(use-package ibuffer
:ensure nil
:bind ([remap list-buffers] . ibuffer))
(use-package dired
:ensure nil ;; This is built-in, no need to fetch it.
:bind
(:map dired-mode-map ("." . dired-omit-mode))
:hook
(dired-mode . dired-omit-mode)
:init
(with-eval-after-load 'dired (require 'dired-x))
:custom
(dired-omit-files "^\\.[a-zA-Z0-9]+")
(dired-listing-switches "-lah --group-directories-first") ;; Display files in a human-readable format and group directories first.
(dired-guess-shell-alist-user
'(("\\.\\(mp[34]\\|m4a\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv --really-quiet" "xdg-open" "open") ;; Open audio and video files with `mpv'.
(".*" "open" "xdg-open")))
(dired-dwim-target t) ;; Enable "do what I mean" for target directories.
(dired-kill-when-opening-new-dired-buffer t) ;; Close the previous buffer when opening a new `dired' instance.
(dired-auto-revert-buffer t)
(dired-mouse-drag-files t)
:config
(when (eq system-type 'darwin)
(let ((gls (executable-find "gls"))) ;; Use GNU ls on macOS if available.
(when gls
(setq insert-directory-program gls)))))
(use-package isearch
:ensure nil ;; This is built-in, no need to fetch it.
:config
(setq isearch-lazy-count t) ;; Enable lazy counting to show current match information.
(setq lazy-count-prefix-format "(%s/%s) ") ;; Format for displaying current match count.
(setq lazy-count-suffix-format nil) ;; Disable suffix formatting for match count.
(setq search-whitespace-regexp ".*?") ;; Allow searching across whitespace.
:bind (("C-s" . isearch-forward) ;; Bind C-s to forward isearch.
("C-r" . isearch-backward))) ;; Bind C-r to backward isearch.
(use-package dictionary
:ensure nil
:bind (("C-c L" . dictionary-lookup-definition))
:config
(setq dictionary-server "dict.org"))
(use-package whitespace
:init
(dolist (hook '(text-mode-hook))
(add-hook hook #'whitespace-mode))
(add-hook 'before-save-hook #'whitespace-cleanup)
:config
(setq whitespace-line-column 80) ;; limit line length
(setq whitespace-style '(face tabs empty trailing)))
(use-package eldoc
:ensure nil ;; This is built-in, no need to fetch it.
:config
(setq eldoc-idle-delay 0) ;; Automatically fetch doc help
(setq eldoc-echo-area-use-multiline-p nil) ;; We use the "K" floating help instead
;; set to t if you want docs on the echo area
(setq eldoc-echo-area-display-truncation-message nil)
:init
(global-eldoc-mode))
(use-package completion-preview
:ensure nil
:hook (after-init . global-completion-preview-mode)
:bind
( :map completion-preview-active-mode-map
("M-n" . completion-preview-next-candidate)
("M-p" . completion-preview-prev-candidate)
("M-<return>" . completion-preview-insert)
("<tab>" . completion-preview-complete))
:custom
(completion-preview-minimum-symbol-length 2) ; Show the preview already after two symbol characters
(completion-preview-exact-match-only nil) ; If t, only show suggestion if there is only one candidate
(completion-preview-idle-delay 0.3) ; If non-nil, wait this many idle seconds before displaying preview
:config
(with-eval-after-load 'org
;; Add Org mode's custom 'self-insert-command' to completion-previews
(push 'org-self-insert-command completion-preview-commands)
)
;; Disable completion preview in Org tables (Emacs 31+)
(defun my/detect-org-table ()
"Return true if point in Org table."
(and (derived-mode-p 'org-mode) (org-at-table-p)))
(add-hook 'completion-preview-inhibit-functions
#'my/detect-org-table))
(use-package tramp
:ensure nil
:commands (sudo-find-file sudo-this-file)
:bind ("C-c f s" . sudo-find-file)
:config
(defun sudo-find-file (file)
"Open FILE as root."
(interactive "FOpen file as root: ")
(when (file-writable-p file)
(user-error "File is user writeable, aborting sudo"))
(find-file (if (file-remote-p file)
(concat "/" (file-remote-p file 'method) ":"
(file-remote-p file 'user) "@" (file-remote-p file 'host)
"|sudo:root@"
(file-remote-p file 'host) ":" (file-remote-p file 'localname))
(concat "/sudo:root@localhost:" file))))
(defun sudoedit ()
"Open the current file as root."
(interactive)
(sudo-find-file (file-truename buffer-file-name)))
(setq remote-file-name-inhibit-locks t
remote-file-name-inhibit-auto-save-visited t
tramp-copy-size-limit (* 1024 1024))
(connection-local-set-profile-variables
'remote-direct-async-process '((tramp-direct-async-process . t)))
(connection-local-set-profiles
'(:application tramp :protocol "scp") 'remote-direct-async-process)
(with-eval-after-load 'compile
(remove-hook 'compilation-mode-hook
#'tramp-compile-disable-ssh-controlmaster-options)))
(use-package project
:ensure nil
:config
(setq project-vc-extra-root-markers '(".project")))
(use-package
|