commit f0a99ee64f97639ac785c662fa8089b20021cf4e
parent bcb67d5b11bbe138203d336fca61f964e0f76fdc
Author: Ethan Long <ethandavidlong@gmail.com>
Date: Fri, 24 Nov 2023 00:27:48 +1100
We no longer need an early-init! Yay! Less files.
There are still many issues that need to be sorted with this config, but
it's getting better.
Diffstat:
| M | config.org | | | 185 | +++++++++++++++++++++++++++++++++++++++++-------------------------------------- |
| D | early-init.el | | | 11 | ----------- |
| M | init.el | | | 15 | ++++++++++++--- |
3 files changed, 109 insertions(+), 102 deletions(-)
diff --git a/config.org b/config.org
@@ -32,30 +32,41 @@ When using emacs-plus, you can have a light and a dark theme :)
We can use ~use-package~ to configure emacs at startup. On MacOS we leave things mostly default because emacs-mac doesn't look fugly, but on Linux we might as well get rid of all the clutter. Also we use spaces not tabs, begone tabs.
#+begin_src emacs-lisp
;; Emacs init config
+ ;; FIXME: This is really bulky, I will maybe make this a hook or something.
+ (defun ethandl/rel-line-nums ()
+ (display-line-numbers-mode t)
+ ;; Set line numbers to relative
+ (setq display-line-numbers 'relative)
+ (setq display-line-numbers-current-absolute t))
(use-package emacs
:elpaca nil
+ :hook
+ (prog-mode . ethandl/rel-line-nums)
:init
- ;; If there are 3 or more completions, cycle around when reaching the end of the completions
- (setq completion-cycle-threshold 3)
;; Get rid of default crud
(setq inhibit-startup-screen t)
(menu-bar-mode 0)
(tool-bar-mode 0)
(scroll-bar-mode 0)
(setq frame-resize-pixelwise t)
- (when (eq system-type 'darwin)
- (setq mac-option-modifier nil
- mac-command-modifier 'meta))
- ;; Modeline line and col number
- (line-number-mode 1)
- (column-number-mode 1)
+ ;; Modeline
+ (line-number-mode 1) ;; Line no.
+ (column-number-mode 1) ;; Col. no.
;; Indentation
(setq-default indent-tabs-mode nil)
- ;; SILENCE
- (setq ring-bell-function 'ignore)
+ (setq ring-bell-function 'ignore) ;; Get rid of the bell
;; Fuck Control+Scroll to zoom, that's terrible and seems to be bound by something in emacs-plus?
(global-unset-key (kbd "<C-wheel-up>"))
- (global-unset-key (kbd "<C-wheel-down>")))
+ (global-unset-key (kbd "<C-wheel-down>"))
+ ;; Autosave files need to piss off
+ (setq backup-directory-alist
+ `((".*" . ,temporary-file-directory)))
+ (setq auto-save-file-name-transforms
+ `((".*" ,temporary-file-directory t)))
+ ;; Ensure that the command key is the emacs meta key
+ (when (eq system-type 'darwin)
+ (setq mac-option-modifier nil
+ mac-command-modifier 'meta)))
#+end_src
** Fonts & Ligature definitions
#+begin_src emacs-lisp
@@ -188,6 +199,7 @@ Based completion. This is an overhaul of the autocomplete. Company mode sucks be
(corfu-cycle t)
(corfu-auto t)
(corfu-scroll-margin 5)
+ (completion-cycle-threshold 3)
:config
(global-corfu-mode)
;; Shouldn't have to do this, but lsp is a little bugged:
@@ -226,97 +238,101 @@ This solution will increase startup time, but will fix any path issues for most
#+end_src
* Org Mode
My org mode is based on [[https://orgmode.org/guide/Hyperlinks.html][a post by Diego Zamboni]]. The general idea is that we want headings to be bigger and more noticable than text, all regular text should be non-monospace, and all code should be in the regular monospace font.
-Starting out, let's configure the basics, we want indentation and variable pitch fonts, as well as lines that fill the whole screen well with variable font. We also want all code blocks to be fontified properly. We will wrap this all up in a function called ~org-mode-base~.
+Starting out, let's configure the basics, we want indentation and variable pitch fonts, as well as lines that fill the whole screen well with variable font. We also want all code blocks to be fontified properly. We will wrap this all up in a function called ~org-base~.
#+begin_src emacs-lisp
- (defun ethandl/org-mode-base ()
+ (defun ethandl/org-base ()
(require 'org)
(org-indent-mode t)
(variable-pitch-mode t)
(visual-line-mode t)
(setq org-src-fontify-natively t
- org-src-tab-acts-natively t))
-#+end_src
-Now let's make org prettier, we want all non-textual markers gone, our fonts to be correct, and bullet points for our headings as well as bullet lists. This is all wrapped up in the ~org-mode-prettify~ function.
-#+begin_src emacs-lisp
- (use-package org-superstar
- :hook (org-mode . org-superstar-mode)
- :config
- (setq org-hide-leading-stars nil)
- (setq org-superstar-leading-bullet ?\s)
- (setq org-indent-mode-turns-on-hiding-stars nil))
-
- (use-package org-autolist
- :hook (org-mode . org-autolist-mode))
-
- (defun ethandl/org-mode-prettify ()
- (setq org-hide-emphasis-markers t)
+ org-src-tab-acts-natively t
+ org-hide-leading-stars nil
+ org-indent-mode-turns-on-hiding-stars nil
+ org-hide-emphasis-markers t)
(font-lock-add-keywords 'org-mode
'(("^ *\\([-]\\) "
- (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))
-
- (let* ((variable-tuple
- (cond ((x-list-fonts "ETBookOT") '(:font "ETBookOT"))
- ((x-family-fonts "Sans Serif") '(:family "Sans Serif"))
- (nil (warn "Cannot find a Sans Serif Font. Install Source Sans Pro."))))
- (base-font-color (face-foreground 'default nil 'default))
- (headline `(:inherit default :weight bold :foreground ,base-font-color)))
-
+ (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•")))))))
+#+end_src
+Now we want to change the fonts:
+#+begin_src emacs-lisp
+ (defun ethandl/org-font ()
+ (require 'org)
+ (let*
+ ;; Variable bindings
+ ((variable-font (if (x-list-fonts "ETBookOT")
+ '(:font "ETBookOT")
+ '(:family "Serif")))
+ (mono-font (if (x-list-fonts "Victor Mono")
+ '(:font "Victor Mono")
+ '(:family "Mono")))
+ (base-font-color (face-foreground 'default nil 'default))
+ (headline `(:inherit default :weight bold :foreground ,base-font-color))
+ (body `(:inherit default :weight thin :foreground ,base-font-color :height 200)) ;; 20 pt
+ (code `(:weight regular :height 0.8 :inherit t)))
+ ;; Actual function body
(custom-theme-set-faces
'user
- `(org-level-8 ((t (,@headline ,@variable-tuple :height 1.1))))
- `(org-level-7 ((t (,@headline ,@variable-tuple :height 1.1))))
- `(org-level-6 ((t (,@headline ,@variable-tuple :height 1.1))))
- `(org-level-5 ((t (,@headline ,@variable-tuple :height 1.1))))
- `(org-level-4 ((t (,@headline ,@variable-tuple :height 1.1))))
- `(org-level-3 ((t (,@headline ,@variable-tuple :height 1.25))))
- `(org-level-2 ((t (,@headline ,@variable-tuple :height 1.5))))
- `(org-level-1 ((t (,@headline ,@variable-tuple :height 1.75))))
- `(org-document-title ((t (,@headline ,@variable-tuple :height 2.0 :underline nil))))))
-
- (custom-theme-set-faces
- 'user
- '(variable-pitch ((t (:family "ETBookOT" :height 200 :weight thin))))
- '(fixed-pitch ((t (:family "Victor Mono" :height 0.8 :weight regular :inherit t)))))
-
- (custom-theme-set-faces
- 'user
- '(org-block ((t (:inherit fixed-pitch))))
- '(org-code ((t (:inherit (shadow fixed-pitch)))))
- '(org-document-info ((t (:foreground "dark orange"))))
- '(org-document-info-keyword ((t (:inherit (shadow fixed-pitch)))))
- '(org-indent ((t (:inherit (org-hide fixed-pitch)))))
- '(org-link ((t (:foreground "royal blue" :underline t))))
- '(org-meta-line ((t (:inherit (font-lock-comment-face fixed-pitch)))))
- '(org-property-value ((t (:inherit fixed-pitch))) t)
- '(org-special-keyword ((t (:inherit (font-lock-comment-face fixed-pitch)))))
- '(org-table ((t (:inherit fixed-pitch :foreground "#83a598"))))
- '(org-tag ((t (:inherit (shadow fixed-pitch) :weight bold :height 0.8))))
- '(org-verbatim ((t (:inherit (shadow fixed-pitch)))))))
-#+end_src
-
-Unfortunately, there are some source mode highlighting issues with the Catppuccin theme in org mode, so this is the current fix until it is built into the Catppuccin theme.
+ `(variable-pitch ((t (,@variable-font ,@body))))
+ `(fixed-pitch ((t (,@mono-font ,@code))))
+ `(org-level-8 ((t (,@variable-font ,@headline :height 1.1))))
+ `(org-level-7 ((t (,@variable-font ,@headline :height 1.2))))
+ `(org-level-6 ((t (,@variable-font ,@headline :height 1.3))))
+ `(org-level-5 ((t (,@variable-font ,@headline :height 1.4))))
+ `(org-level-4 ((t (,@variable-font ,@headline :height 1.5))))
+ `(org-level-3 ((t (,@variable-font ,@headline :height 1.6))))
+ `(org-level-2 ((t (,@variable-font ,@headline :height 1.7))))
+ `(org-level-1 ((t (,@variable-font ,@headline :height 1.8))))
+ `(org-document-title ((t (,@variable-font ,@headline :height 2.0 :underline nil))))
+ '(org-block ((t (:inherit fixed-pitch))))
+ '(org-code ((t (:inherit (shadow fixed-pitch)))))
+ '(org-document-info ((t (:foreground "dark orange"))))
+ '(org-document-info-keyword ((t (:inherit (shadow fixed-pitch)))))
+ '(org-indent ((t (:inherit (org-hide fixed-pitch)))))
+ '(org-link ((t (:foreground "royal blue" :underline t))))
+ '(org-meta-line ((t (:inherit (font-lock-comment-face fixed-pitch)))))
+ '(org-property-value ((t (:inherit fixed-pitch))))
+ '(org-special-keyword ((t (:inherit (font-lock-comment-face fixed-pitch)))))
+ '(org-table ((t (:inherit fixed-pitch :foreground "#83a598"))))
+ '(org-tag ((t (:inherit (shadow fixed-pitch) :weight bold :height 0.8))))
+ '(org-verbatim ((t (:inherit (shadow fixed-pitch))))))))
+#+end_src
+LaTeX in Org settings:
+#+begin_src emacs-lisp
+ (defun ethandl/org-latex ()
+ (setq org-preview-latex-default-process 'dvisvgm)
+ ;; This should not be necessary, but it seems like they are with the experimental version of org
+ (add-to-list 'org-latex-packages-alist '("" "amsmath" t))
+ (add-to-list 'org-latex-packages-alist '("" "amssymb" t))
+ (when (>= (string-to-number (org-version)) 9.7)
+ (org-latex-preview-auto-mode t)))
+#+end_src
+HACK fix for the catppuccin theme: (https://github.com/catppuccin/emacs/issues/61)
#+begin_src emacs-lisp
(add-to-list 'org-src-block-faces (list "" (list :foreground (catppuccin-get-color 'green))))
(defun ctp/text-org-blocks ()
(face-remap-add-relative 'org-block (list :foreground (catppuccin-get-color 'text))))
- (add-hook 'org-mode-hook 'ctp/text-org-blocks)
#+end_src
-
-We need to configure the ~org~ package. Technically we could install the git version here with elpaca, but that version is just broken. We therefore will just use the built-in package that comes with emacs. This initial setup will hook into the ~org-mode-base~ and ~org-mode-prettify~ functions that we made before to give us the final result 😌.
+Finally, we put all the hooks together:
#+begin_src emacs-lisp
- ;; We already installed the latest version of org in our init.el
(use-package org
- :elpaca nil
- :hook ((org-mode . ethandl/org-mode-base)
- (org-mode . turn-on-org-cdlatex)
- (org-mode . ethandl/org-mode-prettify))
- )
+ :elpaca nil ;; Can be removed after 9.7 is released
+ :hook
+ (org-mode . ethandl/org-base)
+ (org-mode . ethandl/org-font)
+ (org-mode . ethandl/org-latex)
+ (org-mode . ctp/text-org-blocks))
#+end_src
-Adding in the ability to seamlessly paste in images from the clipboard:
+Other auxillary packages for Org mode:
#+begin_src emacs-lisp
- (use-package org-download
+ (use-package org-superstar ;; Nicer bullet fonts
+ :hook (org-mode . org-superstar-mode)
+ :config (setq org-superstar-leading-bullet ?\s))
+ (use-package org-autolist ;; Automatic bulleting
+ :hook (org-mode . org-autolist-mode))
+ (use-package org-download ;; Seamless image pasting
:after org
:defer nil
:custom
@@ -331,13 +347,6 @@ Adding in the ability to seamlessly paste in images from the clipboard:
:config
(require 'org-download))
#+end_src
-We want nice ~org-latex~ previews, this isn't strictly necessary because we're using a build of org with better LaTeX previews, but it's still nice to have if that ever changes.
-#+begin_src emacs-lisp
- (setq org-preview-latex-default-process 'dvisvgm)
- ;; This should not be necessary, but it seems the default packages is a lot barer than before.
- (add-to-list 'org-latex-packages-alist '("" "amsmath" t))
- (add-to-list 'org-latex-packages-alist '("" "amssymb" t))
-#+end_src
* Languages
** LSP Setup
LSP, the Language Server Protocol. Very nice for debugging code live as you write it. It depends on the language as to how useful this really is.
diff --git a/early-init.el b/early-init.el
@@ -1,11 +0,0 @@
-;; HACK Work around native compilation on macOS failing with 'ld: library not
-;; found for -lemutls_w'.
-;; https://github.com/d12frosted/homebrew-emacs-plus/issues/554
-(setenv "LIBRARY_PATH"
- (string-join
- '("/opt/homebrew/opt/gcc/lib/gcc/13"
- "/opt/homebrew/opt/libgccjit/lib/gcc/13"
- "/opt/homebrew/opt/gcc/lib/gcc/13/gcc/aarch64-apple-darwin22/13")
- ":"))
-(setq package-enable-at-startup nil)
-;;(add-to-list 'default-frame-alist '(undecorated-round . t))
diff --git a/init.el b/init.el
@@ -1,11 +1,20 @@
-;; Elpaca package manager
-(defvar elpaca-installer-version 0.5)
+;; HACK: Work around native compilation on macOS failing with 'ld: library not
+;; found for -lemutls_w'.
+;; https://github.com/d12frosted/homebrew-emacs-plus/issues/554
+(setenv "LIBRARY_PATH"
+ (string-join
+ '("/opt/homebrew/opt/gcc/lib/gcc/13"
+ "/opt/homebrew/opt/libgccjit/lib/gcc/13"
+ "/opt/homebrew/opt/gcc/lib/gcc/13/gcc/aarch64-apple-darwin22/13")
+ ":"))
+
+(defvar elpaca-installer-version 0.6)
(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"))
+ :files (:defaults "elpaca-test.el" (:exclude "extensions"))
:build (:not elpaca--activate-package)))
(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory))
(build (expand-file-name "elpaca/" elpaca-builds-directory))