Closed nastevens closed 3 years ago
Thanks for the PR @nastevens!
It's hard for me to get excited about this change. In general I don't find that highlighting each last little bit of syntax is useful for readability, and it can get busy (and slow, if taken to the extreme). In my experience highlighting these sorts of "namespacing operators" isn't all too common -- do you have other examples you can point to where vanilla vim does special highlighting for similar constructs?
For instance, in this screenshot of C++ code, you can see that neither the /
(in the #include
s), nor the ::
namespace separator, nor the .
field/method access separator are highlighted:
If we do make this change, I think that for consistency it should also apply to keys that are the names of tables or table arrays:
Probably the best example, since it's also primarily a data language, is YAML. It does highlight the :
after key names:
Rust highlights namespace operators like ::
and ->
, and highlights function calls:
One weird note on the Rust hightlighting - in cmp::min
you see cmp::
is one color and min
is a different color. The ::
is actually a different highlight group though, so this is what I see with my preferred color scheme:
A cursory review of some other languages shows there's not a whole lot of consistency on the subject. Here's the summary:
I was running everything on vim 8.1.2269 with vim --clean
so I wasn't picking up outside plugins. Not sure if this helps or just makes things muddier :smile:
If we do make this change, I think that for consistency it should also apply to keys that are the names of tables or table arrays
Totally agree, I've pushed a change that does this.
@a-vrma could you take a look at this?
I quite like this. The attached image compares main
with this change.
The color change can help people parse the pi example as a key inside a table rather than a decimal. It also helps with the quoted IP address. I also like that you used the display
option so performance shouldn't be affected for people who aren't assigning different colors to tomlKey and tomlDottedKey.
EDIT: I also like this because matching a dot in the key will make it easier to fix #58.
Thanks for the patch!
TOML supports the dotted-key notation for defining keys within subtables as described in the "Keys" section of the spec
This adds a highlight to the dots in dotted-keys by setting the dot's style to
Normal
. The result of this highlight is subtle, but very helpful for picking out the levels of a dotted-key.