vscode-nim
vscode-nim copied to clipboard
Misclassified keywords
true
, false
and assert
, echo
(and probably others) are rendered as keywords. The real list of keywords can be found here:
https://nim-lang.org/docs/manual.html#lexical-analysis-identifiers-amp-keywords
I think this is more of an issue with VSCode's default theme, compare this (Default theme):
And this (Monokai Vibrant):
Maybe it's possible to have a different color for the default theme but I'm not sure.
From the TextMate grammar file:
{
"comment": "Common functions",
"match": "\\b(new|await|assert|echo|defined|declared|newException|countup|countdown|high|low)\\b",
"name": "keyword.other.common.function.nim"
},
Oh, it actually seems like it's only Nim that does this, I can't find other extensions that define "keyword.other.common.function"
A good alternative would be to use the "support" TextMate scope (from https://macromates.com/manual/en/language_grammars):
support — things provided by a framework or library should be below support.
function — functions provided by the framework/library. For example NSLog in Objective-C is support.function. class — when the framework/library provides classes. type — types provided by the framework/library, this is probably only used for languages derived from C, which has typedef (and struct). Most other languages would introduce new types as classes. constant — constants (magic values) provided by the framework/library. variable — variables provided by the framework/library. For example NSApp in AppKit. other — the above should be exhaustive, but for everything else use support.other.
How is that a "good" alternative? It's nonsense, why are class
and type
different, what about let
vs var
, would template/method/iterator/macro be "function" or "other"... Semantic highlighting is a design bug, basing the "semantics" on some lowest common denomiator between languages is even worse.