Last active
February 25, 2025 10:46
-
-
Save axyz/76871b404df376271b521212fba8a621 to your computer and use it in GitHub Desktop.
.emacs.d
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; early-init.el --- Early Init -*- no-byte-compile: t; lexical-binding: t; -*- | |
;;; variables | |
(defvar enable-debug-p nil | |
"non-nil to enable debug.") | |
;;; garbage collection | |
;; garbage collection significantly affects startup times. this setting delays | |
;; garbage collection during startup but will be reset later. | |
;; increase this early, decrease later on again | |
(setq gc-cons-threshold most-positive-fixnum | |
gc-cons-percentage 0.6) | |
(add-hook 'emacs-startup-hook | |
(lambda () | |
(setq gc-cons-threshold (* 16 1024 1024) | |
gc-cons-percentage 0.1))) | |
(set-language-environment "UTF-8") | |
;; Set-language-environment sets default-input-method, which is unwanted. | |
(setq default-input-method nil) | |
;;; performance | |
(setq load-prefer-newer t) | |
;; increase how much is read from processes in a single chunk (default is 4kb). | |
(setq read-process-output-max (* 512 1024)) ; 512kb | |
;;; disable package.el | |
(setq package-enable-at-startup nil) | |
(setq package-quickstart nil) | |
;; reduce rendering/line scan work by not rendering cursors or regions in | |
;; non-focused windows. | |
(setq-default cursor-in-non-selected-windows nil) | |
(setq highlight-nonselected-windows nil) | |
;; disable warnings from the legacy advice api. they aren't useful. | |
(setq ad-redefinition-action 'accept) | |
(setq warning-suppress-types '((lexical-binding))) | |
;; don't ping things that look like domain names. | |
(setq ffap-machine-p-known 'reject) | |
;; by default, emacs "updates" its ui more often than it needs to | |
(setq idle-update-delay 1.0) | |
;; 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) | |
;; 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) | |
;; shave seconds off startup time by starting the scratch buffer in | |
;; `fundamental-mode' | |
(setq initial-major-mode 'fundamental-mode | |
initial-scratch-message nil) | |
;; Activate `native-compile' | |
(setq native-comp-jit-compilation t | |
package-native-compile t) | |
;; suppress compiler warnings and don't inundate users with their popups. | |
(setq native-comp-async-report-warnings-errors 'silent) | |
(setq native-comp-warning-on-missing-source enable-debug-p) | |
(setq debug-on-error enable-debug-p | |
jka-compr-verbose enable-debug-p) | |
(setq byte-compile-warnings enable-debug-p) | |
(setq byte-compile-verbose enable-debug-p) | |
;;; disable unneeded ui elements | |
;; disable startup screens and messages | |
(setq inhibit-splash-screen t) | |
;; Minimal UI | |
(setq scroll-bar-mode nil) | |
(setq menu-bar-mode nil) | |
(setq tool-bar-mode nil) | |
(tooltip-mode -1) | |
;; disable guis because they are inconsistent across systems, desktop | |
;; environments, and themes, and they don't match the look of emacs. | |
(setq use-file-dialog nil) | |
(setq use-dialog-box nil) | |
;; allow for shorter responses: "y" for yes and "n" for no. | |
(if (boundp 'use-short-answers) | |
(setq use-short-answers t) | |
(advice-add #'yes-or-no-p :override #'y-or-n-p)) | |
(defalias #'view-hello-file #'ignore) ; never show the hello file | |
(provide 'early-init) | |
;;; early-init.el ends here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; init.el --- Init -*- no-byte-compile: t; lexical-binding: t; -*- | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; | |
;;; Package management | |
;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; bootstrap elpaca | |
(defvar elpaca-installer-version 0.9) | |
(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory)) | |
(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory)) | |
(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory)) | |
(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git" | |
:ref nil :depth 1 :inherit ignore | |
:files (:defaults "elpaca-test.el" (:exclude "extensions")) | |
:build (:not elpaca--activate-package))) | |
(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory)) | |
(build (expand-file-name "elpaca/" elpaca-builds-directory)) | |
(order (cdr elpaca-order)) | |
(default-directory repo)) | |
(add-to-list 'load-path (if (file-exists-p build) build repo)) | |
(unless (file-exists-p repo) | |
(make-directory repo t) | |
(when (< emacs-major-version 28) (require 'subr-x)) | |
(condition-case-unless-debug err | |
(if-let* ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*")) | |
((zerop (apply #'call-process `("git" nil ,buffer t "clone" | |
,@(when-let* ((depth (plist-get order :depth))) | |
(list (format "--depth=%d" depth) "--no-single-branch")) | |
,(plist-get order :repo) ,repo)))) | |
((zerop (call-process "git" nil buffer t "checkout" | |
(or (plist-get order :ref) "--")))) | |
(emacs (concat invocation-directory invocation-name)) | |
((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch" | |
"--eval" "(byte-recompile-directory \".\" 0 'force)"))) | |
((require 'elpaca)) | |
((elpaca-generate-autoloads "elpaca" repo))) | |
(progn (message "%s" (buffer-string)) (kill-buffer buffer)) | |
(error "%s" (with-current-buffer buffer (buffer-string)))) | |
((error) (warn "%s" err) (delete-directory repo 'recursive)))) | |
(unless (require 'elpaca-autoloads nil t) | |
(require 'elpaca) | |
(elpaca-generate-autoloads "elpaca" repo) | |
(load "./elpaca-autoloads"))) | |
(add-hook 'after-init-hook #'elpaca-process-queues) | |
(elpaca `(,@elpaca-order));;; Populate elpaca queue with the packages that will process the config. | |
;; Install use-package support | |
(elpaca elpaca-use-package | |
;; Enable :elpaca use-package keyword. | |
(elpaca-use-package-mode) | |
;; Assume :ensure t unless otherwise specified. | |
(setq use-package-always-ensure t)) | |
;; Block until current queue processed. | |
(elpaca-wait) | |
;; add modules within this directory to the scope | |
(add-to-list 'load-path | |
(expand-file-name "local-packages" user-emacs-directory));;; settings | |
;;; FIXME: https://www.reddit.com/r/emacs/comments/1954ay9/magit_depends_on_transient_050_on_emacs_291/ | |
(use-package transient) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; | |
;;; Basic settings | |
;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; It may also be wise to raise gc-cons-threshold while the minibuffer is active, so the GC | |
;; doesn’t slow down expensive commands (or completion frameworks, like helm and ivy). Here | |
;; is how Doom does it: | |
(defun doom-defer-garbage-collection-h () | |
"Don't do garbage collection during startup." | |
(setq gc-cons-threshold most-positive-fixnum)) | |
(defun doom-restore-garbage-collection-h () | |
"Defer it so that commands launched immediately after will enjoy the benefits." | |
(run-at-time | |
1 nil (lambda () (setq gc-cons-threshold (* 16 1024 1024))))) | |
(add-hook 'minibuffer-setup-hook #'doom-defer-garbage-collection-h) | |
(add-hook 'minibuffer-exit-hook #'doom-restore-garbage-collection-h) | |
;; Save history of minibuffer | |
(savehist-mode) | |
;;; Save all tempfiles in $TMPDIR/emacs-$UID/ | |
(defconst emacs-tmp-dir | |
(format "%s/%s%s/" temporary-file-directory "emacs-" (user-uid))) | |
(unless (file-directory-p emacs-tmp-dir) | |
(make-directory emacs-tmp-dir)) | |
(setq backup-directory-alist | |
`(("." . ,emacs-tmp-dir))) | |
(setq undo-tree-history-directory-alist | |
`((".*" . ,emacs-tmp-dir))) | |
(setq auto-save-file-name-transforms | |
`((".*" ,emacs-tmp-dir t))) | |
;;; I want to work on the file, not the backup | |
(setq backup-by-copying t) | |
(use-package emacs | |
:ensure nil | |
:custom | |
(display-time-default-load-average nil) ;; this information is useless for most | |
(auto-revert-avoid-polling t) ;; Automatically reread from disk if the underlying file changes | |
(sentence-end-double-space nil) ;; Fix archaic defaults | |
;; Enables faster scrolling through unfontified regions. This may result in | |
;; brief periods of inaccurate syntax highlighting immediately after scrolling, | |
;; which should quickly self-correct. | |
(fast-but-imprecise-scrolling t) | |
(enable-recursive-minibuffers t) ;; Allow recursive minibuffers | |
(completions-detailed t) ;; Show annotations | |
(electric-indent-mode nil) ;; Turn off the weird indenting that Emacs does by default. | |
(dired-kill-when-opening-new-dired-buffer t) ;; Dired don't create new buffer | |
(mouse-wheel-progressive-speed nil) ;; Disable progressive speed when scrolling | |
(scroll-conservatively 10) ;; Smooth scrolling | |
(tab-width 2) | |
(display-fill-column-indicator-column 80) | |
(column-number-mode t) | |
(require-final-newline t) | |
(make-backup-files nil) ;; Stop creating ~ backup files | |
(auto-save-default nil) ;; Stop creating # auto save files | |
(create-lockfiles nil) ;; Stop creating .# lock files | |
(backhup-inhibited t) ;; Disable backup files | |
(inhibit-startup-message t) | |
(warning-minimum-level :emergency) ;; Set the minimum level of warnings to display. | |
(recentf-mode t) ;; Enable recent files | |
(tool-bar-mode nil) ;; Disable the tool bar for a cleaner interface. | |
(menu-bar-mode nil) ;; Disable the menu bar for a more streamlined look. | |
(tab-bar-show nil) ;; Disable the tab bar | |
(scroll-bar-mode nil) ;; Disable the scroll bar | |
(blink-cursor-mode nil) ;; Don't blink cursor | |
(indent-tabs-mode nil) | |
:hook | |
(prog-mode . (lambda () (hs-minor-mode t))) ;; Enable folding hide/show globally | |
(prog-mode . display-fill-column-indicator-mode) ;; Enable fill column indicator globally | |
:config | |
:bind ( | |
([escape] . keyboard-escape-quit) ;; Makes Escape quit prompts (Minibuffer Escape) | |
)) | |
(use-package window | |
:ensure nil | |
:custom | |
(display-buffer-alist | |
'( | |
("\\*.*e?shell\\*" | |
(display-buffer-in-side-window) | |
(window-height . 0.25) | |
(side . bottom) | |
(slot . -1)) | |
("\\*\\(Backtrace\\|Warnings\\|Compile-Log\\|[Hh]elp\\|Messages\\|Bookmark List\\|Ibuffer\\|Occur\\|eldoc.*\\)\\*" | |
(display-buffer-in-side-window) | |
(window-height . 0.25) | |
(side . bottom) | |
(slot . 0)) | |
))) | |
(use-package diminish | |
:config | |
(diminish 'auto-revert-mode) | |
(diminish 'hs-minor-mode) | |
(diminish 'eldoc-mode)) | |
(use-package which-key | |
:ensure nil | |
:defer t | |
:init | |
(which-key-mode 1) | |
:diminish) | |
(use-package prog-mode | |
:ensure nil | |
:init | |
(add-to-list 'auto-mode-alist '("\\.list$" . prog-mode)) | |
;; Display line numbers | |
:hook | |
(prog-mode . display-line-numbers-mode) ;; linum-mode, but efficient | |
(prog-mode . auto-fill-mode) | |
;; open pairs with extra newline in between, and autoindent | |
(prog-mode . electric-indent-local-mode) | |
(prog-mode . electric-pair-local-mode)) | |
(use-package hl-todo | |
:hook (prog-mode . hl-todo-mode) | |
:config | |
(setq hl-todo-highlight-punctuation ":" | |
hl-todo-keyword-faces | |
`(("TODO" warning bold) | |
("FIXME" error bold) | |
("HACK" font-lock-constant-face bold) | |
("REVIEW" font-lock-keyword-face bold) | |
("NOTE" success bold) | |
("DEPRECATED" font-lock-doc-face bold)))) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; | |
;;; Theme | |
;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; UI | |
(use-package catppuccin-theme | |
:config | |
(setq catppuccin-flavor 'mocha) | |
(catppuccin-reload)) | |
(set-face-attribute 'default nil :font "FiraCode Nerd Font") | |
(use-package nerd-icons | |
:if (display-graphic-p)) | |
(use-package nerd-icons-dired | |
:hook (dired-mode . (lambda () (nerd-icons-dired-mode t)))) | |
(use-package nerd-icons-ibuffer | |
:hook (ibuffer-mode . nerd-icons-ibuffer-mode)) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; | |
;;; Evil | |
;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(use-package evil | |
:init ;; Execute code Before a package is loaded | |
(evil-mode) | |
:config ;; Execute code After a package is loaded | |
(defvar my-leader-map (make-sparse-keymap) | |
"Keymap for \"leader key\" shortcuts.") | |
(defun my/leader (key def) | |
"Define a key in the leader key map." | |
(define-key my-leader-map key def)) | |
(define-key evil-normal-state-map (kbd "SPC") my-leader-map) | |
(define-key evil-visual-state-map (kbd "SPC") my-leader-map) | |
(define-key evil-motion-state-map (kbd "SPC") my-leader-map) | |
(my/leader (kbd "SPC") 'project-find-file) | |
(my/leader (kbd "TAB") 'tab-switch) | |
(my/leader (kbd ";") 'vertico-suspend) | |
(my/leader (kbd "`") (lambda () (interactive) (switch-to-buffer nil))) | |
(my/leader (kbd "x") 'scratch-buffer) | |
(my/leader (kbd "*") (lambda () (interactive) (consult-ripgrep nil (thing-at-point 'symbol)))) | |
(my/leader (kbd "/") 'consult-ripgrep) | |
(my/leader (kbd "p") '("Project" . (keymap))) | |
(my/leader (kbd "p p") 'project-switch-project) | |
(my/leader (kbd "p b") 'project-switch-to-buffer) | |
(my/leader (kbd "p d") 'project-find-dir) | |
(my/leader (kbd "p f") 'project-find-file) | |
(my/leader (kbd "f") '("Find" . (keymap))) | |
(my/leader (kbd "f r") 'consult-recent-file) | |
(my/leader (kbd "f f") 'find-file) | |
(my/leader (kbd "f g") 'consult-ripgrep) | |
(my/leader (kbd "f d") 'find-grep-dired) | |
(my/leader (kbd "f m") 'consult-mark) | |
(my/leader (kbd "f l") 'consult-line) | |
(my/leader (kbd "f i") 'consult-imenu) | |
(my/leader (kbd "b") '("Buffer" . (keymap))) | |
(my/leader (kbd "b b") 'consult-buffer) | |
(my/leader (kbd "b k") 'kill-this-buffer) | |
(my/leader (kbd "b i") 'ibuffer) | |
(my/leader (kbd "b n") 'next-buffer) | |
(my/leader (kbd "b p") 'previous-buffer) | |
(my/leader (kbd "b r") 'revert-buffer) | |
(my/leader (kbd "b j") 'consult-bookmark) | |
(my/leader (kbd "b s") 'bookmark-set) | |
(my/leader (kbd "b d") 'bookmark-delete) | |
(my/leader (kbd "b D") 'bookmark-delete-all) | |
(my/leader (kbd "b z") 'my/toggle-maximize-buffer) | |
(my/leader (kbd "d") '("Directory" . (keymap))) | |
(my/leader (kbd "d v") 'dired) | |
(my/leader (kbd "d j") 'dired-jump) | |
(my/leader (kbd "c") '("Code" . (keymap))) | |
(my/leader (kbd "c r") 'eglot-rename) | |
(my/leader (kbd "c e") 'eglot-reconnect) | |
(my/leader (kbd "c a") 'eglot-code-actions) | |
(my/leader (kbd "c f") 'apheleia-format-buffer) | |
(my/leader (kbd "c l") 'consult-flymake) | |
(my/leader (kbd "e") '("Eval" . (keymap))) | |
(my/leader (kbd "e b") 'eval-buffer) | |
(my/leader (kbd "e r") 'eval-region) | |
(my/leader (kbd "o") '("Org" . (keymap))) | |
(my/leader (kbd "o a") 'org-agenda) | |
(my/leader (kbd "o c") 'org-capture) | |
(my/leader (kbd "o l") 'org-store-link) | |
(my/leader (kbd "o f") 'consult-org-agenda) | |
(my/leader (kbd "g") '("Git" . (keymap))) | |
(my/leader (kbd "g g") 'magit-status) | |
(my/leader (kbd "h") '("Emacs" . (keymap))) | |
(my/leader (kbd "h q") 'save-buffers-kill-emacs) | |
(my/leader (kbd "h c") '("Edit init.el" . (lambda () (interactive) (find-file (expand-file-name "init.el" user-emacs-directory))))) | |
(my/leader (kbd "h r") '("Reload init.el" . (lambda () (interactive) (load-file (expand-file-name "init.el" user-emacs-directory))))) | |
(my/leader (kbd "t") '("Toggle / Tabs" . (keymap))) | |
(my/leader (kbd "t n") 'tab-new) | |
(my/leader (kbd "t t") 'consult-theme) | |
(my/leader (kbd "t w") 'visual-line-mode) | |
(my/leader (kbd "t l") 'display-line-numbers-mode) | |
(evil-define-operator my-evil-comment-or-uncomment (beg end) | |
"Toggle comment for the region between BEG and END." | |
(interactive "<r>") | |
(comment-or-uncomment-region beg end)) | |
(evil-define-key 'normal 'global (kbd "gc") 'my-evil-comment-or-uncomment) | |
:custom ;; Customization of package custom variables | |
(evil-want-keybinding nil) ;; Disable evil bindings in other modes (It's not consistent and not good) | |
(evil-want-C-u-scroll t) ;; Set C-u to scroll up | |
(evil-want-C-i-jump nil) ;; Disables C-i jump | |
(evil-undo-system 'undo-redo) ;; C-r to redo | |
(org-return-follows-link t) ;; Sets RETURN key in org-mode to follow links | |
;; Unmap keys in 'evil-maps. If not done, org-return-follows-link will not work | |
:bind (:map evil-motion-state-map | |
("SPC" . nil) | |
("RET" . nil) | |
("TAB" . nil))) | |
(use-package evil-collection | |
:after evil | |
:diminish evil-collection-unimpaired-mode | |
:config | |
;; Setting where to use evil-collection | |
;;(setq evil-collection-mode-list '(dired ibuffer magit corfu vertico consult)) | |
(evil-collection-init)) | |
(use-package eat :ensure t :defer t) | |
(setq project-switch-commands '((project-find-file "Find file" "f") | |
(project-find-dir "Find dir" "d") | |
(project-switch-to-buffer "Switch buffer" "b") | |
(project-dired "Dired" "D") | |
(consult-ripgrep "ripgrep" "/") | |
(magit-project-status "Magit" "g"))) | |
(use-package yasnippet-snippets | |
:defer t | |
:diminish yas-minor-mode | |
:hook (prog-mode . yas-minor-mode)) | |
(use-package org | |
:ensure nil | |
:defer t | |
:config | |
(setq org-directory "~/org") | |
(setq org-agenda-files (list org-directory)) | |
(setq org-capture-templates | |
'(("t" "Todo" entry (file+headline "~/org/todo.org" "Inbox") | |
"* TODO %?" :prepend t) | |
("n" "Note" entry (file+headline "~/org/notes.org" "Inbox") | |
"* %?" :prepend t) | |
("j" "Journal" entry (file+datetree "~/org/journal.org") | |
"* %?"))) | |
:hook | |
(org-mode . org-indent-mode)) | |
(use-package magit | |
;; FIXME: https://www.reddit.com/r/emacs/comments/1954ay9/magit_depends_on_transient_050_on_emacs_291/ | |
:after transient | |
:defer t) | |
(use-package diff-hl | |
:hook ((dired-mode . diff-hl-dired-mode-unless-remote) | |
(magit-pre-refresh . diff-hl-magit-pre-refresh) | |
(magit-post-refresh . diff-hl-magit-post-refresh)) | |
:init (global-diff-hl-mode)) | |
(use-package corfu | |
:defer t | |
:custom | |
(corfu-cycle t) ;; Enable cycling for `corfu-next/previous' | |
(corfu-auto t) ;; Enable auto completion | |
(corfu-auto-prefix 2) ;; Minimum length of prefix for auto completion. | |
(corfu-popupinfo-mode t) ;; Enable popup information | |
(corfu-popupinfo-delay 0.5) ;; Lower popupinfo delay to 0.5 seconds from 2 seconds | |
(corfu-separator ?\s) ;; Orderless field separator, Use M-SPC to enter separator | |
(completion-ignore-case t) | |
;; Enable indentation+completion using the TAB key. | |
;; `completion-at-point' is often bound to M-TAB. | |
(tab-always-indent 'complete) | |
(corfu-preview-current nil) ;; Don't insert completion without confirmation | |
;; Recommended: Enable Corfu globally. This is recommended since Dabbrev can | |
;; be used globally (M-/). See also the customization variable | |
;; `global-corfu-modes' to exclude certain modes. | |
:init | |
(global-corfu-mode)) | |
(use-package nerd-icons-corfu | |
:after corfu | |
:init (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter)) | |
(use-package wgrep :defer t) | |
(use-package cape | |
:defer t | |
:after corfu | |
:init | |
(add-to-list 'completion-at-point-functions #'cape-dabbrev) ;; Complete word from current buffers | |
(add-to-list 'completion-at-point-functions #'cape-dict) ;; Dictionary completion | |
(add-to-list 'completion-at-point-functions #'cape-file) ;; Path completion | |
(add-to-list 'completion-at-point-functions #'cape-elisp-block) ;; Complete elisp in Org or Markdown mode | |
(add-to-list 'completion-at-point-functions #'cape-keyword) ;; Keyword/Snipet completion | |
) | |
(use-package vertico | |
;; (Note: It is recommended to also enable the savehist package.) | |
:bind (:map vertico-map | |
("C-h" . vertico-directory-up) | |
("C-l" . vertico-insert) | |
("C-j" . vertico-next) | |
("C-k" . vertico-previous)) | |
:defer t | |
:init | |
(vertico-mode)) | |
(use-package orderless | |
;; 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. | |
:custom | |
(completion-styles '(orderless basic)) | |
(completion-category-defaults nil) | |
(completion-category-overrides '((file (styles partial-completion))))) | |
(use-package marginalia | |
;; Marginalia allows Embark to offer you preconfigured actions in more contexts. | |
;; In addition to that, Marginalia also enhances Vertico by adding rich | |
;; annotations to the completion candidates displayed in Vertico's interface. | |
:defer t | |
:commands (marginalia-mode marginalia-cycle) | |
:hook (after-init . marginalia-mode)) | |
(use-package nerd-icons-completion | |
:after marginalia | |
:config | |
(nerd-icons-completion-mode) | |
:hook | |
('marginalia-mode-hook . 'nerd-icons-completion-marginalia-setup)) | |
(use-package consult | |
:bind (("C-c M-x" . consult-mode-command)) | |
;; 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) | |
: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 "<")) | |
(use-package embark | |
:defer t | |
:bind | |
(("C-." . embark-act) ;; pick some comfortable binding | |
("C-;" . embark-dwim) ;; good alternative: M-. | |
("C-c C-e" . embark-export) ;; export to buffer | |
("C-c C-c" . embark-collect) ;; collect to buffer | |
("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)) | |
(use-package editorconfig | |
:defer t | |
:diminish editorconfig-mode | |
:init | |
(editorconfig-mode 1)) | |
;;; eglot + snippets | |
(use-package eglot | |
:ensure nil | |
:hook | |
(eglot-managed-mode . my/flymake-eslint-enable-maybe) | |
:config | |
(fset #'jsonrpc--log-event #'ignore) ;; massive perf boost---don't log every event | |
:custom | |
;; Good default | |
(eglot-send-changes-idle-time 0.1) | |
(eglot-extend-to-xref t) ;; activate Eglot in referenced non-project files | |
(eglot-events-buffer-size 0) ;; No event buffers (Lsp server logs) | |
(eglot-autoshutdown t);; Shutdown unused servers. | |
(eglot-report-progress nil) ;; Disable lsp server logs (Don't show lsp messages at the bottom, java) | |
:init | |
(setq completion-category-overrides '((eglot (styles orderless)))) | |
(add-hook 'eglot-managed-mode-hook | |
(lambda () | |
(eglot-inlay-hints-mode -1)))) | |
(use-package eglot-booster | |
:ensure (:host github :repo "jdtsmith/eglot-booster") | |
:after eglot | |
:config (eglot-booster-mode)) | |
(use-package markdown-mode :defer t) | |
(use-package copilot | |
:ensure (:host github :repo "copilot-emacs/copilot.el") | |
:defer t | |
:diminish | |
:hook (prog-mode . copilot-mode) | |
:bind (("<C-return>" . copilot-accept-completion))) | |
(use-package treesit-auto | |
:config | |
(global-treesit-auto-mode)) | |
;;; Typescript | |
(use-package typescript-ts-mode | |
:ensure nil | |
:config | |
(add-to-list 'auto-mode-alist '("\\.mjs\\'" . js-ts-mode)) | |
(add-to-list 'auto-mode-alist '("\\.cjs\\'" . js-ts-mode)) | |
(add-hook 'js-ts-mode-hook 'eglot-ensure) | |
(add-hook 'typescript-ts-mode-hook 'eglot-ensure) | |
(add-hook 'tsx-ts-mode-hook 'eglot-ensure) | |
(add-hook 'ts-mode-hook 'eglot-ensure)) | |
(use-package flymake-eslint | |
:functions flymake-eslint-enable | |
:preface | |
(defun my/flymake-eslint-enable-maybe () | |
"Enable `flymake-eslint' based on the project configuration. | |
Search for the project ESLint configuration to determine whether the buffer | |
should be checked." | |
(when-let* ((root (locate-dominating-file (buffer-file-name) ".git")) | |
(rc (locate-file ".eslintrc" (list root) '(".js" ".json")))) | |
(make-local-variable 'exec-path) | |
(push (file-name-concat root "node_modules" ".bin") exec-path) | |
(flymake-eslint-enable)))) | |
(use-package jest-test-mode | |
:ensure t | |
:commands jest-test-mode | |
:hook (typescript-mode js-mode typescript-tsx-mode | |
typescript-ts-mode js-ts-mode tsx-ts-mode)) | |
(use-package eglot | |
:ensure nil | |
:config | |
(add-to-list 'eglot-server-programs | |
'(typescript-mode "tailwindcss-language-server") | |
'(ts-mode "tailwindcss-language-server") | |
'(typescript-tsx-mode "tailwindcss-language-server") | |
'(typescript-ts-mode "tailwindcss-language-server") | |
'(js-mode "tailwindcss-language-server") | |
'(js-ts-mode "tailwindcss-language-server") | |
'(tsx-ts-mode "tailwindcss-language-server"))) | |
(use-package apheleia | |
:diminish | |
:defer t | |
:hook (prog-mode . apheleia-mode)) | |
;;; Nix | |
(use-package nix-mode | |
:mode "\\.nix\\'") | |
;; C/C++ | |
(use-package cc-mode | |
:ensure nil | |
:hook | |
((c-mode . eglot-ensure) | |
(c-ts-mode . eglot-ensure) | |
(c++-mode . eglot-ensure) | |
(c++-ts-mode . eglot-ensure))) | |
;; Platformio | |
(use-package platformio-mode | |
:defer t | |
:hook (c++-mode . platformio-conditionally-enable) | |
(c++-ts-mode . platformio-conditionally-enable)) | |
;;; Python | |
;; pip install "python-lsp-server[all]" | |
(use-package python | |
:ensure nil | |
:hook | |
((python-ts-mode . eglot-ensure) | |
(python-mode . eglot-ensure))) | |
;;; Rust | |
(use-package rust-mode | |
:mode "\\.rs\\'" | |
:hook | |
((rust-mode . eglot-ensure) | |
(rust-ts-mode . eglot-ensure))) | |
;;; Go | |
(use-package go-mode | |
:mode "\\.go\\'" | |
:hook | |
((go-mode . eglot-ensure) | |
(go-ts-mode . eglot-ensure))) | |
;;; Zig | |
(use-package zig-mode | |
:mode "\\.zig\\'" | |
:hook | |
((zig-mode . eglot-ensure) | |
(zig-ts-mode . eglot-ensure))) | |
;;; Nim | |
(use-package nim-mode | |
:mode "\\.nim\\'" | |
:hook | |
((nim-mode . eglot-ensure) | |
(nim-ts-mode . eglot-ensure))) | |
(use-package eglot | |
:ensure nil | |
:config | |
(add-to-list 'eglot-server-programs | |
'(nim-mode "nimlsp"))) | |
;; YAML | |
(use-package yaml-mode | |
:mode "\\.ya?ml\\'") | |
;; Nickel | |
(use-package nickel-mode | |
:mode "\\.ncl\\'" | |
:config | |
(add-to-list 'eglot-server-programs | |
'(nickel-mode "nls")) | |
:hook | |
((nickel-mode . eglot-ensure))) | |
;;;;;;;;;;;;;;;;;;;;;; | |
;; CUSTOM FUNCTIONS ;; | |
;;;;;;;;;;;;;;;;;;;;;; | |
;; An Emacs function to temporarily make one buffer fullscreen. You can | |
;; quickly restore the old window setup. | |
;; https://gist.github.com/mads-hartmann/3402786 | |
(defun my/toggle-maximize-buffer () "Maximize buffer" | |
(interactive) | |
(if (= 1 (length (window-list))) | |
(jump-to-register '_) | |
(progn | |
(window-configuration-to-register '_) | |
(delete-other-windows)))) | |
(custom-set-variables | |
;; custom-set-variables was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
'(package-selected-packages '(eglot))) | |
(custom-set-faces | |
;; custom-set-faces was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you need to redefine
emacs-startup-hook
ininit.el
?