重玩 vim 之琐碎记录——语法检测

浏览: 70 发布日期: 2016-11-12 分类: vim

适用于前端,所以我加上了 jshint 语法检测,根据其依赖,先来安装 nodejs 和 npm。

sudo apt-get install nodejs npm

sudo npm install jshint -g

安装完成后,打开 ~/.vimrc 把以下复制进去,然后 install 即可(不懂 vundle 的可以谷歌)。


#vundle install

" 状态栏,可以搭配 syntastic 插件
Plugin 'bling/vim-airline'
" 语法检测
Plugin 'scrooloose/syntastic'
" jshint
Plugin 'shutnik/jshint2.vim'

" syntastic
let g:syntastic_error_symbol = '✗'
let g:syntastic_warning_symbol = '⚠'
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_loc_list_height = 5
let g:syntastic_javascript_checkers = ['jshint']

function! ToggleErrors()
    let old_last_winnr = winnr('$')
    lclose
    if old_last_winnr == winnr('$')
        " Nothing was closed, open syntastic error location panel
        Errors
    endif
endfunction
nnoremap <Leader>s :call ToggleErrors()<cr>
nnoremap <Leader>sn :lnext<cr>
nnoremap <Leader>sp :lprevious<cr>
返回顶部