Using Spacemacs with Elm

I’ve recently switched to Spacemacs and am having a problem setting up autocompletion feature in it. I read through documentation for emacs elm-mode, and a few blog posts about it, but couldn’t figure it out.

If someone could show his/her working .spacemacs setup, I’d be really grateful.

Here’s some relevant settings I have:

dotspacemacs-configuration-layers
'(
;; ----------------------------------------------------------------
;; Example of useful layers you may want to use right away.
;; Uncomment some layer names and press (Vim style) or
;; (Emacs style) to install them.
;; ----------------------------------------------------------------
helm
(auto-completion :variables
auto-completion-enable-help-tooltip t
auto-completion-enable-snippets-in-popup t)
better-defaults
emacs-lisp
git
markdown
org
(shell :variables
shell-default-height 30
shell-default-position 'bottom)
spell-checking
(syntax-checking :variables
syntax-checking-enable-tooltips nil)
version-control
(elm :variables
elm-sort-imports-on-save t
elm-format-on-save t
)
javascript
elixir
html
haskell

(defun dotspacemacs/user-config ()
“Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration.
This is the place where most of your configurations should be done. Unless it is
explicitly specified that a variable should be set before a package is loaded,
you should place your code here.”
(with-eval-after-load 'company
(add-to-list 'company-backends 'company-elm))
)

Here’s a link to the full contents of my .spacemacs file.

Howdy there, don’t know if you’ve solved this yet, but for me all it took was installing elm-oracle through npm globally and I get autocompletion :thinking:.

Of note elm-mode seems to currently not support completion of local code, only code from installed packages. This github issue seems to outline the future of elm-mode’s possible fixes to this problem:

Yes, this is certainly related, and is indeed because elm-oracle only knows about symbols in installed packages. Approaches to address this could include:

 * Building a set of known exported bindings in all open Elm files
 * Performing searches on demand for referenced modules, and then identifying exported symbols
 * Waiting for upstream tool support that I believe Evan has been talking about building

Of these, the last one is the most likely to happen, unless someone steps up to try one of the other approaches.
1 Like

For some reason it started working when I rebooted my computer. And yeah, too bad that it has no automatic completion for local codes. Thank you for the reply!

Hi,

Try adding this to your auto-completion layer variables to get local codes completion:

     (auto-completion :variables
                      spacemacs-default-company-backends '(company-dabbrev-code
                                                           company-gtags
                                                           company-etags
                                                           company-keywords
                                                           company-files
                                                           company-dabbrev
                                                           company-elm)
)

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.