Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; init.el --- Main Emacs configuration -*- lexical-binding: t; -*-
- ;; Increase garbage collection threshold during startup
- (setq gc-cons-threshold most-positive-fixnum
- gc-cons-percentage 0.6)
- ;; Configure native compilation to use Homebrew GCC
- (when (and (fboundp 'native-comp-available-p)
- (native-comp-available-p))
- (setq native-comp-driver-options
- (list "-L" "/usr/local/opt/gcc/lib/gcc/current"
- "-I" "/usr/local/opt/gcc/include"))
- ;; Speed up native compilation
- (setq native-comp-speed 2)
- (setq native-comp-async-jobs-number 4))
- ;; Suppress native-comp warnings during async compilation
- (setq native-comp-async-report-warnings-errors nil)
- ;; macOS-specific performance tweaks
- (when (eq system-type 'darwin)
- ;; Disable frame resize animation (reduces lag)
- (setq frame-resize-pixelwise t)
- ;; Faster scrolling on macOS
- (setq mac-mouse-wheel-smooth-scroll nil)
- ;; Reduce input latency
- (setq mac-redisplay-dont-reset-vscroll t)
- ;; Better font rendering
- (setq mac-allow-anti-aliasing t))
- ;; Reduce rendering overhead
- (setq fast-but-imprecise-scrolling t)
- (setq redisplay-skip-fontification-on-input t)
- ;; Disable bidirectional text scanning for performance
- (setq-default bidi-display-reordering nil)
- (setq bidi-inhibit-bpa t)
- (use-package diminish :ensure t)
- ;; Reduce GC after init (but keep it reasonable)
- (add-hook 'emacs-startup-hook
- (lambda ()
- (setq gc-cons-threshold (* 100 1024 1024) ; 100MB
- gc-cons-percentage 0.1)))
- ;; Run GC when Emacs loses focus (prevents pauses during editing)
- (add-hook 'focus-out-hook #'garbage-collect)
- ;;keeping the files clean
- (setq make-backup-files nil)
- (setq backup-inhibited nil) ; Not sure if needed, given `make-backup-files'
- (setq create-lockfiles nil)
- ;; Disable the damn thing by making it disposable.
- (setq custom-file (make-temp-file "emacs-custom-"))
- ;; Initialize package sources
- (setq package-archives '(("melpa" . "https://melpa.org/packages/")
- ("org" . "https://orgmode.org/elpa/")
- ("elpa" . "https://elpa.gnu.org/packages/")))
- (unless package-archive-contents
- (package-refresh-contents));;suppress the warnings
- (use-package gcmh
- :ensure t
- :diminish
- :config
- (setq gcmh-idle-delay 15) ; Run GC after 15 seconds of idle time (instead of 5)
- (setq gcmh-high-cons-threshold (* 128 1024 1024)) ; 128MB
- (gcmh-mode 1))
- ;; Make sure Emacs inherits the shell PATH
- (use-package exec-path-from-shell
- :ensure t
- :if (memq window-system '(mac ns x))
- :config
- ;; Only copy essential variables for speed
- (setq exec-path-from-shell-variables '("PATH" "MANPATH" "GOPATH"))
- (setq exec-path-from-shell-check-startup-files nil)
- (exec-path-from-shell-initialize))
- ;; Treat Mac Command as Meta
- (setq mac-command-modifier 'meta)
- ;; ----------------------------------------
- ;; 3. Init (runs before package is loaded)
- ;; ----------------------------------------
- :init
- (tool-bar-mode -1)
- (menu-bar-mode 1)
- (when scroll-bar-mode
- (scroll-bar-mode -1))
- (global-hl-line-mode -1) ;; No line highlight
- (global-auto-revert-mode 1)
- (setq indent-tabs-mode nil) ;; Use spaces
- (recentf-mode 1)
- (savehist-mode 1)
- (save-place-mode 1)
- (winner-mode 1)
- (xterm-mouse-mode 1)
- (file-name-shadow-mode 1)
- (use-package modus-themes
- :ensure nil
- :init
- (load-theme 'modus-vivendi t))
- (setq-default frame-title-format "")
- (set-frame-parameter nil 'ns-transparent-titlebar t)
- (add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
- (use-package minions
- :ensure t
- :custom
- (mode-line-modes-delimiters nil)
- (minions-mode-line-lighter " …")
- :config
- (minions-mode +1)
- (force-mode-line-update t))
- (use-package moody
- :ensure t
- :config
- (setq-default mode-line-format
- '(""
- mode-line-front-space
- mode-line-client
- mode-line-frame-identification
- mode-line-buffer-identification
- " "
- mode-line-position
- (vc-mode vc-mode)
- (multiple-cursors-mode mc/mode-line)
- mode-line-modes
- mode-line-end-spaces))
- (moody-replace-mode-line-buffer-identification)
- (moody-replace-vc-mode))
- (use-package nyan-mode
- :ensure t
- :custom
- (nyan-bar-length 10)
- :config
- (nyan-mode +1))
- (use-package ligature
- :ensure t
- :config
- ;; Enable the "www" ligature in every possible major mode
- (ligature-set-ligatures 't '("www"))
- ;; Enable traditional ligature support in eww-mode, if the
- ;; `variable-pitch' face supports it
- (ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi"))
- ;; Enable all Cascadia Code ligatures in programming modes
- (ligature-set-ligatures 'prog-mode '("|||>" "<|||" "<==>" "<!--" "####" "~~>" "***" "||=" "||>"
- ":::" "::=" "=:=" "===" "==>" "=!=" "=>>" "=<<" "=/=" "!=="
- "!!." ">=>" ">>=" ">>>" ">>-" ">->" "->>" "-->" "---" "-<<"
- "<~~" "<~>" "<*>" "<||" "<|>" "<$>" "<==" "<=>" "<=<" "<->"
- "<--" "<-<" "<<=" "<<-" "<<<" "<+>" "</>" "###" "#_(" "..<"
- "..." "+++" "/==" "///" "_|_" "www" "&&" "^=" "~~" "~@" "~="
- "~>" "~-" "**" "*>" "*/" "||" "|}" "|]" "|=" "|>" "|-" "{|"
- "[|" "]#" "::" ":=" ":>" ":<" "$>" "==" "=>" "!=" "!!" ">:"
- ">=" ">>" ">-" "-~" "-|" "->" "--" "-<" "<~" "<*" "<|" "<:"
- "<$" "<=" "<>" "<-" "<<" "<+" "</" "#{" "#[" "#:" "#=" "#!"
- "##" "#(" "#?" "#_" "%%" ".=" ".-" ".." ".?" "+>" "++" "?:"
- "?=" "?." "??" ";;" "/*" "/=" "/>" "//" "__" "~~" "(*" "*)"
- "\\\\" "://"))
- ;; per mode with `ligature-mode'.
- (global-ligature-mode t))
- (set-face-attribute 'default nil
- :family "CaskaydiaCove Nerd Font"
- :weight 'Semilight
- :height 180)
- ;; Variable pitch (UI, headings, org, etc.)
- (set-face-attribute 'variable-pitch nil
- :family "DejaVu Sans"
- :height 180)
- ;; Symbol font (for Unicode/math symbols)
- (set-fontset-font t 'symbol "JuliaMono")
- ;; Big font toggle for presentations
- (defun my/toggle-big-font ()
- "This is to make the font BIG when screensharing."
- (interactive)
- (if (= (face-attribute 'default :height) 170)
- (set-face-attribute 'default nil :height 220)
- (set-face-attribute 'default nil :height 170)))
- (global-set-key (kbd "<f9>") #'my/toggle-big-font)
- ;; Make sure ANSI color escapes are honored
- (require 'ansi-color)
- (ansi-color-for-comint-mode-on)
- ;; ============================================================
- ;; Core Emacs settings
- ;; ============================================================
- (use-package emacs
- :ensure nil
- :custom
- (column-number-mode t) ;; Show column number in mode line
- (auto-save-default nil) ;; Disable auto-save
- (create-lockfiles nil) ;; No .# lockfiles
- (delete-by-moving-to-trash t) ;; Move deleted files to trash
- (delete-selection-mode 1) ;; Typing replaces selected text
- ; (display-line-numbers-type 'visual) ;; Relative line numbering
- (display-line-numbers-type 'absolute) ;; Relative line numbering
- (global-auto-revert-non-file-buffers t) ;; Auto-refresh non-file buffers
- (history-length 25) ;; Command history length
- (inhibit-startup-message t) ;; No startup message
- (initial-scratch-message "") ;; Empty *scratch* buffer
- (ispell-dictionary "en_US") ;; Spell-check dictionary
- (make-backup-files nil) ;; No backup~ files
- (pixel-scroll-precision-mode t) ;; Smooth scrolling
- (pixel-scroll-precision-use-momentum nil) ;; No inertial scrolling
- (ring-bell-function 'ignore) ;; No bell sound
- (split-width-threshold 300) ;; Only split if wide enough
- (switch-to-buffer-obey-display-actions t) ;; Respect display actions
- (tab-always-indent 'complete) ;; TAB = indent or complete
- (tab-width 4) ;; Tab size
- (treesit-font-lock-level 4) ;; Treesit max font lock
- (truncate-lines t) ;; Don't wrap lines
- (use-dialog-box nil) ;; No GUI dialogs
- (use-short-answers t) ;; y/n instead of yes/no
- (warning-minimum-level :emergency) ;; Hide most warnings
- ;; ----------------------------------------
- ;; Hooks
- ;; ----------------------------------------
- :hook
- (prog-mode . display-line-numbers-mode) ;; Line numbers in code
- ;; ----------------------------------------
- ;; Config (runs after package is loaded)
- ;; ----------------------------------------
- :config
- ;; Fullscreen by default
- (add-to-list 'default-frame-alist '(fullscreen . maximized))
- ;; Remove title bar & round corners
- (when (display-graphic-p)
- (add-to-list 'default-frame-alist '(undecorated . t))
- (add-to-list 'default-frame-alist '(undecorated-round . t)))
- ;; Use │ instead of |
- (set-display-table-slot standard-display-table
- 'vertical-border
- (make-glyph-code ?│)))
- ;; ============================================================
- ;; Windows Emacs settings
- ;; ============================================================
- (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))
- ;; Example configuration for the LSP help buffer,
- ;; keeps it always on bottom using 25% of the available space:
- ("\\*\\(lsp-help\\)\\*"
- (display-buffer-in-side-window)
- (window-height . 0.25)
- (side . bottom)
- (slot . 0))
- ;; Configuration for displaying various diagnostic buffers on
- ;; bottom 25%:
- ("\\*\\(Flymake diagnostics\\|xref\\|ivy\\|Swiper\\|Completions\\)"
- (display-buffer-in-side-window)
- (window-height . 0.25)
- (side . bottom)
- (slot . 1))
- )))
- ;; Pulsar configuration
- (use-package pulsar
- :ensure t
- :config
- (setq pulsar-pulse t
- pulsar-delay 0.055
- pulsar-iterations 10
- pulsar-face 'pulsar-magenta ; Use built-in pulsar face instead of evil face
- pulsar-highlight-face 'pulsar-yellow)
- ;; Remove problematic evil faces from pulsar
- (setq pulsar-pulse-functions
- '(recenter-top-bottom
- move-to-window-line-top-bottom
- reposition-window
- bookmark-jump
- other-window
- delete-window
- delete-other-windows
- forward-page
- backward-page
- scroll-up-command
- scroll-down-command
- windmove-right
- windmove-left
- windmove-up
- windmove-down))
- (pulsar-global-mode 1))
- (use-package marginalia
- :ensure t
- :hook (after-init . marginalia-mode))
- (use-package orderless
- :ensure t
- :config
- (setq completion-styles '(orderless basic))
- (setq completion-category-defaults nil)
- ;; Keep orderless for fast fuzzy matching everywhere
- ;; For traditional TAB completion on files, use RET to select instead
- (setq completion-category-overrides nil))
- (use-package savehist
- :ensure nil ; it is built-in
- :hook (after-init . savehist-mode))
- (use-package corfu
- :ensure t
- :hook (after-init . global-corfu-mode)
- :bind (:map corfu-map ("<tab>" . corfu-complete))
- :config
- (setq tab-always-indent 'complete)
- (setq corfu-preview-current nil)
- (setq corfu-min-width 20)
- (setq corfu-popupinfo-delay '(1.25 . 0.5))
- (corfu-popupinfo-mode 1) ; shows documentation after `corfu-popupinfo-delay'
- ;;; NERD-ICONS-CORFU
- ;; Provides Nerd Icons to be used with CORFU.
- (defvar ek-use-nerd-fonts t
- "If non-nil, enable nerd-icons support.")
- (use-package nerd-icons-corfu
- :if ek-use-nerd-fonts
- :ensure t
- :defer t
- :after (:all corfu))
- ;; Sort by input history (no need to modify `corfu-sort-function').
- (with-eval-after-load 'savehist
- (corfu-history-mode 1)
- (add-to-list 'savehist-additional-variables 'corfu-history)))
- ;;; CONSULT
- ;; Consult provides powerful completion and narrowing commands for Emacs.
- ;; It integrates well with other completion frameworks like Vertico, enabling
- ;; features like previews and enhanced register management. It's useful for
- ;; navigating buffers, files, and xrefs with ease.
- (use-package consult
- :ensure t
- :demand t; load immdiatly
- :init
- ;; Enhance register preview with thin lines and no mode line.
- (advice-add #'register-preview :override #'consult-register-window)
- :bind
- (("C-s" . consult-line) ;; Search in buffer
- ("M-y" . consult-yank-pop) ;; Show kill ring
- ("C-x b" . consult-buffer) ;; Switch buffer
- ("C-x C-r" . consult-recent-file)
- ("C-x C-f" . find-file) ;; Keep default for browsing
- ("C-c f" . consult-find) ;; Fast fuzzy file finding (like Telescope)
- ("M-g g" . consult-goto-line)
- ("M-g M-g" . consult-goto-line)
- ("M-s r" . consult-ripgrep) ;; Project search
- ("M-s l" . consult-line-multi)
- ("M-s m" . consult-mark)
- ("M-s k" . consult-global-mark)
- ("M-s i" . consult-imenu)))
- ;;; Vertical completion layout (vertico)
- (use-package vertico
- :ensure t
- :hook (after-init . vertico-mode)
- :config
- (setq vertico-scroll-margin 0)
- (setq vertico-count 5)
- (setq vertico-resize t)
- (setq vertico-cycle t)
- (with-eval-after-load 'rfn-eshadow
- ;; This works with `file-name-shadow-mode' enabled. When you are in
- ;; a sub-directory and use, say, `find-file' to go to your home '~/'
- ;; or root '/' directory, Vertico will clear the old path to keep
- ;; only your current input.
- (add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy)))
- ;;; EMBARK
- ;; Embark provides a powerful contextual action menu for Emacs, allowing
- ;; you to perform various operations on completion candidates and other items.
- ;; It extends the capabilities of completion frameworks by offering direct
- ;; actions on the candidates.
- ;; Just `<leader> .' over any text, explore it :)
- ; (use-package embark
- ; :ensure t
- ; :defer t)
- (use-package embark
- :ensure t
- :bind (("C-." . embark-act)
- :map minibuffer-local-map
- ("C-c C-c" . embark-collect)
- ("C-c C-e" . embark-export)))
- ;;; EMBARK-CONSULT
- ;; Embark-Consult provides a bridge between Embark and Consult, ensuring
- ;; that Consult commands, like previews, are available when using Embark.
- (use-package embark-consult
- :ensure t
- :hook
- (embark-collect-mode . consult-preview-at-point-mode)) ;; Enable preview in Embark collect mode.
- ;; The `wgrep' packages lets us edit the results of a grep search
- ;; while inside a `grep-mode' buffer. All we need is to toggle the
- ;; editable mode, make the changes, and then type C-c C-c to confirm
- ;; or C-c C-k to abort.
- ;;
- ;; Further reading: https://protesilaos.com/emacs/dotemacs#h:9a3581df-ab18-4266-815e-2edd7f7e4852
- (use-package wgrep
- :ensure t
- :bind ( :map grep-mode-map
- ("e" . wgrep-change-to-wgrep-mode)
- ("C-x C-q" . wgrep-change-to-wgrep-mode)
- ("C-c C-c" . wgrep-finish-edit)))
- (use-package isearch
- :ensure nil ;; This is built-in, no need to fetch it.
- :config
- (setq isearch-lazy-count t) ;; Enable lazy counting to show current match information.
- (setq lazy-count-prefix-format "(%s/%s) ") ;; Format for displaying current match count.
- (setq lazy-count-suffix-format nil) ;; Disable suffix formatting for match count.
- (setq search-whitespace-regexp ".*?") ;; Allow searching across whitespace.
- :bind (("C-s" . isearch-forward) ;; Bind C-s to forward isearch.
- ("C-r" . isearch-backward))) ;; Bind C-r to backward isearch.
- (use-package dired
- :ensure nil
- :commands (dired)
- :hook
- ((dired-mode . dired-hide-details-mode)
- (dired-mode . hl-line-mode))
- :config
- (setq dired-recursive-copies 'always)
- (setq dired-recursive-deletes 'always)
- (setq delete-by-moving-to-trash t)
- (setq dired-dwim-target t))
- (use-package dired-subtree
- :ensure t
- :after dired
- :bind
- ( :map dired-mode-map
- ("<tab>" . dired-subtree-toggle)
- ("TAB" . dired-subtree-toggle)
- ("<backtab>" . dired-subtree-remove)
- ("S-TAB" . dired-subtree-remove))
- :config
- (setq dired-subtree-use-backgrounds nil))
- (use-package trashed
- :ensure t
- :commands (trashed)
- :config
- (setq trashed-action-confirmer 'y-or-n-p)
- (setq trashed-use-header-line t)
- (setq trashed-sort-key '("Date deleted" . t))
- (setq trashed-date-format "%Y-%m-%d %H:%M:%S"))
- ;;; Interactive and powerful git front-end (Magit)
- (use-package transient
- :defer t
- :config
- (setq transient-show-popup 0.5))
- (use-package magit
- :ensure t
- ; :bind
- ; ( :map global-map
- ; ("C-c g" . magit-status)
- ; :map magit-mode-map
- ; ("C-w" . nil)
- ; ("M-w" . nil))
- :init
- (setq magit-define-global-key-bindings nil)
- ;; Use simple text indicators instead of fringe bitmaps to avoid errors
- (setq magit-section-visibility-indicator nil)
- :config
- (setq git-commit-summary-max-length 50)
- ;; NOTE 2023-01-24: I used to also include `overlong-summary-line'
- ;; in this list, but I realised I do not need it. My summaries are
- ;; always in check. When I exceed the limit, it is for a good
- ;; reason.
- (setq git-commit-style-convention-checks '(non-empty-second-line))
- (setq magit-diff-refine-hunk t)
- ;; Show icons for files in the Magit status and other buffers.
- (with-eval-after-load 'magit
- (setq magit-format-file-function #'magit-format-file-nerd-icons)))
- (use-package magit-repos
- :ensure nil ; part of `magit'
- :commands (magit-list-repositories)
- :init
- (setq magit-repository-directories
- '(("~/Git/Projects" . 1))))
- ;;; Icons
- (use-package nerd-icons
- :ensure t)
- (use-package nerd-icons-completion
- :ensure t
- :if (display-graphic-p)
- :after marginalia
- ;; FIXME 2024-09-01: For some reason this stopped working because it
- ;; macroexpands to `marginalia-mode' instead of
- ;; `marginalia-mode-hook'. What is more puzzling is that this does
- ;; not happen in the next :hook...
- ;; :hook (marginalia-mode . nerd-icons-completion-marginalia-setup))
- :config
- (add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup))
- (use-package nerd-icons-corfu
- :ensure t
- :if (display-graphic-p)
- :after corfu
- :config
- (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))
- (use-package nerd-icons-dired
- :ensure t
- :if (display-graphic-p)
- :hook
- (dired-mode . nerd-icons-dired-mode))
- (use-package nerd-icons-xref
- :ensure t
- :if (display-graphic-p)
- :after xref
- :config
- (nerd-icons-xref-mode 1))
- (use-package nerd-icons-grep
- :ensure t
- :if (display-graphic-p)
- :after grep
- :config
- (when grep-use-headings
- (nerd-icons-grep-mode 1)))
- ;;; ORG-MODE
- (use-package org
- :ensure nil ;; This is built-in, no need to fetch it.
- :defer t
- :config
- ;; Set default directory for org files
- (setq org-directory "~/org")
- (setq org-default-notes-file (concat org-directory "/notes.org"))
- ;; Org-capture templates for quick note-taking
- (setq org-capture-templates
- '(("t" "Todo" entry (file+headline "~/org/tasks.org" "Tasks")
- "* TODO %?\n %i\n %a")
- ("n" "Note" entry (file+headline "~/org/notes.org" "Notes")
- "* %?\n %i\n %a")
- ("j" "Journal" entry (file+datetree "~/org/journal.org")
- "* %?\nEntered on %U\n %i\n %a")))
- ;; Global key binding for org-capture
- :bind
- ("C-c c" . org-capture)
- ("C-c a" . org-agenda))
- (use-package markdown-mode
- :defer t
- :ensure t
- :mode ("README\\.md\\'" . gfm-mode) ;; Use gfm-mode for README.md files.
- :init (setq markdown-command "multimarkdown")) ;; Set the Markdown processing command.
- (use-package yasnippet
- :ensure t
- :defer t
- :hook
- (prog-mode . yas-minor-mode)
- (org-mode . yas-minor-mode)
- :config
- (yas-reload-all))
- ;; Official snippet collection for yasnippet
- (use-package yasnippet-snippets
- :ensure t
- :after yasnippet)
- ;;; EAT (Emulate A Terminal)
- (use-package eat
- :ensure t
- :defer t
- :hook
- (eshell-load . eat-eshell-mode)
- :config
- (setq eat-term-name "xterm-256color")
- :bind
- ("C-c t" . eat))
- ;;; LANGUAGETOOL
- (use-package languagetool
- :ensure t
- :defer t
- :commands (languagetool-check
- languagetool-clear-suggestions
- languagetool-correct-at-point
- languagetool-set-language
- languagetool-server-mode
- languagetool-server-start
- languagetool-server-stop)
- :config
- ;; Set LanguageTool installation path (adjust if needed)
- (setq languagetool-java-arguments '("-Dfile.encoding=UTF-8")
- languagetool-console-command "/opt/homebrew/bin/languagetool"
- languagetool-server-command "/opt/homebrew/bin/languagetool-server")
- ;; Optional: auto-start server mode
- ;; (setq languagetool-default-language "en-US")
- :bind
- ("C-c g c" . languagetool-check)
- ("C-c g s" . languagetool-server-start)
- ("C-c g q" . languagetool-server-stop))
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; TREESITTER
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (use-package treesit-auto
- :ensure t
- :config
- (setq treesit-auto-install 'prompt)
- (treesit-auto-add-to-auto-mode-alist 'all)
- (global-treesit-auto-mode))
- (use-package which-key
- :ensure t
- :defer t ;; Defer loading Which-Key until after init.
- :hook
- (after-init . which-key-mode)) ;; Enable which-key mode after initialization.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Development Enhancements
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (use-package lsp-mode
- :ensure t
- :defer t
- :hook
- (lsp-mode . lsp-enable-which-key-integration)
- (lsp-mode . (lambda () (lsp-headerline-breadcrumb-mode -1)))
- ((js-mode
- tsx-ts-mode
- typescript-ts-base-mode
- css-mode
- go-ts-mode
- go-mode
- js-ts-mode
- prisma-mode
- python-mode
- ruby-base-mode
- rust-ts-mode
- web-mode
- html-mode
- typescript-mode) . lsp-deferred)
- :commands lsp
- :custom
- ;; General
- (lsp-keymap-prefix "C-c l")
- (lsp-session-file (locate-user-emacs-file ".lsp-session"))
- (lsp-log-io nil)
- (lsp-idle-delay 0.5)
- (lsp-keep-workspace-alive nil)
- (lsp-auto-configure t)
- (lsp-enable-xref t)
- (lsp-enable-links nil)
- (lsp-enable-file-watchers nil)
- (lsp-enable-folding nil)
- (lsp-enable-indentation nil)
- (lsp-enable-on-type-formatting nil)
- (lsp-enable-imenu t)
- (lsp-enable-suggest-server-download t)
- (lsp-enable-symbol-highlighting t)
- (lsp-enable-text-document-color t)
- ;; UI
- (lsp-modeline-code-actions-enable nil)
- (lsp-modeline-diagnostics-enable nil)
- (lsp-modeline-workspace-status-enable t)
- (lsp-signature-doc-lines 1)
- (lsp-completion-provider :capf)
- (lsp-completion-enable t)
- (lsp-completion-enable-additional-text-edit t)
- (lsp-completion-show-kind t)
- (lsp-enable-snippet nil)
- ;; Eldoc
- (lsp-eldoc-enable-hover nil)
- (lsp-eldoc-render-all t)
- ;; Breadcrumb/Headerline
- (lsp-headerline-breadcrumb-enable nil)
- (lsp-headerline-breadcrumb-enable-symbol-numbers nil)
- (lsp-headerline-breadcrumb-enable-diagnostics nil)
- (lsp-headerline-breadcrumb-icons-enable nil)
- (lsp-headerline-arrow "▶")
- ;; Semantic tokens
- (lsp-semantic-tokens-enable nil)
- ;; Inlay hints
- (lsp-inlay-hint-enable nil)
- :config
- ;; Disable semgrep language server (use gopls for Go instead)
- (setq lsp-disabled-clients '(semgrep-ls))
- ;; Suppress unknown notification warnings
- (setq lsp-warn-no-matched-clients nil))
- (use-package eldoc
- :ensure nil ; Built-in package
- :hook (prog-mode . eldoc-mode)
- :config
- (setq eldoc-idle-delay 0.2) ; Faster response (was 0.5)
- (setq eldoc-echo-area-use-multiline-p t)
- (setq eldoc-echo-area-display-truncation-message nil)
- (setq eldoc-print-after-edit t)
- ;; Enable eldoc in more modes
- (add-hook 'emacs-lisp-mode-hook #'eldoc-mode)
- (add-hook 'lisp-interaction-mode-hook #'eldoc-mode)
- (add-hook 'ielm-mode-hook #'eldoc-mode)
- ;; Force eldoc to work with LSP
- (with-eval-after-load 'lsp-mode
- (add-hook 'lsp-mode-hook
- (lambda ()
- (eldoc-mode 1)
- (setq eldoc-documentation-strategy 'eldoc-documentation-compose)))))
- ;; Flycheck is the newer version of flymake and is needed to make lsp-mode not freak out.
- (use-package flycheck
- :ensure t
- :defer t
- :config
- (add-hook 'prog-mode-hook 'flycheck-mode) ;; always lint my code
- (add-hook 'after-init-hook #'global-flycheck-mode))
- (use-package diff-hl
- :defer t
- :ensure t
- :hook
- (find-file . (lambda ()
- (global-diff-hl-mode) ;; Enable Diff-HL mode for all files.
- (diff-hl-flydiff-mode) ;; Automatically refresh diffs.
- (diff-hl-margin-mode))) ;; Show diff indicators in the margin.
- :custom
- (diff-hl-side 'left) ;; Set the side for diff indicators.
- (diff-hl-margin-symbols-alist '((insert . "┃") ;; Customize symbols for each change type.
- (delete . "-")
- (change . "┃")
- (unknown . "┆")
- (ignored . "i"))))
- (use-package xclip
- :ensure t
- :defer t
- :hook
- (after-init . xclip-mode)) ;; Enable xclip mode after initialization.
- (use-package indent-guide
- :defer t
- :ensure t
- :hook
- (prog-mode . indent-guide-mode) ;; Activate indent-guide in programming modes.
- :config
- (setq indent-guide-char "│")) ;; Set the character used for the indent guide.
- (use-package add-node-modules-path
- :ensure t
- :defer t
- :custom
- ;; Makes sure you are using the local bin for your
- ;; node project. Local eslint, typescript server...
- (eval-after-load 'typescript-ts-mode
- '(add-hook 'typescript-ts-mode-hook #'add-node-modules-path))
- (eval-after-load 'tsx-ts-mode
- '(add-hook 'tsx-ts-mode-hook #'add-node-modules-path))
- (eval-after-load 'typescriptreact-mode
- '(add-hook 'typescriptreact-mode-hook #'add-node-modules-path))
- (eval-after-load 'js-mode
- '(add-hook 'js-mode-hook #'add-node-modules-path)))
- (use-package rainbow-delimiters
- :defer t
- :ensure t
- :hook
- (prog-mode . rainbow-delimiters-mode))
- ;;; DOTENV
- ;; A simple major mode to provide .env files with color highlighting
- (use-package dotenv-mode
- :defer t
- :ensure t
- :config)
- (use-package undo-tree
- :defer t
- :ensure t
- :hook
- (after-init . global-undo-tree-mode)
- :init
- (setq undo-tree-visualizer-timestamps t
- undo-tree-visualizer-diff t
- ;; Increase undo limits to avoid losing history due to Emacs' garbage collection.
- ;; These values can be adjusted based on your needs.
- ;; 10X bump of the undo limits to avoid issues with premature
- ;; Emacs GC which truncates the undo history very aggressively.
- undo-limit 800000 ;; Limit for undo entries.
- undo-strong-limit 12000000 ;; Strong limit for undo entries.
- undo-outer-limit 120000000) ;; Outer limit for undo entries.
- :config
- ;; Set the directory where `undo-tree' will save its history files.
- ;; This keeps undo history across sessions, stored in a cache directory.
- (setq undo-tree-history-directory-alist
- `(("." . ,(expand-file-name ".cache/undo" user-emacs-directory)))))
- ;; Set Python indentation explicitly to avoid the guessing message
- (use-package python
- :ensure nil ; Built-in package
- :config
- (setq python-indent-offset 4) ; Always use 4 spaces
- (setq python-indent-guess-indent-offset nil)) ; Don't try to guess
- ;; Set tar file for Macos for emacs to find it
- (setenv "PATH" (concat (getenv "PATH") ":/usr/bin:/opt/homebrew/bin"))
- (add-to-list 'exec-path "/usr/bin")
- (add-to-list 'exec-path "/opt/homebrew/bin")
- (provide 'init)
- ;;; init.el ends here
Advertisement
Add Comment
Please, Sign In to add comment