ui/pretty-code: minor reformatting
This commit is contained in:
parent
af69cd0840
commit
74d87a1e24
4 changed files with 208 additions and 209 deletions
|
@ -4,113 +4,113 @@
|
||||||
"Name of the fira code ligature font.")
|
"Name of the fira code ligature font.")
|
||||||
|
|
||||||
(defvar +pretty-code-fira-code-font-ligatures
|
(defvar +pretty-code-fira-code-font-ligatures
|
||||||
'(("www" . #Xe100)
|
'(("www" . #Xe100)
|
||||||
("**" . #Xe101)
|
("**" . #Xe101)
|
||||||
("***" . #Xe102)
|
("***" . #Xe102)
|
||||||
("**/" . #Xe103)
|
("**/" . #Xe103)
|
||||||
("*>" . #Xe104)
|
("*>" . #Xe104)
|
||||||
("*/" . #Xe105)
|
("*/" . #Xe105)
|
||||||
("\\\\" . #Xe106)
|
("\\\\" . #Xe106)
|
||||||
("\\\\\\" . #Xe107)
|
("\\\\\\" . #Xe107)
|
||||||
("{-" . #Xe108)
|
("{-" . #Xe108)
|
||||||
("[]" . #Xe109)
|
("[]" . #Xe109)
|
||||||
("::" . #Xe10a)
|
("::" . #Xe10a)
|
||||||
(":::" . #Xe10b)
|
(":::" . #Xe10b)
|
||||||
(":=" . #Xe10c)
|
(":=" . #Xe10c)
|
||||||
("!!" . #Xe10d)
|
("!!" . #Xe10d)
|
||||||
("!=" . #Xe10e)
|
("!=" . #Xe10e)
|
||||||
("!==" . #Xe10f)
|
("!==" . #Xe10f)
|
||||||
("-}" . #Xe110)
|
("-}" . #Xe110)
|
||||||
("--" . #Xe111)
|
("--" . #Xe111)
|
||||||
("---" . #Xe112)
|
("---" . #Xe112)
|
||||||
("-->" . #Xe113)
|
("-->" . #Xe113)
|
||||||
("->" . #Xe114)
|
("->" . #Xe114)
|
||||||
("->>" . #Xe115)
|
("->>" . #Xe115)
|
||||||
("-<" . #Xe116)
|
("-<" . #Xe116)
|
||||||
("-<<" . #Xe117)
|
("-<<" . #Xe117)
|
||||||
("-~" . #Xe118)
|
("-~" . #Xe118)
|
||||||
("#{" . #Xe119)
|
("#{" . #Xe119)
|
||||||
("#[" . #Xe11a)
|
("#[" . #Xe11a)
|
||||||
("##" . #Xe11b)
|
("##" . #Xe11b)
|
||||||
("###" . #Xe11c)
|
("###" . #Xe11c)
|
||||||
("####" . #Xe11d)
|
("####" . #Xe11d)
|
||||||
("#(" . #Xe11e)
|
("#(" . #Xe11e)
|
||||||
("#?" . #Xe11f)
|
("#?" . #Xe11f)
|
||||||
("#_" . #Xe120)
|
("#_" . #Xe120)
|
||||||
("#_(" . #Xe121)
|
("#_(" . #Xe121)
|
||||||
(".-" . #Xe122)
|
(".-" . #Xe122)
|
||||||
(".=" . #Xe123)
|
(".=" . #Xe123)
|
||||||
(".." . #Xe124)
|
(".." . #Xe124)
|
||||||
("..<" . #Xe125)
|
("..<" . #Xe125)
|
||||||
("..." . #Xe126)
|
("..." . #Xe126)
|
||||||
("?=" . #Xe127)
|
("?=" . #Xe127)
|
||||||
("??" . #Xe128)
|
("??" . #Xe128)
|
||||||
(";;" . #Xe129)
|
(";;" . #Xe129)
|
||||||
("/*" . #Xe12a)
|
("/*" . #Xe12a)
|
||||||
("/**" . #Xe12b)
|
("/**" . #Xe12b)
|
||||||
("/=" . #Xe12c)
|
("/=" . #Xe12c)
|
||||||
("/==" . #Xe12d)
|
("/==" . #Xe12d)
|
||||||
("/>" . #Xe12e)
|
("/>" . #Xe12e)
|
||||||
("//" . #Xe12f)
|
("//" . #Xe12f)
|
||||||
("///" . #Xe130)
|
("///" . #Xe130)
|
||||||
("&&" . #Xe131)
|
("&&" . #Xe131)
|
||||||
("||" . #Xe132)
|
("||" . #Xe132)
|
||||||
("||=" . #Xe133)
|
("||=" . #Xe133)
|
||||||
("|=" . #Xe134)
|
("|=" . #Xe134)
|
||||||
("|>" . #Xe135)
|
("|>" . #Xe135)
|
||||||
("^=" . #Xe136)
|
("^=" . #Xe136)
|
||||||
("$>" . #Xe137)
|
("$>" . #Xe137)
|
||||||
("++" . #Xe138)
|
("++" . #Xe138)
|
||||||
("+++" . #Xe139)
|
("+++" . #Xe139)
|
||||||
("+>" . #Xe13a)
|
("+>" . #Xe13a)
|
||||||
("=:=" . #Xe13b)
|
("=:=" . #Xe13b)
|
||||||
("==" . #Xe13c)
|
("==" . #Xe13c)
|
||||||
("===" . #Xe13d)
|
("===" . #Xe13d)
|
||||||
("==>" . #Xe13e)
|
("==>" . #Xe13e)
|
||||||
("=>" . #Xe13f)
|
("=>" . #Xe13f)
|
||||||
("=>>" . #Xe140)
|
("=>>" . #Xe140)
|
||||||
("<=" . #Xe141)
|
("<=" . #Xe141)
|
||||||
("=<<" . #Xe142)
|
("=<<" . #Xe142)
|
||||||
("=/=" . #Xe143)
|
("=/=" . #Xe143)
|
||||||
(">-" . #Xe144)
|
(">-" . #Xe144)
|
||||||
(">=" . #Xe145)
|
(">=" . #Xe145)
|
||||||
(">=>" . #Xe146)
|
(">=>" . #Xe146)
|
||||||
(">>" . #Xe147)
|
(">>" . #Xe147)
|
||||||
(">>-" . #Xe148)
|
(">>-" . #Xe148)
|
||||||
(">>=" . #Xe149)
|
(">>=" . #Xe149)
|
||||||
(">>>" . #Xe14a)
|
(">>>" . #Xe14a)
|
||||||
("<*" . #Xe14b)
|
("<*" . #Xe14b)
|
||||||
("<*>" . #Xe14c)
|
("<*>" . #Xe14c)
|
||||||
("<|" . #Xe14d)
|
("<|" . #Xe14d)
|
||||||
("<|>" . #Xe14e)
|
("<|>" . #Xe14e)
|
||||||
("<$" . #Xe14f)
|
("<$" . #Xe14f)
|
||||||
("<$>" . #Xe150)
|
("<$>" . #Xe150)
|
||||||
("<!--" . #Xe151)
|
("<!--" . #Xe151)
|
||||||
("<-" . #Xe152)
|
("<-" . #Xe152)
|
||||||
("<--" . #Xe153)
|
("<--" . #Xe153)
|
||||||
("<->" . #Xe154)
|
("<->" . #Xe154)
|
||||||
("<+" . #Xe155)
|
("<+" . #Xe155)
|
||||||
("<+>" . #Xe156)
|
("<+>" . #Xe156)
|
||||||
("<=" . #Xe157)
|
("<=" . #Xe157)
|
||||||
("<==" . #Xe158)
|
("<==" . #Xe158)
|
||||||
("<=>" . #Xe159)
|
("<=>" . #Xe159)
|
||||||
("<=<" . #Xe15a)
|
("<=<" . #Xe15a)
|
||||||
("<>" . #Xe15b)
|
("<>" . #Xe15b)
|
||||||
("<<" . #Xe15c)
|
("<<" . #Xe15c)
|
||||||
("<<-" . #Xe15d)
|
("<<-" . #Xe15d)
|
||||||
("<<=" . #Xe15e)
|
("<<=" . #Xe15e)
|
||||||
("<<<" . #Xe15f)
|
("<<<" . #Xe15f)
|
||||||
("<~" . #Xe160)
|
("<~" . #Xe160)
|
||||||
("<~~" . #Xe161)
|
("<~~" . #Xe161)
|
||||||
("</" . #Xe162)
|
("</" . #Xe162)
|
||||||
("</>" . #Xe163)
|
("</>" . #Xe163)
|
||||||
("~@" . #Xe164)
|
("~@" . #Xe164)
|
||||||
("~-" . #Xe165)
|
("~-" . #Xe165)
|
||||||
("~=" . #Xe166)
|
("~=" . #Xe166)
|
||||||
("~>" . #Xe167)
|
("~>" . #Xe167)
|
||||||
("~~" . #Xe168)
|
("~~" . #Xe168)
|
||||||
("~~>" . #Xe169)
|
("~~>" . #Xe169)
|
||||||
("%%" . #Xe16a)))
|
("%%" . #Xe16a)))
|
||||||
|
|
||||||
(defun +pretty-code-setup-fira-ligatures-h ()
|
(defun +pretty-code-setup-fira-ligatures-h ()
|
||||||
(set-fontset-font t '(#Xe100 . #Xe16f) +pretty-code-fira-code-font-name)
|
(set-fontset-font t '(#Xe100 . #Xe16f) +pretty-code-fira-code-font-name)
|
||||||
|
|
|
@ -4,48 +4,48 @@
|
||||||
"Name of the hasklig ligature font.")
|
"Name of the hasklig ligature font.")
|
||||||
|
|
||||||
(defvar +pretty-code-hasklig-font-ligatures
|
(defvar +pretty-code-hasklig-font-ligatures
|
||||||
'(("&&" . #Xe100)
|
'(("&&" . #Xe100)
|
||||||
("***" . #Xe101)
|
("***" . #Xe101)
|
||||||
("*>" . #Xe102)
|
("*>" . #Xe102)
|
||||||
("\\\\" . #Xe103)
|
("\\\\" . #Xe103)
|
||||||
("||" . #Xe104)
|
("||" . #Xe104)
|
||||||
("|>" . #Xe105)
|
("|>" . #Xe105)
|
||||||
("::" . #Xe106)
|
("::" . #Xe106)
|
||||||
("==" . #Xe107)
|
("==" . #Xe107)
|
||||||
("===" . #Xe108)
|
("===" . #Xe108)
|
||||||
("==>" . #Xe109)
|
("==>" . #Xe109)
|
||||||
("=>" . #Xe10a)
|
("=>" . #Xe10a)
|
||||||
("=<<" . #Xe10b)
|
("=<<" . #Xe10b)
|
||||||
("!!" . #Xe10c)
|
("!!" . #Xe10c)
|
||||||
(">>" . #Xe10d)
|
(">>" . #Xe10d)
|
||||||
(">>=" . #Xe10e)
|
(">>=" . #Xe10e)
|
||||||
(">>>" . #Xe10f)
|
(">>>" . #Xe10f)
|
||||||
(">>-" . #Xe110)
|
(">>-" . #Xe110)
|
||||||
(">-" . #Xe111)
|
(">-" . #Xe111)
|
||||||
("->" . #Xe112)
|
("->" . #Xe112)
|
||||||
("-<" . #Xe113)
|
("-<" . #Xe113)
|
||||||
("-<<" . #Xe114)
|
("-<<" . #Xe114)
|
||||||
("<*" . #Xe115)
|
("<*" . #Xe115)
|
||||||
("<*>" . #Xe116)
|
("<*>" . #Xe116)
|
||||||
("<|" . #Xe117)
|
("<|" . #Xe117)
|
||||||
("<|>" . #Xe118)
|
("<|>" . #Xe118)
|
||||||
("<$>" . #Xe119)
|
("<$>" . #Xe119)
|
||||||
("<>" . #Xe11a)
|
("<>" . #Xe11a)
|
||||||
("<-" . #Xe11b)
|
("<-" . #Xe11b)
|
||||||
("<<" . #Xe11c)
|
("<<" . #Xe11c)
|
||||||
("<<<" . #Xe11d)
|
("<<<" . #Xe11d)
|
||||||
("<+>" . #Xe11e)
|
("<+>" . #Xe11e)
|
||||||
(".." . #Xe11f)
|
(".." . #Xe11f)
|
||||||
("..." . #Xe120)
|
("..." . #Xe120)
|
||||||
("++" . #Xe121)
|
("++" . #Xe121)
|
||||||
("+++" . #Xe122)
|
("+++" . #Xe122)
|
||||||
("/=" . #Xe123)
|
("/=" . #Xe123)
|
||||||
(":::" . #Xe124)
|
(":::" . #Xe124)
|
||||||
(">=>" . #Xe125)
|
(">=>" . #Xe125)
|
||||||
("->>" . #Xe126)
|
("->>" . #Xe126)
|
||||||
("<=>" . #Xe127)
|
("<=>" . #Xe127)
|
||||||
("<=<" . #Xe128)
|
("<=<" . #Xe128)
|
||||||
("<->" . #Xe129)))
|
("<->" . #Xe129)))
|
||||||
|
|
||||||
|
|
||||||
(defun +pretty-code-setup-hasklig-ligatures-h ()
|
(defun +pretty-code-setup-hasklig-ligatures-h ()
|
||||||
|
|
|
@ -1,62 +1,10 @@
|
||||||
;;; ui/pretty-code/settings.el -*- lexical-binding: t; -*-
|
;;; ui/pretty-code/settings.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defvar +pretty-code-symbols
|
|
||||||
'(;; org
|
|
||||||
:name "»"
|
|
||||||
:src_block "»"
|
|
||||||
:src_block_end "«"
|
|
||||||
;; Functional
|
|
||||||
:lambda "λ"
|
|
||||||
:def "ƒ"
|
|
||||||
:composition "∘"
|
|
||||||
:map "↦"
|
|
||||||
;; Types
|
|
||||||
:null "∅"
|
|
||||||
:true "𝕋"
|
|
||||||
:false "𝔽"
|
|
||||||
:int "ℤ"
|
|
||||||
:float "ℝ"
|
|
||||||
:str "𝕊"
|
|
||||||
:bool "𝔹"
|
|
||||||
;; Flow
|
|
||||||
:not "¬"
|
|
||||||
:in "∈"
|
|
||||||
:not-in "∉"
|
|
||||||
:and "∧"
|
|
||||||
:or "∨"
|
|
||||||
:for "∀"
|
|
||||||
:some "∃"
|
|
||||||
:return "⟼"
|
|
||||||
:yield "⟻"
|
|
||||||
;; Other
|
|
||||||
:tuple "⨂"
|
|
||||||
:pipe "" ;; FIXME: find a non-private char
|
|
||||||
:dot "•")
|
|
||||||
"Options plist for `set-pretty-symbols!'.
|
|
||||||
|
|
||||||
This should not contain any symbols from the Unicode Private Area! There is no
|
|
||||||
universal way of getting the correct symbol as that area varies from font to
|
|
||||||
font.")
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defvar +pretty-code-symbols-alist '((t))
|
(defvar +pretty-code-symbols-alist '((t))
|
||||||
"An alist containing a mapping of major modes to its value for
|
"An alist containing a mapping of major modes to its value for
|
||||||
`prettify-symbols-alist'.")
|
`prettify-symbols-alist'.")
|
||||||
|
|
||||||
;;;###autodef
|
|
||||||
(defun +pretty-code--correct-symbol-bounds (ligature-alist)
|
|
||||||
"Prepend non-breaking spaces to a ligature.
|
|
||||||
|
|
||||||
This way `compose-region' (called by `prettify-symbols-mode') will use the
|
|
||||||
correct width of the symbols instead of the width measured by `char-width'."
|
|
||||||
(let ((len (length (car ligature-alist)))
|
|
||||||
(acc (list (cdr ligature-alist))))
|
|
||||||
(while (> len 1)
|
|
||||||
(setq acc (cons #X00a0 (cons '(Br . Bl) acc))
|
|
||||||
len (1- len)))
|
|
||||||
(cons (car ligature-alist) acc)))
|
|
||||||
|
|
||||||
;;;###autodef
|
;;;###autodef
|
||||||
(defun set-pretty-symbols! (modes &rest plist)
|
(defun set-pretty-symbols! (modes &rest plist)
|
||||||
"Associates string patterns with icons in certain major-modes.
|
"Associates string patterns with icons in certain major-modes.
|
||||||
|
|
|
@ -1,13 +1,54 @@
|
||||||
;;; ui/pretty-code/config.el -*- lexical-binding: t; -*-
|
;;; ui/pretty-code/config.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
(cond ((featurep! +fira)
|
(defvar +pretty-code-symbols
|
||||||
(load! "+fira"))
|
'(;; org
|
||||||
((featurep! +iosevka)
|
:name "»"
|
||||||
(load! "+iosevka"))
|
:src_block "»"
|
||||||
((featurep! +hasklig)
|
:src_block_end "«"
|
||||||
(load! "+hasklig"))
|
;; Functional
|
||||||
((featurep! +pragmata-pro)
|
:lambda "λ"
|
||||||
(load! "+pragmata-pro")))
|
:def "ƒ"
|
||||||
|
:composition "∘"
|
||||||
|
:map "↦"
|
||||||
|
;; Types
|
||||||
|
:null "∅"
|
||||||
|
:true "𝕋"
|
||||||
|
:false "𝔽"
|
||||||
|
:int "ℤ"
|
||||||
|
:float "ℝ"
|
||||||
|
:str "𝕊"
|
||||||
|
:bool "𝔹"
|
||||||
|
;; Flow
|
||||||
|
:not "¬"
|
||||||
|
:in "∈"
|
||||||
|
:not-in "∉"
|
||||||
|
:and "∧"
|
||||||
|
:or "∨"
|
||||||
|
:for "∀"
|
||||||
|
:some "∃"
|
||||||
|
:return "⟼"
|
||||||
|
:yield "⟻"
|
||||||
|
;; Other
|
||||||
|
:tuple "⨂"
|
||||||
|
:pipe "" ;; FIXME: find a non-private char
|
||||||
|
:dot "•")
|
||||||
|
"Options plist for `set-pretty-symbols!'.
|
||||||
|
|
||||||
|
This should not contain any symbols from the Unicode Private Area! There is no
|
||||||
|
universal way of getting the correct symbol as that area varies from font to
|
||||||
|
font.")
|
||||||
|
|
||||||
|
(defun +pretty-code--correct-symbol-bounds (ligature-alist)
|
||||||
|
"Prepend non-breaking spaces to a ligature.
|
||||||
|
|
||||||
|
This way `compose-region' (called by `prettify-symbols-mode') will use the
|
||||||
|
correct width of the symbols instead of the width measured by `char-width'."
|
||||||
|
(let ((len (length (car ligature-alist)))
|
||||||
|
(acc (list (cdr ligature-alist))))
|
||||||
|
(while (> len 1)
|
||||||
|
(setq acc (cons #X00a0 (cons '(Br . Bl) acc))
|
||||||
|
len (1- len)))
|
||||||
|
(cons (car ligature-alist) acc)))
|
||||||
|
|
||||||
(defvar +pretty-code-enabled-modes t
|
(defvar +pretty-code-enabled-modes t
|
||||||
"List of major modes in which `prettify-symbols-mode' should be enabled.
|
"List of major modes in which `prettify-symbols-mode' should be enabled.
|
||||||
|
@ -40,3 +81,13 @@ Otherwise it builds `prettify-code-symbols-alist' according to
|
||||||
(prettify-symbols-mode +1))))
|
(prettify-symbols-mode +1))))
|
||||||
|
|
||||||
(add-hook 'after-change-major-mode-hook #'+pretty-code-init-pretty-symbols-h)
|
(add-hook 'after-change-major-mode-hook #'+pretty-code-init-pretty-symbols-h)
|
||||||
|
|
||||||
|
;; Font-specific ligature support
|
||||||
|
(cond ((featurep! +fira)
|
||||||
|
(load! "+fira"))
|
||||||
|
((featurep! +iosevka)
|
||||||
|
(load! "+iosevka"))
|
||||||
|
((featurep! +hasklig)
|
||||||
|
(load! "+hasklig"))
|
||||||
|
((featurep! +pragmata-pro)
|
||||||
|
(load! "+pragmata-pro")))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue