]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/ada/gcc.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 / ada / gcc.vim
1 " Author: Martino Pilia <martino.pilia@gmail.com>
2 " Description: Lint Ada files with GCC
3
4 call ale#Set('ada_gcc_executable', 'gcc')
5
6 " -gnatwa: activate most optional warnings
7 " -gnatq: try semantic analysis even if syntax errors have been found
8 call ale#Set('ada_gcc_options', '-gnatwa -gnatq')
9
10 function! ale_linters#ada#gcc#GetCommand(buffer) abort
11     " Build a suitable output file name. The output file is specified because
12     " the .ali file may be created even if no code generation is attempted.
13     " The output file name must match the source file name (except for the
14     " extension), so here we cannot use the null file as output.
15     let l:tmp_dir = fnamemodify(ale#command#CreateDirectory(a:buffer), ':p')
16     let l:out_file = l:tmp_dir . fnamemodify(bufname(a:buffer), ':t:r') . '.o'
17
18     " -gnatc: Check syntax and semantics only (no code generation attempted)
19     return '%e -x ada -c -gnatc'
20     \   . ' -o ' . ale#Escape(l:out_file)
21     \   . ' -I %s:h'
22     \   . ale#Pad(ale#Var(a:buffer, 'ada_gcc_options'))
23     \   . ' %t'
24 endfunction
25
26 " For the message format please refer to:
27 "   https://gcc.gnu.org/onlinedocs/gnat_ugn/Output-and-Error-Message-Control.html
28 "   https://gcc.gnu.org/onlinedocs/gnat_ugn/Warning-Message-Control.html
29 function! ale_linters#ada#gcc#Handle(buffer, lines) abort
30     " Error format: <filename>:<lnum>:<col>: <text>
31     " Warning format: <filename>:<lnum>:<col>: warning: <text>
32     let l:re = '\v(.+):([0-9]+):([0-9]+):\s+(warning:)?\s*(.+)\s*'
33     let l:output = []
34
35     for l:match in ale#util#GetMatches(a:lines, l:re)
36         call add(l:output, {
37         \   'bufnr': a:buffer,
38         \   'lnum': str2nr(l:match[2]),
39         \   'col': str2nr(l:match[3]),
40         \   'type': l:match[4] is# 'warning:' ? 'W' : 'E',
41         \   'text': l:match[5],
42         \})
43     endfor
44
45     return l:output
46 endfunction
47
48 call ale#linter#Define('ada', {
49 \   'name': 'gcc',
50 \   'output_stream': 'stderr',
51 \   'executable': {b -> ale#Var(b, 'ada_gcc_executable')},
52 \   'command': function('ale_linters#ada#gcc#GetCommand'),
53 \   'callback': 'ale_linters#ada#gcc#Handle',
54 \})