Skip to content

Add autoimport and maybe organize imports feature #736

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

Closed
purpleP opened this issue Aug 26, 2017 · 3 comments
Closed

Add autoimport and maybe organize imports feature #736

purpleP opened this issue Aug 26, 2017 · 3 comments

Comments

@purpleP
Copy link

purpleP commented Aug 26, 2017

Automatic import handling

I have a feature request, we're all busy, so take it or leave it. But it would be nice if jedi could add missing import statements and organize imports. This could be integrated nicely via InsertLeave event. Just check if some unknown identifier have appeared and show a menu where use could choose or type manually what to import.

Another thing I would like to have is to have an api for getting syntax tree of the current buffer. This would allow things like making new end of current syntax element motion which then could be used to delete or surround it with parenthesis and stuff like that.

Unfortunately I wouldn't be able to implement this myself, because right now I'm investigating the possibility of using http://bnfc.digitalgrammars.com/ and Happy to make a service (in the same way jedi is a service) that would complement editor with smart features like autocompletion, refactorings and other stuff. Basically do what jedi does and more but for any language for which someone already wrote BNF (it's done already for the most of the languages). I really think reimplementing parsers for each language is big waste of human potential.

@davidhalter
Copy link
Owner

Import handling is still kind of far away in Jedi. That takes probably 2-3 more years. I'm pretty certain that it's coming, but I just don't have the time right now.

For parsers I can just say that I'm on the verge of releasing https://github.com/davidhalter/parso. The remining issues there mostly revolve around documentation. However that currently doesn't include support for other languages (it might one day, but not at the moment).

The problem with the BNF implementation is that it doesn't support error recovery. Error recovery is crucial if you want to make it usable for most users. Parso does have error recovery BTW.

@zhukovgreen
Copy link

zhukovgreen commented Apr 9, 2019

Just as a workaround I am using the following line in the vim config:

nmap <F3> :w<CR>:!autoflake -i --remove-all-unused-imports --remove-duplicate-keys --remove-unused-variables %<CR>:!black %<CR><CR>:e!<CR>

Note: you have to pip install autoflake before

@davidhalter
Copy link
Owner

Jedi does not support autoimport nor will it in the near future. I'm therefore closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants