Guest User

ForsakenService-Emacs config

a guest
Dec 7th, 2025
28
0
6 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 29.08 KB | Source Code | 0 0
  1. ;; init.el --- Main Emacs configuration -*- lexical-binding: t; -*-
  2.  
  3. ;; Increase garbage collection threshold during startup
  4. (setq gc-cons-threshold most-positive-fixnum
  5.       gc-cons-percentage 0.6)
  6.  
  7. ;; Configure native compilation to use Homebrew GCC
  8. (when (and (fboundp 'native-comp-available-p)
  9.            (native-comp-available-p))
  10.   (setq native-comp-driver-options
  11.         (list "-L" "/usr/local/opt/gcc/lib/gcc/current"
  12.               "-I" "/usr/local/opt/gcc/include"))
  13.   ;; Speed up native compilation
  14.   (setq native-comp-speed 2)
  15.   (setq native-comp-async-jobs-number 4))
  16.  
  17. ;; Suppress native-comp warnings during async compilation
  18. (setq native-comp-async-report-warnings-errors nil)
  19.  
  20. ;; macOS-specific performance tweaks
  21. (when (eq system-type 'darwin)
  22.   ;; Disable frame resize animation (reduces lag)
  23.   (setq frame-resize-pixelwise t)
  24.   ;; Faster scrolling on macOS
  25.   (setq mac-mouse-wheel-smooth-scroll nil)
  26.   ;; Reduce input latency
  27.   (setq mac-redisplay-dont-reset-vscroll t)
  28.   ;; Better font rendering
  29.   (setq mac-allow-anti-aliasing t))
  30.  
  31. ;; Reduce rendering overhead
  32. (setq fast-but-imprecise-scrolling t)
  33. (setq redisplay-skip-fontification-on-input t)
  34.  
  35. ;; Disable bidirectional text scanning for performance
  36. (setq-default bidi-display-reordering nil)
  37. (setq bidi-inhibit-bpa t)
  38.  
  39. (use-package diminish :ensure t)
  40.  
  41. ;; Reduce GC after init (but keep it reasonable)
  42. (add-hook 'emacs-startup-hook
  43.           (lambda ()
  44.             (setq gc-cons-threshold (* 100 1024 1024) ; 100MB
  45.                   gc-cons-percentage 0.1)))
  46.  
  47. ;; Run GC when Emacs loses focus (prevents pauses during editing)
  48. (add-hook 'focus-out-hook #'garbage-collect)
  49.  
  50. ;;keeping the files clean
  51. (setq make-backup-files nil)
  52. (setq backup-inhibited nil) ; Not sure if needed, given `make-backup-files'
  53. (setq create-lockfiles nil)
  54.  
  55. ;; Disable the damn thing by making it disposable.
  56. (setq custom-file (make-temp-file "emacs-custom-"))
  57.  
  58. ;; Initialize package sources
  59. (setq package-archives '(("melpa" . "https://melpa.org/packages/")
  60.                          ("org" . "https://orgmode.org/elpa/")
  61.                          ("elpa" . "https://elpa.gnu.org/packages/")))
  62.  
  63. (unless package-archive-contents
  64.  (package-refresh-contents));;suppress the warnings
  65.  
  66. (use-package gcmh
  67.   :ensure t
  68.   :diminish
  69.   :config
  70.   (setq gcmh-idle-delay 15)  ; Run GC after 15 seconds of idle time (instead of 5)
  71.   (setq gcmh-high-cons-threshold (* 128 1024 1024))  ; 128MB
  72.   (gcmh-mode 1))
  73.  
  74.  ;; Make sure Emacs inherits the shell PATH
  75. (use-package exec-path-from-shell
  76.   :ensure t
  77.   :if (memq window-system '(mac ns x))
  78.   :config
  79.   ;; Only copy essential variables for speed
  80.   (setq exec-path-from-shell-variables '("PATH" "MANPATH" "GOPATH"))
  81.   (setq exec-path-from-shell-check-startup-files nil)
  82.   (exec-path-from-shell-initialize))
  83.  
  84. ;; Treat Mac Command as Meta
  85. (setq mac-command-modifier 'meta)
  86.  
  87.  
  88. ;; ----------------------------------------
  89. ;; 3. Init (runs before package is loaded)
  90. ;; ----------------------------------------
  91. :init
  92. (tool-bar-mode -1)
  93. (menu-bar-mode 1)
  94. (when scroll-bar-mode
  95. (scroll-bar-mode -1))
  96. (global-hl-line-mode -1)                        ;; No line highlight
  97. (global-auto-revert-mode 1)
  98. (setq indent-tabs-mode nil)                     ;; Use spaces
  99. (recentf-mode 1)
  100. (savehist-mode 1)
  101. (save-place-mode 1)
  102. (winner-mode 1)
  103. (xterm-mouse-mode 1)
  104. (file-name-shadow-mode 1)
  105.  
  106. (use-package modus-themes
  107.   :ensure nil
  108.    :init
  109.   (load-theme 'modus-vivendi t))
  110.  
  111.  
  112. (setq-default frame-title-format "")
  113. (set-frame-parameter nil 'ns-transparent-titlebar t)
  114. (add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
  115.  
  116. (use-package minions
  117.   :ensure t
  118.   :custom
  119.   (mode-line-modes-delimiters nil)
  120.   (minions-mode-line-lighter " …")
  121.   :config
  122.   (minions-mode +1)
  123.   (force-mode-line-update t))
  124.  
  125. (use-package moody
  126.   :ensure t
  127.   :config
  128.   (setq-default mode-line-format
  129.                 '(""
  130.                   mode-line-front-space
  131.                   mode-line-client
  132.                   mode-line-frame-identification
  133.                   mode-line-buffer-identification
  134.                   " "
  135.                   mode-line-position
  136.                   (vc-mode vc-mode)
  137.                   (multiple-cursors-mode mc/mode-line)
  138.                   mode-line-modes
  139.                   mode-line-end-spaces))
  140.   (moody-replace-mode-line-buffer-identification)
  141.   (moody-replace-vc-mode))
  142.  
  143.  
  144. (use-package nyan-mode
  145.   :ensure t
  146.   :custom
  147.   (nyan-bar-length 10)
  148.   :config
  149.   (nyan-mode +1))
  150.  
  151.  
  152.  
  153.  
  154. (use-package ligature
  155.   :ensure t
  156.   :config
  157.   ;; Enable the "www" ligature in every possible major mode
  158.   (ligature-set-ligatures 't '("www"))
  159.   ;; Enable traditional ligature support in eww-mode, if the
  160.   ;; `variable-pitch' face supports it
  161.   (ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi"))
  162.   ;; Enable all Cascadia Code ligatures in programming modes
  163.   (ligature-set-ligatures 'prog-mode '("|||>" "<|||" "<==>" "<!--" "####" "~~>" "***" "||=" "||>"
  164.                                         ":::" "::=" "=:=" "===" "==>" "=!=" "=>>" "=<<" "=/=" "!=="
  165.                                         "!!." ">=>" ">>=" ">>>" ">>-" ">->" "->>" "-->" "---" "-<<"
  166.                                         "<~~" "<~>" "<*>" "<||" "<|>" "<$>" "<==" "<=>" "<=<" "<->"
  167.                                         "<--" "<-<" "<<=" "<<-" "<<<" "<+>" "</>" "###" "#_(" "..<"
  168.                                         "..." "+++" "/==" "///" "_|_" "www" "&&" "^=" "~~" "~@" "~="
  169.                                         "~>" "~-" "**" "*>" "*/" "||" "|}" "|]" "|=" "|>" "|-" "{|"
  170.                                         "[|" "]#" "::" ":=" ":>" ":<" "$>" "==" "=>" "!=" "!!" ">:"
  171.                                         ">=" ">>" ">-" "-~" "-|" "->" "--" "-<" "<~" "<*" "<|" "<:"
  172.                                         "<$" "<=" "<>" "<-" "<<" "<+" "</" "#{" "#[" "#:" "#=" "#!"
  173.                                         "##" "#(" "#?" "#_" "%%" ".=" ".-" ".." ".?" "+>" "++" "?:"
  174.                                         "?=" "?." "??" ";;" "/*" "/=" "/>" "//" "__" "~~" "(*" "*)"
  175.                                         "\\\\" "://"))
  176.   ;; per mode with `ligature-mode'.
  177.   (global-ligature-mode t))
  178.  
  179. (set-face-attribute 'default nil
  180.   :family "CaskaydiaCove Nerd Font"
  181.   :weight 'Semilight
  182.   :height 180)
  183.  
  184. ;; Variable pitch (UI, headings, org, etc.)
  185. (set-face-attribute 'variable-pitch nil
  186.   :family "DejaVu Sans"
  187.   :height 180)
  188.  
  189. ;; Symbol font (for Unicode/math symbols)
  190. (set-fontset-font t 'symbol "JuliaMono")
  191.  
  192.  
  193. ;; Big font toggle for presentations
  194. (defun my/toggle-big-font ()
  195.   "This is to make the font BIG when screensharing."
  196.   (interactive)
  197.   (if (= (face-attribute 'default :height) 170)
  198.       (set-face-attribute 'default nil :height 220)
  199.     (set-face-attribute 'default nil :height 170)))
  200.  
  201. (global-set-key (kbd "<f9>") #'my/toggle-big-font)
  202.  
  203.  
  204. ;; Make sure ANSI color escapes are honored
  205. (require 'ansi-color)
  206. (ansi-color-for-comint-mode-on)
  207.  
  208. ;; ============================================================
  209. ;; Core Emacs settings
  210. ;; ============================================================
  211. (use-package emacs
  212.   :ensure nil
  213.  
  214.   :custom
  215.   (column-number-mode t)                          ;; Show column number in mode line
  216.   (auto-save-default nil)                         ;; Disable auto-save
  217.   (create-lockfiles nil)                          ;; No .# lockfiles
  218.   (delete-by-moving-to-trash t)                   ;; Move deleted files to trash
  219.   (delete-selection-mode 1)                       ;; Typing replaces selected text
  220.   ; (display-line-numbers-type 'visual)             ;; Relative line numbering
  221.   (display-line-numbers-type 'absolute)             ;; Relative line numbering
  222.   (global-auto-revert-non-file-buffers t)          ;; Auto-refresh non-file buffers
  223.   (history-length 25)                             ;; Command history length
  224.   (inhibit-startup-message t)                     ;; No startup message
  225.   (initial-scratch-message "")                    ;; Empty *scratch* buffer
  226.   (ispell-dictionary "en_US")                     ;; Spell-check dictionary
  227.   (make-backup-files nil)                         ;; No backup~ files
  228.   (pixel-scroll-precision-mode t)                 ;; Smooth scrolling
  229.   (pixel-scroll-precision-use-momentum nil)       ;; No inertial scrolling
  230.   (ring-bell-function 'ignore)                    ;; No bell sound
  231.   (split-width-threshold 300)                     ;; Only split if wide enough
  232.   (switch-to-buffer-obey-display-actions t)       ;; Respect display actions
  233.   (tab-always-indent 'complete)                   ;; TAB = indent or complete
  234.   (tab-width 4)                                   ;; Tab size
  235.   (treesit-font-lock-level 4)                     ;; Treesit max font lock
  236.   (truncate-lines t)                              ;; Don't wrap lines
  237.   (use-dialog-box nil)                            ;; No GUI dialogs
  238.   (use-short-answers t)                           ;; y/n instead of yes/no
  239.   (warning-minimum-level :emergency)              ;; Hide most warnings
  240.  
  241.   ;; ----------------------------------------
  242.   ;; Hooks
  243.   ;; ----------------------------------------
  244.   :hook
  245.   (prog-mode . display-line-numbers-mode)         ;; Line numbers in code
  246.  
  247.   ;; ----------------------------------------
  248.   ;; Config (runs after package is loaded)
  249.   ;; ----------------------------------------
  250.   :config
  251.   ;; Fullscreen by default
  252.   (add-to-list 'default-frame-alist '(fullscreen . maximized))
  253.  
  254.   ;; Remove title bar & round corners
  255.   (when (display-graphic-p)
  256.     (add-to-list 'default-frame-alist '(undecorated . t))
  257.     (add-to-list 'default-frame-alist '(undecorated-round . t)))
  258.  
  259.   ;; Use │ instead of |
  260.   (set-display-table-slot standard-display-table
  261.                           'vertical-border
  262.                           (make-glyph-code ?│)))
  263.  
  264.  
  265. ;; ============================================================
  266. ;; Windows Emacs settings
  267. ;; ============================================================
  268. (use-package window
  269.   :ensure nil
  270.   :custom
  271.   (display-buffer-alist
  272.    '(
  273.      ;; ("\\*.*e?shell\\*"
  274.      ;;  (display-buffer-in-side-window)
  275.      ;;  (window-height . 0.25)
  276.      ;;  (side . bottom)
  277.      ;;  (slot . -1))
  278.  
  279.      ("\\*\\(Backtrace\\|Warnings\\|Compile-Log\\|[Hh]elp\\|Messages\\|Bookmark List\\|Ibuffer\\|Occur\\|eldoc.*\\)\\*"
  280.       (display-buffer-in-side-window)
  281.       (window-height . 0.25)
  282.       (side . bottom)
  283.       (slot . 0))
  284.  
  285.      ;; Example configuration for the LSP help buffer,
  286.      ;; keeps it always on bottom using 25% of the available space:
  287.      ("\\*\\(lsp-help\\)\\*"
  288.       (display-buffer-in-side-window)
  289.       (window-height . 0.25)
  290.       (side . bottom)
  291.       (slot . 0))
  292.  
  293.      ;; Configuration for displaying various diagnostic buffers on
  294.      ;; bottom 25%:
  295.      ("\\*\\(Flymake diagnostics\\|xref\\|ivy\\|Swiper\\|Completions\\)"
  296.       (display-buffer-in-side-window)
  297.       (window-height . 0.25)
  298.       (side . bottom)
  299.       (slot . 1))
  300.      )))
  301.  
  302. ;; Pulsar configuration
  303. (use-package pulsar
  304.   :ensure t
  305.   :config
  306.   (setq pulsar-pulse t
  307.         pulsar-delay 0.055
  308.         pulsar-iterations 10
  309.         pulsar-face 'pulsar-magenta  ; Use built-in pulsar face instead of evil face
  310.         pulsar-highlight-face 'pulsar-yellow)
  311.  
  312.   ;; Remove problematic evil faces from pulsar
  313.   (setq pulsar-pulse-functions
  314.         '(recenter-top-bottom
  315.           move-to-window-line-top-bottom
  316.           reposition-window
  317.           bookmark-jump
  318.           other-window
  319.           delete-window
  320.           delete-other-windows
  321.           forward-page
  322.           backward-page
  323.           scroll-up-command
  324.           scroll-down-command
  325.           windmove-right
  326.           windmove-left
  327.           windmove-up
  328.           windmove-down))
  329.  
  330.   (pulsar-global-mode 1))
  331.  
  332. (use-package marginalia
  333.   :ensure t
  334.   :hook (after-init . marginalia-mode))
  335.  
  336. (use-package orderless
  337.   :ensure t
  338.   :config
  339.   (setq completion-styles '(orderless basic))
  340.   (setq completion-category-defaults nil)
  341.   ;; Keep orderless for fast fuzzy matching everywhere
  342.   ;; For traditional TAB completion on files, use RET to select instead
  343.   (setq completion-category-overrides nil))
  344.  
  345. (use-package savehist
  346.   :ensure nil ; it is built-in
  347.   :hook (after-init . savehist-mode))
  348.  
  349.  
  350. (use-package corfu
  351.   :ensure t
  352.   :hook (after-init . global-corfu-mode)
  353.   :bind (:map corfu-map ("<tab>" . corfu-complete))
  354.   :config
  355.   (setq tab-always-indent 'complete)
  356.   (setq corfu-preview-current nil)
  357.   (setq corfu-min-width 20)
  358.  
  359.   (setq corfu-popupinfo-delay '(1.25 . 0.5))
  360.   (corfu-popupinfo-mode 1) ; shows documentation after `corfu-popupinfo-delay'
  361.  
  362. ;;; NERD-ICONS-CORFU
  363. ;; Provides Nerd Icons to be used with CORFU.
  364. (defvar ek-use-nerd-fonts t
  365.   "If non-nil, enable nerd-icons support.")
  366. (use-package nerd-icons-corfu
  367.   :if ek-use-nerd-fonts
  368.   :ensure t
  369.   :defer t
  370.   :after (:all corfu))
  371.  
  372.   ;; Sort by input history (no need to modify `corfu-sort-function').
  373.   (with-eval-after-load 'savehist
  374.     (corfu-history-mode 1)
  375.     (add-to-list 'savehist-additional-variables 'corfu-history)))
  376.  
  377. ;;; CONSULT
  378. ;; Consult provides powerful completion and narrowing commands for Emacs.
  379. ;; It integrates well with other completion frameworks like Vertico, enabling
  380. ;; features like previews and enhanced register management. It's useful for
  381. ;; navigating buffers, files, and xrefs with ease.
  382. (use-package consult
  383.   :ensure t
  384.   :demand t; load immdiatly
  385.   :init
  386.   ;; Enhance register preview with thin lines and no mode line.
  387.   (advice-add #'register-preview :override #'consult-register-window)
  388.  
  389.   :bind
  390.   (("C-s" . consult-line)        ;; Search in buffer
  391.    ("M-y" . consult-yank-pop)    ;; Show kill ring
  392.    ("C-x b" . consult-buffer)    ;; Switch buffer
  393.    ("C-x C-r" . consult-recent-file)
  394.    ("C-x C-f" . find-file)       ;; Keep default for browsing
  395.    ("C-c f" . consult-find)      ;; Fast fuzzy file finding (like Telescope)
  396.    ("M-g g" . consult-goto-line)
  397.    ("M-g M-g" . consult-goto-line)
  398.    ("M-s r" . consult-ripgrep)   ;; Project search
  399.    ("M-s l" . consult-line-multi)
  400.    ("M-s m" . consult-mark)
  401.    ("M-s k" . consult-global-mark)
  402.    ("M-s i" . consult-imenu)))
  403.  
  404. ;;; Vertical completion layout (vertico)
  405. (use-package vertico
  406.   :ensure t
  407.   :hook (after-init . vertico-mode)
  408.   :config
  409.   (setq vertico-scroll-margin 0)
  410.   (setq vertico-count 5)
  411.   (setq vertico-resize t)
  412.   (setq vertico-cycle t)
  413.  
  414.   (with-eval-after-load 'rfn-eshadow
  415.     ;; This works with `file-name-shadow-mode' enabled.  When you are in
  416.     ;; a sub-directory and use, say, `find-file' to go to your home '~/'
  417.     ;; or root '/' directory, Vertico will clear the old path to keep
  418.     ;; only your current input.
  419.     (add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy)))
  420.  
  421. ;;; EMBARK
  422. ;; Embark provides a powerful contextual action menu for Emacs, allowing
  423. ;; you to perform various operations on completion candidates and other items.
  424. ;; It extends the capabilities of completion frameworks by offering direct
  425. ;; actions on the candidates.
  426. ;; Just `<leader> .' over any text, explore it :)
  427. ; (use-package embark
  428. ;   :ensure t
  429. ;   :defer t)
  430.  
  431. (use-package embark
  432.   :ensure t
  433.   :bind (("C-." . embark-act)
  434.          :map minibuffer-local-map
  435.          ("C-c C-c" . embark-collect)
  436.          ("C-c C-e" . embark-export)))
  437.  
  438. ;;; EMBARK-CONSULT
  439. ;; Embark-Consult provides a bridge between Embark and Consult, ensuring
  440. ;; that Consult commands, like previews, are available when using Embark.
  441. (use-package embark-consult
  442.   :ensure t
  443.   :hook
  444.   (embark-collect-mode . consult-preview-at-point-mode)) ;; Enable preview in Embark collect mode.
  445.  
  446. ;; The `wgrep' packages lets us edit the results of a grep search
  447. ;; while inside a `grep-mode' buffer.  All we need is to toggle the
  448. ;; editable mode, make the changes, and then type C-c C-c to confirm
  449. ;; or C-c C-k to abort.
  450. ;;
  451. ;; Further reading: https://protesilaos.com/emacs/dotemacs#h:9a3581df-ab18-4266-815e-2edd7f7e4852
  452. (use-package wgrep
  453.   :ensure t
  454.   :bind ( :map grep-mode-map
  455.           ("e" . wgrep-change-to-wgrep-mode)
  456.           ("C-x C-q" . wgrep-change-to-wgrep-mode)
  457.           ("C-c C-c" . wgrep-finish-edit)))
  458.  
  459.  
  460. (use-package isearch
  461.   :ensure nil                                  ;; This is built-in, no need to fetch it.
  462.   :config
  463.   (setq isearch-lazy-count t)                  ;; Enable lazy counting to show current match information.
  464.   (setq lazy-count-prefix-format "(%s/%s) ")   ;; Format for displaying current match count.
  465.   (setq lazy-count-suffix-format nil)          ;; Disable suffix formatting for match count.
  466.   (setq search-whitespace-regexp ".*?")        ;; Allow searching across whitespace.
  467.   :bind (("C-s" . isearch-forward)             ;; Bind C-s to forward isearch.
  468.          ("C-r" . isearch-backward)))          ;; Bind C-r to backward isearch.
  469.  
  470.  
  471. (use-package dired
  472.   :ensure nil
  473.   :commands (dired)
  474.   :hook
  475.   ((dired-mode . dired-hide-details-mode)
  476.    (dired-mode . hl-line-mode))
  477.   :config
  478.   (setq dired-recursive-copies 'always)
  479.   (setq dired-recursive-deletes 'always)
  480.   (setq delete-by-moving-to-trash t)
  481.   (setq dired-dwim-target t))
  482.  
  483. (use-package dired-subtree
  484.   :ensure t
  485.   :after dired
  486.   :bind
  487.   ( :map dired-mode-map
  488.     ("<tab>" . dired-subtree-toggle)
  489.     ("TAB" . dired-subtree-toggle)
  490.     ("<backtab>" . dired-subtree-remove)
  491.     ("S-TAB" . dired-subtree-remove))
  492.   :config
  493.   (setq dired-subtree-use-backgrounds nil))
  494.  
  495. (use-package trashed
  496.   :ensure t
  497.   :commands (trashed)
  498.   :config
  499.   (setq trashed-action-confirmer 'y-or-n-p)
  500.   (setq trashed-use-header-line t)
  501.   (setq trashed-sort-key '("Date deleted" . t))
  502.   (setq trashed-date-format "%Y-%m-%d %H:%M:%S"))
  503.  
  504.  
  505. ;;; Interactive and powerful git front-end (Magit)
  506. (use-package transient
  507.   :defer t
  508.   :config
  509.   (setq transient-show-popup 0.5))
  510.  
  511. (use-package magit
  512.   :ensure t
  513.   ; :bind
  514.   ; ( :map global-map
  515.   ;   ("C-c g" . magit-status)
  516.   ;   :map magit-mode-map
  517.   ;   ("C-w" . nil)
  518.   ;   ("M-w" . nil))
  519.   :init
  520.   (setq magit-define-global-key-bindings nil)
  521.   ;; Use simple text indicators instead of fringe bitmaps to avoid errors
  522.   (setq magit-section-visibility-indicator nil)
  523.   :config
  524.   (setq git-commit-summary-max-length 50)
  525.   ;; NOTE 2023-01-24: I used to also include `overlong-summary-line'
  526.   ;; in this list, but I realised I do not need it.  My summaries are
  527.   ;; always in check.  When I exceed the limit, it is for a good
  528.   ;; reason.
  529.   (setq git-commit-style-convention-checks '(non-empty-second-line))
  530.  
  531.   (setq magit-diff-refine-hunk t)
  532.  
  533.   ;; Show icons for files in the Magit status and other buffers.
  534.   (with-eval-after-load 'magit
  535.     (setq magit-format-file-function #'magit-format-file-nerd-icons)))
  536.  
  537. (use-package magit-repos
  538.   :ensure nil ; part of `magit'
  539.   :commands (magit-list-repositories)
  540.   :init
  541.   (setq magit-repository-directories
  542.         '(("~/Git/Projects" . 1))))
  543.  
  544.  
  545. ;;; Icons
  546. (use-package nerd-icons
  547.   :ensure t)
  548.  
  549. (use-package nerd-icons-completion
  550.   :ensure t
  551.   :if (display-graphic-p)
  552.   :after marginalia
  553.   ;; FIXME 2024-09-01: For some reason this stopped working because it
  554.   ;; macroexpands to `marginalia-mode' instead of
  555.   ;; `marginalia-mode-hook'.  What is more puzzling is that this does
  556.   ;; not happen in the next :hook...
  557.   ;; :hook (marginalia-mode . nerd-icons-completion-marginalia-setup))
  558.   :config
  559.   (add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup))
  560.  
  561. (use-package nerd-icons-corfu
  562.   :ensure t
  563.   :if (display-graphic-p)
  564.   :after corfu
  565.   :config
  566.   (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))
  567.  
  568. (use-package nerd-icons-dired
  569.   :ensure t
  570.   :if (display-graphic-p)
  571.   :hook
  572.   (dired-mode . nerd-icons-dired-mode))
  573.  
  574. (use-package nerd-icons-xref
  575.   :ensure t
  576.   :if (display-graphic-p)
  577.   :after xref
  578.   :config
  579.   (nerd-icons-xref-mode 1))
  580.  
  581. (use-package nerd-icons-grep
  582.   :ensure t
  583.   :if (display-graphic-p)
  584.   :after grep
  585.   :config
  586.   (when grep-use-headings
  587.     (nerd-icons-grep-mode 1)))
  588.  
  589. ;;; ORG-MODE
  590. (use-package org
  591.   :ensure nil     ;; This is built-in, no need to fetch it.
  592.   :defer t
  593.   :config
  594.   ;; Set default directory for org files
  595.   (setq org-directory "~/org")
  596.   (setq org-default-notes-file (concat org-directory "/notes.org"))
  597.  
  598.   ;; Org-capture templates for quick note-taking
  599.   (setq org-capture-templates
  600.         '(("t" "Todo" entry (file+headline "~/org/tasks.org" "Tasks")
  601.            "* TODO %?\n  %i\n  %a")
  602.           ("n" "Note" entry (file+headline "~/org/notes.org" "Notes")
  603.            "* %?\n  %i\n  %a")
  604.           ("j" "Journal" entry (file+datetree "~/org/journal.org")
  605.            "* %?\nEntered on %U\n  %i\n  %a")))
  606.  
  607.   ;; Global key binding for org-capture
  608.   :bind
  609.   ("C-c c" . org-capture)
  610.   ("C-c a" . org-agenda))
  611.  
  612.  
  613.  
  614. (use-package markdown-mode
  615.   :defer t
  616.   :ensure t
  617.   :mode ("README\\.md\\'" . gfm-mode)            ;; Use gfm-mode for README.md files.
  618.   :init (setq markdown-command "multimarkdown")) ;; Set the Markdown processing command.
  619.  
  620. (use-package yasnippet
  621.   :ensure t
  622.   :defer t
  623.   :hook
  624.   (prog-mode . yas-minor-mode)
  625.   (org-mode . yas-minor-mode)
  626.   :config
  627.   (yas-reload-all))
  628.  
  629. ;; Official snippet collection for yasnippet
  630. (use-package yasnippet-snippets
  631.   :ensure t
  632.   :after yasnippet)
  633.  
  634. ;;; EAT (Emulate A Terminal)
  635. (use-package eat
  636.   :ensure t
  637.   :defer t
  638.   :hook
  639.   (eshell-load . eat-eshell-mode)
  640.   :config
  641.   (setq eat-term-name "xterm-256color")
  642.   :bind
  643.   ("C-c t" . eat))
  644.  
  645. ;;; LANGUAGETOOL
  646. (use-package languagetool
  647.   :ensure t
  648.   :defer t
  649.   :commands (languagetool-check
  650.              languagetool-clear-suggestions
  651.              languagetool-correct-at-point
  652.              languagetool-set-language
  653.              languagetool-server-mode
  654.              languagetool-server-start
  655.              languagetool-server-stop)
  656.   :config
  657.   ;; Set LanguageTool installation path (adjust if needed)
  658.   (setq languagetool-java-arguments '("-Dfile.encoding=UTF-8")
  659.         languagetool-console-command "/opt/homebrew/bin/languagetool"
  660.         languagetool-server-command "/opt/homebrew/bin/languagetool-server")
  661.   ;; Optional: auto-start server mode
  662.   ;; (setq languagetool-default-language "en-US")
  663.   :bind
  664.   ("C-c g c" . languagetool-check)
  665.   ("C-c g s" . languagetool-server-start)
  666.   ("C-c g q" . languagetool-server-stop))
  667.  
  668. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  669. ;; TREESITTER
  670. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  671.  
  672. (use-package treesit-auto
  673.   :ensure t
  674.   :config
  675.   (setq treesit-auto-install 'prompt)
  676.   (treesit-auto-add-to-auto-mode-alist 'all)
  677.   (global-treesit-auto-mode))
  678.  
  679. (use-package which-key
  680.   :ensure t
  681.   :defer t        ;; Defer loading Which-Key until after init.
  682.   :hook
  683.   (after-init . which-key-mode)) ;; Enable which-key mode after initialization.
  684.  
  685. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  686. ;; Development Enhancements
  687. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  688.  
  689. (use-package lsp-mode
  690.   :ensure t
  691.   :defer t
  692.   :hook
  693.   (lsp-mode . lsp-enable-which-key-integration)
  694.   (lsp-mode . (lambda () (lsp-headerline-breadcrumb-mode -1)))
  695.   ((js-mode
  696.     tsx-ts-mode
  697.     typescript-ts-base-mode
  698.     css-mode
  699.     go-ts-mode
  700.     go-mode
  701.     js-ts-mode
  702.     prisma-mode
  703.     python-mode
  704.     ruby-base-mode
  705.     rust-ts-mode
  706.     web-mode
  707.     html-mode
  708.     typescript-mode) . lsp-deferred)
  709.   :commands lsp
  710.   :custom
  711.   ;; General
  712.   (lsp-keymap-prefix "C-c l")
  713.   (lsp-session-file (locate-user-emacs-file ".lsp-session"))
  714.   (lsp-log-io nil)
  715.   (lsp-idle-delay 0.5)
  716.   (lsp-keep-workspace-alive nil)
  717.   (lsp-auto-configure t)
  718.   (lsp-enable-xref t)
  719.   (lsp-enable-links nil)
  720.   (lsp-enable-file-watchers nil)
  721.   (lsp-enable-folding nil)
  722.   (lsp-enable-indentation nil)
  723.   (lsp-enable-on-type-formatting nil)
  724.   (lsp-enable-imenu t)
  725.   (lsp-enable-suggest-server-download t)
  726.   (lsp-enable-symbol-highlighting t)
  727.   (lsp-enable-text-document-color t)
  728.  
  729.   ;; UI
  730.   (lsp-modeline-code-actions-enable nil)
  731.   (lsp-modeline-diagnostics-enable nil)
  732.   (lsp-modeline-workspace-status-enable t)
  733.   (lsp-signature-doc-lines 1)
  734.  
  735.   (lsp-completion-provider :capf)
  736.   (lsp-completion-enable t)
  737.   (lsp-completion-enable-additional-text-edit t)
  738.   (lsp-completion-show-kind t)
  739.   (lsp-enable-snippet nil)
  740.  
  741.   ;; Eldoc
  742.   (lsp-eldoc-enable-hover nil)
  743.   (lsp-eldoc-render-all t)
  744.  
  745.   ;; Breadcrumb/Headerline
  746.   (lsp-headerline-breadcrumb-enable nil)
  747.   (lsp-headerline-breadcrumb-enable-symbol-numbers nil)
  748.   (lsp-headerline-breadcrumb-enable-diagnostics nil)
  749.   (lsp-headerline-breadcrumb-icons-enable nil)
  750.   (lsp-headerline-arrow "▶")
  751.  
  752.   ;; Semantic tokens
  753.   (lsp-semantic-tokens-enable nil)
  754.  
  755.   ;; Inlay hints
  756.   (lsp-inlay-hint-enable nil)
  757.  
  758.   :config
  759.   ;; Disable semgrep language server (use gopls for Go instead)
  760.   (setq lsp-disabled-clients '(semgrep-ls))
  761.  
  762.   ;; Suppress unknown notification warnings
  763.   (setq lsp-warn-no-matched-clients nil))
  764.  
  765. (use-package eldoc
  766.   :ensure nil  ; Built-in package
  767.   :hook (prog-mode . eldoc-mode)
  768.   :config
  769.   (setq eldoc-idle-delay 0.2)                           ; Faster response (was 0.5)
  770.   (setq eldoc-echo-area-use-multiline-p t)
  771.   (setq eldoc-echo-area-display-truncation-message nil)
  772.   (setq eldoc-print-after-edit t)
  773.  
  774.   ;; Enable eldoc in more modes
  775.   (add-hook 'emacs-lisp-mode-hook #'eldoc-mode)
  776.   (add-hook 'lisp-interaction-mode-hook #'eldoc-mode)
  777.   (add-hook 'ielm-mode-hook #'eldoc-mode)
  778.  
  779.   ;; Force eldoc to work with LSP
  780.   (with-eval-after-load 'lsp-mode
  781.     (add-hook 'lsp-mode-hook
  782.               (lambda ()
  783.                 (eldoc-mode 1)
  784.                 (setq eldoc-documentation-strategy 'eldoc-documentation-compose)))))
  785.  
  786. ;; Flycheck is the newer version of flymake and is needed to make lsp-mode not freak out.
  787. (use-package flycheck
  788.   :ensure t
  789.   :defer t
  790.   :config
  791.   (add-hook 'prog-mode-hook 'flycheck-mode) ;; always lint my code
  792.   (add-hook 'after-init-hook #'global-flycheck-mode))
  793.  
  794.  
  795. (use-package diff-hl
  796.   :defer t
  797.   :ensure t
  798.   :hook
  799.   (find-file . (lambda ()
  800.                  (global-diff-hl-mode)           ;; Enable Diff-HL mode for all files.
  801.                  (diff-hl-flydiff-mode)          ;; Automatically refresh diffs.
  802.                  (diff-hl-margin-mode)))         ;; Show diff indicators in the margin.
  803.   :custom
  804.   (diff-hl-side 'left)                           ;; Set the side for diff indicators.
  805.   (diff-hl-margin-symbols-alist '((insert . "┃") ;; Customize symbols for each change type.
  806.                                   (delete . "-")
  807.                                   (change . "┃")
  808.                                   (unknown . "┆")
  809.                                   (ignored . "i"))))
  810.  
  811. (use-package xclip
  812.   :ensure t
  813.   :defer t
  814.   :hook
  815.   (after-init . xclip-mode))     ;; Enable xclip mode after initialization.
  816.  
  817.  
  818. (use-package indent-guide
  819.   :defer t
  820.   :ensure t
  821.   :hook
  822.   (prog-mode . indent-guide-mode)  ;; Activate indent-guide in programming modes.
  823.   :config
  824.   (setq indent-guide-char "│"))    ;; Set the character used for the indent guide.
  825.  
  826. (use-package add-node-modules-path
  827.   :ensure t
  828.   :defer t
  829.   :custom
  830.   ;; Makes sure you are using the local bin for your
  831.   ;; node project. Local eslint, typescript server...
  832.   (eval-after-load 'typescript-ts-mode
  833.     '(add-hook 'typescript-ts-mode-hook #'add-node-modules-path))
  834.   (eval-after-load 'tsx-ts-mode
  835.     '(add-hook 'tsx-ts-mode-hook #'add-node-modules-path))
  836.   (eval-after-load 'typescriptreact-mode
  837.     '(add-hook 'typescriptreact-mode-hook #'add-node-modules-path))
  838.   (eval-after-load 'js-mode
  839.     '(add-hook 'js-mode-hook #'add-node-modules-path)))
  840.  
  841.  
  842. (use-package rainbow-delimiters
  843.   :defer t
  844.   :ensure t
  845.   :hook
  846.   (prog-mode . rainbow-delimiters-mode))
  847.  
  848. ;;; DOTENV
  849. ;; A simple major mode to provide .env files with color highlighting
  850. (use-package dotenv-mode
  851.   :defer t
  852.   :ensure t
  853.   :config)
  854.  
  855.  
  856. (use-package undo-tree
  857.   :defer t
  858.   :ensure t
  859.   :hook
  860.   (after-init . global-undo-tree-mode)
  861.   :init
  862.   (setq undo-tree-visualizer-timestamps t
  863.         undo-tree-visualizer-diff t
  864.         ;; Increase undo limits to avoid losing history due to Emacs' garbage collection.
  865.         ;; These values can be adjusted based on your needs.
  866.         ;; 10X bump of the undo limits to avoid issues with premature
  867.         ;; Emacs GC which truncates the undo history very aggressively.
  868.         undo-limit 800000                     ;; Limit for undo entries.
  869.         undo-strong-limit 12000000            ;; Strong limit for undo entries.
  870.         undo-outer-limit 120000000)           ;; Outer limit for undo entries.
  871.   :config
  872.   ;; Set the directory where `undo-tree' will save its history files.
  873.   ;; This keeps undo history across sessions, stored in a cache directory.
  874.   (setq undo-tree-history-directory-alist
  875.         `(("." . ,(expand-file-name ".cache/undo" user-emacs-directory)))))
  876.  
  877. ;; Set Python indentation explicitly to avoid the guessing message
  878. (use-package python
  879.   :ensure nil  ; Built-in package
  880.   :config
  881.   (setq python-indent-offset 4)          ; Always use 4 spaces
  882.   (setq python-indent-guess-indent-offset nil))  ; Don't try to guess
  883.  
  884. ;; Set tar file for Macos for emacs to find it
  885. (setenv "PATH" (concat (getenv "PATH") ":/usr/bin:/opt/homebrew/bin"))
  886. (add-to-list 'exec-path "/usr/bin")
  887. (add-to-list 'exec-path "/opt/homebrew/bin")
  888.  
  889. (provide 'init)
  890. ;;; init.el ends here
Tags: emacs
Advertisement
Add Comment
Please, Sign In to add comment