A vim compiler plugin to run nodelint.
-
Install nodejs
-
Install npm
-
Install nodelint:
sudo npm install -g [email protected]
-
Put the nodelint.vim plugin from the compiler folder into your .vim/compiler folder (create it if it does not exist)
-
Add the following to .vim/after/ftplugin/javascript:
compiler nodelint
After you open a .js file, and save it, it will run nodelint on the file and report errors in the location window. It will jump to the location of the first error.
NB: The environment variable $NODE_PATH
must be set to the location(s) of your node modules. NPM does this automatically on the Mac,
but does not do it on Linux, apparently. You can discover this by a command like 'locate nodelint'.
It will be something like '/usr/local/lib/node_modules'. Set this in your .bashrc like so:
export NODE_PATH=/usr/local/lib/node_nodules
The plugin will search for a file called 'nodelint-config.js' in the directories above the current file, and use the first one it finds.
Otherwise it will use the default config file for nodelint -- see the nodelint-config.js included as an example. (The given example is configured for use in a browser environment, not Node.js, which is the default).
If you set the g:NodelintConfig option, it will override any others and apply globally. eg.
let g:NodelintConfig = $HOME . '/nodelint-config.js'
If you wish to not have the plugin auto-jump to errors, or open the window, set the following in your .vimrc:
let g:NodelintPassive = 1
Then you can open the location window with :lope (and close with :lcl)