From d570c9e9f7f36297ebfe97a37f65444846c68891 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Wed, 24 Jan 2024 09:39:06 -0600 Subject: [PATCH] switching to using ligature-mode instead of self rolled. This makes it so in org mode ligatures aren't used --- README.org | 113 +++++++++++++++++++++++++++++++++-------------------- init.el | 113 +++++++++++++++++++++++++++++++++-------------------- 2 files changed, 142 insertions(+), 84 deletions(-) diff --git a/README.org b/README.org index f27d2e92..e1f2ccf0 100644 --- a/README.org +++ b/README.org @@ -409,26 +409,10 @@ Let's make xref use ripgrep instead of grep for speed. ** Fix NixOS I am currently using NixOS. In order for emacs to have access to certain programs, we need to set some environment variables #+begin_src emacs-lisp -(add-to-list 'exec-path "/home/chris/.nix-profile/bin") -;; (add-to-list 'exec-path "/etc/profiles/per-user/chris/bin") -;; (add-to-list 'exec-path "/run/current-system/sw/bin") -(add-to-list 'exec-path "/run/current-system/profile/bin") (add-to-list 'exec-path "/usr/bin") -;; (add-to-list 'exec-path "/opt/android-sdk/cmdline-tools/latest/bin") -;; (add-to-list 'exec-path "/home/chris/bin") - -;; (setq exec-directory "/usr/bin") (setenv "NIX_CONF_DIR" "/etc/nix") -(setenv "NIX_OTHER_STORES" "/run/nix/remote-stores/*/nix") -(setenv "NIX_PATH" "nixpkgs=%h/nixpkgs:nixos=%h/nixpkgs/nixos:nixos-config=/etc/nixos/configuration.nix") -(setenv "NIX_PROFILES" "${pkgs.lib.concatStringsSep " " config.environment.profiles}") (setenv "NIX_REMOTE" "daemon") -(setenv "NIX_USER_PROFILE_DIR" "/nix/var/nix/profiles/per-user/%u") (setenv "XCURSOR_THEME" "phinger-cursors-light") -;; (load "site-paths" t) -(setenv "CC" "/run/current-system/sw/bin/gcc") -(setenv "CXX" "/run/current-system/sw/bin/g++") -(setenv "QT_AUTO_SCREEN_SCALE_FACTOR" "1") (setenv "QT_SCALE_FACTOR" "1") (defun chris/nix-reload () @@ -509,32 +493,76 @@ Let's use =no-littering= in order to stop emacs from filling all our folders wit ** Ligatures Here let's try to add ligatures to our font system since the VictorMono Nerd Font supports all ligatures being a "Nerd Font". #+begin_src emacs-lisp -(let ((alist '((?! . "\\(?:!\\(?:==\\|[!=]\\)\\)") - (?# . "\\(?:#\\(?:###?\\|_(\\|[!#(:=?[_{]\\)\\)") - (?$ . "\\(?:\\$>\\)") - (?& . "\\(?:&&&?\\)") - (?* . "\\(?:\\*\\(?:\\*\\*\\|[/>]\\)\\)") - (?+ . "\\(?:\\+\\(?:\\+\\+\\|[+>]\\)\\)") - (?- . "\\(?:-\\(?:-[>-]\\|<<\\|>>\\|[<>|~-]\\)\\)") - (?. . "\\(?:\\.\\(?:\\.[.<]\\|[.=?-]\\)\\)") - (?/ . "\\(?:/\\(?:\\*\\*\\|//\\|==\\|[*/=>]\\)\\)") - (?: . "\\(?::\\(?:::\\|\\?>\\|[:<-?]\\)\\)") - (?\; . "\\(?:;;\\)") - (?< . "\\(?:<\\(?:!--\\|\\$>\\|\\*>\\|\\+>\\|-[<>|]\\|/>\\|<[<=-]\\|=\\(?:=>\\|[<=>|]\\)\\||\\(?:||::=\\|[>|]\\)\\|~[>~]\\|[$*+/:<=>|~-]\\)\\)") - (?= . "\\(?:=\\(?:!=\\|/=\\|:=\\|=[=>]\\|>>\\|[=>]\\)\\)") - (?> . "\\(?:>\\(?:=>\\|>[=>-]\\|[]:=-]\\)\\)") - (?? . "\\(?:\\?[.:=?]\\)") - (?\[ . "\\(?:\\[\\(?:||]\\|[<|]\\)\\)") - (?\ . "\\(?:\\\\/?\\)") - (?\] . "\\(?:]#\\)") - (?^ . "\\(?:\\^=\\)") - (?_ . "\\(?:_\\(?:|?_\\)\\)") - (?{ . "\\(?:{|\\)") - (?| . "\\(?:|\\(?:->\\|=>\\||\\(?:|>\\|[=>-]\\)\\|[]=>|}-]\\)\\)") - (?~ . "\\(?:~\\(?:~>\\|[=>@~-]\\)\\)")))) - (dolist (char-regexp alist) - (set-char-table-range composition-function-table (car char-regexp) - `([,(cdr char-regexp) 0 font-shape-gstring])))) +(use-package ligature + :load-path "path-to-ligature-repo" + :config + ;; Enable the "www" ligature in every possible major mode + (ligature-set-ligatures 't '("www")) + ;; Enable traditional ligature support in eww-mode, if the + ;; `variable-pitch' face supports it + (ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi")) + ;; Enable all Cascadia and Fira Code ligatures in programming modes + (ligature-set-ligatures 'prog-mode + '(;; == === ==== => =| =>>=>=|=>==>> ==< =/=//=// =~ + ;; =:= =!= + ("=" (rx (+ (or ">" "<" "|" "/" "~" ":" "!" "=")))) + ;; ;; ;;; + (";" (rx (+ ";"))) + ;; && &&& + ("&" (rx (+ "&"))) + ;; !! !!! !. !: !!. != !== !~ + ("!" (rx (+ (or "=" "!" "\." ":" "~")))) + ;; ?? ??? ?: ?= ?. + ("?" (rx (or ":" "=" "\." (+ "?")))) + ;; %% %%% + ("%" (rx (+ "%"))) + ;; |> ||> |||> ||||> |] |} || ||| |-> ||-|| + ;; |->>-||-<<-| |- |== ||=|| + ;; |==>>==<<==<=>==//==/=!==:===> + ("|" (rx (+ (or ">" "<" "|" "/" ":" "!" "}" "\]" + "-" "=" )))) + ;; \\ \\\ \/ + ("\\" (rx (or "/" (+ "\\")))) + ;; ++ +++ ++++ +> + ("+" (rx (or ">" (+ "+")))) + ;; :: ::: :::: :> :< := :// ::= + (":" (rx (or ">" "<" "=" "//" ":=" (+ ":")))) + ;; // /// //// /\ /* /> /===:===!=//===>>==>==/ + ("/" (rx (+ (or ">" "<" "|" "/" "\\" "\*" ":" "!" + "=")))) + ;; .. ... .... .= .- .? ..= ..< + ("\." (rx (or "=" "-" "\?" "\.=" "\.<" (+ "\.")))) + ;; -- --- ---- -~ -> ->> -| -|->-->>->--<<-| + ("-" (rx (+ (or ">" "<" "|" "~" "-")))) + ;; *> */ *) ** *** **** + ("*" (rx (or ">" "/" ")" (+ "*")))) + ;; www wwww + ("w" (rx (+ "w"))) + ;; <> >->--<<-| + ("-" (rx (+ (or ">" "<" "|" "~" "-")))) + ;; *> */ *) ** *** **** + ("*" (rx (or ">" "/" ")" (+ "*")))) + ;; www wwww + ("w" (rx (+ "w"))) + ;; <>