mirror of
https://github.com/sebaschi/dotfiles.git
synced 2026-06-30 18:40:36 +02:00
Add helix theme; lean up neovim; add emacs .minimal-emacs config; update .gitignore
This commit is contained in:
@@ -3,3 +3,4 @@ PRIVATE
|
||||
.bash*
|
||||
local_*
|
||||
local-*
|
||||
neovim/dot-config/nvim/lua/plugins/*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,492 @@
|
||||
;;; early-init.el --- Early Init -*- lexical-binding: t; -*-
|
||||
|
||||
;; Author: James Cherti <https://www.jamescherti.com/contact/>
|
||||
;; URL: https://github.com/jamescherti/minimal-emacs.d
|
||||
;; Package-Requires: ((emacs "29.1"))
|
||||
;; Keywords: maint
|
||||
;; Version: 1.4.2
|
||||
;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
;;; Commentary:
|
||||
;; The minimal-emacs.d project is a lightweight and optimized Emacs base
|
||||
;; (init.el and early-init.el) that gives you full control over your
|
||||
;; configuration. It provides better defaults, an optimized startup, and a clean
|
||||
;; foundation for building your own vanilla Emacs setup.
|
||||
;;
|
||||
;; Building the minimal-emacs.d init.el and early-init.el was the result of
|
||||
;; extensive research and testing to fine-tune the best parameters and
|
||||
;; optimizations for an Emacs configuration.
|
||||
;;
|
||||
;; Do not modify this file; instead, modify pre-early-init.el or
|
||||
;; post-early-init.el.
|
||||
|
||||
;;; Code:
|
||||
|
||||
;;; Internal variables
|
||||
|
||||
;; Backup of `gc-cons-threshold' and `gc-cons-percentage' before startup.
|
||||
(defvar minimal-emacs--backup-gc-cons-threshold gc-cons-threshold)
|
||||
(defvar minimal-emacs--backup-gc-cons-percentage gc-cons-percentage)
|
||||
|
||||
;; Temporarily raise the garbage collection threshold to its maximum value.
|
||||
;; It will be restored later to controlled values.
|
||||
(setq gc-cons-threshold most-positive-fixnum)
|
||||
(setq gc-cons-percentage 1.0)
|
||||
|
||||
;;; Variables
|
||||
|
||||
(defvar minimal-emacs-ui-features '()
|
||||
"List of user interface features to enable in minimal Emacs setup.
|
||||
This variable holds a list of Emacs UI features that can be enabled:
|
||||
- context-menu (Enables the context menu in graphical environments.)
|
||||
- tool-bar (Enables the tool bar in graphical environments.)
|
||||
- menu-bar (Enables the menu bar in graphical environments.)
|
||||
- dialogs (Enables both file dialogs and dialog boxes.)
|
||||
- tooltips (Enables tooltips.)")
|
||||
|
||||
(defvar minimal-emacs-frame-title-format "%b – Emacs"
|
||||
"Template for displaying the title bar of visible and iconified frame.")
|
||||
|
||||
(defvar minimal-emacs-debug (bound-and-true-p init-file-debug)
|
||||
"Non-nil to enable debug.")
|
||||
|
||||
(defvar minimal-emacs-optimize-startup-gc t
|
||||
"If non-nil, increase `gc-cons-threshold' during startup to reduce pauses.
|
||||
After Emacs finishes loading, `gc-cons-threshold' is restored to the value
|
||||
stored in `minimal-emacs-gc-cons-threshold'.")
|
||||
|
||||
(defvar minimal-emacs-gc-cons-threshold (* 32 1024 1024)
|
||||
"Value to which `gc-cons-threshold' is set after Emacs startup.
|
||||
Ignored if `minimal-emacs-optimize-startup-gc' is nil.")
|
||||
|
||||
(defvar minimal-emacs-gc-cons-percentage gc-cons-percentage
|
||||
"Value to which `gc-cons-percentage' is set after Emacs startup.
|
||||
Ignored if `minimal-emacs-optimize-startup-gc' is nil.")
|
||||
|
||||
(defvar minimal-emacs-gc-cons-threshold-restore-delay nil
|
||||
"Number of seconds to wait before restoring `gc-cons-threshold'.")
|
||||
|
||||
(defvar minimal-emacs-optimize-file-name-handler-alist t
|
||||
"Enable optimization of `file-name-handler-alist'.
|
||||
When non-nil, this variable activates optimizations to reduce file name handler
|
||||
lookups during Emacs startup.")
|
||||
|
||||
(defvar minimal-emacs-disable-mode-line-during-startup t
|
||||
"Disable the mode line during startup.
|
||||
This reduces visual clutter and slightly enhances startup performance. The
|
||||
tradeoff is that the mode line is hidden during the startup phase.")
|
||||
|
||||
(defvar minimal-emacs-package-initialize-and-refresh t
|
||||
"Whether to automatically initialize and refresh packages.
|
||||
When set to non-nil, Emacs will automatically call `package-initialize' and
|
||||
`package-refresh-contents' to set up and update the package system.")
|
||||
|
||||
(defvar minimal-emacs-inhibit-redisplay-during-startup nil
|
||||
"Suppress redisplay during startup to improve performance.
|
||||
This prevents visual updates while Emacs initializes. The tradeoff is that you
|
||||
won't see the progress or activities during the startup process.")
|
||||
|
||||
(defvar minimal-emacs-inhibit-message-during-startup nil
|
||||
"Suppress startup messages for a cleaner experience.
|
||||
This slightly enhances performance. The tradeoff is that you won't be informed
|
||||
of the progress or any relevant activities during startup.")
|
||||
|
||||
(defvar minimal-emacs-user-directory user-emacs-directory
|
||||
"Directory beneath minimal-emacs.d files are placed.
|
||||
Note that this should end with a directory separator.")
|
||||
|
||||
(defvar minimal-emacs-load-pre-early-init t
|
||||
"If non-nil, attempt to load `pre-early-init.el`.")
|
||||
|
||||
(defvar minimal-emacs-load-post-early-init t
|
||||
"If non-nil, attempt to load `post-early-init.el`.")
|
||||
|
||||
(defvar minimal-emacs-load-pre-init t
|
||||
"If non-nil, attempt to load `pre-init.el`.")
|
||||
|
||||
(defvar minimal-emacs-load-post-init t
|
||||
"If non-nil, attempt to load `post-init.el`.")
|
||||
|
||||
;;; Load pre-early-init.el
|
||||
|
||||
;; Prefer loading newer compiled files
|
||||
(setq load-prefer-newer t)
|
||||
(when minimal-emacs-debug
|
||||
(setq debug-on-error minimal-emacs-debug))
|
||||
|
||||
(defvar minimal-emacs--success nil)
|
||||
(defun minimal-emacs--check-success ()
|
||||
"Verify that the Emacs configuration has loaded successfully."
|
||||
(unless minimal-emacs--success
|
||||
(cond
|
||||
((or (file-exists-p (expand-file-name "~/.emacs.el"))
|
||||
(file-exists-p (expand-file-name "~/.emacs")))
|
||||
(error "Emacs ignored loading 'init.el'. Please ensure that files such as ~/.emacs or ~/.emacs.el do not exist, as they may be preventing Emacs from loading the 'init.el' file"))
|
||||
|
||||
(t
|
||||
(error "Configuration error. Debug by starting Emacs with: --debug-init")))))
|
||||
|
||||
(unless noninteractive
|
||||
(add-hook 'emacs-startup-hook #'minimal-emacs--check-success 102))
|
||||
|
||||
(defvar minimal-emacs-load-compiled-init-files nil
|
||||
"If non-nil, attempt to load byte-compiled .elc for init files.
|
||||
This will enable minimal-emacs to load byte-compiled or possibly native-compiled
|
||||
init files for the following initialization files: pre-init.el, post-init.el,
|
||||
pre-early-init.el, and post-early-init.el.")
|
||||
|
||||
(defun minimal-emacs--remove-el-file-suffix (filename)
|
||||
"Remove the Elisp file suffix from FILENAME and return it (.el, .el.gz...)."
|
||||
(let ((suffixes (mapcar (lambda (ext) (concat ".el" ext))
|
||||
load-file-rep-suffixes)))
|
||||
(catch 'done
|
||||
(dolist (suffix suffixes filename)
|
||||
(when (string-suffix-p suffix filename)
|
||||
(setq filename (substring filename 0 (- (length suffix))))
|
||||
(throw 'done t))))
|
||||
filename))
|
||||
|
||||
(defun minimal-emacs-load-user-init (filename)
|
||||
"Execute a file of Lisp code named FILENAME."
|
||||
(let ((init-file (expand-file-name filename
|
||||
minimal-emacs-user-directory)))
|
||||
(if (not minimal-emacs-load-compiled-init-files)
|
||||
(load init-file :no-error (not minimal-emacs-debug) :nosuffix)
|
||||
;; Remove the file suffix (.el, .el.gz, etc.) to let the `load' function
|
||||
;; select between .el and .elc files.
|
||||
(setq init-file (minimal-emacs--remove-el-file-suffix init-file))
|
||||
(load init-file :no-error (not minimal-emacs-debug)))))
|
||||
|
||||
(when minimal-emacs-load-pre-early-init
|
||||
(minimal-emacs-load-user-init "pre-early-init.el"))
|
||||
|
||||
(setq custom-theme-directory
|
||||
(expand-file-name "themes/" minimal-emacs-user-directory))
|
||||
|
||||
(setq custom-file (expand-file-name "custom.el" minimal-emacs-user-directory))
|
||||
|
||||
;;; Garbage collection
|
||||
;; Garbage collection significantly affects startup times. This setting delays
|
||||
;; garbage collection during startup but will be reset later.
|
||||
|
||||
(defun minimal-emacs--restore-gc-values ()
|
||||
"Restore garbage collection values to minimal-emacs.d values."
|
||||
(setq gc-cons-threshold minimal-emacs-gc-cons-threshold)
|
||||
(setq gc-cons-percentage minimal-emacs-gc-cons-percentage))
|
||||
|
||||
(defun minimal-emacs--restore-gc ()
|
||||
"Restore garbage collection settings."
|
||||
(if (and (bound-and-true-p minimal-emacs-gc-cons-threshold-restore-delay)
|
||||
;; In noninteractive mode, the event loop does not run
|
||||
(not noninteractive))
|
||||
;; Defer garbage collection during initialization to avoid 2 collections.
|
||||
(run-with-timer minimal-emacs-gc-cons-threshold-restore-delay nil
|
||||
#'minimal-emacs--restore-gc-values)
|
||||
(minimal-emacs--restore-gc-values)))
|
||||
|
||||
(if minimal-emacs-optimize-startup-gc
|
||||
;; `gc-cons-threshold' is managed by minimal-emacs.d
|
||||
(add-hook 'emacs-startup-hook #'minimal-emacs--restore-gc 105)
|
||||
;; gc-cons-threshold is not managed by minimal-emacs.d.
|
||||
(when (= gc-cons-threshold most-positive-fixnum)
|
||||
(setq gc-cons-threshold minimal-emacs--backup-gc-cons-threshold)
|
||||
(setq gc-cons-percentage minimal-emacs--backup-gc-cons-percentage)))
|
||||
|
||||
;;; Native compilation and Byte compilation
|
||||
|
||||
(unless (and (featurep 'native-compile)
|
||||
(fboundp 'native-comp-available-p)
|
||||
(native-comp-available-p))
|
||||
;; Deactivate the `native-compile' feature if it is not available
|
||||
(setq features (delq 'native-compile features)))
|
||||
|
||||
(setq native-comp-warning-on-missing-source minimal-emacs-debug
|
||||
native-comp-async-report-warnings-errors (or minimal-emacs-debug 'silent))
|
||||
|
||||
(setq jka-compr-verbose minimal-emacs-debug)
|
||||
(setq byte-compile-warnings minimal-emacs-debug
|
||||
byte-compile-verbose minimal-emacs-debug)
|
||||
|
||||
;;; Miscellaneous
|
||||
|
||||
(set-language-environment "UTF-8")
|
||||
|
||||
;; Increase how much is read from processes in a single chunk
|
||||
(setq read-process-output-max (* 2 1024 1024)) ; 1024kb
|
||||
|
||||
(setq process-adaptive-read-buffering nil)
|
||||
|
||||
;; Don't ping things that look like domain names.
|
||||
(setq ffap-machine-p-known 'reject)
|
||||
|
||||
(setq warning-minimum-level (if minimal-emacs-debug :warning :error))
|
||||
(setq warning-suppress-types '((lexical-binding)))
|
||||
|
||||
(when minimal-emacs-debug
|
||||
(setq message-log-max 16384))
|
||||
|
||||
;; In PGTK, this timeout introduces latency. Reducing it from the default 0.1
|
||||
;; improves responsiveness of childframes and related packages.
|
||||
(when (boundp 'pgtk-wait-for-event-timeout)
|
||||
(setq pgtk-wait-for-event-timeout 0.001))
|
||||
|
||||
;; Disable warnings from the legacy advice API. They aren't useful.
|
||||
(setq ad-redefinition-action 'accept)
|
||||
|
||||
;;; Performance: Miscellaneous options
|
||||
|
||||
;; Font compacting can be very resource-intensive, especially when rendering
|
||||
;; icon fonts on Windows. This will increase memory usage.
|
||||
(setq inhibit-compacting-font-caches t)
|
||||
|
||||
(when (not noninteractive)
|
||||
;; Resizing the Emacs frame can be costly when changing the font. Disable this
|
||||
;; to improve startup times with fonts larger than the system default.
|
||||
(setq frame-resize-pixelwise t)
|
||||
|
||||
;; Without this, Emacs will try to resize itself to a specific column size
|
||||
(setq frame-inhibit-implied-resize t)
|
||||
|
||||
;; A second, case-insensitive pass over `auto-mode-alist' is time wasted.
|
||||
;; No second pass of case-insensitive search over auto-mode-alist.
|
||||
(setq auto-mode-case-fold nil)
|
||||
|
||||
;; Reduce *Message* noise at startup. An empty scratch buffer (or the
|
||||
;; dashboard) is more than enough, and faster to display.
|
||||
(setq inhibit-startup-screen t
|
||||
inhibit-startup-echo-area-message user-login-name)
|
||||
(setq initial-buffer-choice nil
|
||||
inhibit-startup-buffer-menu t
|
||||
inhibit-x-resources t)
|
||||
|
||||
;; Disable bidirectional text scanning for a modest performance boost.
|
||||
(setq-default bidi-display-reordering 'left-to-right
|
||||
bidi-paragraph-direction 'left-to-right)
|
||||
|
||||
;; Give up some bidirectional functionality for slightly faster re-display.
|
||||
(setq bidi-inhibit-bpa t)
|
||||
|
||||
;; Remove "For information about GNU Emacs..." message at startup
|
||||
(advice-add 'display-startup-echo-area-message :override #'ignore)
|
||||
|
||||
;; Suppress the vanilla startup screen completely. We've disabled it with
|
||||
;; `inhibit-startup-screen', but it would still initialize anyway.
|
||||
(advice-add 'display-startup-screen :override #'ignore)
|
||||
|
||||
(unless minimal-emacs-debug
|
||||
;; Unset command line options irrelevant to the current OS. These options
|
||||
;; are still processed by `command-line-1` but have no effect.
|
||||
(unless (eq system-type 'darwin)
|
||||
(setq command-line-ns-option-alist nil))
|
||||
(unless (memq initial-window-system '(x pgtk))
|
||||
(setq command-line-x-option-alist nil))))
|
||||
|
||||
;;; Performance: File-name-handler-alist
|
||||
|
||||
(defvar minimal-emacs--old-file-name-handler-alist (default-toplevel-value
|
||||
'file-name-handler-alist))
|
||||
|
||||
(defun minimal-emacs--respect-file-handlers (fn args-left)
|
||||
"Respect file handlers.
|
||||
FN is the function and ARGS-LEFT is the same argument as `command-line-1'.
|
||||
Emacs processes command-line files very early in startup. These files may
|
||||
include special paths like TRAMP paths, so restore `file-name-handler-alist' for
|
||||
this stage of initialization."
|
||||
(let ((file-name-handler-alist (if args-left
|
||||
minimal-emacs--old-file-name-handler-alist
|
||||
file-name-handler-alist)))
|
||||
(funcall fn args-left)))
|
||||
|
||||
(defun minimal-emacs--restore-file-name-handler-alist ()
|
||||
"Restore `file-name-handler-alist'."
|
||||
(set-default-toplevel-value
|
||||
'file-name-handler-alist
|
||||
;; Merge instead of overwrite to preserve any changes made since startup.
|
||||
(delete-dups (append file-name-handler-alist
|
||||
minimal-emacs--old-file-name-handler-alist))))
|
||||
|
||||
(when (and minimal-emacs-optimize-file-name-handler-alist
|
||||
(not minimal-emacs-debug))
|
||||
;; Determine the state of bundled libraries using calc-loaddefs.el. If
|
||||
;; compressed, retain the gzip handler in `file-name-handler-alist`. If
|
||||
;; compiled or neither, omit the gzip handler during startup for improved
|
||||
;; startup and package load time.
|
||||
(set-default-toplevel-value
|
||||
'file-name-handler-alist
|
||||
(if (locate-file-internal "calc-loaddefs.el" load-path)
|
||||
nil
|
||||
(list (rassq 'jka-compr-handler
|
||||
minimal-emacs--old-file-name-handler-alist))))
|
||||
|
||||
;; Ensure the new value persists through any current let-binding.
|
||||
(put 'file-name-handler-alist 'initial-value
|
||||
minimal-emacs--old-file-name-handler-alist)
|
||||
|
||||
;; Emacs processes command-line files very early in startup. These files may
|
||||
;; include special paths TRAMP. Restore `file-name-handler-alist'.
|
||||
(advice-add 'command-line-1 :around #'minimal-emacs--respect-file-handlers)
|
||||
|
||||
(add-hook 'emacs-startup-hook #'minimal-emacs--restore-file-name-handler-alist
|
||||
101))
|
||||
|
||||
;;; Performance: Inhibit redisplay
|
||||
|
||||
(defun minimal-emacs--reset-inhibit-redisplay ()
|
||||
"Reset inhibit redisplay."
|
||||
(setq-default inhibit-redisplay nil)
|
||||
(remove-hook 'post-command-hook #'minimal-emacs--reset-inhibit-redisplay))
|
||||
|
||||
(when (and minimal-emacs-inhibit-redisplay-during-startup
|
||||
(not noninteractive)
|
||||
(not minimal-emacs-debug))
|
||||
;; Suppress redisplay and redraw during startup to avoid delays and
|
||||
;; prevent flashing an unstyled Emacs frame.
|
||||
(setq-default inhibit-redisplay t)
|
||||
(add-hook 'post-command-hook #'minimal-emacs--reset-inhibit-redisplay -100))
|
||||
|
||||
;;; Performance: Inhibit message
|
||||
|
||||
(defun minimal-emacs--reset-inhibit-message ()
|
||||
"Reset inhibit message."
|
||||
(setq-default inhibit-message nil)
|
||||
(remove-hook 'post-command-hook #'minimal-emacs--reset-inhibit-message))
|
||||
|
||||
(when (and minimal-emacs-inhibit-message-during-startup
|
||||
(not noninteractive)
|
||||
(not minimal-emacs-debug))
|
||||
(setq-default inhibit-message t)
|
||||
(add-hook 'post-command-hook #'minimal-emacs--reset-inhibit-message -100))
|
||||
|
||||
;;; Performance: Disable mode-line during startup
|
||||
|
||||
(defvar-local minimal-emacs--hidden-mode-line nil
|
||||
"Store the buffer-local value of `mode-line-format' during startup.")
|
||||
|
||||
(when (and minimal-emacs-disable-mode-line-during-startup
|
||||
(not noninteractive)
|
||||
(not minimal-emacs-debug))
|
||||
(put 'mode-line-format
|
||||
'initial-value (default-toplevel-value 'mode-line-format))
|
||||
(setq-default mode-line-format nil)
|
||||
(dolist (buf (buffer-list))
|
||||
(with-current-buffer buf
|
||||
(when (local-variable-p 'mode-line-format)
|
||||
(setq minimal-emacs--hidden-mode-line mode-line-format)
|
||||
(setq mode-line-format nil)))))
|
||||
|
||||
;;; Restore values
|
||||
|
||||
(defun minimal-emacs--startup-load-user-init-file (fn &rest args)
|
||||
"Advice to reset `mode-line-format'. FN and ARGS are the function and args."
|
||||
(unwind-protect
|
||||
;; Start up as normal
|
||||
(apply fn args)
|
||||
;; If we don't undo inhibit-{message, redisplay} and there's an error, we'll
|
||||
;; see nothing but a blank Emacs frame.
|
||||
(when minimal-emacs-inhibit-message-during-startup
|
||||
(setq-default inhibit-message nil))
|
||||
(when minimal-emacs-inhibit-redisplay-during-startup
|
||||
(setq-default inhibit-redisplay nil))
|
||||
;; Restore the mode-line
|
||||
(when minimal-emacs-disable-mode-line-during-startup
|
||||
(unless (default-toplevel-value 'mode-line-format)
|
||||
(setq-default mode-line-format (get 'mode-line-format
|
||||
'initial-value)))
|
||||
(dolist (buf (buffer-list))
|
||||
(with-current-buffer buf
|
||||
(when (local-variable-p 'minimal-emacs--hidden-mode-line)
|
||||
(setq mode-line-format minimal-emacs--hidden-mode-line)
|
||||
(kill-local-variable 'minimal-emacs--hidden-mode-line)))))))
|
||||
|
||||
(advice-add 'startup--load-user-init-file :around
|
||||
#'minimal-emacs--startup-load-user-init-file)
|
||||
|
||||
;;; UI elements
|
||||
|
||||
(setq frame-title-format minimal-emacs-frame-title-format
|
||||
icon-title-format minimal-emacs-frame-title-format)
|
||||
|
||||
;; Disable startup screens and messages
|
||||
(setq inhibit-splash-screen t)
|
||||
|
||||
;; I intentionally avoid calling `menu-bar-mode', `tool-bar-mode', and
|
||||
;; `scroll-bar-mode' because manipulating frame parameters can trigger or queue
|
||||
;; a superfluous and potentially expensive frame redraw at startup, depending
|
||||
;; on the window system. The variables must also be set to `nil' so users don't
|
||||
;; have to call the functions twice to re-enable them.
|
||||
(unless (memq 'menu-bar minimal-emacs-ui-features)
|
||||
(push '(menu-bar-lines . 0) default-frame-alist)
|
||||
(unless (memq window-system '(mac ns))
|
||||
(setq menu-bar-mode nil)))
|
||||
|
||||
(defun minimal-emacs--setup-toolbar (&rest _)
|
||||
"Setup the toolbar."
|
||||
(when (fboundp 'tool-bar-setup)
|
||||
(advice-remove 'tool-bar-setup #'ignore)
|
||||
(when (bound-and-true-p tool-bar-mode)
|
||||
(funcall 'tool-bar-setup))))
|
||||
|
||||
(unless noninteractive
|
||||
(when (fboundp 'tool-bar-setup)
|
||||
;; Temporarily override the tool-bar-setup function to prevent it from
|
||||
;; running during the initial stages of startup
|
||||
(advice-add 'tool-bar-setup :override #'ignore)
|
||||
|
||||
(advice-add 'startup--load-user-init-file :after
|
||||
#'minimal-emacs--setup-toolbar)))
|
||||
|
||||
(unless (memq 'tool-bar minimal-emacs-ui-features)
|
||||
(push '(tool-bar-lines . 0) default-frame-alist)
|
||||
(setq tool-bar-mode nil))
|
||||
|
||||
(setq default-frame-scroll-bars 'right)
|
||||
(push '(vertical-scroll-bars) default-frame-alist)
|
||||
(push '(horizontal-scroll-bars) default-frame-alist)
|
||||
(setq scroll-bar-mode nil)
|
||||
|
||||
(unless (memq 'tooltips minimal-emacs-ui-features)
|
||||
(when (bound-and-true-p tooltip-mode)
|
||||
(tooltip-mode -1)))
|
||||
|
||||
;; Disable GUIs because they are inconsistent across systems, desktop
|
||||
;; environments, and themes, and they don't match the look of Emacs.
|
||||
(unless (memq 'dialogs minimal-emacs-ui-features)
|
||||
(setq use-file-dialog nil)
|
||||
(setq use-dialog-box nil))
|
||||
|
||||
;;; Security
|
||||
(setq gnutls-verify-error t) ; Prompts user if there are certificate issues
|
||||
(setq tls-checktrust t) ; Ensure SSL/TLS connections undergo trust verification
|
||||
(setq gnutls-min-prime-bits 3072) ; Stronger GnuTLS encryption
|
||||
|
||||
;; This results in a more compact output that emphasizes performance
|
||||
(setq use-package-expand-minimally t)
|
||||
|
||||
(setq use-package-minimum-reported-time (if minimal-emacs-debug 0 0.1))
|
||||
(setq use-package-verbose minimal-emacs-debug)
|
||||
(setq use-package-always-ensure (not noninteractive))
|
||||
(setq use-package-enable-imenu-support t)
|
||||
|
||||
;; package.el
|
||||
(setq package-enable-at-startup nil) ; Let the init.el file handle this
|
||||
(setq package-quickstart-file
|
||||
(expand-file-name "package-quickstart.el" user-emacs-directory))
|
||||
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
|
||||
("gnu" . "https://elpa.gnu.org/packages/")
|
||||
("nongnu" . "https://elpa.nongnu.org/nongnu/")
|
||||
("melpa-stable" . "https://stable.melpa.org/packages/")))
|
||||
(setq package-archive-priorities '(("gnu" . 99)
|
||||
("nongnu" . 80)
|
||||
("melpa" . 70)
|
||||
("melpa-stable" . 50)))
|
||||
|
||||
;;; Load post-early-init.el
|
||||
|
||||
(when minimal-emacs-load-post-early-init
|
||||
(minimal-emacs-load-user-init "post-early-init.el"))
|
||||
|
||||
;; Local variables:
|
||||
;; byte-compile-warnings: (not obsolete free-vars)
|
||||
;; End:
|
||||
|
||||
;;; early-init.el ends here
|
||||
@@ -0,0 +1,579 @@
|
||||
;;; init.el --- Init -*- lexical-binding: t; -*-
|
||||
|
||||
;; Author: James Cherti <https://www.jamescherti.com/contact/>
|
||||
;; URL: https://github.com/jamescherti/minimal-emacs.d
|
||||
;; Package-Requires: ((emacs "29.1"))
|
||||
;; Keywords: maint
|
||||
;; Version: 1.4.2
|
||||
;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
;;; Commentary:
|
||||
;; The minimal-emacs.d project is a lightweight and optimized Emacs base
|
||||
;; (init.el and early-init.el) that gives you full control over your
|
||||
;; configuration. It provides better defaults, an optimized startup, and a clean
|
||||
;; foundation for building your own vanilla Emacs setup.
|
||||
;;
|
||||
;; Building the minimal-emacs.d init.el and early-init.el was the result of
|
||||
;; extensive research and testing to fine-tune the best parameters and
|
||||
;; optimizations for an Emacs configuration.
|
||||
;;
|
||||
;; Do not modify this file; instead, modify pre-init.el or post-init.el.
|
||||
|
||||
;;; Code:
|
||||
|
||||
;;; Load pre-init.el
|
||||
|
||||
(if (fboundp 'minimal-emacs-load-user-init)
|
||||
(when minimal-emacs-load-pre-init
|
||||
(minimal-emacs-load-user-init "pre-init.el"))
|
||||
(error "The early-init.el file failed to load"))
|
||||
|
||||
;;; Before package
|
||||
|
||||
;; The initial buffer is created during startup even in non-interactive
|
||||
;; sessions, and its major mode is fully initialized. Modes like `text-mode',
|
||||
;; `org-mode', or even the default `lisp-interaction-mode' load extra packages
|
||||
;; and run hooks, which can slow down startup.
|
||||
;;
|
||||
;; Using `fundamental-mode' for the initial buffer to avoid unnecessary
|
||||
;; startup overhead.
|
||||
(setq initial-major-mode 'fundamental-mode
|
||||
initial-scratch-message nil)
|
||||
|
||||
;; Set-language-environment sets default-input-method, which is unwanted.
|
||||
(setq default-input-method nil)
|
||||
|
||||
;; Ask the user whether to terminate asynchronous compilations on exit.
|
||||
;; This prevents native compilation from leaving temporary files in /tmp.
|
||||
(setq native-comp-async-query-on-exit t)
|
||||
|
||||
;; Allow for shorter responses: "y" for yes and "n" for no.
|
||||
(setq read-answer-short t)
|
||||
(if (boundp 'use-short-answers)
|
||||
(setq use-short-answers t)
|
||||
(advice-add 'yes-or-no-p :override #'y-or-n-p))
|
||||
|
||||
;;; Undo/redo
|
||||
|
||||
(setq undo-limit (* 13 160000)
|
||||
undo-strong-limit (* 13 240000)
|
||||
undo-outer-limit (* 13 24000000))
|
||||
|
||||
;;; package.el
|
||||
|
||||
(when (and (bound-and-true-p minimal-emacs-package-initialize-and-refresh)
|
||||
(not (bound-and-true-p byte-compile-current-file)))
|
||||
;; Initialize and refresh package contents again if needed
|
||||
(package-initialize)
|
||||
(unless package-archive-contents
|
||||
(package-refresh-contents))
|
||||
(when (and (version< emacs-version "29.1")
|
||||
(not (package-installed-p 'use-package)))
|
||||
(package-install 'use-package))
|
||||
(require 'use-package))
|
||||
|
||||
;;; Minibuffer
|
||||
|
||||
(setq enable-recursive-minibuffers t) ; Allow nested minibuffers
|
||||
|
||||
;; Keep the cursor out of the read-only portions of the.minibuffer
|
||||
(setq minibuffer-prompt-properties
|
||||
'(read-only t intangible t cursor-intangible t face minibuffer-prompt))
|
||||
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
|
||||
|
||||
;;; Display and user interface
|
||||
|
||||
;; By default, Emacs "updates" its ui more often than it needs to
|
||||
(setq which-func-update-delay 1.0)
|
||||
(setq idle-update-delay which-func-update-delay) ;; Obsolete in >= 30.1
|
||||
|
||||
(defalias #'view-hello-file #'ignore) ; Never show the hello file
|
||||
|
||||
;; No beeping or blinking
|
||||
(setq visible-bell nil)
|
||||
(setq ring-bell-function #'ignore)
|
||||
|
||||
;; Position underlines at the descent line instead of the baseline.
|
||||
(setq x-underline-at-descent-line t)
|
||||
|
||||
(setq truncate-string-ellipsis "…")
|
||||
|
||||
(setq display-time-default-load-average nil) ; Omit load average
|
||||
|
||||
;;; Show-paren
|
||||
|
||||
(setq show-paren-delay 0.1
|
||||
show-paren-highlight-openparen t
|
||||
show-paren-when-point-inside-paren t
|
||||
show-paren-when-point-in-periphery t)
|
||||
|
||||
;;; Buffer management
|
||||
|
||||
(setq custom-buffer-done-kill t)
|
||||
|
||||
;; Disable auto-adding a new line at the bottom when scrolling.
|
||||
(setq next-line-add-newlines nil)
|
||||
|
||||
;; This setting forces Emacs to save bookmarks immediately after each change.
|
||||
;; Benefit: you never lose bookmarks if Emacs crashes.
|
||||
(setq bookmark-save-flag 1)
|
||||
|
||||
(setq uniquify-buffer-name-style 'forward)
|
||||
|
||||
(setq remote-file-name-inhibit-cache 50)
|
||||
|
||||
;; Disable fontification during user input to reduce lag in large buffers.
|
||||
;; Also helps marginally with scrolling performance.
|
||||
(setq redisplay-skip-fontification-on-input t)
|
||||
|
||||
;;; Misc
|
||||
|
||||
(setq whitespace-line-column nil) ; Use the value of `fill-column'.
|
||||
|
||||
;; Disable ellipsis when printing s-expressions in the message buffer
|
||||
(setq eval-expression-print-length nil
|
||||
eval-expression-print-level nil)
|
||||
|
||||
;; This directs gpg-agent to use the minibuffer for passphrase entry
|
||||
(setq epg-pinentry-mode 'loopback)
|
||||
|
||||
;; By default, Emacs stores sensitive authinfo credentials as unencrypted text
|
||||
;; in your home directory. Use GPG to encrypt the authinfo file for enhanced
|
||||
;; security.
|
||||
(setq auth-sources (list "~/.authinfo.gpg"))
|
||||
|
||||
;;; `display-line-numbers-mode'
|
||||
|
||||
(setq-default display-line-numbers-width 3)
|
||||
(setq-default display-line-numbers-widen t)
|
||||
|
||||
;;; imenu
|
||||
|
||||
;; Automatically rescan the buffer for Imenu entries when `imenu' is invoked
|
||||
;; This ensures the index reflects recent edits.
|
||||
(setq imenu-auto-rescan t)
|
||||
|
||||
;; Prevent truncation of long function names in `imenu' listings
|
||||
(setq imenu-max-item-length 160)
|
||||
|
||||
;;; Tramp
|
||||
|
||||
(setq tramp-verbose 1)
|
||||
|
||||
;;; Files
|
||||
|
||||
;; Delete by moving to trash in interactive mode
|
||||
(setq delete-by-moving-to-trash (not noninteractive))
|
||||
(setq remote-file-name-inhibit-delete-by-moving-to-trash t)
|
||||
|
||||
;; Ignoring this is acceptable since it will redirect to the buffer regardless.
|
||||
(setq find-file-suppress-same-file-warnings t)
|
||||
|
||||
;; Automatically resolve symlinks to their true paths. This sets the correct
|
||||
;; working directory so C-x C-f opens in the right folder and version control
|
||||
;; tools recognize the Git repository.
|
||||
(setq find-file-visit-truename t
|
||||
;; Automatically follow a symlink to its source if that source is managed
|
||||
;; by a version control system, rather than asking for permission.
|
||||
vc-follow-symlinks t)
|
||||
|
||||
;; Prefer vertical splits over horizontal ones
|
||||
(setq split-width-threshold 170
|
||||
split-height-threshold nil)
|
||||
|
||||
;;; comint (general command interpreter in a window)
|
||||
|
||||
(setq ansi-color-for-comint-mode t
|
||||
comint-prompt-read-only t
|
||||
comint-buffer-maximum-size 4096)
|
||||
|
||||
;;; Compilation
|
||||
|
||||
(setq compilation-ask-about-save nil
|
||||
compilation-always-kill t
|
||||
compilation-scroll-output 'first-error)
|
||||
|
||||
;; Skip confirmation prompts when creating a new file or buffer
|
||||
(setq confirm-nonexistent-file-or-buffer nil)
|
||||
|
||||
;;; Backup files
|
||||
|
||||
;; Disable the creation of lockfiles (e.g., .#filename).
|
||||
;; Modern workflows rely on `global-auto-revert-mode' to handle external file
|
||||
;; changes gracefully, making the restrictive nature of lockfiles unnecessary.
|
||||
(setq create-lockfiles nil)
|
||||
|
||||
;; Disable backup files (e.g., filename~). Note that `auto-save-default'
|
||||
;; remains enabled by default. Even with `make-backup-files' backups disabled,
|
||||
;; Emacs will still generate temporary recovery files (e.g., #filename#) for
|
||||
;; unsaved buffers. This protects your active work from sudden crashes while
|
||||
;; ensuring the file system is cleaned up immediately upon a successful save.
|
||||
(setq make-backup-files nil)
|
||||
|
||||
(setq backup-directory-alist
|
||||
`(("." . ,(expand-file-name "backup" user-emacs-directory))))
|
||||
(setq tramp-backup-directory-alist backup-directory-alist)
|
||||
(setq backup-by-copying-when-linked t)
|
||||
(setq backup-by-copying t) ; Backup by copying rather renaming
|
||||
(setq delete-old-versions t) ; Delete excess backup versions silently
|
||||
(setq version-control t) ; Use version numbers for backup files
|
||||
(setq kept-new-versions 5)
|
||||
(setq kept-old-versions 5)
|
||||
|
||||
;;; VC
|
||||
|
||||
(setq vc-git-print-log-follow t)
|
||||
(setq vc-git-diff-switches '("--histogram")) ; Faster algorithm for diffing.
|
||||
|
||||
;;; Auto save
|
||||
|
||||
;; Enable auto-save to safeguard against crashes or data loss. The
|
||||
;; `recover-file' or `recover-session' functions can be used to restore
|
||||
;; auto-saved data.
|
||||
(setq auto-save-no-message t)
|
||||
|
||||
(when noninteractive
|
||||
;; The command line interface
|
||||
(setq enable-dir-local-variables nil)
|
||||
(setq case-fold-search nil))
|
||||
|
||||
;; Do not auto-disable auto-save after deleting large chunks of
|
||||
;; text.
|
||||
(setq auto-save-include-big-deletions t)
|
||||
|
||||
(setq auto-save-list-file-prefix
|
||||
(expand-file-name "autosave/" user-emacs-directory))
|
||||
(setq tramp-auto-save-directory
|
||||
(expand-file-name "tramp-autosave/" user-emacs-directory))
|
||||
|
||||
(setq auto-save-file-name-transforms
|
||||
`(("\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'"
|
||||
,(file-name-concat auto-save-list-file-prefix "tramp-\\2-") sha1)
|
||||
|
||||
("\\`/\\([^/]+/\\)*\\([^/]+\\)\\'"
|
||||
,(file-name-concat auto-save-list-file-prefix "\\2-") sha1)))
|
||||
|
||||
;; Ensure the directory for auto-save session logs exists with restricted
|
||||
;; permissions.
|
||||
(when auto-save-default
|
||||
(let ((auto-save-dir (file-name-directory auto-save-list-file-prefix)))
|
||||
(unless (file-exists-p auto-save-dir)
|
||||
(with-file-modes #o700
|
||||
(make-directory auto-save-dir t)))))
|
||||
|
||||
;; Auto save options
|
||||
(setq kill-buffer-delete-auto-save-files t)
|
||||
|
||||
;; Remove duplicates from the kill ring to reduce clutter
|
||||
(setq kill-do-not-save-duplicates t)
|
||||
|
||||
;;; Auto revert
|
||||
;; Auto-revert in Emacs is a feature that automatically updates the contents of
|
||||
;; a buffer to reflect changes made to the underlying file.
|
||||
|
||||
;; Revert other buffers (e.g, Dired)
|
||||
(setq global-auto-revert-non-file-buffers t)
|
||||
(setq global-auto-revert-ignore-modes '(Buffer-menu-mode)) ; Resolve issue #29
|
||||
|
||||
;;; recentf
|
||||
|
||||
;; `recentf' is an that maintains a list of recently accessed files.
|
||||
(setq recentf-max-saved-items 300) ; default is 20
|
||||
(setq recentf-max-menu-items 15)
|
||||
(setq recentf-auto-cleanup 'mode)
|
||||
|
||||
;;; saveplace
|
||||
|
||||
;; Enables Emacs to remember the last location within a file upon reopening.
|
||||
(setq save-place-file (expand-file-name "saveplace" user-emacs-directory))
|
||||
(setq save-place-limit 600)
|
||||
|
||||
;;; savehist
|
||||
|
||||
;; `savehist-mode' is an Emacs feature that preserves the minibuffer history
|
||||
;; between sessions.
|
||||
(setq history-length 300)
|
||||
(setq savehist-additional-variables
|
||||
'(register-alist ; macros
|
||||
mark-ring global-mark-ring ; marks
|
||||
search-ring regexp-search-ring)) ; searches
|
||||
|
||||
;;; Frames and windows
|
||||
|
||||
(setq resize-mini-windows 'grow-only)
|
||||
|
||||
;; The native border "uses" a pixel of the fringe on the rightmost
|
||||
;; splits, whereas `window-divider-mode' does not.
|
||||
(setq window-divider-default-bottom-width 1
|
||||
window-divider-default-places t
|
||||
window-divider-default-right-width 1)
|
||||
|
||||
;;; Scrolling
|
||||
|
||||
;; Enables faster scrolling. This may result in brief periods of inaccurate
|
||||
;; syntax highlighting, which should quickly self-correct.
|
||||
(setq fast-but-imprecise-scrolling t)
|
||||
|
||||
;; Move point to top/bottom of buffer before signaling a scrolling error.
|
||||
(setq scroll-error-top-bottom t)
|
||||
|
||||
;; Keep screen position if scroll command moved it vertically out of the window.
|
||||
(setq scroll-preserve-screen-position t)
|
||||
|
||||
;; Emacs recenters the window when the cursor moves past `scroll-conservatively'
|
||||
;; lines beyond the window edge. A value over 101 disables recentering; the
|
||||
;; default (0) is too eager. Here it is set to 20 for a balanced behavior.
|
||||
(setq scroll-conservatively 20)
|
||||
|
||||
;; 1. Preventing automatic adjustments to `window-vscroll' for long lines.
|
||||
;; 2. Resolving the issue of random half-screen jumps during scrolling.
|
||||
(setq auto-window-vscroll nil)
|
||||
|
||||
;; Horizontal scrolling
|
||||
(setq hscroll-margin 2
|
||||
hscroll-step 1)
|
||||
|
||||
;; Emacs 29
|
||||
(when (memq 'context-menu minimal-emacs-ui-features)
|
||||
(when (and (display-graphic-p) (fboundp 'context-menu-mode))
|
||||
(add-hook 'after-init-hook #'context-menu-mode)))
|
||||
|
||||
;;; Cursor
|
||||
|
||||
;; The blinking cursor is distracting and interferes with cursor settings in
|
||||
;; some minor modes that try to change it buffer-locally (e.g., Treemacs).
|
||||
(when (bound-and-true-p blink-cursor-mode)
|
||||
(blink-cursor-mode -1))
|
||||
|
||||
;; Don't blink the paren matching the one at point, it's too distracting.
|
||||
(setq blink-matching-paren nil)
|
||||
|
||||
;; Reduce rendering/line scan work by not rendering cursors or regions in
|
||||
;; non-focused windows.
|
||||
(setq highlight-nonselected-windows nil)
|
||||
|
||||
;;; Text editing, indent, font, and formatting
|
||||
|
||||
;; Avoid automatic frame resizing when adjusting settings.
|
||||
(setq global-text-scale-adjust-resizes-frames nil)
|
||||
|
||||
;; A longer delay can be annoying as it causes a noticeable pause after each
|
||||
;; deletion, disrupting the flow of editing.
|
||||
(setq delete-pair-blink-delay 0.03)
|
||||
|
||||
;; Continue wrapped lines at whitespace rather than breaking in the
|
||||
;; middle of a word.
|
||||
(setq-default word-wrap t)
|
||||
|
||||
;; Disable wrapping by default due to its performance cost.
|
||||
(setq-default truncate-lines t)
|
||||
|
||||
;; If enabled and `truncate-lines' is disabled, soft wrapping will not occur
|
||||
;; when the window is narrower than `truncate-partial-width-windows' characters.
|
||||
(setq truncate-partial-width-windows nil)
|
||||
|
||||
;; Configure automatic indentation to be triggered exclusively by newline and
|
||||
;; DEL (backspace) characters.
|
||||
(setq-default electric-indent-chars '(?\n ?\^?))
|
||||
|
||||
;; Prefer spaces over tabs. Spaces offer a more consistent default compared to
|
||||
;; 8-space tabs. This setting can be adjusted on a per-mode basis as needed.
|
||||
(setq-default indent-tabs-mode nil
|
||||
tab-width 4)
|
||||
|
||||
;; Enable indentation and completion using the TAB key
|
||||
(setq tab-always-indent 'complete)
|
||||
(setq tab-first-completion 'word-or-paren-or-punct)
|
||||
|
||||
;; Perf: Reduce command completion overhead.
|
||||
(setq read-extended-command-predicate #'command-completion-default-include-p)
|
||||
|
||||
;; Enable multi-line commenting which ensures that `comment-indent-new-line'
|
||||
;; properly continues comments onto new lines.
|
||||
(setq comment-multi-line t)
|
||||
|
||||
;; Ensures that empty lines within the commented region are also commented out.
|
||||
;; This prevents unintended visual gaps and maintains a consistent appearance.
|
||||
(setq comment-empty-lines t)
|
||||
|
||||
;; We often split terminals and editor windows or place them side-by-side,
|
||||
;; making use of the additional horizontal space.
|
||||
(setq-default fill-column 80)
|
||||
|
||||
;; Disable the obsolete practice of end-of-line spacing from the typewriter era.
|
||||
(setq sentence-end-double-space nil)
|
||||
|
||||
;; According to the POSIX, a line is defined as "a sequence of zero or more
|
||||
;; non-newline characters followed by a terminating newline".
|
||||
(setq require-final-newline t)
|
||||
|
||||
;; Eliminate delay before highlighting search matches
|
||||
(setq lazy-highlight-initial-delay 0)
|
||||
|
||||
;;; Filetype
|
||||
|
||||
;; Do not notify the user each time Python tries to guess the indentation offset
|
||||
(setq python-indent-guess-indent-offset-verbose nil)
|
||||
|
||||
(setq sh-indent-after-continuation 'always)
|
||||
|
||||
;;; Dired and ls-lisp
|
||||
|
||||
(setq dired-free-space nil
|
||||
dired-dwim-target t ; Propose a target for intelligent moving/copying
|
||||
dired-deletion-confirmer 'y-or-n-p
|
||||
dired-filter-verbose nil
|
||||
dired-recursive-deletes 'top
|
||||
dired-recursive-copies 'always
|
||||
dired-vc-rename-file t
|
||||
dired-create-destination-dirs 'ask
|
||||
;; Suppress Dired buffer kill prompt for deleted dirs
|
||||
dired-clean-confirm-killing-deleted-buffers nil)
|
||||
|
||||
;; This is a higher-level predicate that wraps `dired-directory-changed-p'
|
||||
;; with additional logic. This `dired-buffer-stale-p' predicate handles remote
|
||||
;; files, wdired, unreadable dirs, and delegates to dired-directory-changed-p
|
||||
;; for modification checks.
|
||||
(setq auto-revert-remote-files nil)
|
||||
(setq dired-auto-revert-buffer 'dired-buffer-stale-p)
|
||||
|
||||
;; dired-omit-mode
|
||||
(setq dired-omit-verbose nil
|
||||
dired-omit-files (concat "\\`[.]\\'"))
|
||||
|
||||
(setq ls-lisp-verbosity nil)
|
||||
(setq ls-lisp-dirs-first t)
|
||||
|
||||
;;; Ediff
|
||||
|
||||
;; Configure Ediff to use a single frame and split windows horizontally
|
||||
(setq ediff-window-setup-function 'ediff-setup-windows-plain
|
||||
ediff-split-window-function 'split-window-horizontally)
|
||||
|
||||
;;; Help
|
||||
|
||||
;; Enhance `apropos' and related functions to perform more extensive searches
|
||||
(setq apropos-do-all t)
|
||||
|
||||
;; Fixes #11: Prevents help command completion from triggering autoload.
|
||||
;; Loading additional files for completion can slow down help commands and may
|
||||
;; unintentionally execute initialization code from some libraries.
|
||||
(setq help-enable-completion-autoload nil)
|
||||
(setq help-enable-autoload nil)
|
||||
(setq help-enable-symbol-autoload nil)
|
||||
(setq help-window-select t) ;; Focus new help windows when opened
|
||||
|
||||
;;; Eglot
|
||||
|
||||
(setq eglot-report-progress minimal-emacs-debug) ; Prevent minibuffer spam
|
||||
(setq eglot-autoshutdown t) ; Shut down after killing last managed buffer
|
||||
|
||||
;; A setting of nil or 0 means Eglot will not block the UI at all, allowing
|
||||
;; Emacs to remain fully responsive, although LSP features will only become
|
||||
;; available once the connection is established in the background.
|
||||
(setq eglot-sync-connect 0)
|
||||
|
||||
;; Activate Eglot in cross-referenced non-project files
|
||||
(setq eglot-extend-to-xref t)
|
||||
|
||||
;; Eglot optimization
|
||||
(if minimal-emacs-debug
|
||||
(setq eglot-events-buffer-config '(:size 2000000 :format full))
|
||||
;; This reduces log clutter to improves performance.
|
||||
(setq jsonrpc-event-hook nil)
|
||||
;; Reduce memory usage and avoid cluttering *EGLOT events* buffer
|
||||
(setq eglot-events-buffer-size 0) ; Deprecated
|
||||
(setq eglot-events-buffer-config '(:size 0 :format short)))
|
||||
|
||||
;;; Flymake
|
||||
|
||||
(setq flymake-show-diagnostics-at-end-of-line nil)
|
||||
(setq flymake-wrap-around nil)
|
||||
|
||||
;;; hl-line-mode
|
||||
|
||||
;; Highlighting the current window, reducing clutter and improving performance
|
||||
(setq hl-line-sticky-flag nil)
|
||||
(setq global-hl-line-sticky-flag nil)
|
||||
|
||||
;;; icomplete
|
||||
|
||||
;; Do not delay displaying completion candidates in `fido-mode' or
|
||||
;; `fido-vertical-mode'
|
||||
(setq icomplete-compute-delay 0.01)
|
||||
|
||||
;;; flyspell
|
||||
|
||||
;; Improves flyspell performance by preventing messages from being displayed for
|
||||
;; each word when checking the entire buffer.
|
||||
(setq flyspell-issue-message-flag nil)
|
||||
(setq flyspell-issue-welcome-flag nil)
|
||||
|
||||
;;; ispell
|
||||
|
||||
;; In Emacs 30 and newer, disable Ispell completion to avoid annotation errors
|
||||
;; when no `ispell' dictionary is set.
|
||||
(setq text-mode-ispell-word-completion nil)
|
||||
|
||||
(setq ispell-silently-savep t)
|
||||
|
||||
;;; ibuffer
|
||||
|
||||
(setq ibuffer-formats
|
||||
'((mark modified read-only locked
|
||||
" " (name 55 55 :left :elide)
|
||||
" " (size 8 -1 :right)
|
||||
" " (mode 18 18 :left :elide) " " filename-and-process)
|
||||
(mark " " (name 16 -1) " " filename)))
|
||||
|
||||
;;; xref
|
||||
|
||||
;; Enable completion in the minibuffer instead of the definitions buffer
|
||||
(setq xref-show-definitions-function 'xref-show-definitions-completing-read
|
||||
xref-show-xrefs-function 'xref-show-definitions-completing-read)
|
||||
|
||||
;;; abbrev
|
||||
|
||||
;; Ensure the abbrev_defs file is stored in the correct location when
|
||||
;; `user-emacs-directory' is modified, as it defaults to ~/.emacs.d/abbrev_defs
|
||||
;; regardless of the change.
|
||||
(setq abbrev-file-name (expand-file-name "abbrev_defs" user-emacs-directory))
|
||||
|
||||
(setq save-abbrevs 'silently)
|
||||
|
||||
;;; dabbrev
|
||||
|
||||
(setq dabbrev-upcase-means-case-search t)
|
||||
|
||||
(setq dabbrev-ignored-buffer-modes
|
||||
'(archive-mode image-mode docview-mode tags-table-mode
|
||||
pdf-view-mode tags-table-mode))
|
||||
|
||||
(setq dabbrev-ignored-buffer-regexps
|
||||
'(;; - Buffers starting with a space (internal or temporary buffers)
|
||||
"\\` "
|
||||
;; Tags files such as ETAGS, GTAGS, RTAGS, TAGS, e?tags, and GPATH,
|
||||
;; including versions with numeric extensions like <123>
|
||||
"\\(?:\\(?:[EG]?\\|GR\\)TAGS\\|e?tags\\|GPATH\\)\\(<[0-9]+>\\)?"))
|
||||
|
||||
;;; Remove warnings from narrow-to-region, upcase-region...
|
||||
|
||||
(dolist (cmd '(list-timers narrow-to-region narrow-to-page
|
||||
upcase-region downcase-region
|
||||
list-threads erase-buffer scroll-left
|
||||
dired-find-alternate-file set-goal-column))
|
||||
(put cmd 'disabled nil))
|
||||
|
||||
;;; Load post init
|
||||
|
||||
(when (and minimal-emacs-load-post-init
|
||||
(fboundp 'minimal-emacs-load-user-init))
|
||||
(minimal-emacs-load-user-init "post-init.el"))
|
||||
|
||||
(setq minimal-emacs--success t)
|
||||
|
||||
;; Local variables:
|
||||
;; byte-compile-warnings: (not obsolete free-vars)
|
||||
;; End:
|
||||
|
||||
;;; init.el ends here
|
||||
@@ -0,0 +1,842 @@
|
||||
;;; post-init.el --- DESCRIPTION -*- no-byte-compile: t; lexical-binding: t; -*-
|
||||
|
||||
;; Auto-revert in Emacs is a feature that automatically updates the
|
||||
;; contents of a buffer to reflect changes made to the underlying file
|
||||
;; on disk.
|
||||
(use-package exec-path-from-shell
|
||||
:if (and (or (display-graphic-p) (daemonp))
|
||||
(eq system-type 'darwin)) ; macOS only
|
||||
:demand t
|
||||
:functions exec-path-from-shell-initialize
|
||||
:config
|
||||
(dolist (var '("TMPDIR"
|
||||
"SSH_AUTH_SOCK" "SSH_AGENT_PID"
|
||||
"GPG_AGENT_INFO"
|
||||
;; "FZF_DEFAULT_COMMAND" "FZF_DEFAULT_OPTS" ; fzf
|
||||
;; "VIRTUAL_ENV" ; Python
|
||||
;; "GOPATH" "GOROOT" "GOBIN" ; Go
|
||||
;; "CARGO_HOME" "RUSTUP_HOME" ; Rust
|
||||
;; "NVM_DIR" "NODE_PATH" ; Node/JS
|
||||
"LANG" "LC_CTYPE"))
|
||||
(add-to-list 'exec-path-from-shell-variables var))
|
||||
;; Initialize
|
||||
(exec-path-from-shell-initialize))
|
||||
|
||||
;; Recentf is an Emacs package that maintains a list of recently
|
||||
;; accessed files, making it easier to reopen files you have worked on
|
||||
;; recently.
|
||||
(use-package autorevert
|
||||
:ensure nil
|
||||
:commands (auto-revert-mode global-auto-revert-mode)
|
||||
:hook
|
||||
(after-init . global-auto-revert-mode)
|
||||
:init
|
||||
;; (setq auto-revert-verbose t)
|
||||
(setq auto-revert-interval 3)
|
||||
(setq auto-revert-remote-files nil)
|
||||
(setq auto-revert-use-notify t)
|
||||
(setq auto-revert-avoid-polling nil))
|
||||
|
||||
;; Recentf is an Emacs package that maintains a list of recently
|
||||
;; accessed files, making it easier to reopen files you have worked on
|
||||
;; recently.
|
||||
(use-package recentf
|
||||
:ensure nil
|
||||
:commands (recentf-mode recentf-cleanup)
|
||||
:hook
|
||||
(after-init . recentf-mode)
|
||||
|
||||
:init
|
||||
(setq recentf-auto-cleanup (if (daemonp) 300 'never))
|
||||
(setq recentf-exclude
|
||||
(list "\\.tar$" "\\.tbz2$" "\\.tbz$" "\\.tgz$" "\\.bz2$"
|
||||
"\\.bz$" "\\.gz$" "\\.gzip$" "\\.xz$" "\\.zip$"
|
||||
"\\.7z$" "\\.rar$"
|
||||
"COMMIT_EDITMSG\\'"
|
||||
"\\.\\(?:gz\\|gif\\|svg\\|png\\|jpe?g\\|bmp\\|xpm\\)$"
|
||||
"-autoloads\\.el$" "autoload\\.el$"))
|
||||
|
||||
:config
|
||||
;; A cleanup depth of -90 ensures that `recentf-cleanup' runs before
|
||||
;; `recentf-save-list', allowing stale entries to be removed before the list
|
||||
;; is saved by `recentf-save-list', which is automatically added to
|
||||
;; `kill-emacs-hook' by `recentf-mode'.
|
||||
(add-hook 'kill-emacs-hook #'recentf-cleanup -90))
|
||||
|
||||
;; savehist is an Emacs feature that preserves the minibuffer history between
|
||||
;; sessions. It saves the history of inputs in the minibuffer, such as commands,
|
||||
;; search strings, and other prompts, to a file. This allows users to retain
|
||||
;; their minibuffer history across Emacs restarts.
|
||||
(use-package savehist
|
||||
:ensure nil
|
||||
:commands (savehist-mode savehist-save)
|
||||
:hook
|
||||
(after-init . savehist-mode)
|
||||
:init
|
||||
(setq history-length 300)
|
||||
(setq savehist-autosave-interval 600))
|
||||
|
||||
;; save-place-mode enables Emacs to remember the last location within a file
|
||||
;; upon reopening. This feature is particularly beneficial for resuming work at
|
||||
;; the precise point where you previously left off.
|
||||
(use-package saveplace
|
||||
:ensure nil
|
||||
:commands (save-place-mode save-place-local-mode)
|
||||
:hook
|
||||
(after-init . save-place-mode)
|
||||
:init
|
||||
(setq save-place-limit 400))
|
||||
|
||||
;; Enable `auto-save-mode' to prevent data loss. Use `recover-file' or
|
||||
;; `recover-session' to restore unsaved changes.
|
||||
(setq auto-save-default t)
|
||||
|
||||
;; Trigger an auto-save after 300 keystrokes
|
||||
(setq auto-save-interval 300)
|
||||
|
||||
;; Trigger an auto-save 30 seconds of idle time.
|
||||
(setq auto-save-timeout 30)
|
||||
|
||||
;; When auto-save-visited-mode is enabled, Emacs will auto-save file-visiting
|
||||
;; buffers after a certain amount of idle time if the user forgets to save it
|
||||
;; with save-buffer or C-x s for example.
|
||||
;;
|
||||
;; This is different from auto-save-mode: auto-save-mode periodically saves
|
||||
;; all modified buffers, creating backup files, including those not associated
|
||||
;; with a file, while auto-save-visited-mode only saves file-visiting buffers
|
||||
;; after a period of idle time, directly saving to the file itself without
|
||||
;; creating backup files.
|
||||
(setq auto-save-visited-interval 5) ; Save after 5 seconds if inactivity
|
||||
(auto-save-visited-mode 1)
|
||||
|
||||
;; Vertico provides a vertical completion interface, making it easier to
|
||||
;; navigate and select from completion candidates (e.g., when `M-x` is pressed).
|
||||
(use-package vertico
|
||||
;; (Note: It is recommended to also enable the savehist package.)
|
||||
:config
|
||||
(vertico-mode))
|
||||
|
||||
;; Vertico leverages Orderless' flexible matching capabilities, allowing users
|
||||
;; to input multiple patterns separated by spaces, which Orderless then
|
||||
;; matches in any order against the candidates.
|
||||
(use-package orderless
|
||||
:custom
|
||||
(completion-styles '(orderless basic))
|
||||
(completion-category-defaults nil)
|
||||
(completion-category-overrides '((file (styles partial-completion)))))
|
||||
|
||||
;; Marginalia allows Embark to offer you preconfigured actions in more contexts.
|
||||
;;
|
||||
;; annotations to the completion candidates displayed in Vertico's interface.
|
||||
(use-package marginalia
|
||||
:commands (marginalia-mode marginalia-cycle)
|
||||
:hook (after-init . marginalia-mode))
|
||||
|
||||
;; Embark integrates with Consult and Vertico to provide context-sensitive
|
||||
;; actions and quick access to commands based on the current selection, further
|
||||
;; improving user efficiency and workflow within Emacs. Together, they create a
|
||||
;; cohesive and powerful environment for managing completions and interactions.
|
||||
(use-package embark
|
||||
;; Embark is an Emacs package that acts like a context menu, allowing
|
||||
;; users to perform context-sensitive actions on selected items
|
||||
;; directly from the completion interface.
|
||||
:commands (embark-act
|
||||
embark-dwim
|
||||
embark-export
|
||||
embark-collect
|
||||
embark-bindings
|
||||
embark-prefix-help-command)
|
||||
:bind
|
||||
(("C-." . embark-act) ;; pick some comfortable binding
|
||||
("C-;" . embark-dwim) ;; good alternative: M-.
|
||||
("C-h B" . embark-bindings)) ;; alternative for `describe-bindings'
|
||||
|
||||
:init
|
||||
(setq prefix-help-command #'embark-prefix-help-command)
|
||||
|
||||
:config
|
||||
;; Hide the mode line of the Embark live/completions buffers
|
||||
(add-to-list 'display-buffer-alist
|
||||
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
|
||||
nil
|
||||
(window-parameters (mode-line-format . none)))))
|
||||
|
||||
(use-package embark-consult
|
||||
:hook
|
||||
(embark-collect-mode . consult-preview-at-point-mode))
|
||||
|
||||
;; Consult offers a suite of commands for efficient searching, previewing, and
|
||||
;; interacting with buffers, file contents, and more, improving various tasks.
|
||||
(use-package consult
|
||||
:bind (;; C-c bindings in `mode-specific-map'
|
||||
("C-c M-x" . consult-mode-command)
|
||||
("C-c h" . consult-history)
|
||||
("C-c k" . consult-kmacro)
|
||||
("C-c m" . consult-man)
|
||||
("C-c i" . consult-info)
|
||||
([remap Info-search] . consult-info)
|
||||
;; C-x bindings in `ctl-x-map'
|
||||
("C-x M-:" . consult-complex-command)
|
||||
("C-x b" . consult-buffer)
|
||||
("C-x 4 b" . consult-buffer-other-window)
|
||||
("C-x 5 b" . consult-buffer-other-frame)
|
||||
("C-x t b" . consult-buffer-other-tab)
|
||||
("C-x r b" . consult-bookmark)
|
||||
("C-x p b" . consult-project-buffer)
|
||||
;; Custom M-# bindings for fast register access
|
||||
("M-#" . consult-register-load)
|
||||
("M-'" . consult-register-store)
|
||||
("C-M-#" . consult-register)
|
||||
;; Other custom bindings
|
||||
("M-y" . consult-yank-pop)
|
||||
;; M-g bindings in `goto-map'
|
||||
("M-g e" . consult-compile-error)
|
||||
("M-g f" . consult-flymake)
|
||||
("M-g g" . consult-goto-line)
|
||||
("M-g M-g" . consult-goto-line)
|
||||
("M-g o" . consult-outline)
|
||||
("M-g m" . consult-mark)
|
||||
("M-g k" . consult-global-mark)
|
||||
("M-g i" . consult-imenu)
|
||||
("M-g I" . consult-imenu-multi)
|
||||
;; M-s bindings in `search-map'
|
||||
("M-s d" . consult-find)
|
||||
("M-s c" . consult-locate)
|
||||
("M-s g" . consult-grep)
|
||||
("M-s G" . consult-git-grep)
|
||||
("M-s r" . consult-ripgrep)
|
||||
("M-s l" . consult-line)
|
||||
("M-s L" . consult-line-multi)
|
||||
("M-s k" . consult-keep-lines)
|
||||
("M-s u" . consult-focus-lines)
|
||||
;; Isearch integration
|
||||
("M-s e" . consult-isearch-history)
|
||||
:map isearch-mode-map
|
||||
("M-e" . consult-isearch-history)
|
||||
("M-s e" . consult-isearch-history)
|
||||
("M-s l" . consult-line)
|
||||
("M-s L" . consult-line-multi)
|
||||
;; Minibuffer history
|
||||
:map minibuffer-local-map
|
||||
("M-s" . consult-history)
|
||||
("M-r" . consult-history))
|
||||
|
||||
;; Enable automatic preview at point in the *Completions* buffer.
|
||||
:hook (completion-list-mode . consult-preview-at-point-mode)
|
||||
|
||||
:init
|
||||
;; Optionally configure the register formatting. This improves the register
|
||||
(setq register-preview-delay 0.5
|
||||
register-preview-function #'consult-register-format)
|
||||
|
||||
;; Optionally tweak the register preview window.
|
||||
(advice-add #'register-preview :override #'consult-register-window)
|
||||
|
||||
;; Use Consult to select xref locations with preview
|
||||
(setq xref-show-xrefs-function #'consult-xref
|
||||
xref-show-definitions-function #'consult-xref)
|
||||
|
||||
;; Aggressive asynchronous that yield instantaneous results. (suitable for
|
||||
;; high-performance systems.) Note: Minad, the author of Consult, does not
|
||||
;; recommend aggressive values.
|
||||
;; Read: https://github.com/minad/consult/discussions/951
|
||||
;;
|
||||
;; However, the author of minimal-emacs.d uses these parameters to achieve
|
||||
;; immediate feedback from Consult.
|
||||
;; (setq consult-async-input-debounce 0.02
|
||||
;; consult-async-input-throttle 0.05
|
||||
;; consult-async-refresh-delay 0.02)
|
||||
|
||||
:config
|
||||
(consult-customize
|
||||
consult-theme :preview-key '(:debounce 0.2 any)
|
||||
consult-ripgrep consult-git-grep consult-grep
|
||||
consult-bookmark consult-recent-file consult-xref
|
||||
consult-source-bookmark consult-source-file-register
|
||||
consult-source-recent-file consult-source-project-recent-file
|
||||
;; :preview-key "M-."
|
||||
:preview-key '(:debounce 0.4 any))
|
||||
(setq consult-narrow-key "<"))
|
||||
|
||||
;; The easysession Emacs package is a session manager for Emacs that can persist
|
||||
;; and restore file editing buffers, indirect buffers/clones, Dired buffers,
|
||||
;; windows/splits, the built-in tab-bar (including tabs, their buffers, and
|
||||
;; windows), and Emacs frames. It offers a convenient and effortless way to
|
||||
;; manage Emacs editing sessions and utilizes built-in Emacs functions to
|
||||
;; persist and restore frames.
|
||||
(use-package easysession
|
||||
:commands (easysession-switch-to
|
||||
easysession-save-as
|
||||
easysession-save-mode
|
||||
easysession-load-including-geometry)
|
||||
|
||||
:custom
|
||||
(easysession-mode-line-misc-info t) ; Display the session in the modeline
|
||||
(easysession-save-interval (* 10 60)) ; Save every 10 minutes
|
||||
|
||||
:init
|
||||
;; Key mappings
|
||||
(global-set-key (kbd "C-c ss") #'easysession-save)
|
||||
(global-set-key (kbd "C-c sl") #'easysession-switch-to)
|
||||
(global-set-key (kbd "C-c sL") #'easysession-switch-to-and-restore-geometry)
|
||||
(global-set-key (kbd "C-c sr") #'easysession-rename)
|
||||
(global-set-key (kbd "C-c sR") #'easysession-reset)
|
||||
(global-set-key (kbd "C-c sd") #'easysession-delete)
|
||||
|
||||
(if (fboundp 'easysession-setup)
|
||||
;; The `easysession-setup' function adds hooks:
|
||||
;; - To enable automatic session loading during `emacs-startup-hook', or
|
||||
;; `server-after-make-frame-hook' when running in daemon mode.
|
||||
;; - To automatically save the session at regular intervals, and when
|
||||
;; Emacs exits.
|
||||
(easysession-setup)
|
||||
;; Legacy
|
||||
;; The depth 102 and 103 have been added to to `add-hook' to ensure that the
|
||||
;; session is loaded after all other packages. (Using 103/102 is
|
||||
;; particularly useful for those using minimal-emacs.d, where some
|
||||
;; optimizations restore `file-name-handler-alist` at depth 101 during
|
||||
;; `emacs-startup-hook`.)
|
||||
(add-hook 'emacs-startup-hook #'easysession-load-including-geometry 102)
|
||||
(add-hook 'emacs-startup-hook #'easysession-save-mode 103)))
|
||||
|
||||
;; The markdown-mode package provides a major mode for Emacs for syntax
|
||||
;; highlighting, editing commands, and preview support for Markdown documents.
|
||||
;; It supports core Markdown syntax as well as extensions like GitHub Flavored
|
||||
;; Markdown (GFM).
|
||||
(use-package markdown-mode
|
||||
:commands (gfm-mode
|
||||
gfm-view-mode
|
||||
markdown-mode
|
||||
markdown-view-mode)
|
||||
:mode (("\\.markdown\\'" . markdown-mode)
|
||||
("\\.md\\'" . markdown-mode)
|
||||
("README\\.md\\'" . gfm-mode))
|
||||
:bind
|
||||
(:map markdown-mode-map
|
||||
("C-c C-e" . markdown-do)))
|
||||
;; Automatically generate a table of contents when editing Markdown files
|
||||
(use-package markdown-toc
|
||||
:commands (markdown-toc-generate-toc
|
||||
markdown-toc-generate-or-refresh-toc
|
||||
markdown-toc-delete-toc
|
||||
markdown-toc--toc-already-present-p)
|
||||
:custom
|
||||
(markdown-toc-header-toc-title "**Table of Contents**"))
|
||||
|
||||
(use-package kirigami
|
||||
:commands (kirigami-open-fold
|
||||
kirigami-open-fold-rec
|
||||
kirigami-close-fold
|
||||
kirigami-toggle-fold
|
||||
kirigami-open-folds
|
||||
kirigami-close-folds-except-current
|
||||
kirigami-close-folds)
|
||||
|
||||
:bind
|
||||
(("C-c z o" . kirigami-open-fold) ; Open fold at point
|
||||
("C-c z O" . kirigami-open-fold-rec) ; Open fold recursivelyo
|
||||
("C-c z r" . kirigami-open-folds) ; Open all folds
|
||||
("C-c z c" . kirigami-close-fold) ; Close fold at point
|
||||
("C-c z m" . kirigami-close-folds) ; Close all folds
|
||||
("C-c z a" . kirigami-toggle-fold))) ; Toggle fold at point
|
||||
|
||||
;; Uncomment the following if you are an `evil-mode' user:
|
||||
;; (with-eval-after-load 'evil
|
||||
;; (define-key evil-normal-state-map "zo" 'kirigami-open-fold)
|
||||
;; (define-key evil-normal-state-map "zO" 'kirigami-open-fold-rec)
|
||||
;; (define-key evil-normal-state-map "zc" 'kirigami-close-fold)
|
||||
;; (define-key evil-normal-state-map "za" 'kirigami-toggle-fold)
|
||||
;; (define-key evil-normal-state-map "zr" 'kirigami-open-folds)
|
||||
;; (define-key evil-normal-state-map "zm" 'kirigami-close-folds))
|
||||
|
||||
;; The built-in outline-minor-mode provides structured code folding in modes
|
||||
;; such as Emacs Lisp and Python, allowing users to collapse and expand sections
|
||||
;; based on headings or indentation levels. This feature enhances navigation and
|
||||
;; improves the management of large files with hierarchical structures.
|
||||
(use-package outline
|
||||
:ensure nil
|
||||
:commands outline-minor-mode
|
||||
:hook
|
||||
(;; Use " ▼" instead of the default ellipsis "..." for folded text to make
|
||||
;; folds more visually distinctive and readable.
|
||||
(outline-minor-mode
|
||||
.
|
||||
(lambda()
|
||||
(let* ((display-table (or buffer-display-table (make-display-table)))
|
||||
(face-offset (* (face-id 'shadow) (ash 1 22)))
|
||||
(value (vconcat (mapcar (lambda (c) (+ face-offset c)) " ▼"))))
|
||||
(set-display-table-slot display-table 'selective-display value)
|
||||
(setq buffer-display-table display-table))))))
|
||||
|
||||
;; Enable the mode
|
||||
(add-hook 'emacs-lisp-mode-hook #'outline-minor-mode)
|
||||
(add-hook 'lisp-mode-hook #'outline-minor-mode)
|
||||
(add-hook 'conf-mode-hook #'outline-minor-mode)
|
||||
(add-hook 'markdown-mode-hook #'outline-minor-mode)
|
||||
(add-hook 'diff-mode-hook #'outline-minor-mode)
|
||||
|
||||
|
||||
;; Systems and General Purpose
|
||||
(add-hook 'c-mode-hook #'hs-minor-mode)
|
||||
(add-hook 'c++-mode-hook #'hs-minor-mode)
|
||||
(add-hook 'java-mode-hook #'hs-minor-mode)
|
||||
(add-hook 'rust-mode-hook #'hs-minor-mode)
|
||||
(add-hook 'go-mode-hook #'hs-minor-mode)
|
||||
(add-hook 'ruby-mode-hook #'hs-minor-mode)
|
||||
|
||||
;; Web and Frontend
|
||||
(add-hook 'js-mode-hook #'hs-minor-mode)
|
||||
(add-hook 'typescript-mode-hook #'hs-minor-mode)
|
||||
(add-hook 'css-mode-hook #'hs-minor-mode)
|
||||
|
||||
;; Scripting, Data, and Infrastructure
|
||||
(add-hook 'sh-mode-hook #'hs-minor-mode) ; for bash/shell scripts
|
||||
(add-hook 'json-mode-hook #'hs-minor-mode)
|
||||
(add-hook 'lua-mode-hook #'hs-minor-mode)
|
||||
(add-hook 'nxml-mode-hook #'hs-minor-mode)
|
||||
(add-hook 'html-mode-hook #'hs-minor-mode) ;; mhtml and html
|
||||
|
||||
;; Intelligent code folding by using the structural understanding of the
|
||||
;; built-in tree-sitter parser. Unlike traditional folding methods that rely on
|
||||
;; regular expressions or indentation, treesit-fold uses the actual syntax tree
|
||||
;; of the code to accurately identify foldable regions such as functions,
|
||||
;; classes, comments, and documentation strings. This allows for faster and more
|
||||
;; precise folding behavior that respects the grammar of the programming
|
||||
;; language, ensuring that fold boundaries are always syntactically correct even
|
||||
;; in complex or nested code structures.
|
||||
(use-package treesit-fold
|
||||
:commands (treesit-fold-close
|
||||
treesit-fold-close-all
|
||||
treesit-fold-open
|
||||
treesit-fold-toggle
|
||||
treesit-fold-open-all
|
||||
treesit-fold-mode
|
||||
global-treesit-fold-mode
|
||||
treesit-fold-open-recursively
|
||||
treesit-fold-line-comment-mode)
|
||||
|
||||
:custom
|
||||
(treesit-fold-line-count-show t)
|
||||
(treesit-fold-line-count-format " ▼")
|
||||
|
||||
:config
|
||||
(set-face-attribute 'treesit-fold-replacement-face nil
|
||||
:foreground "#808080"
|
||||
:box nil
|
||||
:weight 'bold))
|
||||
|
||||
;; Systems and General Purpose
|
||||
(add-hook 'c-ts-mode-hook #'treesit-fold-mode)
|
||||
(add-hook 'c++-ts-mode-hook #'treesit-fold-mode)
|
||||
(add-hook 'java-ts-mode-hook #'treesit-fold-mode)
|
||||
(add-hook 'rust-ts-mode-hook #'treesit-fold-mode)
|
||||
(add-hook 'go-ts-mode-hook #'treesit-fold-mode)
|
||||
(add-hook 'ruby-ts-mode-hook #'treesit-fold-mode)
|
||||
|
||||
;; Web and Frontend
|
||||
(add-hook 'js-ts-mode-hook #'treesit-fold-mode)
|
||||
(add-hook 'typescript-ts-mode-hook #'treesit-fold-mode)
|
||||
(add-hook 'tsx-ts-mode-hook #'treesit-fold-mode)
|
||||
(add-hook 'css-ts-mode-hook #'treesit-fold-mode)
|
||||
(add-hook 'html-ts-mode-hook #'treesit-fold-mode)
|
||||
|
||||
;; Scripting and Infrastructure
|
||||
(add-hook 'bash-ts-mode-hook #'treesit-fold-mode)
|
||||
(add-hook 'cmake-ts-mode-hook #'treesit-fold-mode)
|
||||
(add-hook 'dockerfile-ts-mode-hook #'treesit-fold-mode)
|
||||
|
||||
;; Data and Configuration
|
||||
(add-hook 'json-ts-mode-hook #'treesit-fold-mode)
|
||||
(add-hook 'toml-ts-mode-hook #'treesit-fold-mode)
|
||||
|
||||
;; Third-party
|
||||
;; (add-hook 'kotlin-ts-mode-hook #'treesit-fold-mode)
|
||||
;; (add-hook 'swift-ts-mode-hook #'treesit-fold-mode)
|
||||
;; (add-hook 'elixir-ts-mode-hook #'treesit-fold-mode)
|
||||
;; (add-hook 'zig-ts-mode-hook #'treesit-fold-mode)
|
||||
|
||||
;; The [dumb-jump](https://github.com/jacktasia/dumb-jump) package provides context-aware 'go to definition' functionality for 50+ programming languages without requiring a language server. It works by using simple heuristics and regular expression searches to locate the definitions of functions, variables, and symbols across project files.
|
||||
;;
|
||||
;; Unlike more sophisticated language-aware tools (e.g., eglot or lsp-mode), `dumb-jump' does not parse code semantically, which makes it lightweight and fast, but sometimes less precise. It integrates with popular navigation packages like `xref', allowing users to jump to definitions or references.
|
||||
|
||||
(use-package dumb-jump
|
||||
:commands dumb-jump-xref-activate
|
||||
:init
|
||||
;; Register `dumb-jump' as an xref backend so it integrates with
|
||||
;; `xref-find-definitions'. A priority of 90 ensures it is used only when no
|
||||
;; more specific backend is available.
|
||||
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate 90)
|
||||
|
||||
(setq dumb-jump-aggressive nil)
|
||||
;; (setq dumb-jump-quiet t)
|
||||
|
||||
;; Number of seconds a rg/grep/find command can take before being warned to
|
||||
;; use ag and config.
|
||||
(setq dumb-jump-max-find-time 3)
|
||||
|
||||
;; Use `completing-read' so that selection of jump targets integrates with the
|
||||
;; active completion framework (e.g., Vertico, Ivy, Helm, Icomplete),
|
||||
;; providing a consistent minibuffer-based interface whenever multiple
|
||||
;; definitions are found.
|
||||
(setq dumb-jump-selector 'completing-read)
|
||||
|
||||
;; If ripgrep is available, force `dumb-jump' to use it because it is
|
||||
;; significantly faster and more accurate than the default searchers (grep,
|
||||
;; ag, etc.).
|
||||
(when (executable-find "rg")
|
||||
(setq dumb-jump-force-searcher 'rg)
|
||||
(setq dumb-jump-prefer-searcher 'rg)))
|
||||
|
||||
;; The stripspace Emacs package provides stripspace-local-mode, a minor mode
|
||||
;; that automatically removes trailing whitespace and blank lines at the end of
|
||||
;; the buffer when saving.
|
||||
(use-package stripspace
|
||||
:commands stripspace-local-mode
|
||||
|
||||
;; Enable for prog-mode-hook, text-mode-hook, conf-mode-hook
|
||||
:hook ((prog-mode . stripspace-local-mode)
|
||||
(text-mode . stripspace-local-mode)
|
||||
(conf-mode . stripspace-local-mode))
|
||||
|
||||
:custom
|
||||
;; The `stripspace-only-if-initially-clean' option:
|
||||
;; - nil to always delete trailing whitespace.
|
||||
;; - Non-nil to only delete whitespace when the buffer is clean initially.
|
||||
;; (The initial cleanliness check is performed when `stripspace-local-mode'
|
||||
;; is enabled.)
|
||||
(stripspace-only-if-initially-clean nil)
|
||||
|
||||
;; Enabling `stripspace-restore-column' preserves the cursor's column position
|
||||
;; even after stripping spaces. This is useful in scenarios where you add
|
||||
;; extra spaces and then save the file. Although the spaces are removed in the
|
||||
;; saved file, the cursor remains in the same position, ensuring a consistent
|
||||
;; editing experience without affecting cursor placement.
|
||||
(stripspace-restore-column t))
|
||||
|
||||
;; The [diff-hl](https://github.com/dgutov/diff-hl) package highlights uncommitted changes in the window margin, enabling navigation between them. Also known as source control gutter indicators, it displays added, modified, and deleted lines in real time. In Git-controlled buffers, changes can be staged and unstaged directly, providing a clear view of version-control changes without running `git diff`. By default, the module does not start `diff-hl-mode` automatically.
|
||||
|
||||
```elisp
|
||||
(use-package diff-hl
|
||||
:commands (diff-hl-mode
|
||||
global-diff-hl-mode)
|
||||
:hook (prog-mode . diff-hl-mode)
|
||||
:init
|
||||
(setq diff-hl-flydiff-delay 0.4) ; Faster
|
||||
(setq diff-hl-show-staged-changes nil) ; Realtime feedback
|
||||
(setq diff-hl-update-async t) ; Do not block Emacs
|
||||
(setq diff-hl-global-modes '(not pdf-view-mode image-mode)))
|
||||
|
||||
|
||||
;; Org mode is a major mode designed for organizing notes, planning, task
|
||||
;; management, and authoring documents using plain text with a simple and
|
||||
;; expressive markup syntax. It supports hierarchical outlines, TODO lists,
|
||||
;; scheduling, deadlines, time tracking, and exporting to multiple formats
|
||||
;; including HTML, LaTeX, PDF, and Markdown.
|
||||
(use-package org
|
||||
:commands (org-mode org-version)
|
||||
:mode
|
||||
("\\.org\\'" . org-mode)
|
||||
:custom
|
||||
(org-hide-leading-stars t)
|
||||
(org-startup-indented t)
|
||||
(org-adapt-indentation nil)
|
||||
(org-edit-src-content-indentation 0)
|
||||
;; (org-fontify-done-headline t)
|
||||
;; (org-fontify-todo-headline t)
|
||||
;; (org-fontify-whole-heading-line t)
|
||||
;; (org-fontify-quote-and-verse-blocks t)
|
||||
(org-startup-truncated t))
|
||||
|
||||
;; Set up the Language Server Protocol (LSP) servers using Eglot.
|
||||
(use-package eglot
|
||||
:ensure nil
|
||||
:commands (eglot-ensure
|
||||
eglot-rename
|
||||
eglot-format-buffer))
|
||||
|
||||
;; This automates the process of updating installed packages
|
||||
(use-package auto-package-update
|
||||
:custom
|
||||
;; Set the number of days between automatic updates.
|
||||
;; Here, packages will only be updated if at least 7 days have passed
|
||||
;; since the last successful update.
|
||||
(auto-package-update-interval 7)
|
||||
|
||||
;; Suppress display of the *auto-package-update results* buffer after updates.
|
||||
;; This keeps the user interface clean and avoids unnecessary interruptions.
|
||||
(auto-package-update-hide-results t)
|
||||
|
||||
;; Automatically delete old package versions after updates to reduce disk
|
||||
;; usage and keep the package directory clean. This prevents the accumulation
|
||||
;; of outdated files in Emacs's package directory, which consume
|
||||
;; unnecessary disk space over time.
|
||||
(auto-package-update-delete-old-versions t)
|
||||
|
||||
;; Uncomment the following line to enable a confirmation prompt
|
||||
;; before applying updates. This can be useful if you want manual control.
|
||||
(auto-package-update-prompt-before-update t)
|
||||
|
||||
:config
|
||||
;; Run package updates automatically at startup, but only if the configured
|
||||
;; interval has elapsed.
|
||||
(auto-package-update-maybe)
|
||||
|
||||
;; Schedule a background update attempt daily at 10:00 AM.
|
||||
;; This uses Emacs' internal timer system. If Emacs is running at that time,
|
||||
;; the update will be triggered. Otherwise, the update is skipped for that
|
||||
;; day. Note that this scheduled update is independent of
|
||||
;; `auto-package-update-maybe` and can be used as a complementary or
|
||||
;; alternative mechanism.
|
||||
(auto-package-update-at-time "10:00"))
|
||||
|
||||
;; The [buffer-terminator](https://github.com/jamescherti/buffer-terminator.el) Emacs package *automatically and safely kills buffers*, ensuring a clean and efficient workspace while *enhancing the performance of Emacs* by reducing open buffers, which minimizes active modes, timers, processes...
|
||||
;;
|
||||
;; ;; Beyond performance, *buffer-terminator* provides other benefits. For instance, if you occasionally need to close annoying or unused buffers, *buffer-terminator* can handle this automatically, eliminating the need for manual intervention. (The default configuration is suitable for most users. However, the *buffer-terminator* package is highly customizable. You can define specific rules for retaining or terminating buffers by modifying the `buffer-terminator-rules-alist` with your preferred set of rules.)
|
||||
(use-package buffer-terminator
|
||||
:custom
|
||||
;; Enable/Disable verbose mode to log buffer cleanup events
|
||||
(buffer-terminator-verbose nil)
|
||||
|
||||
;; Set the inactivity timeout (in seconds) after which buffers are considered
|
||||
;; inactive (default is 30 minutes):
|
||||
(buffer-terminator-inactivity-timeout (* 30 60)) ; 30 minutes
|
||||
|
||||
;; Define how frequently the cleanup process should run (default is every 10
|
||||
;; minutes):
|
||||
(buffer-terminator-interval (* 10 60)) ; 10 minutes
|
||||
|
||||
:config
|
||||
(buffer-terminator-mode 1))
|
||||
|
||||
|
||||
;; A file and project explorer for Emacs that displays a structured tree
|
||||
;; layout, similar to file browsers in modern IDEs. It functions as a sidebar
|
||||
;; in the left window, providing a persistent view of files, projects, and
|
||||
;; other elements.
|
||||
(use-package treemacs
|
||||
:commands (treemacs
|
||||
treemacs-select-window
|
||||
treemacs-delete-other-windows
|
||||
treemacs-select-directory
|
||||
treemacs-bookmark
|
||||
treemacs-find-file
|
||||
treemacs-find-tag)
|
||||
|
||||
:bind
|
||||
(:map global-map
|
||||
("M-0" . treemacs-select-window)
|
||||
("C-x t 1" . treemacs-delete-other-windows)
|
||||
("C-x t t" . treemacs)
|
||||
("C-x t d" . treemacs-select-directory)
|
||||
("C-x t B" . treemacs-bookmark)
|
||||
("C-x t C-t" . treemacs-find-file)
|
||||
("C-x t M-t" . treemacs-find-tag))
|
||||
|
||||
:init
|
||||
(with-eval-after-load 'winum
|
||||
(define-key winum-keymap (kbd "M-0") #'treemacs-select-window))
|
||||
|
||||
:config
|
||||
(setq treemacs-collapse-dirs (if treemacs-python-executable 3 0)
|
||||
treemacs-deferred-git-apply-delay 0.5
|
||||
treemacs-directory-name-transformer #'identity
|
||||
treemacs-display-in-side-window t
|
||||
treemacs-eldoc-display 'simple
|
||||
treemacs-file-event-delay 2000
|
||||
treemacs-file-extension-regex treemacs-last-period-regex-value
|
||||
treemacs-file-follow-delay 0.2
|
||||
treemacs-file-name-transformer #'identity
|
||||
treemacs-follow-after-init t
|
||||
treemacs-expand-after-init t
|
||||
treemacs-find-workspace-method 'find-for-file-or-pick-first
|
||||
treemacs-git-command-pipe ""
|
||||
treemacs-goto-tag-strategy 'refetch-index
|
||||
treemacs-header-scroll-indicators '(nil . "^^^^^^")
|
||||
treemacs-hide-dot-git-directory t
|
||||
treemacs-indentation 2
|
||||
treemacs-indentation-string " "
|
||||
treemacs-is-never-other-window nil
|
||||
treemacs-max-git-entries 5000
|
||||
treemacs-missing-project-action 'ask
|
||||
treemacs-move-files-by-mouse-dragging t
|
||||
treemacs-move-forward-on-expand nil
|
||||
treemacs-no-png-images nil
|
||||
treemacs-no-delete-other-windows t
|
||||
treemacs-project-follow-cleanup nil
|
||||
treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory)
|
||||
treemacs-position 'left
|
||||
treemacs-read-string-input 'from-child-frame
|
||||
treemacs-recenter-distance 0.1
|
||||
treemacs-recenter-after-file-follow nil
|
||||
treemacs-recenter-after-tag-follow nil
|
||||
treemacs-recenter-after-project-jump 'always
|
||||
treemacs-recenter-after-project-expand 'on-distance
|
||||
treemacs-litter-directories '("/node_modules" "/.venv" "/.cask")
|
||||
treemacs-project-follow-into-home nil
|
||||
treemacs-show-cursor nil
|
||||
treemacs-show-hidden-files t
|
||||
treemacs-silent-filewatch nil
|
||||
treemacs-silent-refresh nil
|
||||
treemacs-sorting 'alphabetic-asc
|
||||
treemacs-select-when-already-in-treemacs 'move-back
|
||||
treemacs-space-between-root-nodes t
|
||||
treemacs-tag-follow-cleanup t
|
||||
treemacs-tag-follow-delay 1.5
|
||||
treemacs-text-scale nil
|
||||
treemacs-user-mode-line-format nil
|
||||
treemacs-user-header-line-format nil
|
||||
treemacs-wide-toggle-width 70
|
||||
treemacs-width 35
|
||||
treemacs-width-increment 1
|
||||
treemacs-width-is-initially-locked t
|
||||
treemacs-workspace-switch-cleanup nil)
|
||||
|
||||
;; The default width and height of the icons is 22 pixels. If you are
|
||||
;; using a Hi-DPI display, uncomment this to double the icon size.
|
||||
;; (treemacs-resize-icons 44)
|
||||
|
||||
(treemacs-follow-mode t)
|
||||
(treemacs-filewatch-mode t)
|
||||
(treemacs-fringe-indicator-mode 'always)
|
||||
|
||||
;;(when treemacs-python-executable
|
||||
;; (treemacs-git-commit-diff-mode t))
|
||||
|
||||
(pcase (cons (not (null (executable-find "git")))
|
||||
(not (null treemacs-python-executable)))
|
||||
(`(t . t)
|
||||
(treemacs-git-mode 'deferred))
|
||||
(`(t . _)
|
||||
(treemacs-git-mode 'simple)))
|
||||
|
||||
(treemacs-hide-gitignored-files-mode nil))
|
||||
|
||||
;; (use-package treemacs-evil
|
||||
;; :after (treemacs evil)
|
||||
;;
|
||||
;; (use-package treemacs-icons-dired
|
||||
;; :hook (dired-mode . treemacs-icons-dired-enable-once)
|
||||
;;
|
||||
;; (use-package treemacs-tab-bar ; treemacs-tab-bar if you use tab-bar-mode
|
||||
;; :after (treemacs)
|
||||
;; :config (treemacs-set-scope-type 'Tabs))
|
||||
;;
|
||||
;; (treemacs-start-on-boot)
|
||||
|
||||
;; Helpful is an alternative to the built-in Emacs help that provides much more
|
||||
;; contextual information.
|
||||
(use-package helpful
|
||||
:commands (helpful-callable
|
||||
helpful-variable
|
||||
helpful-key
|
||||
helpful-command
|
||||
helpful-at-point
|
||||
helpful-function)
|
||||
:bind
|
||||
([remap describe-command] . helpful-command)
|
||||
([remap describe-function] . helpful-callable)
|
||||
([remap describe-key] . helpful-key)
|
||||
([remap describe-symbol] . helpful-symbol)
|
||||
([remap describe-variable] . helpful-variable)
|
||||
:custom
|
||||
(helpful-max-buffers 7))
|
||||
|
||||
;; The [avy](https://github.com/abo-abo/avy) package is a navigation framework designed for jumping directly to any visible text on the screen with minimal keystrokes. The primary benefit of *avy* is a substantial increase in navigational efficiency, as it minimizes keystrokes compared to iterative methods like arrow keys or standard search.
|
||||
;;
|
||||
;; It operates by generating a dynamic, temporary mapping: upon invocation, such as with the command `avy-goto-char` or `avy-goto-char-2`, the user inputs a target character, and `avy` highlights all visible instances on the screen with unique key sequences. Typing the short sequence corresponding to the desired location instantly moves the point directly there.
|
||||
;;
|
||||
;; To configure **avy**, add the following to `~/.emacs.d/post-init.el`:
|
||||
|
||||
(use-package avy
|
||||
:commands (avy-goto-char
|
||||
avy-goto-char-2
|
||||
avy-next)
|
||||
:init
|
||||
(global-set-key (kbd "C-'") 'avy-goto-char-2))
|
||||
|
||||
|
||||
;; The author recommends using `avy-goto-char-2` (typically bound to `C-'`). Upon invocation, *avy* prompts the user to input a two-character sequence. Subsequently, all visible instances of this sequence are highlighted with unique, concise labels (e.g., single letters or numbers). The user then simply presses the key corresponding to the desired label, and *avy* instantly transports the cursor to that specific occurrence.
|
||||
|
||||
(use-package bufferfile
|
||||
:commands (bufferfile-copy
|
||||
bufferfile-rename
|
||||
bufferfile-delete)
|
||||
:custom
|
||||
;; If non-nil, display messages during file renaming operations
|
||||
(bufferfile-verbose nil)
|
||||
|
||||
;; If non-nil, enable using version control (VC) when available
|
||||
(bufferfile-use-vc nil)
|
||||
|
||||
;; Specifies the action taken after deleting a file and killing its buffer.
|
||||
(bufferfile-delete-switch-to 'parent-directory))
|
||||
|
||||
;; Configure the `tab-bar-show` variable to 1 to display the tab bar exclusively
|
||||
;; when multiple tabs are open:
|
||||
(setopt tab-bar-show 1)
|
||||
|
||||
|
||||
;; ### Persisting and Restoring Text Scale
|
||||
;;
|
||||
;; The [persist-text-scale](https://github.com/jamescherti/persist-text-scale.el) Emacs package provides `persist-text-scale-mode`, which ensures that all adjustments made with `text-scale-increase` and `text-scale-decrease` are persisted and restored across sessions. As a result, the text size in each buffer remains consistent, even after restarting Emacs.
|
||||
;;
|
||||
;; This package also facilitates grouping buffers into categories, allowing buffers within the same category to share a consistent text scale. This ensures uniform font sizes when adjusting text scaling. By default:
|
||||
;; - Each file-visiting buffer has its own independent text scale.
|
||||
;; - Special buffers, identified by their buffer names, each retain their own text scale setting.
|
||||
;; - All Dired buffers maintain the same font size, treating Dired as a unified "file explorer" where the text scale remains consistent across different buffers.
|
||||
;;
|
||||
;; This category-based behavior can be further customized by assigning a function to the `persist-text-scale-buffer-category-function` variable. The function determines how buffers are categorized by returning a category identifier (string) based on the buffer's context. Buffers within the same category will share the same text scale.
|
||||
;;
|
||||
;; To configure the *persist-text-scale* package, add the following to your `~/.emacs.d/post-init.el`:
|
||||
|
||||
(use-package persist-text-scale
|
||||
:commands (persist-text-scale-mode
|
||||
persist-text-scale-restore)
|
||||
|
||||
:hook (after-init . persist-text-scale-mode)
|
||||
|
||||
:custom
|
||||
(text-scale-mode-step 1.07))
|
||||
|
||||
;; Display the current line and column numbers in the mode line
|
||||
(setq line-number-mode t)
|
||||
(setq column-number-mode t)
|
||||
(setq mode-line-position-column-line-format '("%l:%C"))
|
||||
|
||||
;; Display of line numbers in the buffer:
|
||||
(setq-default display-line-numbers-type 'absolute)
|
||||
(dolist (hook '(prog-mode-hook text-mode-hook conf-mode-hook))
|
||||
(add-hook hook #'display-line-numbers-mode))
|
||||
|
||||
(use-package which-key
|
||||
:ensure nil ; builtin
|
||||
:commands which-key-mode
|
||||
:hook (after-init . which-key-mode)
|
||||
:custom
|
||||
(which-key-idle-delay 1.5)
|
||||
(which-key-idle-secondary-delay 0.25)
|
||||
(which-key-add-column-padding 1)
|
||||
(which-key-max-description-length 40))
|
||||
|
||||
(unless (and (eq window-system 'mac)
|
||||
(bound-and-true-p mac-carbon-version-string))
|
||||
;; Enables `pixel-scroll-precision-mode' on all operating systems and Emacs
|
||||
;; versions, except for emacs-mac.
|
||||
;;
|
||||
;; Enabling `pixel-scroll-precision-mode' is unnecessary with emacs-mac, as
|
||||
;; this version of Emacs natively supports smooth scrolling.
|
||||
;; https://bitbucket.org/mituharu/emacs-mac/commits/65c6c96f27afa446df6f9d8eff63f9cc012cc738
|
||||
(setq pixel-scroll-precision-use-momentum nil) ; Precise/smoother scrolling
|
||||
(pixel-scroll-precision-mode 1))
|
||||
|
||||
;; Paren match highlighting
|
||||
(add-hook 'after-init-hook #'show-paren-mode)
|
||||
|
||||
(use-package uniquify
|
||||
:ensure nil
|
||||
:custom
|
||||
(uniquify-buffer-name-style 'reverse)
|
||||
(uniquify-separator "•")
|
||||
(uniquify-after-kill-buffer-p t))
|
||||
|
||||
;; (setq truncate-lines nil)
|
||||
@@ -0,0 +1,5 @@
|
||||
;;; pre-early-init.el --- DESCRIPTION -*- no-byte-compile: t; lexical-binding: t; -*-
|
||||
(setq user-emacs-directory (expand-file-name "var/" minimal-emacs-user-directory))
|
||||
(setq package-user-dir (expand-file-name "elpa" user-emacs-directory))
|
||||
|
||||
(setq inhibit-default-init t)
|
||||
@@ -0,0 +1,139 @@
|
||||
# author: Gael Lopes Da Silva
|
||||
# project: Yellowed
|
||||
# github: https://github.com/Gael-Lopes-Da-Silva/YellowedHelix
|
||||
|
||||
"attribute" = { fg = "text" }
|
||||
"type" = { fg = "text" }
|
||||
"type.builtin" = { fg = "keywords" }
|
||||
"type.enum" = { fg = "keywords" }
|
||||
"constructor" = { fg = "text", modifiers = ["bold"] }
|
||||
"constant" = { fg = "text", modifiers = ["bold"] }
|
||||
"constant.builtin" = { fg = "constants", modifiers = ["bold"] }
|
||||
"constant.character" = { fg = "string" }
|
||||
"constant.character.escape" = { fg = "constants", modifiers = ["bold"] }
|
||||
"constant.numeric" = { fg = "keywords" }
|
||||
"string" = { fg = "string" }
|
||||
"string.regexp" = { fg = "constants" }
|
||||
"comment" = { fg = "comment" }
|
||||
"variable" = { fg = "text" }
|
||||
"variable.builtin" = { fg = "keywords" }
|
||||
"variable.parameter" = { fg = "text", modifiers = ["italic"] }
|
||||
"label" = { fg = "text" }
|
||||
"punctuation" = { fg = "text" }
|
||||
"punctuation.special" = { fg = "constants", modifiers = ["bold"] }
|
||||
"keyword" = { fg = "keywords", modifiers = ["bold"] }
|
||||
"keyword.control" = { fg = "keywords" }
|
||||
"keyword.control.return" = { fg = "keywords", modifiers = ["bold"] }
|
||||
"keyword.operator" = { fg = "keywords" }
|
||||
"keyword.directive" = { fg = "keywords" }
|
||||
"operator" = { fg = "keywords" }
|
||||
"function" = { fg = "text", modifiers = ["bold"] }
|
||||
"tag" = { fg = "keywords", modifiers = ["bold"] }
|
||||
"namespace" = { fg = "text" }
|
||||
"special" = { fg = "yellow" }
|
||||
|
||||
"markup.heading.marker" = { fg = "keywords", modifiers = ["bold"] }
|
||||
"markup.heading.1" = { fg = "text", modifiers = ["bold"] }
|
||||
"markup.heading.2" = { fg = "text", modifiers = ["bold"] }
|
||||
"markup.heading.3" = { fg = "text", modifiers = ["bold"] }
|
||||
"markup.heading.4" = { fg = "text", modifiers = ["bold"] }
|
||||
"markup.heading.5" = { fg = "text", modifiers = ["bold"] }
|
||||
"markup.heading.6" = { fg = "text", modifiers = ["bold"] }
|
||||
"markup.list" = { fg = "keywords", modifiers = ["bold"] }
|
||||
"markup.bold" = { modifiers = ["bold"] }
|
||||
"markup.italic" = { modifiers = ["italic"] }
|
||||
"markup.link.url" = { fg = "text", modifiers = ["underlined"] }
|
||||
"markup.link.text" = { fg = "string" }
|
||||
"markup.quote" = { fg = "text" }
|
||||
"markup.raw" = { fg = "string" }
|
||||
|
||||
"diff.plus" = { fg = "green" }
|
||||
"diff.minus" = { fg = "red" }
|
||||
"diff.delta" = { fg = "blue" }
|
||||
"diff.delta.moved" = { fg = "gray" }
|
||||
|
||||
"ui.background" = { bg = "dark_gray", fg = "text" }
|
||||
"ui.background.separator" = { fg = "text" }
|
||||
"ui.cursor" = { bg = "yellow", fg = "black" }
|
||||
"ui.cursor.normal" = { bg = "yellow", fg = "black" }
|
||||
"ui.cursor.insert" = { bg = "yellow", fg = "black" }
|
||||
"ui.cursor.select" = { bg = "yellow", fg = "black" }
|
||||
"ui.cursor.match" = { bg = "light_gray" }
|
||||
"ui.cursor.primary" = { bg = "yellow", fg = "black" }
|
||||
"ui.cursor.primary.normal" = { bg = "yellow", fg = "black" }
|
||||
"ui.cursor.primary.insert" = { bg = "yellow", fg = "black" }
|
||||
"ui.cursor.primary.select" = { bg = "yellow", fg = "black" }
|
||||
"ui.debug.breakpoint" = { fg = "red" }
|
||||
"ui.debug.active" = { fg = "green" }
|
||||
"ui.gutter" = { fg = "light_gray" }
|
||||
"ui.gutter.selected" = { fg = "light_gray" }
|
||||
"ui.highlight.frameline" = { fg = "gray" }
|
||||
"ui.linenr" = { fg = "light_gray" }
|
||||
"ui.linenr.selected" = { fg = "yellow" }
|
||||
"ui.statusline" = { fg = "text", bg = "gray" }
|
||||
"ui.statusline.inactive" = { fg = "light_gray", bg = "gray" }
|
||||
"ui.statusline.normal" = { bg = "light_gray" }
|
||||
"ui.statusline.insert" = { bg = "green" }
|
||||
"ui.statusline.select" = { bg = "purple" }
|
||||
"ui.statusline.separator" = { fg = "dark_gray" }
|
||||
"ui.popup" = { bg = "menu", fg = "text" }
|
||||
"ui.popup.info" = { bg = "menu", fg = "text" }
|
||||
"ui.window" = { fg = "text" }
|
||||
"ui.help" = { fg = "text", bg = "menu" }
|
||||
"ui.text" = { fg = "text" }
|
||||
"ui.text.focus" = { bg = "gray" }
|
||||
"ui.text.inactive" = { fg = "text" }
|
||||
"ui.text.info" = { fg = "text" }
|
||||
"ui.virtual.ruler" = { bg = "light_gray" }
|
||||
"ui.virtual.whitespace" = { fg = "light_gray" }
|
||||
"ui.virtual.indent-guide" = { fg = "light_gray" }
|
||||
"ui.virtual.inlay-hint" = { fg = "light_gray" }
|
||||
"ui.virtual.inlay-hint.parameter" = { fg = "light_gray" }
|
||||
"ui.virtual.inlay-hint.type" = { fg = "light_gray" }
|
||||
"ui.virtual.wrap" = { fg = "light_gray" }
|
||||
"ui.virtual.jump-label" = { fg = "blue", bg = "selection", modifiers = ["bold", "underlined"] }
|
||||
"ui.menu" = { fg = "text", bg = "gray" }
|
||||
"ui.menu.selected" = { fg = "text", bg = "light_gray", modifiers = ["bold"] }
|
||||
"ui.menu.scroll" = { fg = "light_gray", bg = "dark_gray" }
|
||||
"ui.selection" = { bg = "selection" }
|
||||
"ui.selection.primary" = { bg = "selection" }
|
||||
"ui.highlight" = { bg = "light_gray" }
|
||||
"ui.cursorline.primary" = { bg = "gray" }
|
||||
"ui.cursorline.secondary" = { bg = "gray" }
|
||||
"ui.cursorcolumn.primary" = { bg = "gray" }
|
||||
"ui.cursorcolumn.secondary" = { bg = "gray" }
|
||||
|
||||
"warning" = { fg = "warning" }
|
||||
"error" = { fg = "error" }
|
||||
"info" = { fg = "info" }
|
||||
"hint" = { fg = "hint" }
|
||||
|
||||
"diagnostic.warning" = { underline = { color = "warning", style = "curl" } }
|
||||
"diagnostic.error" = { underline = { color = "error", style = "curl" } }
|
||||
"diagnostic.info" = { underline = { color = "info", style = "curl" } }
|
||||
"diagnostic.hint" = { underline = { color = "hint", style = "curl" } }
|
||||
"diagnostic.unnecessary" = { modifiers = ["dim"] }
|
||||
"diagnostic.deprecated" = { modifiers = ["crossed_out"] }
|
||||
|
||||
[palette]
|
||||
# interface
|
||||
yellow = "#ffd900"
|
||||
gray = "#2a2a2a"
|
||||
dark_gray = "#242424"
|
||||
light_gray = "#545454"
|
||||
purple = "#994c92"
|
||||
blue = "#008DFF"
|
||||
menu = "#202020"
|
||||
selection = "#3f3f3f"
|
||||
yellowish = "#ffdf00"
|
||||
|
||||
# syntax
|
||||
text = "#FFFFFF"
|
||||
comment = "#6b6b6b"
|
||||
string = "#378b1d"
|
||||
constants = "#ff80f4"
|
||||
keywords = "#ffd900"
|
||||
warning = "#FF9C00"
|
||||
error = "#FF0000"
|
||||
info = "#0092FF"
|
||||
hint = "#4DFF00"
|
||||
@@ -1,245 +0,0 @@
|
||||
-- since this is just an example spec, don't actually load anything here and return an empty spec
|
||||
-- stylua: ignore
|
||||
if true then return {} end
|
||||
|
||||
-- every spec file under the "plugins" directory will be loaded automatically by lazy.nvim
|
||||
--
|
||||
-- In your plugin files, you can:
|
||||
-- * add extra plugins
|
||||
-- * disable/enabled LazyVim plugins
|
||||
-- * override the configuration of LazyVim plugins
|
||||
return {
|
||||
-- add gruvbox
|
||||
{ "ellisonleao/gruvbox.nvim" },
|
||||
|
||||
-- Configure LazyVim to load gruvbox
|
||||
{
|
||||
"LazyVim/LazyVim",
|
||||
opts = {
|
||||
colorscheme = "gruvbox",
|
||||
},
|
||||
},
|
||||
|
||||
-- change trouble config
|
||||
{
|
||||
"folke/trouble.nvim",
|
||||
-- opts will be merged with the parent spec
|
||||
opts = { use_diagnostic_signs = true },
|
||||
},
|
||||
|
||||
-- disable trouble
|
||||
{ "folke/trouble.nvim", enabled = false },
|
||||
|
||||
-- override nvim-cmp and add cmp-emoji
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = { "hrsh7th/cmp-emoji" },
|
||||
---@param opts cmp.ConfigSchema
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.sources, { name = "emoji" })
|
||||
end,
|
||||
},
|
||||
|
||||
-- change some telescope options and a keymap to browse plugin files
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
keys = {
|
||||
-- add a keymap to browse plugin files
|
||||
-- stylua: ignore
|
||||
{
|
||||
"<leader>fp",
|
||||
function() require("telescope.builtin").find_files({ cwd = require("lazy.core.config").options.root }) end,
|
||||
desc = "Find Plugin File",
|
||||
},
|
||||
},
|
||||
-- change some options
|
||||
opts = {
|
||||
defaults = {
|
||||
layout_strategy = "horizontal",
|
||||
layout_config = { prompt_position = "top" },
|
||||
sorting_strategy = "ascending",
|
||||
winblend = 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- add pyright to lspconfig
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
---@class PluginLspOpts
|
||||
opts = {
|
||||
---@type lspconfig.options
|
||||
servers = {
|
||||
-- pyright will be automatically installed with mason and loaded with lspconfig
|
||||
pyright = {},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- add tsserver and setup with typescript.nvim instead of lspconfig
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
"jose-elias-alvarez/typescript.nvim",
|
||||
init = function()
|
||||
require("lazyvim.util").lsp.on_attach(function(_, buffer)
|
||||
-- stylua: ignore
|
||||
vim.keymap.set( "n", "<leader>co", "TypescriptOrganizeImports", { buffer = buffer, desc = "Organize Imports" })
|
||||
vim.keymap.set("n", "<leader>cR", "TypescriptRenameFile", { desc = "Rename File", buffer = buffer })
|
||||
end)
|
||||
end,
|
||||
},
|
||||
---@class PluginLspOpts
|
||||
opts = {
|
||||
---@type lspconfig.options
|
||||
servers = {
|
||||
-- tsserver will be automatically installed with mason and loaded with lspconfig
|
||||
tsserver = {},
|
||||
},
|
||||
-- you can do any additional lsp server setup here
|
||||
-- return true if you don't want this server to be setup with lspconfig
|
||||
---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
|
||||
setup = {
|
||||
-- example to setup with typescript.nvim
|
||||
tsserver = function(_, opts)
|
||||
require("typescript").setup({ server = opts })
|
||||
return true
|
||||
end,
|
||||
-- Specify * to use this function as a fallback for any server
|
||||
-- ["*"] = function(server, opts) end,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- for typescript, LazyVim also includes extra specs to properly setup lspconfig,
|
||||
-- treesitter, mason and typescript.nvim. So instead of the above, you can use:
|
||||
{ import = "lazyvim.plugins.extras.lang.typescript" },
|
||||
|
||||
-- add more treesitter parsers
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"html",
|
||||
"javascript",
|
||||
"json",
|
||||
"lua",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"python",
|
||||
"query",
|
||||
"regex",
|
||||
"tsx",
|
||||
"typescript",
|
||||
"vim",
|
||||
"yaml",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- since `vim.tbl_deep_extend`, can only merge tables and not lists, the code above
|
||||
-- would overwrite `ensure_installed` with the new value.
|
||||
-- If you'd rather extend the default config, use the code below instead:
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = function(_, opts)
|
||||
-- add tsx and treesitter
|
||||
vim.list_extend(opts.ensure_installed, {
|
||||
"tsx",
|
||||
"typescript",
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- the opts function can also be used to change the default opts:
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.sections.lualine_x, "😄")
|
||||
end,
|
||||
},
|
||||
|
||||
-- or you can return new options to override all the defaults
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = function()
|
||||
return {
|
||||
--[[add your custom lualine config here]]
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
||||
-- use mini.starter instead of alpha
|
||||
{ import = "lazyvim.plugins.extras.ui.mini-starter" },
|
||||
|
||||
-- add jsonls and schemastore packages, and setup treesitter for json, json5 and jsonc
|
||||
{ import = "lazyvim.plugins.extras.lang.json" },
|
||||
|
||||
-- add any tools you want to have installed below
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"stylua",
|
||||
"shellcheck",
|
||||
"shfmt",
|
||||
"flake8",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Use <tab> for completion and snippets (supertab)
|
||||
-- first: disable default <tab> and <s-tab> behavior in LuaSnip
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
keys = function()
|
||||
return {}
|
||||
end,
|
||||
},
|
||||
-- then: setup supertab in cmp
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-emoji",
|
||||
},
|
||||
---@param opts cmp.ConfigSchema
|
||||
opts = function(_, opts)
|
||||
local has_words_before = function()
|
||||
unpack = unpack or table.unpack
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
local luasnip = require("luasnip")
|
||||
local cmp = require("cmp")
|
||||
|
||||
opts.mapping = vim.tbl_extend("force", opts.mapping, {
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
|
||||
-- this way you will only jump inside the snippet region
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
return { "ellisonleao/glow.nvim", config = true, cmd = "Glow" }
|
||||
@@ -7,8 +7,9 @@
|
||||
"lazyvim.plugins.extras.util.dot",
|
||||
"lazyvim.plugins.extras.util.mini-hipatterns"
|
||||
],
|
||||
"install_version": 7,
|
||||
"news": {
|
||||
"NEWS.md": "10960"
|
||||
"NEWS.md": "11866"
|
||||
},
|
||||
"version": 7
|
||||
"version": 8
|
||||
}
|
||||
Reference in New Issue
Block a user