Does anyone know a good color scheme for syntax highlighting adapted to Elixir.
In my case I’m using VSCode.
I tried some Color Themes dedicated to Elixir found on the extension market but even so I found them not suited for Elixir.
For example when using an inline def, none of them highlights correctly the do: like the def.
I know that it’s in fact a keyword (even in the implementation) but semantically I wanted the do: to be the same as the def.
Anyway, if anyone have a good suggestion I’ll be happy to try it…
Thank you…
Edit: I’ll also try to look at how syntax highlighting works (probably a lot of regex) and I’ll try to tinker with it myself…
The issue with the specific case you describe (do: treated as atom in inline def), is unfortunately not something theme designers can control.
The relevant code is here. The summary is that the syntax currently used by the ElixirLS Fork extension has a long lineage (Atom -> vscode-elixir -> ElixirLS), and no one has yet tackled the specific tweak for do:.
I don’t actually know if do: is a legal keyword/atom name. Presumably not. If it isn’t, then simply adjusting the regexes for keyword.control.elixir (allow do to be followed by :) and/or constant.other.symbol.elixir (disallow do: when it appears alone), would fix the problem.
In the meantime, please check out my Yarra Valley theme for Elixir
:do is definitely a valid atom, and indeed the do: in def something, do: ... is just a normal atom key in a keyword list. So having a special rule for :do atoms would probably not work well.
By the way, really nice theme, I would love to see a port to Vim to be able to use it in my everyday editor
This would be wrong in my opinion. To be honest, in my opinion, even do/end pairs should be colored as atoms, as they are just syntactic sugar for do: ….
I’d even say, def and friends shouldn’t get special treatment/colors as well, it is just a function call and should not have any different color than foo in foo(:bar).
Well…
Indeed we can treat all the keywords as the compiler see them…
Or we can treat them as developers and consider the semantic meaning of them…
Which is actually performed by Elixir itself by providing the syntactic sugar of the keywords listed by @LostKobrakai
I mean if Elixir itself apply some special formatting, indentation, etc. (and even macros under the hoods) to those syntactic sugars, coloring them make total sense in the point we are.
I though of a regex something like that to distinguish do: in inline defs:
/(?!^\s*def.+,\s)(do:)/gm
And if I look at the source code of the vscode-elixir-ls extension provided by @Dusty above the following might work: