知名的 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的性能。這能夠極大提高你代碼輸寫的正確性。異步