-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve syntax highlighting (types) #74
Comments
VS Code is getting highlights based on semantic information from the analysis server. We don't have a way to do that. (In theory an LSP plugin could do something here, but it's not easy in vim. There has been talk about making it easier but even if we get nice APIs in vim we probably would push that to an LSP plugin instead of implementing it here). We could maybe make assumptions about semantics, like assuming that everything that starts with a capital letter is a type. It would fall down with non-idiomatic code, but maybe that isn't a problem? |
Agreed that making assumptions about capital or underscore-capital identifiers feels a bit dodgy. Playing devil's advocate for a bit, it's worth noting that we already make certain assumptions about code being idiomatic -- e.g. we highlight That said, I have no firm opinion one way or another. My general inclination would be to ask what other similarly-lightweight vim language plugins do. |
I played around a bit with the built in java config and it behaves similarly to what we have today. I also tried highlighting capitalized names as @lleaff - if you want to propose something that you like we can consider it, but I'm not able to find something that I think is an improvement over what we have today... |
I agree that the long term solution is to have that provided by the language server as in VS Code. Tracking those issues in the major clients: The uppercase assumption seems like a smart temporary solution ! I played around a little bit with those rules: syntax match dartType "\<[A-Z][A-Za-z0-9_]*\>"
syntax match dartConstant "\<[A-Z][A-Z0-9_]\+\>" Of course as you pointed out you then need to differentiate between Personally I think it's a definite improvement, without it I find any language with C-style type annotations unreadable. |
Currently, there are no syntax rules to detect type annotations, other than a list of built-ins (
int
,String
, etc).It would be nice if any value used as a type could be highlighted, either in function arguments, return types, or variable declarations.
Here is a comparison screenshot, Vim with
dart-vim-plugin
on the left, VS Code with the Dart plugin on the right:For instance, in the line with:
Widget build(BuildContext context) {
,Widget
andBuildContext
should be highlighted differently thancontext
.The text was updated successfully, but these errors were encountered: