Fix #168 - Make the Fortran linter more configurable
This commit is contained in:
parent
d824466230
commit
7682fab294
@ -1,6 +1,15 @@
|
||||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: gcc for Fortran files
|
||||
|
||||
" This option can be set to 0 to use -ffixed-form
|
||||
if !exists('g:ale_fortran_gcc_use_free_form')
|
||||
let g:ale_fortran_gcc_use_free_form = 1
|
||||
endif
|
||||
|
||||
if !exists('g:ale_fortran_gcc_executable')
|
||||
let g:ale_fortran_gcc_executable = 'gcc'
|
||||
endif
|
||||
|
||||
" Set this option to change the GCC options for warnings for Fortran.
|
||||
if !exists('g:ale_fortran_gcc_options')
|
||||
let g:ale_fortran_gcc_options = '-Wall'
|
||||
@ -52,16 +61,26 @@ function! ale_linters#fortran#gcc#Handle(buffer, lines) abort
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale_linters#fortran#gcc#GetExecutable(buffer) abort
|
||||
return g:ale_fortran_gcc_executable
|
||||
endfunction
|
||||
|
||||
function! ale_linters#fortran#gcc#GetCommand(buffer) abort
|
||||
return 'gcc -S -x f95 -fsyntax-only -ffree-form '
|
||||
\ . g:ale_fortran_gcc_options
|
||||
\ . ' -'
|
||||
let l:layout_option = g:ale_fortran_gcc_use_free_form
|
||||
\ ? '-ffree-form'
|
||||
\ : '-ffixed-form'
|
||||
|
||||
return ale_linters#fortran#gcc#GetExecutable(a:buffer)
|
||||
\ . ' -S -x f95 -fsyntax-only '
|
||||
\ . l:layout_option . ' '
|
||||
\ . g:ale_fortran_gcc_options . ' '
|
||||
\ . '-'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('fortran', {
|
||||
\ 'name': 'gcc',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'gcc',
|
||||
\ 'executable_callback': 'ale_linters#fortran#gcc#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#fortran#gcc#GetCommand',
|
||||
\ 'callback': 'ale_linters#fortran#gcc#Handle',
|
||||
\})
|
||||
|
@ -5,6 +5,15 @@ ALE Fortran Integration *ale-fortran-options*
|
||||
-------------------------------------------------------------------------------
|
||||
gcc *ale-fortran-gcc*
|
||||
|
||||
g:ale_fortran_gcc_executable *g:ale_fortran_gcc_executable*
|
||||
|
||||
Type: |String|
|
||||
Default: `'gcc'`
|
||||
|
||||
This variable can be changed to modify the executable used for checking
|
||||
Fortran code with GCC.
|
||||
|
||||
|
||||
g:ale_fortran_gcc_options *g:ale_fortran_gcc_options*
|
||||
|
||||
Type: |String|
|
||||
@ -13,5 +22,15 @@ g:ale_fortran_gcc_options *g:ale_fortran_gcc_options*
|
||||
This variable can be changed to modify flags given to gcc.
|
||||
|
||||
|
||||
g:ale_fortran_gcc_use_free_form *g:ale_fortran_gcc_use_free_form*
|
||||
|
||||
Type: |Number|
|
||||
Default: `1`
|
||||
|
||||
When set to `1`, the `-ffree-form` flag will be used for GCC, to check files
|
||||
with the free form layout. When set to `0`, `-ffixed-form` will be used
|
||||
instead, for checking files with fixed form layouts.
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||
|
31
test/command_callback/test_gfortran_command_callback.vader
Normal file
31
test/command_callback/test_gfortran_command_callback.vader
Normal file
@ -0,0 +1,31 @@
|
||||
Before:
|
||||
runtime ale_linters/fortran/gcc.vim
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
let g:ale_fortran_gcc_options = '-Wall'
|
||||
let g:ale_fortran_gcc_use_free_form = 1
|
||||
let g:ale_fortran_gcc_executable = 'gcc'
|
||||
|
||||
Execute(The fortran gcc command callback should return the correct default string):
|
||||
AssertEqual 'gcc -S -x f95 -fsyntax-only -ffree-form -Wall -',
|
||||
\ join(split(ale_linters#fortran#gcc#GetCommand(1)))
|
||||
|
||||
Execute(The fortran gcc command callback should let you set options):
|
||||
let g:ale_fortran_gcc_options = '-Wotherthings'
|
||||
|
||||
AssertEqual 'gcc -S -x f95 -fsyntax-only -ffree-form -Wotherthings -',
|
||||
\ join(split(ale_linters#fortran#gcc#GetCommand(1)))
|
||||
|
||||
Execute(The fortran gcc command callback should let you use -ffixed-form):
|
||||
let g:ale_fortran_gcc_use_free_form = 0
|
||||
|
||||
AssertEqual 'gcc -S -x f95 -fsyntax-only -ffixed-form -Wall -',
|
||||
\ join(split(ale_linters#fortran#gcc#GetCommand(1)))
|
||||
|
||||
Execute(The fortran executable should be configurable):
|
||||
let g:ale_fortran_gcc_executable = 'gfortran'
|
||||
|
||||
AssertEqual 'gfortran', ale_linters#fortran#gcc#GetExecutable(1)
|
||||
AssertEqual 'gfortran -S -x f95 -fsyntax-only -ffree-form -Wall -',
|
||||
\ join(split(ale_linters#fortran#gcc#GetCommand(1)))
|
Loading…
Reference in New Issue
Block a user