]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/fortran/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:

Do not set EDITOR/VISUAL for shell
[etc/vim.git] / .vim / bundle / ale / ale_linters / fortran / gcc.vim
1 " Author: w0rp <devw0rp@gmail.com>
2 " Description: gcc for Fortran files
3
4 " This option can be set to 0 to use -ffixed-form
5 call ale#Set('fortran_gcc_use_free_form', 1)
6 call ale#Set('fortran_gcc_executable', 'gcc')
7 " Set this option to change the GCC options for warnings for Fortran.
8 call ale#Set('fortran_gcc_options', '-Wall')
9
10 function! ale_linters#fortran#gcc#Handle(buffer, lines) abort
11     " We have to match a starting line and a later ending line together,
12     " like so.
13     "
14     " :21.34:
15     " Error: Expected comma in I/O list at (1)
16     let l:line_marker_pattern = ':\(\d\+\)[.:]\=\(\d\+\)\=:\=$'
17     let l:message_pattern = '^\(Error\|Warning\): \(.\+\)$'
18     let l:looking_for_message = 0
19     let l:last_loclist_obj = {}
20
21     let l:output = []
22
23     for l:line in a:lines
24         if l:looking_for_message
25             let l:match = matchlist(l:line, l:message_pattern)
26         else
27             let l:match = matchlist(l:line, l:line_marker_pattern)
28         endif
29
30         if len(l:match) == 0
31             continue
32         endif
33
34         if l:looking_for_message
35             let l:looking_for_message = 0
36
37             " Now we have the text, we can set it and add the error.
38             let l:last_loclist_obj.text = l:match[2]
39             let l:last_loclist_obj.type = l:match[1] is# 'Warning' ? 'W' : 'E'
40             call add(l:output, l:last_loclist_obj)
41         else
42             let l:last_loclist_obj = {
43             \   'bufnr': a:buffer,
44             \   'lnum': l:match[1] + 0,
45             \   'col': l:match[2] + 0,
46             \}
47
48             " Start looking for the message and error type.
49             let l:looking_for_message = 1
50         endif
51     endfor
52
53     return l:output
54 endfunction
55
56 function! ale_linters#fortran#gcc#GetCommand(buffer) abort
57     let l:layout_option = ale#Var(a:buffer, 'fortran_gcc_use_free_form')
58     \   ? '-ffree-form'
59     \   : '-ffixed-form'
60
61     return '%e -S -x f95 -fsyntax-only ' . l:layout_option
62     \   . ale#Pad(ale#Var(a:buffer, 'fortran_gcc_options'))
63     \   . ' -'
64 endfunction
65
66 call ale#linter#Define('fortran', {
67 \   'name': 'gcc',
68 \   'output_stream': 'stderr',
69 \   'executable': {b -> ale#Var(b, 'fortran_gcc_executable')},
70 \   'command': function('ale_linters#fortran#gcc#GetCommand'),
71 \   'callback': 'ale_linters#fortran#gcc#Handle',
72 \})