Syntastic doesn't detect JSHint as an available checker - vim

I have installed Syntastic with Pathogen.
Syntastic works for Python files but not for JavaScript files with JSHint.
JSHint works via command line or with other vim plugin like https://github.com/Shutnik/jshint2.vim
→ which jshint
/usr/local/share/npm/bin/jshint
→ jshint --version
jshint v2.1.10
→ echo $PATH
/usr/local/share/npm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
When I run :SyntasticInfo, it doesn't find any checkers.
Syntastic info for filetype: javascript
Available checkers:
Currently active checker(s):
My vimrc
set nocompatible
filetype off
call pathogen#infect()
call pathogen#helptags()
filetype plugin indent on
syntax on
let g:syntastic_check_on_open=1
let g:syntastic_javascript_checkers = ['jshint']
I don't know what I've missed, if you have any idea why Syntastic doesn't detect JSHint. Thanks

Long story short; Syntastic needs the path of jshint.
I encountered a similar problem on Windows 8. After installing nodejs v0.10.22 and syntastic >= 3.2.0, the Vim command :SyntasticInfo would give me:
Syntastic: active mode enabled
Syntastic info for filetype: vim
Available checker(s):
Currently enabled checker(s):
The documentation over at jshint.com/docs suggests that this is sufficient to install the module.
$ npm install jshint -g
This is true, apart from a somewhat surprising meaning of flag -g installs JSHint globally on your system. It means in your user's %AppData% folder:
(abbreviated output from previous command)
C:\Users\jaroslav\AppData\Roaming\npm\jshint -> \
C:\Users\jaroslav\AppData\Roaming\npm\node_modules\jshint\bin\jshint
jshint#2.3.0 C:\Users\jaroslav\AppData\Roaming\npm\node_modules\jshint
├── console-browserify#0.1.6
├── underscore#1.4.4
├── shelljs#0.1.4
├── minimatch#0.2.12 (sigmund#1.0.0, lru-cache#2.5.0)
└── cli#0.4.5 (glob#3.2.7)
Another piece of documentation from the syntastic FAQ reads:
Q. I installed syntastic but it isn't reporting any errors...
A. The most likely reason is that none of the syntax checkers that it requires is installed. For example: python requires either flake8, pyflakes or pylint to be installed and in $PATH. To see which executables are supported, just look in syntax_checkers//*.vim. Note that aliases do not work; the actual executable must be available in your $PATH. Symbolic links are okay. You can see syntastic's idea of available checkers by running :SyntasticInfo.
The solution amounts to setting the path of the jshint command in ~/.vimrc:
let g:syntastic_jshint_exec='C:\Users\jaroslav\AppData\Roaming\npm\jshint.cmd'
:source $HOME/_vimrc
:SyntasticInfo
Syntastic: active mode enabled
Syntastic info for filetype: javascript
Available checker(s): jshint
Currently enabled checker(s): jshint
Alternatively, one could:
> cmd.exe
> cd C:\Users\jaroslav\AppData\Roaming\npm
> setx PATH "%cd%:%PATH%"
and let g:syntastic_jshint_exec='jshint.cmd'. I didn't try the last solution with %PATH% because Winders doesn't like long %PATH% variables.
Hopefully this saves you some time.

Related

How standalone installation of vim plugin can be done in Unix

At my work I want to use vim plugins but I cannot install plugins via git hub command which are mentioned in forums. I need to install plugins manually by copying required files but it does not work. Can someone let me know how to install vim plugins manually in Linux environment .
Here are the steps i have done:
Downloaded github.com/VundleVim/Vundle.vim
Created ~/.vim/bundle, ~/.vim/plugin directories
Copied vundle.vim into ~/.vim/bundle/vundle.vim
I have copied below message in .vimrc file
set rtp+=~/.vim/bundle/vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'file:/nfs/iind/home/bvedula/.vim/plugin'
call vundle#end() " required
filetype plugin indent on " required
When i run vim in my xterm i get following error:
Error detected while processing ~/.vimrc,
E117: Unknown function: vundle#begin,
E492: Not an editor command: Plugin 'VundleVim/Vundle.vim',
E492: Not an editor command: Plugin 'file:~/.vim/plugin
The error says, that vundle#begin is unknown, means that Vundle.vim was not even loaded. Looks like you have vundle.vim instead of Vundle.vim (with uppercase first letter) in the set rtp+=~/.vim/bundle/vundle.vim.
But anyway Vundle is not a good choice if you don't have access to the Internet.
Instead you can use pathogen which doesn't try to download plugins and only loads them:
any plugins you wish to install can be extracted to a subdirectory
under ~/.vim/bundle, and they will be added to the 'runtimepath'

VIM Unable to install plugins

I have some plugins already installed in VIM. They are working find. Recently I was trying to install Flake8 in my VIM through Vundle. When I type :BundleInstall andviro/flake8 it downloads well and installs the plugin. In addition I am able to see it by :BundleList. But when I restart the VIM it is not there. I tried to install other plugins also but when I restart the VIM lastly installed plugins are removed.
add the plugin to your .vimrc.
As it says vundle github page you want something like:
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Bundle 'gmarik/Vundle.vim'
Bundle 'andviro/flake8-vim'
call vundle#end()
typing just :BundleInstall will grab all of your addons listed in your .vimrc and make sure they're installed and updated.

vimrc test for if_lua during vundle BundleInstall

I use the same .vimrc file on lots of systems. I'd like to bypass vundle installing some modules that I know won't work if 'if_lua' is not present.
Is there a vim script way of conditionally doing
Bundle 'Shougo/neocomplete.vim'
only if vim was compiled with lua to avoid the start up error:
$ vim myprogram.c
neocomplete does not work this version of Vim.
It requires Vim 7.3.885 or above and "if_lua" enabled Vim.
Press ENTER or type command to continue
thx
if has('lua')
Bundle 'Shougo/neocomplete.vim'
end

Can't search plugin in local but on the net when install Plugin with Vundle (configure Vim)

I have successfully installed the Vundle for vim
With the help-docs, i know that using command "PluginInstall **" can install this plugin
i have already download some plugins, but when i type :PluginInstall **
to install ** , it's not install ** from local but again search on the net.
So, how can i specify the path should this command ":PluginInstall" install plugin from where i want.
=======================for example:
:PluginSearch taglist
it shows
Plugin 'taglist-plus'
Plugin 'taglist.vim'
my local file is taglist_46 which download from www.vim.org/script.php?script_id=273‎
but it doesn't show up in result
First, you should add the follow settings in your vimrc:
Bundle 'taglist.vim'
And then, run :BundleInstall, Vundle will download the plugin automatically. (automatic is the important reason to using it)
By the way, Vundle using git download the plugin, it should be installed.
If you don't have git (In windows for example), you can download by manually of cause. Just move the taglist folder to the right path. It was set by rpt+=<the right path>. For example, my setting is:
if has('win32') || has('win64')
set rtp+=$VIM/bundle/vundle
call vundle#rc('$VIM/bundle')
else
set rtp+=~/.vim/bundle/vundle
call vundle#rc()
endif
Means the right path in Windows should be $VIM/bundle/vundle, and ~/.vim/bundle/vundle in Linux

Syntastic and jshint not displaying errors in vim

I can't get Syntastic to work for JavaScript files in MacVim. If I save a file with errors in it, nothing is displayed: there is no error margin.
If I run :SyntasticInfo, then I see:
Syntastic info for filetype: javascript
Available checkers: jshint
Currently active checker(s): jshint
If I run jshint directly, using :!jshint %, then I see the errors I expect.
I had a custom syntastic_javascript_jshint_conf setting:
let g:syntastic_javascript_jshint_conf="~/.jshintrc"
...and the ~/.jshintrc file was missing. Recreating it fixed the problem, and now I get the error margin.
Updated to add: I've added a feature to my .vimrc, so that it tracks the "nearest" .jshintrc file: https://github.com/rlipscombe/vimrc/blob/master/vimrc#L176

Resources