Closed msanders closed 6 years ago
Thank you for the PR. I will review this on the weekends.
Highlighting property accesses and method calls will be helpful.
The regexp for enum cases seems to be bit buggy and may confuse users (see https://gist.github.com/taku0/5ce67840ce2824409877a6be6988cd5f). Fixing it would be difficult, so I suggest removing it. Vim doesn't seem to highlight enum cases.
Another concern is method/function calls with blocks. The following is a method call,
foo.bar {
}
while the following is not
if foo.bar {
}
Options:
What's your opinion?
Good catch, I've removed the enum regex for now. The pattern used in TextMate is a bit complicated (involving nested regexes), so it will probably be rather involved to get it working. Although it may be possible using a function similar to the property call matcher.
Regarding trailing closures, I'm personally fine with option (B) as it matches the behavior in both TextMate and Vim, and other editors using TextMate's bundle. The drawback to including curly braces is it also highlights patterns such as if let foo = bar {}
which is less than ideal. A workaround would be introducing lookahead for if statements (and potentially others I've missed), but that would be pretty involved and potentially prone to bugs. I think this gets us most of the way there while making things a lot more readable.
It's reasonable. Could you squash the commits, rebase the branch onto #145, and fix conflicts? I will merge this after merging #145. Thank you!
Merged abf34260ef0bb98a54c15e1a834d3ce56bfdb6ef
This brings swift-mode in line with other editors such as TextMate and Vim, which distinguish between function/method calls, properties, and enum declarations with syntax highlighting. Here's a before & after screenshot.
I'm pretty new to Elisp, so let me know if anything could be improved.