From e670c9781c1bdaf423541bc4249c1d92d9d3cd5b Mon Sep 17 00:00:00 2001 From: Tarik Graba Date: Sun, 20 Jul 2025 12:27:25 +0200 Subject: [PATCH] Slang verilog Linter: set default searchpath and output filename (#4999) * Sets module search path to file directory for slang/verilog linter Similar to iverilog behaviour. See 699c0dbe80e4395370a4d2dc9816a4d18d85371f Reasonable default behaviour, can be changed by adding '-y%s:h' to `b:ale_verilog_slang_options` buffer variable. * Adds filename to slang/verilog linter output slang can parse other files based on the modules instances names find in the current file and returns warning/error messages related to those files that have the same pattern. Adding the file name to the outputs avoid polluting the active buffer with those messages. * Absolute paths in slang/verilog linter messages Otherwise temp files are not correctly detected --- ale_linters/verilog/slang.vim | 3 +++ test/handler/test_slang_handler.vader | 4 +++- test/linter/test_slang.vader | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ale_linters/verilog/slang.vim b/ale_linters/verilog/slang.vim index 40299a34..9681c7fc 100644 --- a/ale_linters/verilog/slang.vim +++ b/ale_linters/verilog/slang.vim @@ -9,7 +9,9 @@ endif " --lint-only function! ale_linters#verilog#slang#GetCommand(buffer) abort return 'slang -Weverything ' + \ . '--diag-abs-paths ' \ . '-I%s:h ' + \ . '-y%s:h ' \ . ale#Var(a:buffer, 'verilog_slang_options') .' ' \ . '%t' endfunction @@ -28,6 +30,7 @@ function! ale_linters#verilog#slang#Handle(buffer, lines) abort for l:match in ale#util#GetMatches(a:lines, l:pattern) let l:item = { + \ 'filename': l:match[1], \ 'lnum': str2nr(l:match[2]), \ 'type': (l:match[4] is# 'error') ? 'E' : 'W', \ 'text': s:RemoveUnicodeQuotes(l:match[5]), diff --git a/test/handler/test_slang_handler.vader b/test/handler/test_slang_handler.vader index 529eb718..25d2e6c4 100644 --- a/test/handler/test_slang_handler.vader +++ b/test/handler/test_slang_handler.vader @@ -8,12 +8,14 @@ Execute(The slang handler should parse lines correctly): AssertEqual \ [ \ { + \ 'filename' : 'foo.sv', \ 'lnum': 11, \ 'col': 1, \ 'type': 'W', \ 'text': 'extra '';'' has no effect [-Wempty-member]', \ }, \ { + \ 'filename' : 'bar.sv', \ 'lnum': 24, \ 'col': 12, \ 'type': 'E', @@ -22,5 +24,5 @@ Execute(The slang handler should parse lines correctly): \ ], \ ale_linters#verilog#slang#Handle(bufnr(''), [ \ 'foo.sv:11:1: warning: extra '';'' has no effect [-Wempty-member]', - \ 'foo.sv:24:12: error: cannot mix continuous and procedural assignments to variable ''data_o''', + \ 'bar.sv:24:12: error: cannot mix continuous and procedural assignments to variable ''data_o''', \ ]) diff --git a/test/linter/test_slang.vader b/test/linter/test_slang.vader index deeb0663..75103639 100644 --- a/test/linter/test_slang.vader +++ b/test/linter/test_slang.vader @@ -5,10 +5,10 @@ After: call ale#assert#TearDownLinterTest() Execute(The default slang command should be correct): - AssertLinter 'slang', 'slang -Weverything -I%s:h %t' + AssertLinter 'slang', 'slang -Weverything --diag-abs-paths -I%s:h -y%s:h %t' Execute(slang options should be configurable): " Additional args for the linter let g:ale_verilog_slang_options = '--define-macro DWIDTH=12' - AssertLinter 'slang', 'slang -Weverything -I%s:h --define-macro DWIDTH=12 %t' + AssertLinter 'slang', 'slang -Weverything --diag-abs-paths -I%s:h -y%s:h --define-macro DWIDTH=12 %t'