Using Ubuntu 12.
I installed jshint with
sudo npm install jshint -g
which jshint
shows /usr/local/bin/jshint, which is also in the PATH variable
Then, I downloaded https://github.com/walm/jshint.vim/blob/master/plugin/jshint.vim and put it in ~/.vim/bundle/jshint.vim (I am using Pathogen)
Now, when opening a js-File, such as
vim test.js
errors are not detected.
:JSHint
results in "Not an editor command: JSHint"
:Helptags
results in, well, nothing.. I don't really see what that command is for, anyway..
I am a vim noob, but other pathogen bundles seem to work, so I do not really know what is not working here..
The default way to install plugins is to put their individual pieces in some subdirectories of your ~/.vim/
directory. Taking this plugin as example:
~/.vim/plugin/jshint.vim
~/.vim/doc/jshint.txt
The :Helptags
command is used to generate the index (tags
) used by Vim to navigate through the documentation of third party plugins. You are supposed to use it like that:
:Helptags ~/.vim/doc
The idea behind Pathogen and other plugin managers is that each plugin should be in its own directory rather than be scattered through your ~/.vim/
directory. In Pathogen's case (and others followed, but there's no standard), that's the bundle directory: ~/.vim/bundle/
.
Therefore, the correct location for your plugin should be:
~/.vim/bundle/jshint/plugin/jshint.vim
~/.vim/bundle/jshint/doc/jshint.txt
~/.vim/bundle/jshint/README.md
~/.vim/bundle/jshint/LICENSE
In order for pathogen to work its magic, you are supposed to add these two lines to your ~/.vimrc
:
silent! call pathogen#infect()
silent! call pathogen#helptags()
The first line takes care of "registering" and loading each plugin found in ~/.vim/bundle/
. The second line indexes their documentation, the equivalent of :Helptags …
that you don't need to run, then.
So…
Make sure Pathogen is installed and configured correctly.
Install the JSHint plugin where it should be.
?
Enjoy writing JavaScript in Vim!
To run :JSHint
on the current buffer every time you write it, add this line to your ~/.vimrc
:
autocmd! BufWritePost *.js JSHint