Created
May 24, 2019 07:16
-
-
Save Deiru2k/e13bbfc5742fb1c2512349eeed4b092a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Font Ligatures | |
(defun my-correct-symbol-bounds (pretty-alist) | |
"Prepend a TAB character to each symbol in this alist, | |
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." | |
(mapcar (lambda (el) | |
(setcdr el (string ?\t (cdr el))) | |
el) | |
pretty-alist)) | |
(defun my-ligature-list (ligatures codepoint-start) | |
"Create an alist of strings to replace with | |
codepoints starting from codepoint-start." | |
(let ((codepoints (-iterate '1+ codepoint-start (length ligatures)))) | |
(-zip-pair ligatures codepoints))) | |
(setq my-fira-code-ligatures | |
(let* ((ligs '("www" "**" "***" "**/" "*>" "*/" "\\\\" "\\\\\\" | |
"{-" "[]" "::" ":::" ":=" "!!" "!=" "!==" "-}" | |
"--" "---" "-->" "->" "->>" "-<" "-<<" "-~" | |
"#{" "#[" "##" "###" "####" "#(" "#?" "#_" "#_(" | |
".-" ".=" ".." "..<" "..." "?=" "??" ";;" "/*" | |
"/**" "/=" "/==" "/>" "//" "///" "&&" "||" "||=" | |
"|=" "|>" "^=" "$>" "++" "+++" "+>" "=:=" "==" | |
"===" "==>" "=>" "=>>" "<=" "=<<" "=/=" ">-" ">=" | |
">=>" ">>" ">>-" ">>=" ">>>" "<*" "<*>" "<|" "<|>" | |
"<$" "<$>" "<!--" "<-" "<--" "<->" "<+" "<+>" "<=" | |
"<==" "<=>" "<=<" "<>" "<<" "<<-" "<<=" "<<<" "<~" | |
"<~~" "</" "</>" "~@" "~-" "~=" "~>" "~~" "~~>" "%%" | |
"x" ":" "+" "+" "*"))) | |
(my-correct-symbol-bounds (my-ligature-list ligs #Xe100)))) | |
(defun my-set-fira-code-ligatures () | |
"Add fira code ligatures for use with prettify-symbols-mode." | |
(setq prettify-symbols-alist | |
(append my-fira-code-ligatures prettify-symbols-alist)) | |
(prettify-symbols-mode)) | |
(add-hook 'prog-mode-hook 'my-set-fira-code-ligatures) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment