georgewfraser / vscode-tree-sitter

Accurate syntax coloring for VSCode using tree-sitter
MIT License
175 stars 25 forks source link

[Bug] [Rust] Inconsistent hightligting on paths #6

Closed lnicola closed 5 years ago

lnicola commented 5 years ago
use std::time::Duration;
fn foo1(x: std::time::Duration) {}

image

lnicola commented 5 years ago

Actually, this might be intended, I'm not sure.

georgewfraser commented 5 years ago

This is intended---Duration is a type, the other path elements are not.

lnicola commented 5 years ago

I was referring to the Duration in use std::time::Duration;.

georgewfraser commented 5 years ago

I spent some time trying to colorize use declarations last night. It turns out it's very hard to correctly recognize types in use declarations. We could rely on naming conventions + a list of builtin types.

I tried to outline a "colorization philosophy" in https://github.com/georgewfraser/vscode-tree-sitter#fixing-colorization-of-an-existing-language. I definitely think it would be better if types in use declarations were colorized as types, because it would be more consistent.

lnicola commented 5 years ago

Thanks :-). In the meanwhile, I'm trying to improve the syntax highlighting of https://github.com/rust-analyzer/rust-analyzer/, which in the long run should be more precise, because it has full semantic information.

maxbrunsfeld commented 5 years ago

👋 Nice work on this plugin @georgewfraser. In Atom, we use the naming convention for this problem. I believe we treat capitalized items in paths as types.

georgewfraser commented 5 years ago

Thanks for the tip @maxbrunsfeld !