Closed porglezomp closed 9 years ago
Thanks for the PR! Someone else added the encoding='utf8' recently to fix a unicode issue. I don't think that's relevant anymore with the change you've made (since it's not based on the current path) - does that make sense to you?
Also, when I first wrote the plugin, I initially used something similar (a temp path) but I found racer didn't autocomplete items from the local project unless the tempfile was stored alongside them - but maybe that has been resolved now?
If you can confirm the above items are not an issue, I'll merge this and make a new release!
Thanks, I hadn't considered all of those issues, so I'll investigate some more to confirm they work.
It looks like you indeed have to be in the same folder as the sources for it to work. I'll see about doing the best possible thing to find the code folder, and only use the system tmp folder as a last resort.
In terms of the encoding issue, does the open([stuff], encoding="utf-8")
even work without Python 3? I know ST3 uses Python 3.3, but ST2 uses the system Python, so I don't know if the current code will work on most installations of ST2.
Sounds good. I'm not sure about the encoding stuff - but I only use ST3 and I'm fine with this plugin being ST3-only (it's only listed as ST3 compatible in package control I think). Unless there's an easy way to make it work with ST2 as well, which I guess would be ideal.
Okay, I didn't see that it was ST3 only. Since I know I'm targeting Python 3.3 I can fix the encoding for sure.
I have a few ideas about things that we could do to guess where to put it. Currently you're saving the temp file next to the file, and I'm saving it to the global tmp
now if it's unsaved.
Should I attempt to treat it as a cargo project if the window has an open folder? I would save unsaved temp files into os.path.join(window.folders()[0], "src")
which would look like ~/Dev/project-name/src
?
Furthermore, if there's no open folder, should I try to guess where to save it based on the stems of open files? Maybe only if they're all in the same directory?
Note that currently racer doesn't handle very complex file structures right now, so if someone has a project like:
main.rs
module.rs
moremodule/
mod.rs
item.rs
I don't think it's able to complete any code inside moremodule::
from main.rs
I think the best idea might be to ask the author of racer (https://github.com/phildawes/racer) where he would recommend saving the temp file?
I'll ask him about doing that, but in the meantime I've hacked together a solution that I think does a better job than what we have currently.
Looks good - does it handle the utf8 encoding change we discussed above? I couldn't see where it handles that but I may have missed it.
That's odd, I appear to have left it off. It should be fixed now?
Thanks!
Use tempfile to create tempfiles instead of current folder