syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.58k stars 4.9k forks source link

FiraCode “Ligature” integration #6972

Open Profpatsch opened 7 years ago

Profpatsch commented 7 years ago

FiraCode is a nice derivation from Fira Mono that adds many ligatures for a nice code look. It uses Unicode ligatures, but Emacs sadly doesn’t support them (yet). I’d like to add a layer to Spacemacs to support that.

There is a page about integration into Emacs via font-lock, and the second example is also how Hasklig can be made to work with Emacs. I noticed integrating too many ligatures that way makes font rendering very slow.

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

hyiltiz commented 4 years ago

@github-actions this issue is still open and awaits action from the devs to support in the develop branch out of the box (or via an option via a variable `spacemacs-use-font-ligature 'always/'code/'never).

@Profpatsch not sure which one is more convenient/easy to do: writing up a layer for spacemacs, or publishing a melpa package?

Profpatsch commented 4 years ago

@Profpatsch not sure which one is more convenient/easy to do: writing up a layer for spacemacs, or publishing a melpa package?

I don’t know, I have never created a melpa package

nixmaniack commented 4 years ago

We should keep this issue open.

ViktorHaag commented 3 years ago

emacs-mac doesn't override your old emacs installation automatically.

Homebrew has probably installed emacs-mac in /usr/local/opt/emacs-mac/.

Another solution is to use homebrew to install the cask of emacs-mac instead of building from a recipe. It trails the version available via recipe sometimes, but otherwise it's solid and it installs /Applications/Emacs.app automagically.

jerbaroo commented 3 years ago

You can also use the development version of Emacs (28) which has ligature support. emacs-plus@28 on homebrew. https://github.com/d12frosted/homebrew-emacs-plus

hyiltiz commented 3 years ago

@barischrooneyj care to share your set up for the ligature support in Emacs 28? There was HarfBuzz support there but seemed it seeded some configuration [1,2].

[1] https://www.reddit.com/r/emacs/comments/byddvm/emacsdevel_harfbuzz_is_now_available_on_master/ [2] https://www.reddit.com/r/emacs/comments/a5upu5/emacs_text_shaping_using_harfbuzz/

liny01-nbsa commented 3 years ago

I think even Emacs 27 has the support too. https://github.com/microsoft/cascadia-code/issues/153#issuecomment-548622886. Use the config from it, I have tested with JetBrainsMono FiraCode.

hyiltiz commented 3 years ago

Copied from https://github.com/microsoft/cascadia-code/issues/153#issuecomment-548622886 for convenience here:

(use-package composite
  :defer t
  :init
  (defvar composition-ligature-table (make-char-table nil))
  :hook
  (((prog-mode conf-mode nxml-mode markdown-mode help-mode)
    . (lambda () (setq-local composition-function-table composition-ligature-table))))
  :config
  ;; support ligatures, some toned down to prevent hang
  (when (version<= "27.0" emacs-version)
    (let ((alist
           '((33 . ".\\(?:\\(==\\|[!=]\\)[!=]?\\)")
             (35 . ".\\(?:\\(###?\\|_(\\|[(:=?[_{]\\)[#(:=?[_{]?\\)")
             (36 . ".\\(?:\\(>\\)>?\\)")
             (37 . ".\\(?:\\(%\\)%?\\)")
             (38 . ".\\(?:\\(&\\)&?\\)")
             (42 . ".\\(?:\\(\\*\\*\\|[*>]\\)[*>]?\\)")
             ;; (42 . ".\\(?:\\(\\*\\*\\|[*/>]\\).?\\)")
             (43 . ".\\(?:\\([>]\\)>?\\)")
             ;; (43 . ".\\(?:\\(\\+\\+\\|[+>]\\).?\\)")
             (45 . ".\\(?:\\(-[->]\\|<<\\|>>\\|[-<>|~]\\)[-<>|~]?\\)")
             ;; (46 . ".\\(?:\\(\\.[.<]\\|[-.=]\\)[-.<=]?\\)")
             (46 . ".\\(?:\\(\\.<\\|[-=]\\)[-<=]?\\)")
             (47 . ".\\(?:\\(//\\|==\\|[=>]\\)[/=>]?\\)")
             ;; (47 . ".\\(?:\\(//\\|==\\|[*/=>]\\).?\\)")
             (48 . ".\\(?:\\(x[a-fA-F0-9]\\).?\\)")
             (58 . ".\\(?:\\(::\\|[:<=>]\\)[:<=>]?\\)")
             (59 . ".\\(?:\\(;\\);?\\)")
             (60 . ".\\(?:\\(!--\\|\\$>\\|\\*>\\|\\+>\\|-[-<>|]\\|/>\\|<[-<=]\\|=[<>|]\\|==>?\\||>\\||||?\\|~[>~]\\|[$*+/:<=>|~-]\\)[$*+/:<=>|~-]?\\)")
             (61 . ".\\(?:\\(!=\\|/=\\|:=\\|<<\\|=[=>]\\|>>\\|[=>]\\)[=<>]?\\)")
             (62 . ".\\(?:\\(->\\|=>\\|>[-=>]\\|[-:=>]\\)[-:=>]?\\)")
             (63 . ".\\(?:\\([.:=?]\\)[.:=?]?\\)")
             (91 . ".\\(?:\\(|\\)[]|]?\\)")
             ;; (92 . ".\\(?:\\([\\n]\\)[\\]?\\)")
             (94 . ".\\(?:\\(=\\)=?\\)")
             (95 . ".\\(?:\\(|_\\|[_]\\)_?\\)")
             (119 . ".\\(?:\\(ww\\)w?\\)")
             (123 . ".\\(?:\\(|\\)[|}]?\\)")
             (124 . ".\\(?:\\(->\\|=>\\||[-=>]\\||||*>\\|[]=>|}-]\\).?\\)")
             (126 . ".\\(?:\\(~>\\|[-=>@~]\\)[-=>@~]?\\)"))))
      (dolist (char-regexp alist)
        (set-char-table-range composition-ligature-table (car char-regexp)
                              `([,(cdr char-regexp) 0 font-shape-gstring]))))
    (set-char-table-parent composition-ligature-table composition-function-table))
  )
github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

Profpatsch commented 2 years ago

:space_invader: :space_invader: :space_invader:

activityyyyy

lebensterben commented 2 years ago

@Profpatsch

There will be no ligature for any specific font. But ligature in general is already supported with unicode-fonts layer. The only issue is currently it won't work with Emacs 27.

github-actions[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!