# Syntax highlighting issues in Juno(language-julia)

**URL:** <https://discourse.julialang.org/t/syntax-highlighting-issues-in-juno-language-julia/24872>\
**Category:** Juno\
**Created:** [June 3, 2019, 5:26am UTC](https://discourse.julialang.org/t/syntax-highlighting-issues-in-juno-language-julia/24872 "2019-06-03T05:26:09Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![jarrison](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jarrison/32/5740_2.png) [@jarrison](https://discourse.julialang.org/u/jarrison)\
**Post date:** [June 3, 2019, 5:26am UTC](https://discourse.julialang.org/t/syntax-highlighting-issues-in-juno-language-julia/24872/1 "2019-06-03T05:26:09Z")

</div>

Hi all,  
I was poking around and endlessly customizing my stylesheet in atom and got to wondering whether it would be useful to bring Juno’s naming conventions more in line with various other language packages in Atom. I have often noticed that common syntax themes had a less than impressive appearance when applied to Julia, and was wondering if i was missing something that would improve my experience. If this is a common enough problem I would love to take a couple of days and revamp some of the syntax labeling. Likewise, if i am missing some easy customization i would be equally happy. I realize that many themes include custom styles, but i think Julia is lacking even a basic alignment with common standards.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [June 3, 2019, 8:36am UTC](https://discourse.julialang.org/t/syntax-highlighting-issues-in-juno-language-julia/24872/2 "2019-06-03T08:36:30Z")

</div>

Do you have any concrete examples where we don’t conform with “common syntax themes”? Imho `language-julia` looks fairly good with One Dark/Light, which are the de-facto standard.  
Of course that theme makes the choice to e.g. not highlight operators, but that’s not something we should mess with I think.  
Compare One Dark  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/7/5/75a3a8ad23feec67ad80f45e2c9098391134c47a.png)  
with e.g. Gruvbox Plus  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/d/1/d1bd4d3680c7f7a7283e283fc26545b2da29413d.png)

> I realize that many themes include custom styles, but i think Julia is lacking even a basic alignment with common standards.

So far surprisingly few people have complained about that. I’m also not sure what you base the common standards on, considering that there’s no documented API except for the theme implementation that’s shipped with Atom.

---

<div class="post-metadata">

**Author:** ![jarrison](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jarrison/32/5740_2.png) [@jarrison](https://discourse.julialang.org/u/jarrison)\
**Post date:** [June 3, 2019, 3:55pm UTC](https://discourse.julialang.org/t/syntax-highlighting-issues-in-juno-language-julia/24872/3 "2019-06-03T15:55:07Z")

</div>

My choice of words was pretty poor in regard to “common standards” but i think there are a couple of issues with the way the tokens are named. Taking a look at One Dark, I think that more of the theme designers colors are incorporated due to tokenization of properties/fields and variables.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/d/0d1c981ab3ff198713124f557d05eb4befd3cf73.png) I agree that this lies in the dangerous realm of personal preference, and that if this isn’t a common complaint then it is far better solved by the customization provided by Atom.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [June 3, 2019, 4:00pm UTC](https://discourse.julialang.org/t/syntax-highlighting-issues-in-juno-language-julia/24872/4 "2019-06-03T16:00:40Z")

</div>

Hm, so a couple of things we could improve (judging by your screenshot) would be

1. tokenize `in`/`isa` as keywords instead of operators
2. maybe add `undef` to the list of built-ins
3. add `getproperty` tokenization for `.*\.\w*` (basically)

Anything else you’d like to see?

---

<div class="post-metadata">

**Author:** ![jarrison](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jarrison/32/5740_2.png) [@jarrison](https://discourse.julialang.org/u/jarrison)\
**Post date:** [June 3, 2019, 4:09pm UTC](https://discourse.julialang.org/t/syntax-highlighting-issues-in-juno-language-julia/24872/5 "2019-06-03T16:09:04Z")

</div>

Along with your list I would include parsing module names and struct names. Additionally it would be nice to highlight qualified imports like

```julia
import LinearAlgebra
LinearAlgebra.BLAS

```

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [June 3, 2019, 4:40pm UTC](https://discourse.julialang.org/t/syntax-highlighting-issues-in-juno-language-julia/24872/6 "2019-06-03T16:40:47Z")

</div>

It’s not really possible to do that with Atom’s regex based syntax highlighting, afaict.

---

<div class="post-metadata">

**Author:** ![jarrison](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jarrison/32/5740_2.png) [@jarrison](https://discourse.julialang.org/u/jarrison)\
**Post date:** [June 3, 2019, 5:07pm UTC](https://discourse.julialang.org/t/syntax-highlighting-issues-in-juno-language-julia/24872/7 "2019-06-03T17:07:42Z")

</div>

I think it would be doable but you would have to be careful. I would try and make sure it gets treated like a “Class” for highlighting purposes.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [June 3, 2019, 5:09pm UTC](https://discourse.julialang.org/t/syntax-highlighting-issues-in-juno-language-julia/24872/8 "2019-06-03T17:09:47Z")

</div>

But how would you distinguish

```julia
foo = Foo(1,2)
foo.field1

```

from

```julia
using Bar
Bar.foo

```

? A CamelCase heuristic might work, but doesn’t seem like a great idea to me.

---

<div class="post-metadata">

**Author:** ![jarrison](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jarrison/32/5740_2.png) [@jarrison](https://discourse.julialang.org/u/jarrison)\
**Post date:** [June 3, 2019, 5:11pm UTC](https://discourse.julialang.org/t/syntax-highlighting-issues-in-juno-language-julia/24872/9 "2019-06-03T17:11:44Z")

</div>

Haha, I personally use the camelcase for my own highlighting, but yeah, I don’t think that’s a universal solution. If I come up with anything better I’ll submit a pull 🙂

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [June 3, 2019, 6:25pm UTC](https://discourse.julialang.org/t/syntax-highlighting-issues-in-juno-language-julia/24872/10 "2019-06-03T18:25:58Z")

</div>

There’s no syntactic distinction between property access and qualified name access, so it seems like trying to color them differently would be error prone at best and potentially misleading.

---

<div class="post-metadata">

**Author:** ![jarrison](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jarrison/32/5740_2.png) [@jarrison](https://discourse.julialang.org/u/jarrison)\
**Post date:** [June 3, 2019, 8:33pm UTC](https://discourse.julialang.org/t/syntax-highlighting-issues-in-juno-language-julia/24872/11 "2019-06-03T20:33:54Z")

</div>

Cooked this up,

 ![image](https://global.discourse-cdn.com/julialang/original/3X/f/8/f8a3ab73f2cd034739b88a00c159f1ad9b79639c.png)

What do you think about the style? I think that adding a new root group for types as well as moving them out of the “support” category will look pretty nice.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [June 4, 2019, 8:52am UTC](https://discourse.julialang.org/t/syntax-highlighting-issues-in-juno-language-julia/24872/12 "2019-06-04T08:52:46Z")

</div>

Looks pretty neat, mostly. Wanna open a PR so we can iterate on it?

---

<div class="post-metadata">

**Author:** ![StevenSiew](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevensiew/32/218393_2.png) [@StevenSiew](https://discourse.julialang.org/u/StevenSiew)\
**Post date:** [June 4, 2019, 9:13am UTC](https://discourse.julialang.org/t/syntax-highlighting-issues-in-juno-language-julia/24872/13 "2019-06-04T09:13:13Z")

</div>

I seems to have incorrect text highlighting in Juno. You can try it out for yourself with this code snippets.

```julia
str = " hello world "
newstr = replace(str,r"^\s+" => s"")
newstr = replace(newstr,r"\s+$" => s"")

```

Picture of incorrect hightlighting  
 ![20%20PM](https://global.discourse-cdn.com/julialang/original/3X/e/e/ee3a4dd380d483bec6558fc0039916665ab6c3ae.png)

---

<div class="post-metadata">

**Author:** ![xtalax](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xtalax/32/35293_2.png) [@xtalax](https://discourse.julialang.org/u/xtalax)\
**Post date:** [September 3, 2019, 11:35am UTC](https://discourse.julialang.org/t/syntax-highlighting-issues-in-juno-language-julia/24872/14 "2019-09-03T11:35:41Z")

</div>

Hey, did this go anywhere? I really like this seperated highlighting for types, and would love to get my Atom to look like this.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [September 4, 2019, 8:32am UTC](https://discourse.julialang.org/t/syntax-highlighting-issues-in-juno-language-julia/24872/15 "2019-09-04T08:32:05Z")

</div>

Kinda:  
[https://github.com/JuliaEditorSupport/atom-language-julia/pull/189](https://github.com/JuliaEditorSupport/atom-language-julia/pull/189)

Didn’t yet find the time/motivation to look into this, sorry.
