知名的 vim 代码检测插件主要是两个javascript
ALE 虽是后起之秀,但目前是功能最强大的一个java
mkdir -p ~/.vim/pack/git-plugins/start git clone https://github.com/w0rp/ale.git ~/.vim/pack/git-plugins/start/ale
mkdir -p ~/.local/share/nvim/site/pack/git-plugins/start git clone https://github.com/w0rp/ale.git ~/.local/share/nvim/site/pack/git-plugins/start/ale
## Run these commands in the "Git for Windows" Bash terminal mkdir -p ~/vimfiles/pack/git-plugins/start git clone https://github.com/w0rp/ale.git ~/vimfiles/pack/git-plugins/start/ale
把下面行加入到,vimrcpython
Plugin 'w0rp/ale'
ale 的 linter 都要本身安装
还好系统通常都是有 gcc, python, gofmt 之类的
须要额外安装的大约有git
安装方法以下:github
pip3 install vim-vint
安装方法以下:shell
gem install mdl
安装 gperf, 下载源码: 连接vim
./configure && make && make install
下载 iverilog 源码:markdown
git clone https://github.com/steveicarus/iverilog.git cd iverilog ./autoconf.sh ./configure && make && make isntall
"----------------------------------------------------------------------------- " plugin - ale.vim "----------------------------------------------------------------------------- "keep the sign gutter open let g:ale_sign_column_always = 1 let g:ale_sign_error = '>>' let g:ale_sign_warning = '--' " show errors or warnings in my statusline let g:airline#extensions#ale#enabled = 1 " self-define statusline "function! LinterStatus() abort " let l:counts = ale#statusline#Count(bufnr('')) " " let l:all_errors = l:counts.error + l:counts.style_error " let l:all_non_errors = l:counts.total - l:all_errors " " return l:counts.total == 0 ? 'OK' : printf( " \ '%dW %dE', " \ all_non_errors, " \ all_errors " \) "endfunction "set statusline=%{LinterStatus()} " echo message " %s is the error message itself " %linter% is the linter name " %severity is the severity type " let g:ale_echo_msg_error_str = 'E' " let g:ale_echo_msg_warning_str = 'W' " let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' " use quickfix list instead of the loclist let g:ale_set_loclist = 0 let g:ale_set_quickfix = 1 " only enable these linters "let g:ale_linters = { "\ 'javascript': ['eslint'] "\} nmap <silent> <C-k> <Plug>(ale_previous_wrap) nmap <silent> <C-J> <Plug>(ale_next_wrap) " run lint only on saving a file " let g:ale_lint_on_text_changed = 'never' " dont run lint on opening a file " let g:ale_lint_on_enter = 0 "------------------------END ale.vim--------------------------------------
可看到由于第69,70,71, 73行的几个模块定义没有提供,因此左边线上有红色的>>
把光标定位到73行, 在下面命令行会给出具体的错误:并发
Unknown module type: pmu
ALE能够让你一边编码一边实时检查代码的语法问题,同时还彻底不影响vim的性能。这能够极大提高你代码输写的正确性。异步