Dan2552 / SublimeTextSwiftAutocomplete

Swift autocompletion in Sublime Text using SourceKitten
MIT License
155 stars 7 forks source link

A few updates and improvements #26

Closed nettlep closed 6 years ago

nettlep commented 6 years ago

First, great job on this!

When I loaded it up, the first thing it did was to throw an exception complaining about an ASCII code. It turns out there was a copyright symbol in one of the source files that was tripping it up when trying to convert to raw ASCII for writing to a text file. So 08d213e converts it to utf-8 and writes that stream to a binary file. With that out of the way, I was able to see the awesomeness that is SubllimeTextSwiftAutocomplete.

The next issue I ran into came when hovering over MemoryLayout<SomeClass>.size. This one, too, caused an exception. It turns out that the tag parsing wasn't taking into account that CDATA blocks can have tags in them without escaping the leading<. So d392249 was created to locate CDATA blocks, escape the tags with < and then rip out the CDATA head/tail.

Next was the root directory. I have a rather extensive directory tree for my project (with documents, large PSDs, a good number of video files, etc.) and the Swift code is in one subdirectory. So in 5639bc9, I added the ability to create a setting called stsa.project_root to specify the root. I put mine in my project settings. If that setting is not present, it will revert to the original behavior.

And finally, no documentation showed up for me. After some investigation, it looked like it might work in some cases, but not in my case (not really sure why - maybe a tools version issue?) So I did some work to parse out the Abstract and Discussion bits separately in order to display them as first-class citizens in the popup and e0e0e31 was born. To accomplish this, I had to add filter regex patterns to _popup_section_from_dict so that it could generate sections for specific subsets of the input XML. This also includes some cleanup work to <CodeListing> sections, which included simulating pre-formatted text blocks (ST3 doesn't support this natively) by setting a monospace font and swapping tabs/spaces with Unicode NO-BREAK SPACE characters that aren't filtered out by the HTML renderer. That last bit feels a bit hacky to me, but it was the only thing that produced correct results.

The end result looks a like this:

screen shot 2018-02-15 at 10 42 53 am
Dan2552 commented 6 years ago

Sounds great, thanks! 🥇 I'll try to read over code in the PR soon!