swift-emacs / swift-mode

Emacs support for Apple's Swift programming language.
GNU General Public License v3.0
363 stars 47 forks source link

Add more comprehensive support for highlighting built-ins #145

Closed msanders closed 6 years ago

msanders commented 6 years ago

This brings swift-mode's highlighting for built-ins up to par with TextMate’s Swift bundle. I’ve converted the regexes pertaining to built-ins from there for Swift 3 and up using pcre2el.

I've expanded the keyword regexes from there using exrex.generate in Python and applied them using regexpt-opt.

taku0 commented 6 years ago

Thank you for the PR. I will review this on the weekends.

taku0 commented 6 years ago

Here is a test file https://gist.github.com/taku0/21fd1c4f6eeda75d951067f48d6948e9.

msanders commented 6 years ago

Thanks @taku0! Foundation types were generated using this script against the Foundation header copy-pasted from Xcode (jump to definition on import Foundation). It unfortunately only includes native Swift types, not the bridged classes. Not sure how to generate those without parsing the Objective-C headers. TextMate's regexes were expanded using the following in Python:

print("'({})".format(" ".join('"{}"'.format(x) for x in exrex.generate(pattern))))
taku0 commented 6 years ago

All looks good. Could you squash commits, then I will merge it. Thank you!

msanders commented 6 years ago

Done 👍