0

I'm writing a language grammar, and as an example, I'd like to display -> as , without changing the actual text. Is this possible to do in a language package? How?

Dr. John A Zoidberg
  • 1,168
  • 2
  • 14
  • 25

1 Answers1

2

I don't think that's a good idea. How would a user make out the difference between a fake and a literal ? Unicode is everywhere these days, don't keep people from using it.

Apart from these concerns, I think the best way would be to use (or create) a font that uses ligatures. Fira Code seems to have several ligatures for coding.

Another possibility could be assigning a special class for -> (e.g. .arrow), then hide it and override its content.

Example:

atom-text-editor::shadow {
    span.arrow.yourgrammar {
      visibility: hidden;
    }
    span.arrow.yourgrammar:before {
        content: "\21DB";
        visibility: visible;
    }
}

There are still some disadvantages to consider. First, there will be visible space (this hack might help). More importantly, copy & paste will act in undesirable ways.

As I said before, I don't think it's a good idea.

Community
  • 1
  • 1
idleberg
  • 12,634
  • 7
  • 43
  • 70
  • To explain why I want this, fstar-mode for emacs does this- it also does things like displaying 'int' as ℤ and 'nat' as ℕ. I'm trying to port it to Atom. – Dr. John A Zoidberg Sep 16 '16 at 16:03
  • Maybe ask around on the [Atom forum](https://discuss.atom.io/), people usually get good responses there – idleberg Sep 16 '16 at 17:00
  • 1
    Back to ligatures: Maybe you can request this feature for [Fira Code](https://github.com/tonsky/FiraCode), it already has a couple of ligatures for programming – idleberg Sep 17 '16 at 11:57