- Notifications
You must be signed in to change notification settings - Fork 44
Add more comprehensive support for highlighting built-ins #145
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
Conversation
| Thank you for the PR. I will review this on the weekends. |
716136d to 903cbdf Compare There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impressive. Where do those foundation type/member names come from? The documentation? The source? I want to know it to update them future.
swift-mode-font-lock.el Outdated
| font-lock-builtin-face) | ||
| | ||
| (,(concat "\\.\\s-*" | ||
| (regexp-opt swift-mode:member-functions-trailing-closure 'words) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, should this be swift-mode:member-functions?
| swift-mode:foundation-structs | ||
| swift-mode:protocols | ||
| swift-mode:structs | ||
| swift-mode:typealiases) 'words) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should swift-mode:enum-types be here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixed.
| "weak" "willSet") | ||
| "Keywords reserved in particular contexts.") | ||
| | ||
| (defconst swift-mode:build-config-keywords |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed.
swift-mode-font-lock.el Outdated
| 1 | ||
| font-lock-builtin-face) | ||
| | ||
| (,(concat "\\(^Process\\.\\|[^_[:alnum:]]Process\\.\\|^CommandLine\\.\\|[^_[:alnum:]]CommandLine\\.\\)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just \\<...\\>? Should \\s-* be inserted around the dot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, good point. This only matches fields pertaining to Process/CommandLine, but I suppose that would be simpler. I've updated it to be combined with the other properties.
| Here is a test file https://gist.github.com/taku0/21fd1c4f6eeda75d951067f48d6948e9. |
| Thanks @taku0! Foundation types were generated using this script against the Foundation header copy-pasted from Xcode (jump to definition on print("'({})".format(" ".join('"{}"'.format(x) for x in exrex.generate(pattern)))) |
| All looks good. Could you squash commits, then I will merge it. Thank you! |
* Expand regexes for built-ins * Update existing keywords to use regexp-opt for consistency * Move keyword comments to docstrings * Add compactMap * Add Foundation types * Address PR feedback * Simplify property matching
51cb369 to 869eff9 Compare | Done 👍 |
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.generatein Python and applied them usingregexpt-opt.