aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiran Bastaja <miran.bastaja04@gmail.com>2023-12-11 13:34:24 +0100
committerMiran Bastaja <miran.bastaja04@gmail.com>2023-12-11 13:34:24 +0100
commit29f838ed5ad2746b156338fad1d4938671fcbe57 (patch)
tree51276c32bf2ab8827e44fbf61902afb5d4bc1faa
parent74c1182bbf0b74a96cd2b9e3b2080f9e2acb2461 (diff)
WIP
-rw-r--r--share/home/emacs/default.nix2
-rw-r--r--share/home/emacs/early-init.el6
-rw-r--r--share/home/emacs/emacs.el185
-rw-r--r--share/home/emacs/emacs.org155
4 files changed, 132 insertions, 216 deletions
diff --git a/share/home/emacs/default.nix b/share/home/emacs/default.nix
index fbef3f1..6c40b78 100644
--- a/share/home/emacs/default.nix
+++ b/share/home/emacs/default.nix
@@ -1,7 +1,7 @@
{ pkgs, ... }:
let
my-emacs = pkgs.emacsWithPackagesFromUsePackage {
- config = ./emacs.org;
+ config = ./emacs.el;
defaultInitFile = true;
package = pkgs.emacs-pgtk;
alwaysEnsure = true;
diff --git a/share/home/emacs/early-init.el b/share/home/emacs/early-init.el
new file mode 100644
index 0000000..bbfc354
--- /dev/null
+++ b/share/home/emacs/early-init.el
@@ -0,0 +1,6 @@
+;;; early-init.el --- Early Initalization -*- lexical-binding: t; -*-
+;; All our packages come from Nix
+(setq package-enable-at-startup nil
+ package-archives nil)
+(provide 'early-init)
+;;; early-init.el ends here
diff --git a/share/home/emacs/emacs.el b/share/home/emacs/emacs.el
index 8eb5a89..76d7f9f 100644
--- a/share/home/emacs/emacs.el
+++ b/share/home/emacs/emacs.el
@@ -1,5 +1,4 @@
-;; -*- lexical-binding: t -*-
-;;; emacs-config --- My emacs config
+;;; init.el --- Initalization -*- lexical-binding: t; -*-
;;;
;;; Commentary:
;;; Various resources were used to hack together this config:
@@ -8,7 +7,55 @@
;;;
;;; Code:
-;;; Early stuff
+;;;;;;;;;;;;;;;;;;;;;;;
+;;; Startup ;;;
+;;;;;;;;;;;;;;;;;;;;;;;
+
+;;; Startup - Use package ;;;
+
+;; Most of this config is broken down into [[https://github.com/jwiegley/use-package][~use-package~]] stanzas. All
+;; dependencies are managed by [[https://nixos.org/][Nix]]. Any package with a true ~:ensure~
+;; keyword is found by [[https://github.com/nix-community/emacs-overlay#extra-library-functionality][~emacsWithPackagesFromUsePackage~]] to generate
+;; the set of Emacs packages to install with Nix.
+;;
+;; In the brutish non-Nix world, ~:ensure~ triggers Emacs' own package
+;; manager with willy nilly downloads. To prevent this, we tell
+;; ~use-package~ to assume the package is there and merely look for its
+;; autoloads.
+
+(defun ross/use-package-ensure-already-installed
+ (name _ensure state &optional _context)
+ "Value for `use-package-ensure-function` that assumes the package
+ is already installed. This is true in our Nix environment."
+ (let ((autoloads-file-name (format "%s-autoloads" name)))
+ (with-demoted-errors "Error loading autoloads: %s"
+ (load autoloads-file-name t t))))
+
+(setq use-package-ensure-function #'ross/use-package-ensure-already-installed)
+
+;; ~use-package~ also by default appends ~"-hook"~ to all its hooks.
+;; This impairs ripgreppability. Let's be explicit:
+
+(setq use-package-hook-name-suffix nil)
+
+;; use-package doesn't use itself. (Well, I think it could, but this
+;; is the recommended approach...)
+
+(eval-when-compile
+ (require 'use-package))
+
+;; some packages complain if I don't have this
+(use-package bind-key
+ :demand t
+ :bind
+ (:prefix-map rab/files-map
+ :prefix "C-c f")
+ :bind
+ (:prefix-map rab/toggles-map
+ :prefix "C-c t"))
+
+;;; Startup - Benchmarking ;;;
+
(use-package benchmark-init
:ensure t
:demand t
@@ -16,19 +63,15 @@
:config
(benchmark-init/activate))
-;;; GC
+;;; Startup - Garbage collection ;;;
+
(use-package gcmh
:ensure t
:diminish
:init (setq gc-cons-threshold (* 80 1024 1024))
:hook (emacs-startup . gcmh-mode))
-;; Trusted connections?
-(use-package gnutls
- :defer t
- :custom
- (gnutls-verify-error t))
-
+;;; Startup - Better cache location ;;;
(use-package no-littering
:ensure t
:init
@@ -39,19 +82,32 @@
(convert-standard-filename
(expand-file-name "eln-cache/" no-littering-var-directory)))))
-;;; use-package keywords
-(use-package bind-key
- :demand t
- :bind
- (:prefix-map rab/files-map
- :prefix "C-c f")
- :bind
- (:prefix-map rab/toggles-map
- :prefix "C-c t"))
-(use-package diminish :ensure t)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Customization ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;; Customization - Scrolling ;;;
+;; TODO: Smooth scroll
+
+;;; Customization - Theme ;;;
-;;; Disable menu-bar, tool-bar, and scroll-bar.
+(use-package doom-themes
+ :ensure t
+ :config
+ ;; Global settings (defaults)
+ (setq doom-themes-enable-bold t ; if nil, bold is universally disabled
+ doom-themes-enable-italic t) ; if nil, italics is universally disabled
+ (load-theme 'doom-one t)
+
+ ;; Enable flashing mode-line on errors
+ (doom-themes-visual-bell-config)
+ ;; Corrects (and improves) org-mode's native fontification.
+ (doom-themes-org-config))
+
+;;; Customization - General settings ;;;
+
+;; Disable menu-bar, tool-bar, and scroll-bar.
(if (fboundp 'menu-bar-mode)
(menu-bar-mode -1))
(if (fboundp 'tool-bar-mode)
@@ -59,21 +115,7 @@
(if (fboundp 'scroll-bar-mode)
(scroll-bar-mode -1))
-;;; Setup package.el
-(require 'package)
-(setq package-enable-at-startup nil)
-(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
-(unless package--initialized (package-initialize))
-
-;;; Setup use-package
-(unless (package-installed-p 'use-package)
- (package-refresh-contents)
- (package-install 'use-package))
-(eval-when-compile
- (require 'use-package))
-(setq use-package-always-ensure t)
-
-;;; Useful Defaults
+;; Useful Defaults
(setq-default cursor-type 'bar) ; Line-style cursor similar to other text editors
(setq inhibit-startup-screen t) ; Disable startup screen
(setq initial-scratch-message "") ; Make *scratch* buffer blank
@@ -82,45 +124,28 @@
(fset 'yes-or-no-p 'y-or-n-p) ; y-or-n-p makes answering questions faster
(show-paren-mode 1) ; Show closing parens by default
(global-auto-revert-mode t) ; Auto-update buffer if file has changed on disk
-(setopt create-lockfiles nil)
+(setopt create-lockfiles nil) ; Don't create lockfiles
+(electric-pair-mode 1) ; Autopairs
-(use-package display-line-numbers
- :custom
- (display-line-numbers-widen t)
- :hook
- ((prog-mode conf-mode) . display-line-numbers-mode))
+;;; Customization - Highlight current line ;;;
(use-package hl-line
:hook (on-first-buffer . global-hl-line-mode))
-;;; Load wheatgrass as the default theme if one is not loaded already
-(if (not custom-enabled-themes)
- (load-theme 'wheatgrass t))
-
-;; Autopairs
-(electric-pair-mode 1)
+;;; Customization - Evil ;;;
;; Set up vi keybinds
(use-package evil
:config
(evil-mode 1))
+;;; Customization - Direnv support ;;;
+
(use-package envrc
:ensure t
:hook (on-first-file . envrc-global-mode))
-(use-package nix-mode
- :mode "\\.nix\\'")
-
-;; Set up proof general for working with coq
-(use-package proof-general
- :mode ("\\.v\\'" . coq-mode))
-
-(use-package flycheck
- :init (global-flycheck-mode))
-
-(use-package company
- :init (global-company-mode))
+;;; Customziation - Completion framework ;;;
(use-package helm
:init
@@ -138,9 +163,49 @@
completion-category-defaults nil
completion-category-overrides nil))
+;;; Customization - Project management ;;;
+
(use-package projectile
:bind-keymap ("C-c p" . projectile-command-map)
:config
(projectile-mode +1))
+;;; Customization - Completions ;;;
+
+(use-package company
+ :init (global-company-mode))
+
+;;; Customization - Syntax checking ;;;
+
+(use-package flycheck
+ :init (global-flycheck-mode))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Languages ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;; Langauges - Emacs lisp ;;;
+
+;; Preserve indentation in org mode source blocks
+(dolist (pair '((org-src-preserve-indentation . t) (org-src-tab-acts-natively . t)))
+ (add-to-list 'safe-local-variable-values pair))
+
+;;; Languages - Nix ;;;
+
+(use-package nix-mode
+ :mode "\\.nix\\'")
+
+;;; Languages - Coq ;;;
+
+(use-package proof-general
+ :mode ("\\.v\\'" . coq-mode))
+
+;; ----------------------------------------------------------------------- ;;
+
+;; (use-package display-line-numbers
+;; :custom
+;; (display-line-numbers-widen t)
+;; :hook
+;; ((prog-mode conf-mode) . display-line-numbers-mode))
+
;;; emacs.el ends here
diff --git a/share/home/emacs/emacs.org b/share/home/emacs/emacs.org
deleted file mode 100644
index aa5dbae..0000000
--- a/share/home/emacs/emacs.org
+++ /dev/null
@@ -1,155 +0,0 @@
-#+TITLE: Miran Bastaja's Emacs Configuration
-#+PROPERTY: header-args :tangle init.el
-#+TOC: headlines 2
-
-* Preface
-
-** Inspiration
-
-The current structure of this config was pretty much entirely copied from
-[[https://rossabaker.com/configs/emacs/][Ross A. Baker's configuration]]. Many other resources such as stack overflow,
-and other peoples configs were used. Here's some of the more notable ones:
-- [[https://sanemacs.com/][sanemacs]]
-- [https://idiomdrottning.org/bad-emacs-defaults]
-
-** TODO Licensing
-
-* Startup
-
-** Early Init
-
-From preliterate items.
-#+begin_src emacs-lisp :tangle early-init.el
- ;; All our packages come from Nix
- (setq package-enable-at-startup nil
- package-archives nil)
- (provide 'early-init)
- ;;; early-init.el ends here
-#+end_src
-
-** Packages
-
-*** Ensuring packages
-
-Most of this config is broken down into [[https://github.com/jwiegley/use-package][~use-package~]] stanzas. All
-dependencies are managed by [[https://nixos.org/][Nix]]. Any package with a true ~:ensure~
-keyword is found by [[https://github.com/nix-community/emacs-overlay#extra-library-functionality][~emacsWithPackagesFromUsePackage~]] to generate
-the set of Emacs packages to install with Nix.
-
-In the brutish non-Nix world, ~:ensure~ triggers Emacs' own package
-manager with willy nilly downloads. To prevent this, we tell
-~use-package~ to assume the package is there and merely look for its
-autoloads.
-
-#+begin_src emacs-lisp
-(defun ross/use-package-ensure-already-installed
- (name _ensure state &optional _context)
- "Value for `use-package-ensure-function` that assumes the package
- is already installed. This is true in our Nix environment."
- (let ((autoloads-file-name (format "%s-autoloads" name)))
- (with-demoted-errors "Error loading autoloads: %s"
- (load autoloads-file-name t t))))
-
-(setq use-package-ensure-function #'ross/use-package-ensure-already-installed)
-#+end_src
-
-*** Hook naming
-
-~use-package~ also by default appends ~"-hook"~ to all its hooks.
-This impairs ripgreppability. Let's be explicit:
-
-#+begin_src emacs-lisp
-(setq use-package-hook-name-suffix nil)
-#+end_src
-
-*** Load it
-
-~use-package~ doesn't use itself. (Well, I think it could, but this
-is the recommended approach...)
-
-#+begin_src emacs-lisp
-(eval-when-compile
- (require 'use-package))
-#+end_src
-
-** Helpers
-
-*** General
-
-[[https://github.com/noctuid/general.el][General]] is known for keybindings, particularly among [[https://github.com/emacs-evil/evil][the evil]]. A
-lesser known feature is [[https://github.com/noctuid/general.el#settings][~general-setq~]], which understands the ~:set~
-hooks of custom variables. [[https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21695][#21695]] raged on for a half decade without
-a consensus, and I find this solution as tidy as any,
-
-#+begin_src emacs-lisp
-(use-package general :ensure)
-#+end_src
-
-* Personalization
-
-#+begin_src emacs-lisp
-(general-setq user-full-name "Miran Bastaja"
- user-mail-address "miran.bastaja04@gmail.com")
-#+end_src
-
-* Display
-
-** Scrolling
-
-Emacs' default scrolling behavior feels a bit janky in the 2020s.
-
-- ~scroll-conservatively~ has a magic number of ~100~. Greater than
- this scrolls just enough to get the point back on screen without
- recentering.
-
-- ~scroll-margin~ specifies how many lines of context to keep above
- and below the point.
-
-#+begin_src emacs-lisp
-(use-package emacs
- :custom
- (frame-inhibit-implied-resize t)
- (scroll-conservatively 101)
- (scroll-margin 2)
- (scroll-preserve-screen-position t))
-#+end_src
-
-* Customization
-
-** Theme
-
-I use [[https://github.com/doomemacs/themes][Doom emacs' theme pack]] to source my themes.
-
-#+begin_src emacs-lisp
-(use-package doom-themes
- :ensure t
- :config
- ;; Global settings (defaults)
- (setq doom-themes-enable-bold t ; if nil, bold is universally disabled
- doom-themes-enable-italic t) ; if nil, italics is universally disabled
- (load-theme 'doom-one t)
-
- ;; Enable flashing mode-line on errors
- (doom-themes-visual-bell-config)
- ;; Corrects (and improves) org-mode's native fontification.
- (doom-themes-org-config))
-#+end_src
-
-* Languages
-
-** Emacs Lisp
-
-I use local variables in this config to keep the code from indenting
-two spaces. Without this, we get prompted the first time we read
-this file:
-
-#+begin_src emacs-lisp
-(dolist (pair '((org-src-preserve-indentation . t) (org-src-tab-acts-natively . t)))
- (add-to-list 'safe-local-variable-values pair))
-#+end_src
-
-** Org
-
-#+begin_src emacs-lisp
-
-#+end_src