aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--oni-gui.el25
1 files changed, 23 insertions, 2 deletions
diff --git a/oni-gui.el b/oni-gui.el
index 85c9519..352fe8d 100644
--- a/oni-gui.el
+++ b/oni-gui.el
@@ -65,6 +65,24 @@ If FRAME is nil, they’re set for the current frame."
(set-fontset-font t ?✿ dejavu-sans-mono frame)
(set-fontset-font t ?✓ dejavu-sans-mono frame)))
+;; Thanks to the article at
+;; https://andreyorst.gitlab.io/posts/2020-07-21-programming-ligatures-in-emacs/
+(defun oni-gui-setup-ligatures (&optional _)
+ "Define ligatures supported by Fantasque Sans Mono."
+ (let ((ligatures
+ `((?= . ,(regexp-opt '("==" "===" "=/=" "=>" "==>" "=>>" "=<<")))
+ (?! . ,(regexp-opt '("!=" "!==")))
+ (?< . ,(regexp-opt '("<-<" "<<-" "<--" "<-" "<->" "<=<" "<<=" "<=="
+ "<=>" "<~>" "<~~" "<~" "<<<" "<<" "<=" "<>"
+ "<|||" "<||" "<|" "<|>" "<!--")))
+ (?- . ,(regexp-opt '("->" "-->" "->>" "-<" "-<<")))
+ (?> . ,(regexp-opt '(">->" ">=>" ">>=" ">>-" ">-" ">=" ">>" ">>>")))
+ (?~ . ,(regexp-opt '("~~" "~>" "~~>")))
+ (?| . ,(regexp-opt '("|>" "||>" "|||>"))))))
+ (dolist (char-regexp ligatures)
+ (set-char-table-range composition-function-table (car char-regexp)
+ `([,(cdr char-regexp) 0 font-shape-gstring])))))
+
(with-eval-after-load 'isearch
(diminish 'isearch-mode (string ?\s oni-gui-isearch-icon)))
(with-eval-after-load 'autorevert
@@ -90,8 +108,11 @@ _bi_: Auto Insert ^^ ^^
(mode-icons-mode)
(if (daemonp)
- (add-hook 'after-make-frame-functions #'oni-gui-setup-fontsets)
- (oni-gui-setup-fontsets nil))
+ (progn
+ (add-hook 'after-make-frame-functions #'oni-gui-setup-fontsets)
+ (add-hook 'after-make-frame-functions #'oni-gui-setup-ligatures))
+ (oni-gui-setup-fontsets nil)
+ (oni-gui-setup-ligatures))
(global-unset-key (kbd "C-z"))
(global-set-key (kbd "C-c c") 'oni-gui-hydra/body)