jcollard / elm-mode

Elm mode for emacs
GNU General Public License v3.0
373 stars 67 forks source link

Add autoimports #128

Closed TatriX closed 3 years ago

TatriX commented 6 years ago

Is it possible to achieve something like this?

I know that purescript-mode has this feature. Probably it may be used as a source of inspiration.

purcell commented 6 years ago

Yes, it would probably be possible, at least for completion + auto-import of symbols in third-party libraries. company-mode, which we use for completion, supports a post-completion command, which we could use to auto-insert an import.

However, our candidates right now come from elm-oracle (which only supports symbols found in third-party packages, not the current project's source code), and we explicitly limit the completion candidates to symbols imported by the current file. To get a list of absolutely all symbols in all the third-party libraries listed as dependencies in the current project one can run elm-oracle elm-package.json "". We'd need to change our completion caching strategy in order to cache completions project-wide rather than per-buffer.

Overall this is a bit of work, and I'm unlikely to tackle it myself, but happy to help provide direction if someone else wants to dig in.

kritzcreek commented 6 years ago

purescript-mode doesn't have it, it's psc-ide-emacs. All the logic resides inside the PureScript compilers IDE server though, so there's not a lot of inspiration to draw from the Elisp, unless you get one of those servers yourself^^

purcell commented 3 years ago

I think this is something that would now get supported via LSP if it happens at all.