TheEnigmaBlade / atom-language-rust-redux

Maintained syntax highlighting and snippets for Rust in Atom.
MIT License
3 stars 1 forks source link

Improve syntax for function #5

Open GrayJack opened 5 years ago

GrayJack commented 5 years ago

Would be possible to do something like this in function definition? Where "fn" gets itallic and bright and the parameters of the function have a different color

image

TheEnigmaBlade commented 5 years ago

Syntax themes are what control the exact coloring and style of your code, while the language packages parse the text based on a grammar and provide a set of CSS classes used by syntax themes.

You can customize most elements of your syntax theme in your local stylesheet. For example:

.syntax--source.syntax--rust {
  .syntax--keyword.syntax--fn {
    color: #66D9EF !important;
    font-style: italic;
  }
}

Pressing ctrl-alt-shift-p will display a pop-up message with a list of CSS classes applied to the text at the location of the cursor. Pick the ones you want and prefix each with .syntax--.


Function parameters currently aren't given any special classes because that type of highlighting is typically performed by full language parsers (the Rust Language Server, for example) for context-aware syntax highlighting. If the highlighting of function parameters were to be added to this language package, the colors would only apply to the variables within the function declaration and no where else in the function.

GrayJack commented 5 years ago

the colors would only apply to the variables within the function declaration and no where else in the function

That was exactly what I wanted

And thanks for the info :3

GrayJack commented 5 years ago

Another question, is there a way to colorize structs ?

TheEnigmaBlade commented 5 years ago

Structs individually, no. The struct keyword is currently grouped together with enum, trait, union, and type.

You can re-style them with .storage.type:not(.core).

GrayJack commented 5 years ago

Oh, I thinks I expressed myself wrong, I mean colorize a struct name, no matter what, like, if I define a sctruct, when I instance a object of that struct, the struct name gets colorized. Kinda like the std lib structs names, but for crates structs and in code structs

TheEnigmaBlade commented 5 years ago

Doing that requires semantic syntax highlighting, which Atom doesn't support.

GrayJack commented 5 years ago

It's really impossible to tokennize function parameters? Like it's done in ocaml, python, etc?