minism / SublimeLove

LÖVE support for SublimeText2
http://love2d.org
41 stars 16 forks source link

fixed autocomplete #5

Closed qwook closed 10 years ago

qwook commented 10 years ago

Removed the sublime autocomplete definitions and used a script that will parse src/api.txt and src/callbacks.txt and generates autocomplete data.

It is much more cleaner when you code and doesn't do repeats.

it is also using 0.9.0 api

minism commented 10 years ago

Hmm, I believe that the completions file is already being generated by src/build.py, so I'd rather not introduce another file that does the same thing.

Furthermore, I think I prefer pre-generating the completions and checking them in is better to generating them on the fly. Aside from the obvious performance benefit, the completions would only change when the API changes, meaning we need to update the repository anyway, so there isn't any benefit to dynamically computing them.

That being said, I'd love the new 0.9 API txt files, can you split those into a separate pull request?

qwook commented 10 years ago

No it does not generate the completions file. It is using your pre-generated completions and are not generating them on the fly.

This only reads your api.txt and callbacks.txt file and parses them into a python array (which is not saved anywhere and is only used in the python script) and removes the need for the .SublimeComplete file.

The core of the python file really just makes it so the autocomplete only shows up when you do love. or love.graphics. and only shows autocompletion pertaining to the library.

SK83RJOSH commented 10 years ago

Though I'd absolutely love for this to be merged, it doesn't appear to work on my end. But I definitely think that this would be the way to go once whatever issue persists with it is corrected, because the default completions are absolutely obnoxious sometimes.

Especially the fact I have to always correct 'love.filesystem.append' to 'end' every time I need to close a function.

qwook commented 10 years ago

Do you have something like this in your user preferences/settings?

{
    "auto_complete_triggers":
    [
        {
            "characters": ".",
            "selector": "source"
        },
        {
            "characters": ":",
            "selector": "source"
        }
    ]
}

Otherwise, you must do ctrl-space or cmd-space after every dot you make. This is not like the original autocomplete where it completes the entire function on word suggestion, instead this is an autocomplete when your cursor is next to a ..

SK83RJOSH commented 10 years ago

Still nothing even with the edits to my user configuration, I'm just receiving the standard auto-completions. I took the liberty of removing the default auto-completions file after noticing this and I ensured the src directory was there after I review the python file.

But this resulted in nothing at all occurring when I manually invoked auto-complete with ctrl+space other than previously typed variables appearing (which is just as bothersome as auto-completion sometimes).

qwook commented 10 years ago

Do you have any python errors that show up? I'm currently using Sublime Text 3 on Mac OSX 10.9

If it's windows, I think I might have found one of the problems.

edit: I made a tiny, tiny fix. You can try pulling it and seeing if it works but I'm going to be testing on my windows partition.

edit2: Seems like that fixed it. Try it now.

SK83RJOSH commented 10 years ago

Awesome, that seemed to do the trick. Great work man! :)

minism commented 10 years ago

Sorry, I was tired when I responded and didn't understand the point of this change. Checking it out now! (for the record i've been unhappy with the way these completions work too)

minism commented 10 years ago

Okay, so I still dont totally understand why this is better than a completions file, but I'm fine with it being programmatically generated and cached at startup, and I understand that it lets us be more flexible with triggering and completions.

That being said there are still two regression issues I'm having that would need to be fixed first:

I'm on ST2 by the way. Thanks for your work!

qwook commented 10 years ago

Works for words now instead of just after a dot. As well as that it has proper syntax detection, so it works on new blank files.

Also, it's better than the completions file because sometimes when using the completion file, it will end up with something like "love.love.graphics.draw(..)" or "love.graphics.love.graphics.draw(...)"

minism commented 10 years ago

Awesome, this is a huge improvement. Sorry it took me so long to approve this.