aboutsummaryrefslogtreecommitdiff
path: root/.vim/autoload/neomake/makers/ft/elixir.vim
blob: 4de652ec2ebbfe8e53b99a5b82bef78a85483c86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
" vim: ts=4 sw=4 et

" Credo error types.
" F -> Refactoring opportunities
" W -> Warnings
" C -> Convention violation
" D -> Software design suggestions
" R -> Readability suggestions
" Map structure {CredoError: NeomakeType, ...}
let s:neomake_elixir_credo_config_typemap = {
    \ 'F': 'W',
    \ 'C': 'W',
    \ 'D': 'I',
    \ 'R': 'I'}

function! neomake#makers#ft#elixir#PostprocessEnforceMaxBufferLine(entry) abort
    let buffer_lines = str2nr(line('$'))
    if (buffer_lines < a:entry.lnum)
        let a:entry.lnum = buffer_lines
    endif
endfunction

function! neomake#makers#ft#elixir#PostprocessCredo(entry) abort
    let type = toupper(a:entry.type)
    let type_map = extend(s:neomake_elixir_credo_config_typemap,
                \ get(g:, 'neomake_elixir_credo_config_typemap', {}))
    if has_key(type_map, type)
        let a:entry.type = type_map[type]
    endif
endfunction

function! neomake#makers#ft#elixir#EnabledMakers() abort
    return ['mix']
endfunction

function! neomake#makers#ft#elixir#elixir() abort
    return {
        \ 'errorformat':
            \ '%E** %s %f:%l: %m,'.
            \ '%W%f:%l: warning: %m'
        \ }
endfunction

function! neomake#makers#ft#elixir#credo() abort
    return {
      \ 'exe': 'mix',
      \ 'args': ['credo', 'list', '--format=oneline'],
      \ 'postprocess': function('neomake#makers#ft#elixir#PostprocessCredo'),
      \ 'errorformat':
          \'[%t] %. %f:%l:%c %m,' .
          \'[%t] %. %f:%l %m'
      \ }
endfunction

function! neomake#makers#ft#elixir#mix() abort
    return {
      \ 'exe' : 'mix',
      \ 'args': ['compile', '--warnings-as-errors'],
      \ 'postprocess': function('neomake#makers#ft#elixir#PostprocessEnforceMaxBufferLine'),
      \ 'errorformat':
        \ '** %s %f:%l: %m,'.
        \ '%Ewarning: %m,%C  %f:%l,%Z'
      \ }
endfunction

function! neomake#makers#ft#elixir#dogma() abort
    return {
      \ 'exe': 'mix',
      \ 'args': ['dogma', '--format=flycheck'],
      \ 'errorformat': '%E%f:%l:%c: %.: %m'
      \ }
endfunction