summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/fortran/gcc.vim27
-rw-r--r--doc/ale-fortran.txt19
-rw-r--r--test/command_callback/test_gfortran_command_callback.vader31
3 files changed, 73 insertions, 4 deletions
diff --git a/ale_linters/fortran/gcc.vim b/ale_linters/fortran/gcc.vim
index 0f390852..9b66f449 100644
--- a/ale_linters/fortran/gcc.vim
+++ b/ale_linters/fortran/gcc.vim
@@ -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',
\})
diff --git a/doc/ale-fortran.txt b/doc/ale-fortran.txt
index 73e21037..e761983a 100644
--- a/doc/ale-fortran.txt
+++ b/doc/ale-fortran.txt
@@ -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:
diff --git a/test/command_callback/test_gfortran_command_callback.vader b/test/command_callback/test_gfortran_command_callback.vader
new file mode 100644
index 00000000..501e92fd
--- /dev/null
+++ b/test/command_callback/test_gfortran_command_callback.vader
@@ -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)))