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?
Asked
Active
Viewed 434 times
0

Dr. John A Zoidberg
- 1,168
- 2
- 14
- 25
1 Answers
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.
-
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
-
1Back 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