Skip to content

Instantly share code, notes, and snippets.

@jjwatt
Created April 20, 2026 21:51
Show Gist options
  • Select an option

  • Save jjwatt/e3ccc5f839d8240fd28cd264741db280 to your computer and use it in GitHub Desktop.

Select an option

Save jjwatt/e3ccc5f839d8240fd28cd264741db280 to your computer and use it in GitHub Desktop.
Modern Emacs with magit and lsp starter kit v1
;; -*- lexical-binding: t; -*-
;;;; Package Manager Setup (Straight.el)
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(setq straight-use-package-by-default t)
(straight-use-package 'use-package)
;;;; UI & Editor Behavior
(use-package emacs
:init
(setq vc-follow-symlinks t
sentence-end-double-space nil
inhibit-startup-screen t
kill-whole-line t
indent-tabs-mode nil)
(scroll-bar-mode 0)
(tool-bar-mode -1)
(column-number-mode 1)
(show-paren-mode 1)
(global-display-line-numbers-mode 1)
(setq display-line-numbers-type 'relative)
(global-prettify-symbols-mode 1)
:custom
(context-menu-mode t)
(enable-recursive-minibuffers t)
(read-extended-command-predicate #'command-completion-default-include-p))
(use-package which-key :init (which-key-mode 1))
(use-package which-func :init (which-function-mode 1))
(use-package ligature :config (global-ligature-mode t))
(use-package smartparens
:hook (((prog-mode text-mode markdown-mode) . smartparens-mode)
(emacs-lisp-mode . smartparens-strict-mode))
:config (require 'smartparens-config)
:bind (:map smartparens-mode-map
("C-M-f" . sp-forward-sexp)
("C-M-b" . sp-backward-sexp)
("C-<right>" . sp-forward-slurp-sexp)
("M-<right>" . sp-forward-barf-sexp)
("C-<left>" . sp-backward-slurp-sexp)
("M-<left>" . sp-backward-barf-sexp)))
(use-package iedit)
;; Theme
(straight-use-package
'(everforest :type git :repo "https://github.com/Theory-of-Everything/everforest-emacs.git"))
(load-theme 'everforest-hard-light t)
;;;; Completion Stack (Vertico, Consult, Embark)
(use-package vertico
:custom (vertico-count 20) (vertico-cycle t)
:init (vertico-mode))
(use-package vertico-directory
:straight nil
:bind (:map vertico-map
("RET" . vertico-directory-enter)
("DEL" . vertico-directory-delete-char)
("M-DEL" . vertico-directory-delete-word)))
(use-package savehist :init (savehist-mode))
(use-package orderless
:custom
(completion-styles '(orderless basic))
(completion-category-overrides '((file (styles partial-completion)))))
(use-package marginalia :init (marginalia-mode))
(use-package consult
:bind (("C-x b" . consult-buffer)
("M-y" . consult-yank-pop)
("M-g g" . consult-goto-line)
("M-s r" . consult-ripgrep)
("M-s l" . consult-line) ; From T14s
("C-c c" . compile))
:init
(advice-add #'register-preview :override #'consult-register-window)
(setq xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref))
(use-package embark
:bind (("C-." . embark-act))
:init (setq prefix-help-command #'embark-prefix-help-command))
(use-package embark-consult)
(straight-use-package
'(consult-lsp :type git :host github :repo "gagbo/consult-lsp"))
(use-package consult-lsp
:after (lsp-mode consult))
;;;; Essential Utilities & Movement
(use-package magit)
(use-package projectile
:bind-keymap ("C-c p" . projectile-command-map)
:init (projectile-mode +1))
(use-package company
:hook (prog-mode . company-mode)
:config (setq company-idle-delay 0.1 company-minimum-prefix-length 1))
(use-package avy
:bind (("C-:" . avy-goto-char) ("M-o" . ace-window))
:config (avy-setup-default))
(use-package ace-window
:custom (aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)))
(use-package move-text :config (move-text-default-bindings))
;;;; LSP Configuration
(use-package lsp-mode
:commands (lsp lsp-deferred)
:init (setq lsp-keymap-prefix "C-c l")
:custom
(lsp-headerline-breadcrumb-enable t)
(lsp-enable-symbol-highlighting t)
(lsp-enable-which-key-integration t)
(lsp-remote-path '("~/.local/bin" "pylsp" "/usr/bin"))
:hook ((python-mode . lsp-deferred)
(sh-mode . lsp-deferred)
(typescript-ts-mode . lsp-deferred)
(rust-mode . lsp-deferred)
(lsp-mode . lsp-enable-which-key-integration))
:config
(setq read-process-output-max (* 1024 1024))
(setq lsp-idle-delay 0.5))
(use-package lsp-ui
:commands lsp-ui-mode
:custom
(lsp-ui-doc-enable t)
(lsp-ui-doc-position 'at-point)
(lsp-ui-sideline-enable t))
;;;; Languages & Formatting
(use-package nix-mode
:mode "\\.nix\\'")
(use-package typescript-ts-mode)
(use-package rust-mode
:init
(setq rust-mode-treesitter-derive t))
(use-package python
:config
(when (eq system-type 'gnu/linux)
(add-to-list 'exec-path (expand-file-name "~/.local/bin"))))
(use-package flycheck
:hook (sh-mode python-mode)
:config
(add-hook 'python-mode-hook
;; Don't try to run flycheck over TRAMP.
(lambda ()
(when (file-remote-p default-directory)
(setq-local flycheck-disabled-checkers
'(python-mypy python-pylint python-flake8))))))
;; Uncomment if you use direnv
;; (use-package envrc :hook (after-init . envrc-global-mode))
(use-package markdown-mode)
(use-package yaml-mode)
(use-package lua-mode)
(use-package dired
:straight nil
:config
(require 'dired-x)
(setq dired-dwim-target t
dired-listing-switches "-alh"
dired-mouse-drag-files t))
;;;; Custom Functions & Startup
(defun rc/duplicate-line ()
"Duplicate current line"
(interactive)
(let ((column (- (point) (point-at-bol)))
(line (thing-at-point 'line t)))
(save-excursion
(move-end-of-line 1)
(insert "\n" (string-trim-right line)))
(forward-line 1)
(forward-char column)))
(global-set-key (kbd "C-c C-,") 'rc/duplicate-line)
;; Start with recent files
(recentf-mode 1)
(setq initial-buffer-choice #'recentf-open-files)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment