Files
ale/ale_linters/verilog/slang.vim
T
Tarik Graba e670c9781c 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 699c0dbe80

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
2025-07-20 11:27:25 +01:00

57 lines
1.5 KiB
VimL

" Author: Alvin Rolling <alvinrolling@gmail.com>
" Description: slang for verilog files
" Set this option to change Slang lint options
if !exists('g:ale_verilog_slang_options')
let g:ale_verilog_slang_options = ''
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
function! s:RemoveUnicodeQuotes(text) abort
let l:text = a:text
let l:text = substitute(l:text, '[`´‘’]', '''', 'g')
let l:text = substitute(l:text, '[“”]', '"', 'g')
return l:text
endfunction
function! ale_linters#verilog#slang#Handle(buffer, lines) abort
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+)?:?(\d+)?:? ([^:]+): (.+)$'
let l:output = []
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]),
\}
if !empty(l:match[3])
let l:item.col = str2nr(l:match[3])
endif
call add(l:output, l:item)
endfor
return l:output
endfunction
call ale#linter#Define('verilog', {
\ 'name': 'slang',
\ 'output_stream': 'stderr',
\ 'executable': 'slang',
\ 'command': function('ale_linters#verilog#slang#GetCommand'),
\ 'callback': 'ale_linters#verilog#slang#Handle',
\ 'read_buffer': 0,
\})