aboutsummaryrefslogtreecommitdiff
path: root/.config/emacs
diff options
context:
space:
mode:
authorLuca Matei Pintilie <luca@lucamatei.com>2025-02-13 21:07:37 +0000
committerLuca Matei Pintilie <luca@lucamatei.com>2025-02-13 21:08:02 +0000
commita3faadfd9b0dc2332c64087b29b878f546e44d87 (patch)
tree470d573220e71d11a9cf3238ddfacda8a812fc71 /.config/emacs
parent1ce79bbf109eaef85fbb81c891cd594f48323e76 (diff)
downloaddotfiles-master.tar
dotfiles-master.tar.gz
dotfiles-master.tar.bz2
dotfiles-master.tar.lz
dotfiles-master.tar.xz
dotfiles-master.tar.zst
dotfiles-master.zip
emacs: new configHEADmaster
Diffstat (limited to '')
-rw-r--r--.config/emacs/custom.el13
-rw-r--r--.config/emacs/early-init.el1
-rw-r--r--.config/emacs/init.el421
3 files changed, 372 insertions, 63 deletions
diff --git a/.config/emacs/custom.el b/.config/emacs/custom.el
new file mode 100644
index 0000000..ab4d983
--- /dev/null
+++ b/.config/emacs/custom.el
@@ -0,0 +1,13 @@
+(custom-set-variables
+ ;; custom-set-variables was added by Custom.
+ ;; If you edit it by hand, you could mess it up, so be careful.
+ ;; Your init file should contain only one such instance.
+ ;; If there is more than one, they won't work right.
+ '(inhibit-default-init 1)
+ '(inhibit-startup-screen t))
+(custom-set-faces
+ ;; custom-set-faces was added by Custom.
+ ;; If you edit it by hand, you could mess it up, so be careful.
+ ;; Your init file should contain only one such instance.
+ ;; If there is more than one, they won't work right.
+ )
diff --git a/.config/emacs/early-init.el b/.config/emacs/early-init.el
deleted file mode 100644
index 512068a..0000000
--- a/.config/emacs/early-init.el
+++ /dev/null
@@ -1 +0,0 @@
-(setq package-enable-at-startup nil)
diff --git a/.config/emacs/init.el b/.config/emacs/init.el
index 23883f6..2ff7501 100644
--- a/.config/emacs/init.el
+++ b/.config/emacs/init.el
@@ -1,70 +1,367 @@
-(defvar elpaca-installer-version 0.3)
-(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
- :files (:defaults (: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)
- (condition-case-unless-debug err
- (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
- ((zerop (call-process "git" nil buffer t "clone"
- (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)))
- (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))
-
-;; Install use-package support
-(elpaca elpaca-use-package
- ;; Enable :elpaca use-package keyword.
- (elpaca-use-package-mode)
- ;; Assume :elpaca t unless otherwise specified.
- (setq elpaca-use-package-by-default t))
-
-;; Block until current queue processed.
-(elpaca-wait)
-
-
-(use-package evil :demand t)
+;;; init.el --- Emacs configuration -*- lexical-binding: t -*-
+
+;;; Commentary:
+
+;; Save the contents of this file to ~/.config/emacs/init.el and
+;; you're ready to boot up Emacs.
+
+;; Hack this file! One of the best ways to get started with Emacs is
+;; to look at other peoples' configurations and extract the pieces
+;; that work for you. That's where this configuration started. I
+;; encourage you to read through the code in this file and explore the
+;; functions and variables using the built-in help system (details
+;; below). Happy hacking!
+
+;; "C-<chr> means hold the CONTROL key while typing the character <chr>.
+;; Thus, C-f would be: hold the CONTROL key and type f." (Emacs tutorial)
+;;
+;; - C-h t: Start the Emacs tutorial
+;; - C-h o some-symbol: Describe symbol
+;; - C-h C-q: Pull up the quick-help cheatsheet
+
+;;; Code:
+
+;; Performance tweaks for modern machines
+(setq gc-cons-threshold 100000000) ; 100 mb
+(setq read-process-output-max
+ (* 1024 1024)) ; 1mb
+
+;; Remove extra UI clutter by hiding the scrollbar, menubar, and toolbar.
+(menu-bar-mode -1)
+(tool-bar-mode -1)
+(scroll-bar-mode -1)
+;; Set the font. Note: height = px * 100
+;; (set-face-attribute 'default nil :font "Courier New" :height 120)
+
+;; Add unique buffer names in the minibuffer where there are many
+;; identical files. This is super useful if you rely on folders for
+;; organization and have lots of files with the same name,
+;; e.g. foo/index.ts and bar/index.ts.
+(require 'uniquify)
+
+;; Automatically insert closing parens
+(electric-pair-mode t)
+
+;; Visualize matching parens
+(show-paren-mode 1)
+
+;; Prefer spaces to tabs
+(setq-default indent-tabs-mode nil)
+
+;; Automatically save your place in files
+(save-place-mode t)
+
+;; Save history in minibuffer to keep recent commands easily accessible
+(savehist-mode t)
+
+;; Keep track of open files
+(recentf-mode t)
+
+;; Keep files up-to-date when they change outside Emacs
+(global-auto-revert-mode t)
+
+;; Tabs
+(global-tab-line-mode)
+
+;; Display line numbers only when in programming modes
+(add-hook 'prog-mode-hook
+ 'display-line-numbers-mode)
+
+;; Resize text, like in a terminal
+(global-set-key (kbd "C-+") 'text-scale-increase)
+(global-set-key (kbd "C--") 'text-scale-decrease)
+
+;; The `setq' special form is used for setting variables. Remember
+;; that you can look up these variables with "C-h v variable-name".
+(setq uniquify-buffer-name-style
+ 'forward
+ window-resize-pixelwise
+ t
+ frame-resize-pixelwise
+ t
+ load-prefer-newer
+ t
+ backup-by-copying
+ t
+ display-line-numbers 'relative
+ state-directory (concat (getenv "XDG_STATE_HOME") "/emacs")
+ ;; Backups are placed into your Emacs directory, e.g. ~/.config/emacs/backups
+ backup-directory-alist `(("." . ,(concat state-directory "backups")))
+ ;; I'll add an extra note here since user customizations are important.
+ ;; Emacs actually offers a UI-based customization menu, "M-x customize".
+ ;; You can use this menu to change variable values across Emacs. By default,
+ ;; changing a variable will write to your init.el automatically, mixing
+ ;; your hand-written Emacs Lisp with automatically-generated Lisp from the
+ ;; customize menu. The following setting instead writes customizations to a
+ ;; separate file, custom.el, to keep your init.el clean.
+ custom-file
+ (expand-file-name "custom.el" user-emacs-directory))
+
+(load custom-file)
+
+;; Bring in package utilities so we can install packages from the web.
+(require 'package)
+
+;; Add MELPA, an unofficial (but well-curated) package registry to the
+;; list of accepted package registries. By default Emacs only uses GNU
+;; ELPA and NonGNU ELPA, https://elpa.gnu.org/ and
+;; https://elpa.nongnu.org/ respectively.
+(add-to-list 'package-archives
+ '("melpa" . "https://melpa.org/packages/"))
+
+;; Unless we've already fetched (and cached) the package archives,
+;; refresh them.
+;; (unless package-archive-contents
+;; (package-refresh-contents))
+
+;; Add the :vc keyword to use-package, making it easy to install
+;; packages directly from git repositories.
+(unless (package-installed-p 'vc-use-package)
+ (package-vc-install "https://github.com/slotThe/vc-use-package"))
+(require 'vc-use-package)
+
+;; A quick primer on the `use-package' function (refer to
+;; "C-h f use-package" for the full details).
+;;
+;; (use-package my-package-name
+;; :ensure t ; Ensure my-package is installed
+;; :after foo ; Load my-package after foo is loaded (seldom used)
+;; :init ; Run this code before my-package is loaded
+;; :bind ; Bind these keys to these functions
+;; :custom ; Set these variables
+;; :config ; Run this code after my-package is loaded
+
+;; A package with a great selection of themes:
+;; https://protesilaos.com/emacs/ef-themes
+(use-package dracula-theme :ensure t :config
+ (load-theme 'dracula t))
+
+;; Minibuffer completion is essential to your Emacs workflow and
+;; Vertico is currently one of the best out there. There's a lot to
+;; dive in here so I recommend checking out the documentation for more
+;; details: https://elpa.gnu.org/packages/vertico.html. The short and
+;; sweet of it is that you search for commands with "M-x do-thing" and
+;; the minibuffer will show you a filterable list of matches.
+(use-package vertico
+ :ensure
+ t
+ :custom
+ (vertico-cycle t)
+ (read-buffer-completion-ignore-case t)
+ (read-file-name-completion-ignore-case t)
+ (completion-styles '(basic substring partial-completion flex))
+ :init
+ (vertico-mode))
+
+;; Improve the accessibility of Emacs documentation by placing
+;; descriptions directly in your minibuffer. Give it a try:
+;; "M-x find-file".
+(use-package marginalia
+ :after
+ vertico
+ :ensure
+ t
+ :init
+ (marginalia-mode))
+
+;; Adds intellisense-style code completion at point that works great
+;; with LSP via Eglot. You'll likely want to configure this one to
+;; match your editing preferences, there's no one-size-fits-all
+;; solution.
+(use-package corfu
+ :ensure
+ t
+ :init
+ (global-corfu-mode)
+ :custom
+ (corfu-auto t)
+ ;; You may want to play with delay/prefix/styles to suit your preferences.
+ (corfu-auto-delay 0)
+ (corfu-auto-prefix 0)
+ (completion-styles '(basic)))
+
+;; Adds LSP support. Note that you must have the respective LSP
+;; server installed on your machine to use it with Eglot. e.g.
+;; rust-analyzer to use Eglot with `rust-mode'.
(use-package eglot
- :commands (eglot eglot-ensure)
- :hook ((python-mode . eglot-ensure)
- (csharp-mode . eglot-ensure))
+ :ensure
+ t
+ :bind
+ (("s-<mouse-1>" . eglot-find-implementation)
+ ("C-c ." . eglot-code-action-quickfix)
+ ("C-c r" . eglot-rename)
+ ("C-c f" . eglot-format))
+ ;; Add your programming modes here to automatically start Eglot,
+ ;; assuming you have the respective LSP server installed.
+ :hook
+ ((go-mode . eglot-ensure)
+ (web-mode . eglot-ensure)
+ (rust-mode . eglot-ensure)
+ (csharp-ts-mode . eglot-ensure)
+ (scheme-mode . eglot-ensure))
+ :config
+ ;; You can configure additional LSP servers by modifying
+ ;; `eglot-server-programs'. The following tells eglot to use TypeScript
+ ;; language server when working in `web-mode'.
+ (add-to-list 'eglot-server-programs
+ '(web-mode . ("typescript-language-server" "--stdio"))
+ '(scheme-mode . ("guile-lsp-server"))))
+
+
+
+;; Add extra context to Emacs documentation to help make it easier to
+;; search and understand. This configuration uses the keybindings
+;; recommended by the package author.
+;; Add extra context to Emacs documentation to help make it easier to
+;; search and understand. This configuration uses the keybindings
+;; recommended by the package author.
+(use-package helpful
+ :ensure t
+ :bind (("C-h f" . #'helpful-callable)
+ ("C-h v" . #'helpful-variable)
+ ("C-h k" . #'helpful-key)
+ ("C-c C-d" . #'helpful-at-point)
+ ("C-h F" . #'helpful-function)
+ ("C-h C" . #'helpful-command)))
+
+;; Adds vim emulation. Activate `evil-mode' to swap your default Emacs
+;; keybindings with the modal editor of great infamy. There's a ton of
+;; keybindings that Evil needs to modify, so this configuration also
+;; includes `evil-collection' to fill in the gaps.
+(use-package evil
+ :ensure
+ t
+ :init
+ (setq evil-want-integration t)
+ (setq evil-want-keybinding nil)
+ :config
+ (evil-mode 1))
+
+(use-package evil-collection
+ :after
+ evil
+ :ensure
+ t
+ :config
+ (evil-collection-init))
+
+(use-package evil-surround
+ :after evil
+ :ensure t
:config
- (progn
- (define-key eglot-mode-map (kbd "C-c e r") 'eglot-rename)
- (define-key eglot-mode-map (kbd "C-c e f") 'eglot-format)
- (define-key eglot-mode-map (kbd "C-c e h") 'eglot-help-at-point)
- (add-to-list 'eglot-server-programs
- `(csharp-mode . ("omnisharp" "-lsp")))))
+ (global-evil-surround-mode 1))
+
+;; `org-mode' is great but Denote makes it even better by adding
+;; features that you'd find in something like Obsidian (like
+;; backlinks!). You can write your notes in org, markdown, or plain
+;; text, though I recommend giving `org-mode' a try if you've never
+;; used it before. The Denote manual is also excellent:
+;; https://protesilaos.com/emacs/denote
+(use-package denote
+ :ensure
+ t
+ :custom
+ (denote-known-keywords '("emacs" "journal"))
+ ;; This is the directory where your notes live.
+ (denote-directory (expand-file-name "~/denote/"))
+ :bind
+ (("C-c n n" . denote) ("C-c n f" . denote-open-or-create)
+ ("C-c n i" . denote-link)))
+
+;; An extremely feature-rich git client. Activate it with "C-c g".
+(use-package magit :ensure t :bind
+ (("C-c g" . magit-status)))
+
+;; In addition to installing packages from the configured package
+;; registries, you can also install straight from version control
+;; with the :vc keyword argument. For the full list of supported
+;; fetchers, view the documentation for the variable
+;; `vc-use-package-fetchers'.
+;;
+;; Breadcrumb adds, well, breadcrumbs to the top of your open buffers
+;; and works great with project.el, the Emacs project manager.
+;;
+;; Read more about projects here:
+;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Projects.html
+(use-package breadcrumb :vc
+ (:fetcher github :repo joaotavora/breadcrumb) :init
+ (breadcrumb-mode))
+
+;; As you've probably noticed, Lisp has a lot of parentheses.
+;; Maintaining the syntactical correctness of these parentheses
+;; can be a pain when you're first getting started with Lisp,
+;; especially when you're fighting the urge to break up groups
+;; of closing parens into separate lines. Luckily we have
+;; Paredit, a package that maintains the structure of your
+;; parentheses for you. At first, Paredit might feel a little
+;; odd; you'll probably need to look at a tutorial (linked
+;; below) or read the docs before you can use it effectively.
+;; But once you pass that initial barrier you'll write Lisp
+;; code like it's second nature.
+;; http://danmidwood.com/content/2014/11/21/animated-paredit.html
+;; https://stackoverflow.com/a/5243421/3606440
+(use-package paredit :ensure t :hook
+ ((emacs-lisp-mode . enable-paredit-mode)
+ (lisp-mode . enable-paredit-mode)
+ (ielm-mode . enable-paredit-mode)
+ (lisp-interaction-mode . enable-paredit-mode)
+ (scheme-mode . enable-paredit-mode)))
+
+(use-package go-mode
+ :ensure
+ t
+ :bind
+ (:map go-mode-map
+ ("C-c C-f" quote gofmt))
+ :hook
+ (before-save . gofmt-before-save))
-(use-package company :demand t)
+(use-package lua-mode :ensure t)
-(when (version<= "26.0.50" emacs-version )
- (global-display-line-numbers-mode))
+(use-package markdown-mode
+ :ensure
+ t
+ ;; These extra modes help clean up the Markdown editing experience.
+ ;; `visual-line-mode' turns on word wrap and helps editing commands
+ ;; work with paragraphs of text. `flyspell-mode' turns on an
+ ;; automatic spell checker.
+ :hook
+ ((markdown-mode . visual-line-mode)
+ (markdown-mode . flyspell-mode))
+ :init
+ (setq markdown-command "multimarkdown"))
-(setq backup-directory-alist '(("" . "~/.local/emacs/backup")))
+;; Note that `php-mode' assumes php code is separate from HTML.
+;; If you prefer working with PHP and HTML in a single file you
+;; may prefer `web-mode'.
+(use-package php-mode :ensure t)
+;; TypeScript, JS, and JSX/TSX support.
+(use-package web-mode
+ :ensure
+ t
+ :mode
+ (("\\.ts\\'" . web-mode) ("\\.js\\'" . web-mode)
+ ("\\.mjs\\'" . web-mode)
+ ("\\.tsx\\'" . web-mode)
+ ("\\.jsx\\'" . web-mode))
+ :custom
+ (web-mode-content-types-alist '(("jsx" . "\\.js[x]?\\'")))
+ (web-mode-code-indent-offset 2)
+ (web-mode-css-indent-offset 2)
+ (web-mode-markup-indent-offset 2)
+ (web-mode-enable-auto-quoting nil))
-; (add-hook 'after-init-hook 'global-company-mode)
+(use-package rust-mode
+ :ensure
+ t
+ :bind
+ (:map rust-mode-map
+ ("C-c C-r" quote rust-run)
+ ("C-c C-c" quote rust-compile)
+ ("C-c C-f" quote rust-format-buffer)
+ ("C-c C-t" quote rust-test))
+ :hook
+ (rust-mode . prettify-symbols-mode))
+(use-package yaml-mode :ensure t)