简体   繁体   English

JSHint在vim中不起作用

[英]JSHint doesn't work in vim

On invoking :SyntasticInfo : 调用时:SyntasticInfo

Syntastic version: 3.8.0-94 (Vim 800, Linux, GUI) 同步版本:3.8.0-94(Vim 800,Linux,GUI)
Info for filetype: javascript 文件类型信息:javascript
Global mode: active 全局模式:激活
Filetype javascript is active 文件类型javascript处于活动状态
The current file will be checked automatically 当前文件将被自动检查
Available checker: jshint 可用的检查器:jshint
Currently enabled checker: jshint 当前启用的检查器:jshint

I've installed both JSHint and Syntastic via vim-pathogen. 我已经通过vim-pathogen安装了JSHint和Syntastic。

What is one supposed to configure in order to make the syntax checking work? 为了使语法检查有效,应该配置什么?

In Syntastic's documentation on JSHint , nothing special is mentioned about configuration, other than Syntastic的有关JSHint的文档中,除配置外没有提及任何特殊之处,除了

This checker is initialised using the "makeprgBuild()" function and thus it accepts the standard options described at |syntastic-config-makeprg|. 该检查器使用“ makeprgBuild()”函数初始化,因此它接受| syntastic-config-makeprg |中描述的标准选项。

On a side note, syntax checking does work for TypeScript, using Syntastic. 附带一提,语法检查确实适用于使用Syntastic的TypeScript。

.vimrc: .vimrc中:

syntax on
colorscheme industry

execute pathogen#infect()
filetype plugin on

set textwidth=0
set softtabstop=4
let &shiftwidth=&softtabstop
set autoindent
set number

" Used for using buffers and tabs the right way.
set hidden

" Enable airline
let g:airline#extensions#tabline#enabled = 1

" Use powerline fonts
let g:airline_powerline_fonts = 1

"Open NERDTree on startup
"autocmd vimenter * NERDTree

map <C-n> :NERDTreeToggle<CR>

:let mapleader = "/"

" Mappings to access buffers (don't use "\p" because a
" delay before pressing "p" would accidentally paste).
" \l       : list buffers
" \b \f \g : go back/forward/last-used
" \1 \2 \3 : go to buffer 1/2/3 etc
nnoremap <Leader>l :ls<CR>
nnoremap <Leader>b :bp<CR>
nnoremap <Leader>f :bn<CR>
nnoremap <Leader>g :e#<CR>
nnoremap <Leader>1 :1b<CR>
nnoremap <Leader>2 :2b<CR>
nnoremap <Leader>3 :3b<CR>
nnoremap <Leader>4 :4b<CR>
nnoremap <Leader>5 :5b<CR>
nnoremap <Leader>6 :6b<CR>
nnoremap <Leader>7 :7b<CR>
nnoremap <Leader>8 :8b<CR>
nnoremap <Leader>9 :9b<CR>
nnoremap <Leader>0 :10b<CR>
" It's useful to show the buffer number in the status line.
"set laststatus=2 statusline=%02n:%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P

" Enable color highlighting by Powerline in vim.
set t_Co=256

" Display buffer number in Airline
 let g:airline#extensions#tabline#buffer_nr_show = 1

" Enable tab support in Airline
let g:airline#extensions#tabline#enabled = 1

autocmd BufNewFile,BufRead *.ts setlocal filetype=typescript

" Close a buffer without closing its window
map <Leader>q :bp<bar>sp<bar>bn<bar>bd<CR>

" Split a window without resizing the others
set noequalalways

" Don't autoindent when editing text files --- no suffix filenames.
set noautoindent
augroup vimrc_indent
    au!
    autocmd FileType * set autoindent
augroup END

"Toggle scrolling by display lines instead of file lines.
noremap <silent> <Leader>w :call ToggleWrap()<CR>
function ToggleWrap()
  if &wrap
    echo "Wrap OFF"
    setlocal nowrap
    set virtualedit=all
    silent! nunmap <buffer> <Up>
    silent! nunmap <buffer> <Down>
    silent! nunmap <buffer> <Home>
    silent! nunmap <buffer> <End>
    silent! iunmap <buffer> <Up>
    silent! iunmap <buffer> <Down>
    silent! iunmap <buffer> <Home>
    silent! iunmap <buffer> <End>
  else
    echo "Wrap ON"
    setlocal wrap linebreak nolist
    set virtualedit=
    setlocal display+=lastline
    noremap  <buffer> <silent> <Up>   gk
    noremap  <buffer> <silent> <Down> gj
    noremap  <buffer> <silent> <Home> g<Home>
    noremap  <buffer> <silent> <End>  g<End>
    inoremap <buffer> <silent> <Up>   <C-o>gk
    inoremap <buffer> <silent> <Down> <C-o>gj
    inoremap <buffer> <silent> <Home> <C-o>g<Home>
    inoremap <buffer> <silent> <End>  <C-o>g<End>
    noremap  <buffer> <silent> k gk
    noremap  <buffer> <silent> j gj
    noremap  <buffer> <silent> 0 g0
    noremap  <buffer> <silent> $ g$
  endif
endfunction

"Disable folding
set foldenable

"JS syntax checking
let g:syntastic_javascript_checkers = ['jshint']

You don't have any configuration for Syntastic telling it to run. 您没有Syntastic告诉它运行的任何配置。 You might start with the recommended settings as listed when you run :help syntastic-recommended : 您可以从运行时列出的推荐设置开始:help syntastic-recommended

set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0

You can also manually invoke Syntastic with :SyntasticCheck 您也可以使用:SyntasticCheck手动调用:SyntasticCheck

If it is on-the-fly linting that you desire, as recommended in one of the comments, then you should switch from Syntastic to ALE (I recommend ALE in general) 如果您希望即时更新,如评论之一所建议,那么您应该从Syntastic切换到ALE (我一般建议使用ALE)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM