How to enable REPL Syntax Highlighting in 1.13?

Julia 1.13 News.md says:

" The REPL now provides syntax highlighting for input as you type. See the REPL docs for more info about customization."

Julia 1.13 REPL doc says:

“The REPL provides syntax highlighting for input as you type. Syntax highlighting is enabled by default…”

But I’m not seeing any highlighting in 1.13:
image

By contrast, this was my experience in 1.12 with OhMyREPL:
image

However, OhMyREPL.jl is incompatible with 1.13 and supposedly redundant with it, but that has not been my experience during the beta and now release of 1.13. (I never did receive any official responses.) How do I get that functionality back?

Everything is in the Julia documentation: The Julia REPL · The Julia Language

TLDR; this is a faces.toml file in ~/.julia/config/ and you can look at the possible properties at JuliaSyntaxHighlighting · Julia Syntax Highlighting

There aren’t any default configuration options provided?!

Also, if I have to manually set a static file, it won’t adapt if I change my terminal theme (background color), and I’ll have to start over.

There is an example here The Julia REPL · The Julia Language

It would be cool if there was a Julia package that has a bunch of REPL color themes to preview and choose from.

The highlighting is enabled by default, try e.g. "foo" to see string highlighting. The default theme just doesn’t have highlights in your example expression.

The Monokai example in the docs is functional for now (though brighter than I’d like).

image

~/.julia/config/faces.toml

# Monokai color theme for Julia syntax highlighting

[julia_macro]
foreground = "#A6E22E"

[julia_symbol]
foreground = "#AE81FF"

[julia_singleton_identifier]
inherit = "julia_symbol"

[julia_type]
foreground = "#66D9EF"

[julia_typedec]
foreground = "#66D9EF"
weight = "bold"

[julia_comment]
foreground = "#75715E"
italic = true

[julia_string]
foreground = "#E6DB74"

[julia_regex]
inherit = "julia_string"

[julia_backslash_literal]
foreground = "#FD971F"
inherit = "julia_string"

[julia_string_delim]
foreground = "#E6DB74"
weight = "bold"

[julia_cmdstring]
inherit = "julia_string"

[julia_char]
inherit = "julia_string"

[julia_char_delim]
inherit = "julia_string_delim"

[julia_number]
foreground = "#AE81FF"

[julia_bool]
foreground = "#AE81FF"
weight = "bold"

[julia_funcall]
foreground = "#A6E22E"

[julia_broadcast]
foreground = "#F92672"
weight = "bold"

[julia_builtin]
foreground = "#66D9EF"
weight = "bold"

[julia_operator]
foreground = "#F92672"

[julia_comparator]
inherit = "julia_operator"

[julia_assignment]
foreground = "#F92672"
weight = "bold"

[julia_keyword]
foreground = "#F92672"
weight = "bold"

[julia_parentheses]
foreground = "#F8F8F2"

[julia_unpaired_parentheses]
background = "#F92672"
foreground = "#F8F8F0"
weight = "bold"

[julia_error]
background = "#F92672"
foreground = "#F8F8F0"

[julia_rainbow_paren_1]
foreground = "#A6E22E"
inherit = "julia_parentheses"

[julia_rainbow_paren_2]
foreground = "#66D9EF"
inherit = "julia_parentheses"

[julia_rainbow_paren_3]
foreground = "#FD971F"
inherit = "julia_parentheses"

[julia_rainbow_paren_4]
inherit = "julia_rainbow_paren_1"

[julia_rainbow_paren_5]
inherit = "julia_rainbow_paren_2"

[julia_rainbow_paren_6]
inherit = "julia_rainbow_paren_3"

# Rainbow brackets
[julia_rainbow_bracket_1]
foreground = "#AE81FF"
inherit = "julia_parentheses"

[julia_rainbow_bracket_2]
foreground = "#E6DB74"
inherit = "julia_parentheses"

[julia_rainbow_bracket_3]
inherit = "julia_rainbow_bracket_1"

[julia_rainbow_bracket_4]
inherit = "julia_rainbow_bracket_2"

[julia_rainbow_bracket_5]
inherit = "julia_rainbow_bracket_1"

[julia_rainbow_bracket_6]
inherit = "julia_rainbow_bracket_2"

# Rainbow curlies
[julia_rainbow_curly_1]
foreground = "#F92672"
inherit = "julia_parentheses"

[julia_rainbow_curly_2]
foreground = "#A6E22E"
inherit = "julia_parentheses"

[julia_rainbow_curly_3]
inherit = "julia_rainbow_curly_1"

[julia_rainbow_curly_4]
inherit = "julia_rainbow_curly_2"

[julia_rainbow_curly_5]
inherit = "julia_rainbow_curly_1"

[julia_rainbow_curly_6]
inherit = "julia_rainbow_curly_2"

I still wish I could just keep using OhMyREPL.jl though. It is much easier to use.

Is there a place where different color themes are being collected? If someone has already beaten me to setting up Solarized Light, that would be nice!

It seems this needs to be replaced by

[julia_cmd]
inherit = "julia_string"

[julia_cmd_delim]
inherit = "julia_string_delim"

julia_cmdstring seems to have no effect.

I do happen to have

Which I think satisfies

Via DoomThemes.list().


Two other things

1: There is a default configuration. You should see some colour if your terminal supports colour and doesn’t report something confusing.

2: You can just use 4-bit ANSI named colours instead of hex codes.

I can’t seem to get DoomThemes.jl to work, it completely freezes the REPL when I run for example: DoomThemes.load!(:meltbus)
I’m using Konsole on Linux if that is relevant.

OhMyREPL.jl was updated today to work with Julia 1.13+, so the original syntax highlighting is back without needing to generate my own faces.toml file!

That said, the number of available colorshemes is fairly small.

No Solarized, for example. So, I think a larger collection of easy to access REPL themes is still needed.

DoomThemes.jl worked for me. However, it isn’t in the general registry, so you have to add it by url:
pkg> add https://code.tecosaur.net/tec/DoomThemes.jl.git

image

The theme list is larger, but still not large enough. Nothing to match the One Dark Pro VSCode extension for example. It’s also hard to search since there is no obvious ordering to the theme list.

I don’t know if I missed it in the docs somewhere, but what is the best way to permanently change the highlight style? The way I have it now is simply to add the line

@eval colorscheme!("Dracula")

to my startup.jl file along with the standard OhMYREPL.jl startup script.

That works for me without @eval :man_shrugging:

hmmmmmmm, when I set the colorscheme and restart Julia, the default theme switches back to the Monokai default. I will need to do some more investigation.

Just using OhMyREPL yields Monokai, yes. You need to set the colorscheme in your startup, if you want something different, but you can to that without the eval upfront, at least in my startup just the colorscheme! command works just fine.

If you can collect any more info on what’s going on here, I’d be very interested to hear more.

I think there is a timeout bug here: https://code.tecosaur.net/tec/DoomThemes.jl/src/commit/d63d1acf5b5957abaacf1836b53ad3eb39c85235/src/termtheme.jl#L47

start - time() < timeout looks backwards. (it should also probably be using time_ns since time might not be monotonic)

This whole function is using undocumented internal base functions, so it is hard to know what is going on. There is probably a way to do what you are trying to do using tasks, channels, and timers.

Oh yea, that bit is impossible to do correctly with Julia and libuv. I’ve bothered Jameosn and a few others on this. It’s been a while, but I remember trying a whole bunch of alternative approaches.

The best way to do this is lazily as part of REPL, which we’ll start doing in 1.14 (see my PR: Read the terminal colour scheme on REPL startup - Pull Request #59958 - JuliaLang/julia - GitHub).

In the meantime, you can use DoomThemes.load(<theme>, false) (false = don’t do anything with with the current terminal) and DoomThemes.applytheme! should work just fine.

I’ve also added pre-generated TOML files in a branch: https://code.tecosaur.net/tec/DoomThemes.jl/src/branch/toml-themes