This is a simple minor mode for Fira Code ligatures, built from these instructions on the FiraCode repo.
You don't need to use Fira Code as your main font in Emacs for this to work! Using this minor mode will give you just the ligatures from the Fira Code font; it won't alter your fonts or faces in any other way. (Of course, you're free to use Fira Code as your main font alongside this package - that's what I do!)
Install fira-code-mode
. (from MELPA: M-x package-install RET fira-code-mode RET
)
Install the Fira Code Symbol
font to your system with M-x fira-code-mode-install-fonts RET
Fira Code Symbol
font is not the same as the real Fira Code
font, and you need to install Fira Code Symbol
whether you have regular Fira Code
on your system or not.Enable fira-code-mode
in your config, either using (global-fira-code-mode)
or by adding fira-code-mode
to whichever hooks you like.
Done, enjoy the ligatures!
With use-package (this is the config that I use personally):
(use-package fira-code-mode
:custom (fira-code-mode-disabled-ligatures '("[]" "#{" "#(" "#_" "#_(" "x")) ;; List of ligatures to turn off
:hook prog-mode) ;; Enables fira-code-mode automatically for programming major modes
Feel free to remove or change the :custom
and :hook
values of course, but those are the ones I've found useful. Most of the ligatures I've disabled are purely preferential; some of them conflicted with other syntax styling for e.g. Clojure reader macros.
If you want to use the global minor mode with use-package:
(use-package fira-code-mode
:config (global-fira-code-mode))
An example config without use-package:
(require 'fira-code-mode)
(custom-set-variable 'fira-code-mode-disabled-ligatures '("[]" "#{" "#(" "#_" "#_(" "x")) ;; List of ligatures to turn off
;; Enable fira-code-mode automatically for programming major modes
(add-hook 'prog-mode-hook 'fira-code-mode)
;; Or, you can use the global mode instead of adding a hook:
(global-fira-code-mode)
fira-code-mode-disabled-ligatures
: Add a string to this list to prevent that string from being displayed with a ligature. You can put any ligature powered by fira-code-mode
in here, and you can also put "lambda"
in this list to disable the Emacs default "lambda" ligature. You cannot use this list to disable ligatures provided by other packages, however.fira-code-mode-enable-hex-literal
(defaults to t
): When non-nil, display the \"x\" in hex literals (like 0x12) with a ligature.
If you see unexpected symbols where ligatures should be, then it's likely that some other font on your system is being used to resolve the prettified symbols instead of Fira Code Symbol. You should be able to resolve this by:
Fira Code Symbol
font installed - see Getting Started step 2 aboveFira Code Symbol
installed, but another font is still being used to display the ligatures, then add this function call to your config: (fira-code-mode-set-font)
use-package
, this should go in your :config
. Otherwise, it can go anywhere after (require 'fira-code-mode)
.This is the first Emacs package that I've made, and I'm making it available in hopes that it will make your lives easier as it did mine. I welcome suggestions and contributions, but here are a couple things to be aware of: