vscode-nim icon indicating copy to clipboard operation
vscode-nim copied to clipboard

Misclassified keywords

Open Araq opened this issue 3 years ago • 5 comments

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

Araq avatar Mar 09 '21 07:03 Araq

I think this is more of an issue with VSCode's default theme, compare this (Default theme):

image

And this (Monokai Vibrant):

image

Maybe it's possible to have a different color for the default theme but I'm not sure.

Yardanico avatar Mar 15 '21 23:03 Yardanico

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"
    },

Yardanico avatar Mar 15 '21 23:03 Yardanico

Oh, it actually seems like it's only Nim that does this, I can't find other extensions that define "keyword.other.common.function"

Yardanico avatar Mar 15 '21 23:03 Yardanico

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.

Yardanico avatar Mar 15 '21 23:03 Yardanico

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.

Araq avatar Mar 16 '21 09:03 Araq