Last active
August 28, 2024 23:33
-
-
Save axyz/76871b404df376271b521212fba8a621 to your computer and use it in GitHub Desktop.
.emacs.d
This file contains 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
;;; Package --- Summary -*- 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)))) | |
;;; performance | |
;; In noninteractive sessions, prioritize non-byte-compiled source files to | |
;; prevent the use of stale byte-code. Otherwise, it saves us a little IO time | |
;; to skip the mtime checks on every *.elc file. | |
(setq load-prefer-newer noninteractive) | |
;; increase how much is read from processes in a single chunk (default is 4kb). | |
(setq read-process-output-max (* 512 1024)) ; 512kb | |
(unless (or (daemonp) noninteractive) | |
;; Site files tend to use `load-file', which emits "Loading X..." messages in | |
;; the echo area, which in turn triggers a redisplay. Redisplays can have a | |
;; substantial effect on startup times and in this case happens so early that | |
;; Emacs may flash white while starting up. | |
(define-advice load-file (:override (file) silence) | |
(load file nil 'nomessage)) | |
;; Undo our `load-file' advice above, to limit the scope of any edge cases it | |
;; may introduce down the road. | |
(define-advice startup--load-user-init-file (:before (&rest _) init-doom) | |
(advice-remove #'load-file #'load-file@silence))) | |
;;; disable package.el | |
(setq package-enable-at-startup 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) | |
;; 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 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 --- Summary -*- lexical-binding: t; -*- | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; | |
;;; Package management | |
;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; bootstrap elpaca | |
(defvar elpaca-installer-version 0.7) | |
(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 | |
: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 | |
;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Startup speed, annoyance suppression | |
;; | |
;; We have started, bring gc threshold back down | |
(setq doom-gc-cons-threshold (* 16 1024 1024)) ;; 16 MB | |
(add-hook 'emacs-startup-hook | |
(lambda () | |
(setq gc-cons-threshold doom-gc-cons-threshold | |
gc-cons-percentage 0.1))) | |
;; 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 doom-gc-cons-threshold)))) | |
(add-hook 'minibuffer-setup-hook #'doom-defer-garbage-collection-h) | |
(add-hook 'minibuffer-exit-hook #'doom-restore-garbage-collection-h) | |
;; garbage collection is hard, let a library do it | |
(use-package gcmh | |
:delight (gcmh-mode) | |
:commands (gcmh-mode) | |
:functions (gcmh-idle-garbage-collect) | |
:custom | |
(gcmh-idle-delay 'auto) | |
(gcmh-auto-idle-delay-factor 10) | |
(gcmh-high-cons-threshold (* 16 1024 1024)) | |
(gcmh-verbose nil) | |
:hook | |
(emacs-startup-hook . gcmh-mode)) | |
(setq byte-compile-warnings '(not obsolete)) | |
(setq warning-suppress-log-types '((comp) (bytecomp))) | |
;;; auto-byte-compile | |
(setq load-prefer-newer t) | |
(use-package auto-compile | |
:config | |
'((auto-compile-on-load-mode) | |
(auto-compile-on-save-mode))) | |
;; file encoding | |
(prefer-coding-system 'utf-8) | |
(setq buffer-file-coding-system 'utf-8) | |
;; 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 | |
(recentf-mode t) ;; Enable recent files | |
(enable-recursive-minibuffers t) ;; Allow recursive minibuffers | |
(completions-detailed t) ;; Show annotations | |
(scroll-bar-mode nil) ;; Disable the scroll bar | |
(tool-bar-mode nil) ;; Disable the tool bar | |
(electric-indent-mode nil) ;; Turn off the weird indenting that Emacs does by default. | |
(blink-cursor-mode nil) ;; Don't blink cursor | |
(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 | |
(indent-tabs-mode nil) | |
(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 | |
: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 diminish | |
:config | |
(diminish 'auto-revert-mode) | |
(diminish 'hs-minor-mode) | |
(diminish 'eldoc-mode)) | |
(use-package which-key | |
: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)) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; | |
;;; 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 | |
(evil-set-initial-state 'vterm-mode 'insert) ;; Set initial state in eat terminal to insert mode | |
(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") 'comment-line) | |
(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 "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 q") 'save-buffers-kill-emacs) | |
(my/leader (kbd "h c") (lambda () (interactive) (find-file (expand-file-name "init.el" user-emacs-directory)))) | |
(my/leader (kbd "h r") (lambda () (interactive) (load-file (expand-file-name "init.el" user-emacs-directory)))) | |
(my/leader (kbd "t") '("Toggle" . (keymap))) | |
(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)) | |
;;; vterm | |
(use-package vterm :defer t) | |
(use-package vterm-toggle | |
:defer t | |
:bind | |
("C-'" . vterm-toggle) | |
:custom | |
(vterm-toggle-scope 'project) | |
(vterm-toggle-fullscreen-p nil) | |
(vterm-toggle-cd-auto-create-buffer nil) | |
:config | |
(add-to-list 'display-buffer-alist | |
'((lambda (buffer-or-name _) | |
(let ((buffer (get-buffer buffer-or-name))) | |
(with-current-buffer buffer | |
(or (equal major-mode 'vterm-mode) | |
(string-prefix-p vterm-buffer-name (buffer-name buffer)))))) | |
(display-buffer-reuse-window display-buffer-in-side-window) | |
(side . bottom) | |
(dedicated . t) ;dedicated is supported in emacs27 | |
(reusable-frames . visible) | |
(window-height . 0.3)))) | |
(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 | |
:config | |
(setq org-directory "~/org") | |
(setq org-agenda-files (list org-directory)) | |
: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 ((after-save . eglot-format)) | |
:hook | |
(eglot-managed-mode . my/flymake-eslint-enable-maybe) | |
:custom | |
;; Good default | |
(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 apheleia | |
:diminish | |
:defer t | |
:hook (prog-mode . apheleia-mode)) |
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
?