From 1afe2992e29c40e445ce29394d8923eb85cec6e2 Mon Sep 17 00:00:00 2001 From: RedBug312 Date: Mon, 20 Nov 2017 06:59:17 +0800 Subject: [PATCH] Make options configurable for iverilog (#1143) --- ale_linters/verilog/iverilog.vim | 10 +++++++++- test/test_verilog_iverilog_options.vader | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 test/test_verilog_iverilog_options.vader diff --git a/ale_linters/verilog/iverilog.vim b/ale_linters/verilog/iverilog.vim index 18769d56..c64a3be6 100644 --- a/ale_linters/verilog/iverilog.vim +++ b/ale_linters/verilog/iverilog.vim @@ -1,6 +1,14 @@ " Author: Masahiro H https://github.com/mshr-h " Description: iverilog for verilog files +call ale#Set('verilog_iverilog_options', '') + +function! ale_linters#verilog#iverilog#GetCommand(buffer) abort + return 'iverilog -t null -Wall ' + \ . ale#Var(a:buffer, 'verilog_iverilog_options') + \ . ' %t' +endfunction + function! ale_linters#verilog#iverilog#Handle(buffer, lines) abort " Look for lines like the following. " @@ -30,6 +38,6 @@ call ale#linter#Define('verilog', { \ 'name': 'iverilog', \ 'output_stream': 'stderr', \ 'executable': 'iverilog', -\ 'command': 'iverilog -t null -Wall %t', +\ 'command_callback': 'ale_linters#verilog#iverilog#GetCommand', \ 'callback': 'ale_linters#verilog#iverilog#Handle', \}) diff --git a/test/test_verilog_iverilog_options.vader b/test/test_verilog_iverilog_options.vader new file mode 100644 index 00000000..1fbaea21 --- /dev/null +++ b/test/test_verilog_iverilog_options.vader @@ -0,0 +1,18 @@ +Before: + Save g:ale_verilog_iverilog_options + let g:ale_verilog_iverilog_options = '' + +After: + Restore + call ale#linter#Reset() + +Execute(Set Verilog iverilog linter additional options to `-y.`): + runtime! ale_linters/verilog/iverilog.vim + + " Additional args for the linter + let g:ale_verilog_iverilog_options = '-y.' + + call ale#Lint() + + let g:cmd = ale_linters#verilog#iverilog#GetCommand(bufnr('')) + AssertEqual g:cmd, 'iverilog -t null -Wall -y. %t'