vim - ¿Cómo configurar Syntastic con JSHint?
(3)
Aquí hay una información más actualizada, hay una configuración para asociar una extensión de archivo a un comprobador,
en tu .vimrc
let g:syntastic_javascript_checkers = [''jshint'']
También para obtener información sobre lo que está pasando ejecuta este comando en vim
:SyntasticInfo
Y obtendrás un resultado similar a esto:
Syntastic info for filetype: javascript
Available checkers: gjslint jshint
Currently active checker(s): gjslint
Press ENTER or type command to continue
¿Cómo usar el complemento Syntastic Vim con JSHint para validar el código JavaScript?
Ambiente:
- Ubuntu 11.04
- VIM - Vi IMproved 7.3
Lo que tengo instalado, siguiendo la solución en VIM + JSLint? :
- Vundle
- node.js
- Administrador de paquetes de nodo
- jshint, globalmente
- Syntastic instalado a través de Vundle (usó el comando: BundleInstall dentro de Vim para asegurarse de que Syntastic estaba instalado).
.vimrc:
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle ''gmarik/vundle''
" My Bundles here:
Bundle ''scrooloose/syntastic''
filetype plugin indent on " required!
let g:syntastic_enable_signs=1
let g:syntastic_auto_jump=1
let g:syntastic_stl_format = ''[%E{Err: %fe #%e}%B{, }%W{Warn: %fw #%w}]''
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
buscando ejecutables instalados:
$ which gjslint
$ which jslint
$ which jsl
$ which jshint
/home/fernando/local/node/bin/jshint
$
$ echo $PATH
>/home/fernando/local/bin:/home/fernando/local/node/bin:/home/fernando/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
$ jshint test.js
test.js: línea 3, col 1, ''blbla'' no está definido.
test.js: línea 4, col 1, ''x'' no está definido.
test.js: línea 4, col 5, ''nonono'' no está definido.
test.js: línea 6, col 1, ''a'' no está definido.
test.js: línea 7, col 1, ''b'' no está definido.
test.js: línea 8, col 5, ''a'' no está definido.
test.js: línea 8, col 10, ''b'' no está definido.
test.js: línea 8, col 7, se esperaba ''==='' y en su lugar se veía ''==''.8 errores
$ vi test.js -- no error message shown
:SyntasticEnable -- Vim exits and restarts, opening the same file, but still no message
:w -- still no error message
:Errors -- the location list opens but it is empty
Parece que tanto jshint como Syntastic están instalados, pero probablemente falte algo. ¿Qué podría ser?
Solo tuve el mismo problema. Resulta que Syntastic busca jsl (JSLint) antes de buscar jshint. Si los tiene instalados, es probable que los engañen. Moví jsl a algún lugar no en mi PATH, y jshint fue detectado muy bien.
SyntasticInfo con este problema por días y SyntasticInfo no reconoció jshint como un comprobador disponible incluso después de que agregué let g:syntastic_javascript_checkers[''jshint''] a mi .vimrc . Estoy usando Ubuntu 15.04 y seguí this tutorial para instalar nvm, nodejs y jshint en Ubuntu. Después de hacerlo, descubrí que si eliminaba la filetype plugin indent on de filetype plugin indent on línea desde mi .vimrc luego abría un archivo .js todo funcionaba perfectamente. Para resumir...
- sigue el tutorial vinculado anteriormente
- agregue
~/.nvm/<version_number>/bina la ruta en.bashrc - eliminar la
filetype plugin indent ondesde.vimrc - agregue
let g:syntastic_javascript_checkers[''jshint'']a.vimrc -
:so %dentro de vim - abra un archivo
.js - agrega la
filetype plugin indent ona tu.vimrc - todo funciona mágicamente ahora