]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/verilog/slang.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / ale_linters / verilog / slang.vim
1 " Author: Alvin Rolling <alvinrolling@gmail.com>
2 " Description: slang for verilog files
3
4 " Set this option to change Slang lint options
5 if !exists('g:ale_verilog_slang_options')
6     let g:ale_verilog_slang_options = ''
7 endif
8
9 " --lint-only
10 function! ale_linters#verilog#slang#GetCommand(buffer) abort
11     return 'slang -Weverything '
12     \   . '-I%s:h '
13     \   . ale#Var(a:buffer, 'verilog_slang_options') .' '
14     \   . '%t'
15 endfunction
16
17 function! s:RemoveUnicodeQuotes(text) abort
18     let l:text = a:text
19     let l:text = substitute(l:text, '[`´‘’]', '''', 'g')
20     let l:text = substitute(l:text, '[“”]', '"', 'g')
21
22     return l:text
23 endfunction
24
25 function! ale_linters#verilog#slang#Handle(buffer, lines) abort
26     let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+)?:?(\d+)?:? ([^:]+): (.+)$'
27     let l:output = []
28
29     for l:match in ale#util#GetMatches(a:lines, l:pattern)
30         let l:item = {
31         \   'lnum': str2nr(l:match[2]),
32         \   'type': (l:match[4] is# 'error') ? 'E' : 'W',
33         \   'text': s:RemoveUnicodeQuotes(l:match[5]),
34         \}
35
36         if !empty(l:match[3])
37             let l:item.col = str2nr(l:match[3])
38         endif
39
40         call add(l:output, l:item)
41     endfor
42
43     return l:output
44 endfunction
45
46 call ale#linter#Define('verilog', {
47 \   'name': 'slang',
48 \   'output_stream': 'stderr',
49 \   'executable': 'slang',
50 \   'command': function('ale_linters#verilog#slang#GetCommand'),
51 \   'callback': 'ale_linters#verilog#slang#Handle',
52 \   'read_buffer': 0,
53 \})