How to setup JavaScript auto-complete in Spacemacs on Windows

Install NodeJS

Install NodeJS.

Install Tern

Open a command prompt and run:

npm install -g tern

Note the path where Tern is installed:

shows tern install path

Update your .spacemacs

Add the tern-command line below to the .spacemacs file in your home directory (but modify the path to be where Tern was installed on your system):

(defun dotspacemacs/user-config ()
  "Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration. You are free to put any user code."

  (setq tern-command '("node" "C:/Users/Jason/AppData/Roaming/npm/node_modules/tern/bin/tern"))

  )

Open a sample JavaScript file

Let's open a file containing the JavaScript found in this tutorial and start typing:

shows tern autocomplete in Spacemacs

It's working great, but it doesn't auto-complete symbols from different files.

How can I get this to work across files?

We need to create a JSON configuration file for Tern. We can do this by creating a .tern-project file in our project's directory. See the next article below.

Next: How to setup Spacemacs for JavaScript auto-complete and go-to-definition across files

Comments

Leave a comment

What color are green eyes? (spam prevention)
Submit
Code under MIT License unless otherwise indicated.
© 2020, Downranked, LLC.