All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Masahiro H https://github.com/mshr-h
2 " Description: verilator for verilog files
4 " Set this option to change Verilator lint options
5 if !exists('g:ale_verilog_verilator_options')
6 let g:ale_verilog_verilator_options = ''
9 function! ale_linters#verilog#verilator#GetCommand(buffer) abort
10 " the path to the current file is systematically added to the search path
11 return 'verilator --lint-only -Wall -Wno-DECLFILENAME '
13 \ . ale#Var(a:buffer, 'verilog_verilator_options') .' '
17 function! ale_linters#verilog#verilator#Handle(buffer, lines) abort
18 " Look for lines like the following.
20 " %Error: addr_gen.v:3: syntax error, unexpected IDENTIFIER
21 " %Warning-WIDTH: addr_gen.v:26: Operator ASSIGNDLY expects 12 bits on the Assign RHS, but Assign RHS's CONST '20'h0' generates 20 bits.
22 " %Warning-UNUSED: test.v:3: Signal is not used: a
23 " %Warning-UNDRIVEN: test.v:3: Signal is not driven: clk
24 " %Warning-UNUSED: test.v:4: Signal is not used: dout
25 " %Warning-BLKSEQ: test.v:10: Blocking assignments (=) in sequential (flop or latch) block; suggest delayed assignments (<=).
26 " Since version 4.032 (04/2020) verilator linter messages also contain the column number,
28 " %Error: /tmp/test.sv:3:1: syntax error, unexpected endmodule, expecting ';'
30 " to stay compatible with old versions of the tool, the column number is
31 " optional in the researched pattern
32 let l:pattern = '^%\(Warning\|Error\)[^:]*:\s*\([^:]\+\):\(\d\+\):\(\d\+\)\?:\? \(.\+\)$'
35 for l:match in ale#util#GetMatches(a:lines, l:pattern)
37 \ 'lnum': str2nr(l:match[3]),
39 \ 'type': l:match[1] is# 'Error' ? 'E' : 'W',
40 \ 'filename': l:match[2],
44 let l:item.col = str2nr(l:match[4])
47 call add(l:output, l:item)
53 call ale#linter#Define('verilog', {
54 \ 'name': 'verilator',
55 \ 'output_stream': 'stderr',
56 \ 'executable': 'verilator',
57 \ 'command': function('ale_linters#verilog#verilator#GetCommand'),
58 \ 'callback': 'ale_linters#verilog#verilator#Handle',