johncsnyder / SwiftKitten

Swift autocompleter for Sublime Text, via the adorable SourceKitten framework
MIT License
139 stars 18 forks source link

Not sure how to get it working #7

Open Dan2552 opened 8 years ago

Dan2552 commented 8 years ago

Hey. Nice work on this. I'd absolutely love to use Sublime over Xcode.

I'm not having luck here on getting this working...

I see on the README it says

SwiftKitten uses ijson to parse completions results from SourceKitten. By default, SwiftKitten will use the pure python backend. If the faster yajl2_cffi backend is available, SwiftKitten will automatically load it. It is highly recommended that you build the cffi backend.

I've installed SourceKitten with homebrew but I'm unfamiliar with all things Python - is there anything I need to do for ijson or anything else?

reloading plugin SwiftKitten.SwiftKitten
WARNING:root:Failed to import yajl2_cffi backend for ijson.
plugins loaded
Package Control: Skipping automatic upgrade, last run at 2016-10-06 12:57:43, next run at 2016-10-06 13:57:43 or after
Exception in thread Thread-4:
Traceback (most recent call last):
  File "/Users/dan/Library/Application Support/Sublime Text 3/Installed Packages/SwiftKitten.sublime-package/ijson/ijson/backends/python.py", line 125, in parse_value
    yield ('number', common.number(symbol))
  File "/Users/dan/Library/Application Support/Sublime Text 3/Installed Packages/SwiftKitten.sublime-package/ijson/ijson/common.py", line 158, in number
    number = decimal.Decimal(str_value)
  File "./python3.3/decimal.py", line 590, in __new__
  File "./python3.3/decimal.py", line 4045, in _raise_error
decimal.InvalidOperation: Invalid literal for Decimal: 'U'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./python3.3/threading.py", line 901, in _bootstrap_inner
  File "./python3.3/threading.py", line 858, in run
  File "SwiftKitten in /Users/dan/Library/Application Support/Sublime Text 3/Installed Packages/SwiftKitten.sublime-package", line 415, in _autocomplete
  File "SwiftKitten in /Users/dan/Library/Application Support/Sublime Text 3/Installed Packages/SwiftKitten.sublime-package", line 378, in _autocomplete_request
  File "SwiftKitten in /Users/dan/Library/Application Support/Sublime Text 3/Installed Packages/SwiftKitten.sublime-package", line 339, in _parse_completions
  File "/Users/dan/Library/Application Support/Sublime Text 3/Installed Packages/SwiftKitten.sublime-package/ijson/ijson/common.py", line 65, in parse
    for event, value in basic_events:
  File "/Users/dan/Library/Application Support/Sublime Text 3/Installed Packages/SwiftKitten.sublime-package/ijson/ijson/backends/python.py", line 185, in basic_parse
    for value in parse_value(lexer):
  File "/Users/dan/Library/Application Support/Sublime Text 3/Installed Packages/SwiftKitten.sublime-package/ijson/ijson/backends/python.py", line 127, in parse_value
    raise UnexpectedSymbol(symbol, pos)
ijson.backends.python.UnexpectedSymbol: Unexpected symbol 'U' at 0

Request denied: completion for "" already in progress.
Request denied: completion for "" already in progress.
Exception in thread Thread-7:
Traceback (most recent call last):
  File "/Users/dan/Library/Application Support/Sublime Text 3/Installed Packages/SwiftKitten.sublime-package/ijson/ijson/backends/python.py", line 125, in parse_value
    yield ('number', common.number(symbol))
  File "/Users/dan/Library/Application Support/Sublime Text 3/Installed Packages/SwiftKitten.sublime-package/ijson/ijson/common.py", line 158, in number
    number = decimal.Decimal(str_value)
  File "./python3.3/decimal.py", line 590, in __new__
  File "./python3.3/decimal.py", line 4045, in _raise_error
decimal.InvalidOperation: Invalid literal for Decimal: 'U'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./python3.3/threading.py", line 901, in _bootstrap_inner
  File "./python3.3/threading.py", line 858, in run
  File "SwiftKitten in /Users/dan/Library/Application Support/Sublime Text 3/Installed Packages/SwiftKitten.sublime-package", line 415, in _autocomplete
  File "SwiftKitten in /Users/dan/Library/Application Support/Sublime Text 3/Installed Packages/SwiftKitten.sublime-package", line 378, in _autocomplete_request
  File "SwiftKitten in /Users/dan/Library/Application Support/Sublime Text 3/Installed Packages/SwiftKitten.sublime-package", line 339, in _parse_completions
  File "/Users/dan/Library/Application Support/Sublime Text 3/Installed Packages/SwiftKitten.sublime-package/ijson/ijson/common.py", line 65, in parse
    for event, value in basic_events:
  File "/Users/dan/Library/Application Support/Sublime Text 3/Installed Packages/SwiftKitten.sublime-package/ijson/ijson/backends/python.py", line 185, in basic_parse
    for value in parse_value(lexer):
  File "/Users/dan/Library/Application Support/Sublime Text 3/Installed Packages/SwiftKitten.sublime-package/ijson/ijson/backends/python.py", line 127, in parse_value
    raise UnexpectedSymbol(symbol, pos)
ijson.backends.python.UnexpectedSymbol: Unexpected symbol 'U' at 0
Dan2552 commented 8 years ago

OK, I did a little bit of digging, and the problem seems to be unexpected output from sourcekitten

The plugin will try to run something like:

/usr/local/bin/sourcekitten complete --text 'import UIKit
              import SpriteKit

              class MapScene: SKScene {
                  var map: Map = Map()

                  override init() {
                      super.init()
                      setup()
                      self.' --offset 159 --compilerargs -- ' '

and will get:

Unrecognized arguments: --compilerargs

Without --compilerargs it kind of works but seems quite unreliable - I'm not sure how reliable sourcekitten itself is. I might play around a bit more.

ghost commented 7 years ago

I get the same error I think:

Package Control: Skipping automatic upgrade, last run at 2016-12-06 09:25:07, next run at 2016-12-06 10:25:07 or after Request denied: completion for ".Kitura" already in progress. Request denied: completion for "" already in progress. Request denied: completion for ".Kitura" already in progress. Request denied: completion for "" already in progress. Request denied: completion for ".Kitura" already in progress. Request denied: completion for "" already in progress. Request denied: completion for ".Kitura" already in progress. Request denied: completion for "" already in progress. Request denied: completion for ".Kitura" already in progress. Request denied: completion for "" already in progress. Request denied: completion for ".Kitura" already in progress. Request denied: completion for "" already in progress. Exception in thread Thread-18: Traceback (most recent call last): File "/Users/oyalhi/Library/Application Support/Sublime Text 3/Packages/SwiftKitten/ijson/ijson/backends/python.py", line 125, in parse_value yield ('number', common.number(symbol)) File "/Users/oyalhi/Library/Application Support/Sublime Text 3/Packages/SwiftKitten/ijson/ijson/common.py", line 158, in number number = decimal.Decimal(str_value) File "./python3.3/decimal.py", line 590, in new File "./python3.3/decimal.py", line 4045, in _raise_error decimal.InvalidOperation: Invalid literal for Decimal: 'U'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "./python3.3/threading.py", line 901, in _bootstrap_inner File "./python3.3/threading.py", line 858, in run File "/Users/oyalhi/Library/Application Support/Sublime Text 3/Packages/SwiftKitten/SwiftKitten.py", line 415, in _autocomplete stub, text, offset) File "/Users/oyalhi/Library/Application Support/Sublime Text 3/Packages/SwiftKitten/SwiftKitten.py", line 378, in _autocomplete_request completions = list(self._parse_completions(parser, included=included)) File "/Users/oyalhi/Library/Application Support/Sublime Text 3/Packages/SwiftKitten/SwiftKitten.py", line 339, in _parse_completions for prefix, event, value in parser: File "/Users/oyalhi/Library/Application Support/Sublime Text 3/Packages/SwiftKitten/ijson/ijson/common.py", line 65, in parse for event, value in basic_events: File "/Users/oyalhi/Library/Application Support/Sublime Text 3/Packages/SwiftKitten/ijson/ijson/backends/python.py", line 185, in basic_parse for value in parse_value(lexer): File "/Users/oyalhi/Library/Application Support/Sublime Text 3/Packages/SwiftKitten/ijson/ijson/backends/python.py", line 127, in parse_value raise UnexpectedSymbol(symbol, pos) ijson.backends.python.UnexpectedSymbol: Unexpected symbol 'U' at 0

Request denied: completion for "" already in progress. using gpu buffer for window

Dan2552 commented 7 years ago

Given the lack of response on issues/PRs and the months since last commit I gathered this project is pretty dead.

I decided to learn some Python, get a bit more familiar with SourceKitten, and give this a try myself. Here's the result: https://github.com/Dan2552/SourceKittenSubl

It doesn't have documentation popups or caching like SwiftKitten, but it's got unit tests and is in a state where it's mostly working for me.

monomadic commented 7 years ago

@Dan2552 you're my hero

Dan2552 commented 7 years ago

@robsaunders If you do end up using it, check back every now and then for any updates (do a git pull on your clone to update) 👍

freesuraj commented 7 years ago

@Dan2552 I loved the fact that you had the patience to go and rewrite everything from scratch, pretty good job. It works, but I find it's kinda slow. Probably occupies a lot of main thread. Would be great, if you could have a look at that.

Dan2552 commented 7 years ago

I'm a little sidetracked at the moment (job searching and soon will be starting a new job) so wont be able to do anything on it in the immediate future, but yeah speed is definitely an issue I've noticed. There's a PR I opened (https://github.com/Dan2552/SourceKittenSubl/pull/16) that improves suggestions, but slows it down a lot lot more, so speed is definitely next concern.

I'm not too sure how I'd approach using alternate threads, as I'm not sure if that would just result in a lot of places you expect suggestions to just simply not show anything. If you have any thoughts on how to approach that, feel free to contribute ideas in the issues (or of course PRs!) on the repo. I'm also planning on having a bit of a look at https://github.com/Dan2552/SourceKittenSubl/issues/17 which has potential to speed it up (depending on how much time is for sourcekitten & json parsing).