Digressions of a research engineer

Emacs Setup for Javascript WRT Company and Flycheck

I kew for a while, that http://ternjs.net was the way to go for editing javascript file, as it provides autocompletion on variables and properties, function argument hints, querying the type of an expression, finding the definition of something, automatic refactoring.

The completion of course, comes from emacs comany package, but I also wanted to have a checker, emacs flycheck working when editing javascript files.

Here is how to get them both working easily, even though I must admit it requires third party npm packages, everything is not as well integrated directly into one’s emacs configuration such as irony.

Let’s start with completion. It is necessary to install the tern utiliy, globally for instance as show in the following command.

$ npm install -g tern tern-lint

Let’s configure our emacs setup completion layers.

First step is to require company-tern, and to add it to the list of company-backends. Finally, we add a hook on js2-mode to trigger company-mode.