vim + syntastic + verilator or iverilog

若文章有錯誤請留言指證
須要轉載請通知筆者html

Introduction

syntastic讓你能夠在vim裡能夠使用lint功能,讓你在寫code時檢查看看有沒有語法上的錯誤或者可能潛在的錯誤git


Install

linter

首先要先安裝linter有兩種選擇: Icarus Verilog或是verilator,看你偏好哪一種
我是經由homebrew安裝:github

$brew install verilator
$brew install iverilog

syntastic

syntastic我是使用vundle安裝,你也能夠透過其餘package manager安裝.請參考官方文件vim

透過vundle安裝(這裡我是透過vundle安裝syntastic,若是不會使用vundle,請參考Vundle官方)bash

Plugin 'scrooloose/syntastic'

vimrc加上如下幾行, 如下是參考syntastic官方的設定wordpress

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

設置lintor:verilatoriverilog我都設定了,兩個都有則會一塊兒檢查,如果第一個掛了它會自動找第二個,若是你只想使用其中一種,留著你要的那一個便可post

let g:syntastic_verilog_checkers = ['verilator','iverilog']

Use

完成之後能夠用:SyntasticInfo查看是否有配置完成
這裏寫圖片描述spa

接下來就能夠使用:SyntasticCheck開啟語法檢查功能啦
syntastic好像也有提供在:w時提供檢查的功能.net


Some problem

syntastic會根據filetype去開啟不一樣語言的linter
能夠用:set filetype?看看是否是verilog插件

有些人會使用verilog_systemverilog的套件來讓verilog產生語法高亮,filetype則會是verilog_systemverilog,此時syntastic則不會支持

目前個人解法是在verilog_systemverilog套件裡判斷副檔名的地方更改.
本來是長這樣:

au! BufNewFile,BufRead *.v,*.vh,*.vp,*.sv,*.svi,*.svh,*.svp setfiletype verilog_systemverilog

為了同時使用syntastic verilog_systemverilog的語法高亮,個人作法是將.v檔案當成普通的verilog並讓syntastic只支持.v,我將上面改爲:

au! BufNewFile,BufRead *.vh,*.vp,*.sv,*.svi,*.svh,*.svp setfiletype verilog_systemverilog

au! BufNewFile,BufRead *.v setfiletype verilog_systemverilog.verilog

也就是讓.v檔案同時有兩種filetype, .v檔案以外都當成verilog_systemverilog.


Summary

簡單來說你能夠用一樣的方法去設定其餘語言的linter
能夠分紅如下step:

1. 安裝語言相對應的linter
2. 安裝syntastic(若是本來就有能夠跳此步驟)
3. 查看syntastic官方文件,看syntastic有沒有支持你的linter
4. 根據syntastic官方文件去設定你的linter

step3syntastic所支持的linter列表


Reference

  1. [VIM插件: SYNTASTIC[語法檢查]](http://www.wklken.me/posts/20...

  2. [[資工雜筆] 建置 vim + syntastic + eslint + gcclint](https://noootown.wordpress.co...

相關文章
相關標籤/搜索