vim插件: syntastic[语法检查]

k-vim配置 github


作用: 语法检查, 支持大部分的语言

github: syntastic

安装

Bundle 'scrooloose/syntastic'

使用

被动技能, 设置打开时开启, 则打开对应文件的时候, 会自动进行语法检查, 高亮错误位置

注意, 针对某些具体语言, 指定了checker, 需要对应安装外部依赖, 例如pyflakes/pep8/jshint等等

主动技能, k-vim中配置绑定了<leader>s打开错误列表面板

syntastic.png

默认

:Errors 显示错误面板
:lnext  到下一个错误
:lprevious 到上一个错误

最终配置

Bundle 'scrooloose/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_enable_highlighting=1
let g:syntastic_python_checkers=['pyflakes'] " 使用pyflakes,速度比pylint快
let g:syntastic_javascript_checkers = ['jsl', 'jshint']
let g:syntastic_html_checkers=['tidy', 'jshint']
" 修改高亮的背景色, 适应主题
highlight SyntasticErrorSign guifg=white guibg=black

" to see error location list
let g:syntastic_always_populate_loc_list = 0
let g:syntastic_auto_loc_list = 0
let g:syntastic_loc_list_height = 5
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>

建议

  1. 支持语言的列表, 见 这里

vim

324 Words

2015-06-07 10:08 +0000