Files
ale/ale_linters/fortran/fortitude.vim
w0rp 29f1ff2579 Add support for fortitude (fortran linter) #5004
* add support for fortitude fortran linter
* add fortitude fortran linter doc
* Add a fortitude linter test file
* docs listings are now alphabetically sorted

Co-Authored-By: gomfol12 <info@marekb.de>
2025-08-13 15:24:35 +01:00

48 lines
1.3 KiB
VimL

" Author: gomfol12
" Desciption: A linter for fortran using fortitude.
call ale#Set('fortran_fortitude_executable', 'fortitude')
call ale#Set('fortran_fortitude_options', '')
let s:severity_map = {
\ 'E': 'E',
\ 'C': 'W',
\ 'OB': 'I',
\ 'MOD': 'I',
\ 'S': 'I',
\ 'PORT': 'I',
\ 'FORT': 'I',
\}
function! ale_linters#fortran#fortitude#Handle(buffer, lines) abort
let l:output = []
for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
let l:prefix = matchstr(l:error['code'], '^\a\+')
let l:type = get(s:severity_map, l:prefix, 'I')
call add(l:output, {
\ 'lnum': l:error['location']['row'],
\ 'end_lnum': l:error['end_location']['row'],
\ 'col': l:error['location']['column'],
\ 'end_col': l:error['end_location']['column'],
\ 'text': l:error['message'],
\ 'type': l:type,
\ 'code': l:error['code'],
\})
endfor
return l:output
endfunction
call ale#linter#Define('fortran', {
\ 'name': 'fortitude',
\ 'output_stream': 'stdout',
\ 'executable': {b -> ale#Var(b, 'fortran_fortitude_executable')},
\ 'command': {b ->
\ '%e' . ' check --output-format json' . ale#Pad(ale#Var(b, 'fortran_fortitude_options')) . ' %s'
\ },
\ 'callback': 'ale_linters#fortran#fortitude#Handle',
\ 'lint_file': 1,
\})