commit 5d47b09ea393c9432c6e6c9c53e547420e396177
parent f0a99ee64f97639ac785c662fa8089b20021cf4e
Author: Ethan Long <ethandavidlong@gmail.com>
Date: Sat, 25 Nov 2023 00:37:36 +1100
Some minor tweaks to the config :)
Next I just want to focus on speeding things up, the config is already
pretty minimal, I just need to exchange LSP-mode for the built-in LSP.
Diffstat:
| M | config.org | | | 202 | +++++++++++++++++++++++++++++++++++++++++-------------------------------------- |
1 file changed, 104 insertions(+), 98 deletions(-)
diff --git a/config.org b/config.org
@@ -28,16 +28,97 @@ When using emacs-plus, you can have a light and a dark theme :)
(add-hook 'ns-system-appearance-change-functions #'ethandl/apply-theme)
#+end_src
-* General Emacs/Editor settings
-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.
+* My Custom Elisp Functions
+** General Programming Configuration
#+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))
+#+end_src
+#+begin_src emacs-lisp
+ (defun ethandl/set-fonts (fontname &optional frame)
+ (with-selected-frame (or frame (selected-frame))
+ (set-face-attribute 'default nil :font fontname)
+ (set-face-attribute 'font-lock-comment-face nil :slant 'italic)
+ (set-face-attribute 'font-lock-keyword-face nil :slant 'italic)))
+#+end_src
+** Org Mode Configuration
+The following function is the base config for org-mode, it sets org to indent on section depth, sets the font to be variable pitch, turns on visual lines for wrapped lines.
+#+begin_src emacs-lisp
+ (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
+ org-hide-leading-stars nil
+ org-indent-mode-turns-on-hiding-stars nil
+ org-hide-emphasis-markers t)
+ (font-lock-add-keywords 'org-mode ;; HACK to fix the catppuccin theme
+ '(("^ *\\([-]\\) "
+ (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•")))))))
+#+end_src
+The following function is the config for org to set all the fonts. It is still a bit rough around the edges, I'd like to programatically set the heading sizes.
+#+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
+ `(variable-pitch ((t (,@variable-font ,@body))) t "Variable width font")
+ `(fixed-pitch ((t (,@mono-font ,@code))) t "Fixed width font")
+ `(org-level-8 ((t (,@variable-font ,@headline :height 1.1))) t "Heading level 8")
+ `(org-level-7 ((t (,@variable-font ,@headline :height 1.2))) t "Heading level 7")
+ `(org-level-6 ((t (,@variable-font ,@headline :height 1.3))) t "Heading level 6")
+ `(org-level-5 ((t (,@variable-font ,@headline :height 1.4))) t "Heading level 5")
+ `(org-level-4 ((t (,@variable-font ,@headline :height 1.5))) t "Heading level 4")
+ `(org-level-3 ((t (,@variable-font ,@headline :height 1.6))) t "Heading level 3")
+ `(org-level-2 ((t (,@variable-font ,@headline :height 1.7))) t "Heading level 2")
+ `(org-level-1 ((t (,@variable-font ,@headline :height 1.8))) t "Heading level 1")
+ `(org-document-title ((t (,@variable-font ,@headline :height 2.0 :underline nil))) t "Document title")
+ '(org-block ((t (:inherit fixed-pitch))) t "Verbatim block")
+ '(org-code ((t (:inherit (shadow fixed-pitch)))) t "Code block")
+ '(org-document-info ((t (:foreground "dark orange"))) t "Document info")
+ '(org-document-info-keyword ((t (:inherit (shadow fixed-pitch)))) t "Document info keys")
+ '(org-indent ((t (:inherit (org-hide fixed-pitch)))) t "Trailing Org Indentation")
+ '(org-link ((t (:foreground "royal blue" :underline t))) t "Links")
+ '(org-meta-line ((t (:inherit (font-lock-comment-face fixed-pitch)))) t "Metadata")
+ '(org-property-value ((t (:inherit fixed-pitch))) t "Org value")
+ '(org-special-keyword ((t (:inherit (font-lock-comment-face fixed-pitch)))) t "Org keyword")
+ '(org-table ((t (:inherit fixed-pitch :foreground "#83a598"))) t "Org table")
+ '(org-tag ((t (:inherit (shadow fixed-pitch) :weight bold :height 0.8))) t "Org tag")
+ '(org-verbatim ((t (:inherit (shadow fixed-pitch)))) t "Verbatim"))))
+#+end_src
+Some configuration for the LaTeX that appears in Org mode. We want to make sure that it's SVG, and also if we have the ability to, we should auto-render it.
+#+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
+* General Emacs/Editor settings
+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
(use-package emacs
:elpaca nil
:hook
@@ -71,14 +152,9 @@ We can use ~use-package~ to configure emacs at startup. On MacOS we leave things
** Fonts & Ligature definitions
#+begin_src emacs-lisp
;; Set the fonts
- (defun custom-set-fonts (&optional frame)
- (with-selected-frame (or frame (selected-frame))
- ;;(set-face-attribute 'default nil :font "Comic Code Ligatures-16")
- (set-face-attribute 'default nil :font "Victor Mono-16")
- (set-face-attribute 'font-lock-comment-face nil :slant 'italic)
- (set-face-attribute 'font-lock-keyword-face nil :slant 'italic)))
- (custom-set-fonts)
- (add-hook 'after-make-frame-functions 'custom-set-fonts)
+ ;; (ethandl/set-fonts "Comic Code Ligatures-16")
+ (ethandl/set-fonts "Victor Mono-16")
+ (add-hook 'after-make-frame-functions 'ethandl/set-fonts)
#+end_src
#+begin_src emacs-lisp
(setq comic-code-ligs '(("-" (rx (+ "-"))) ("-" (rx (* "-") ">"))
@@ -102,17 +178,18 @@ We can use ~use-package~ to configure emacs at startup. On MacOS we leave things
"==" "===" "::" ":=" ":>" ":<" ">:" ";;" "<|" "<|>"
"|>" "<>" "<$" "<$>" "$>" "<+" "<+>" "+>" "?=" "/="
"/==" "/\\" "\\/" "__" "&&" "++" "+++"))
+ (setq ligs victor-mono-ligs)
#+end_src
* Packages
** Ivy and Counsel (Better Text Navigation)
[[https://github.com/abo-abo/swiper][Ivy and Counsel]] are replacements for the default ~find-file~ and =M-x= menus.
#+begin_src emacs-lisp
;; ivy mode instead of ido mode:
- (use-package ivy)
- (add-hook 'elpaca-after-init-hook (lambda () (ivy-mode t)))
+ (use-package ivy
+ :hook (elpaca-after-init . ivy-mode))
;; counsel extends ivy:
- (use-package counsel)
- (add-hook 'elpaca-after-init-hook (lambda () (counsel-mode t)))
+ (use-package counsel
+ :hook (elpaca-after-init . counsel-mode))
#+end_src
** Ligature.el / Ligature set up
Ligatures are native on =emacs-mac=, so we just call the built in helper function if we are using that. If not, we will use [[https://github.com/mickeynp/ligature.el][ligature.el]] to give ligatures with Harfbuzz.
@@ -124,7 +201,7 @@ Ligatures are native on =emacs-mac=, so we just call the built in helper functio
;; Else, we're in a vanilla emacs
(use-package ligature
:config
- (ligature-set-ligatures 'prog-mode victor-mono-ligs)
+ (ligature-set-ligatures 'prog-mode ligs)
(global-ligature-mode t)))
#+end_src
** Rainbow Delimiters
@@ -138,9 +215,8 @@ Rainbow delimiters are essential for working with LISP, and are just nice to hav
This modeline is supposedly sexier than the original, honestly I don't mind the original either, it's also very nice. If there's ever a reason to ditch this because of some bug or performance issue, etc. then don't be afraid to.
#+begin_src emacs-lisp
;; Doom modeline:
- (use-package doom-modeline)
-
- (add-hook 'elpaca-after-init-hook (lambda () (doom-modeline-mode t)))
+ (use-package doom-modeline
+ :hook (elpaca-after-init . doom-modeline-mode))
#+end_src
** Which Key?
Fix my ineptitude in this keyboard chord hell.
@@ -165,7 +241,7 @@ Fix my ineptitude in this chord hell that is emacs. I mean seriously, chords jus
(setq evil-want-C-i-jump nil)
(setq evil-undo-system 'undo-redo)
:config
- (evil-mode 1)
+ (evil-mode t)
;; Enabling C-g to exit from normal mode, and C-h to do what it normally does in emacs
(define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state)
(define-key evil-insert-state-map (kbd "C-h") 'evil-delete-backward-char-and-join)
@@ -220,12 +296,12 @@ Here are a few more nice things for scrolling.
;; Change the default scroll behaviour to smooth scroll
(pixel-scroll-precision-mode t))
;; Scrolling down a file only goes down a single line when reaching the bottom
- (setq scroll-step 1)
- (setq hscroll-step 1)
- ;; The region that the curser needs to enter to trigger scrolling
- ;;(setq scroll-margin 5)
- ;; Necessary to stop random jumps
- (setq scroll-conservatively 10000)
+ (setq scroll-step 1
+ hscroll-step 1
+ ;; The region that the curser needs to enter to trigger scrolling
+ scroll-margin 5
+ ;; Necessary to stop random jumps
+ scroll-conservatively 10000)
#+end_src
** Exec path from shell (Fix Path issues)
When running emacs as a daemon, we have a notable lack of things in our ~PATH~ because daemons are started in a minimal environment, at least on MacOS.
@@ -238,76 +314,6 @@ 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-base~.
-#+begin_src emacs-lisp
- (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
- 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) "•")))))))
-#+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
- `(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))))
@@ -315,7 +321,7 @@ HACK fix for the catppuccin theme: (https://github.com/catppuccin/emacs/issues/6
(defun ctp/text-org-blocks ()
(face-remap-add-relative 'org-block (list :foreground (catppuccin-get-color 'text))))
#+end_src
-Finally, we put all the hooks together:
+The org configuration uses a lot of custom functions, see the
#+begin_src emacs-lisp
(use-package org
:elpaca nil ;; Can be removed after 9.7 is released