-
Notifications
You must be signed in to change notification settings - Fork 67
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
Fix completion and eldoc for Elm 0.19, broken by reliance on elm-oracle #142
Comments
Update: I worked on this a little bit and wrote an |
While I feel integrating a parser is the way to go, I have a couple concerns. Namely, type annotations are not obligatory, hence when parsing un-annotated expressions we'd have no way of telling their type signature, unless we performed some compilation steps. I feel that the effort required to implement this from scratch in Elisp is so huge that it could easily overwhelm everyone involved in this package. And not just because it's a time-consuming task on its own - but we have to keep in mind that it this parser will have to be then kept in sync with the upstream version of elm compiler. While changes are unlikely to occur there frequently, individual action would have to be taken to port each such change back to Elisp. In my opinion, it would be a good move to fork |
@mewa It might be worth noting that |
We don't need type annotations: if the source code doesn't declare it, then type annotations simply won't appear in completions, but the functions and types themselves would still be detected and available for completion/navigation etc.
I agree it's non-trivial, but I think it's not as hard as you're imagining. The main fiddly cases are multi-line type declarations with interspersed comments and data type constructors, and I feel that these are all quite manageable. I'd also note that we've relied on an upstream tool up to now, and suddenly (but perhaps not unexpectedly) have been left high and dry.
That sounds like massively more work IMO, even if it would be ideal for the community and all us tool-writers.
I'll be interested to see if this works out, but it feels a bit backwards that |
It looks like elmi-to-json might be helpful here... |
I've been stalled on this, but just pushed what I had already written to a branch: https://github.com/jcollard/elm-mode/compare/completion-0.19 The branch adds |
dunno if this is in anyway helpful, so please forgive my ignorance, but it looks like there is currently work on an elm language server, https://github.com/elm-tooling/elm-language-server, wondering if that could be helpful in getting closer to better Elm support in combination with https://github.com/emacs-lsp/lsp-mode? |
Yeah, if progress is made on that, then I imagine a good way forward would be to completely drop completion / navigation support from |
I see, and thanks for the quick response (and a nice emacs package 👍) |
Hi! Is the commit above 1.) something we can start using and 2.) something you'd like us to use to start getting feedback on your work? |
Just came back around to this issue, and wanted to say that the elm language server is now working pretty great, and there is a client included in lsp-mode now! Combined with this mode, elm dev in emacs is looking pretty good! |
Good to hear. Are you using it with |
Lsp-mode |
Thanks! |
Such great attention to detail from me there, LOL. But still worth asking, I guess. I test drove both |
lol no worries. Thanks for this package! Yeah, personally I never tried eglot because lsp-mode seemed to have a lot more community behind it, and its what works with dap-mode for languages that support it. Anything in particular you found frustrating in lsp-mode? |
There's a lot of weird opinionated set-up that gets run by default via magical non-standard methods, e.g. flycheck messages suddenly get shown on the right side of the window, and that stuff's really hard to override. I'd prefer if the basic package just integrated in a standard way with |
@Daniel-V1 is there anything you had to do other than what's on the lsp and elm language server sites to get lsp-mode and elm-language-server working? I tried going that route but had some problems https://emacs.stackexchange.com/questions/50832/configuring-lsp-mode-to-run-elm-language-server |
@flooose No, it works for me just like that. I took a look at the elm-ls::stderr buffer on mine though and it definitely is throwing some weird exceptions. The functionality still seems to work though, I've got completions/docs, etc. |
In the I also get eldoc errors and don't know who's causing them, or activating eldoc in my elm buffers, so I guess I have to debug a little more :) Are you using nvm or something like it? |
Oh, so you're getting an elm-analyse error about error parsing file on the first line of your elm file? This happened to me too, for me it was because elm-analyse freaks out about not having Module declaration at the top of the file (even though there generally aren't in the examples), and then everything else seems to die. Once I added |
That was it! It's not totally streamlined yet because some of the documentation popups cover up all of the source code sometimes, but I've got support for the stuff you mentioned above and I can work with it now. Thanks! I'm not sure if you're into collecting points on emacs.stackexchange, but if you want to post the answer, I'll give you the ✔️ for the solution. Otherwise I'll just answer it, in case other people have this problem. |
I've updated the README to recommend use of elm-language-server with Elm 0.19+. At a certain point we should probably just drop Elm 0.18 support (at least w.r.t. completion and eldoc) and delete all of the code relating to |
Closing this because we've just ripped out |
It seems that
elm-oracle
is unlikely to get updated satisfactorily for Elm 0.19, and it would make sense to work around this by taking matters into our own hands. The vscode Elm support has done exactly this.The completion system in
elm-mode
currently caches the results ofelm-oracle
queries for currently-imported libraries in memory. Dependency source code is stored in~/.elm
and dependencies are listed inelm.json
, so I envisage a system whereby docstrings and function signatures would be obtained directly from the source code via elisp parsing and cached in memory. If done correctly, this approach would also allow us to provide completions andxref
"jump-to-definition" navigation for identifiers defined in the user's source code, which was never supported byelm-oracle
.Unfortunately this all needs a good chunk of work. I'm likely starting a big Elm 0.19 project soon, which might prompt me to tackle this for my own sake.
The text was updated successfully, but these errors were encountered: