diff options
author | w0rp <devw0rp@gmail.com> | 2018-08-02 23:44:12 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2018-08-02 23:44:12 +0100 |
commit | 217284360d35711b751859ed27a7a3c3da300e85 (patch) | |
tree | 4b26a84b397e3ac15a8b13a572b1f9a50312dbab /ale_linters/fortran | |
parent | 9ef266d050d698c3ed3be3456ce6a5da5755d5ef (diff) | |
download | ale-217284360d35711b751859ed27a7a3c3da300e85.zip |
Simplify the code for most linters and tests with closures
Diffstat (limited to 'ale_linters/fortran')
-rw-r--r-- | ale_linters/fortran/gcc.vim | 28 | ||||
-rw-r--r-- | ale_linters/fortran/language_server.vim | 12 |
2 files changed, 9 insertions, 31 deletions
diff --git a/ale_linters/fortran/gcc.vim b/ale_linters/fortran/gcc.vim index 5f2ac018..f1595789 100644 --- a/ale_linters/fortran/gcc.vim +++ b/ale_linters/fortran/gcc.vim @@ -2,18 +2,10 @@ " 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 - +call ale#Set('fortran_gcc_use_free_form', 1) +call ale#Set('fortran_gcc_executable', 'gcc') " 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' -endif +call ale#Set('fortran_gcc_options', '-Wall') function! ale_linters#fortran#gcc#Handle(buffer, lines) abort " We have to match a starting line and a later ending line together, @@ -61,26 +53,20 @@ function! ale_linters#fortran#gcc#Handle(buffer, lines) abort return l:output endfunction -function! ale_linters#fortran#gcc#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'fortran_gcc_executable') -endfunction - function! ale_linters#fortran#gcc#GetCommand(buffer) abort let l:layout_option = ale#Var(a:buffer, '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 . ' ' - \ . ale#Var(a:buffer, 'fortran_gcc_options') . ' ' - \ . '-' + return '%e -S -x f95 -fsyntax-only ' . l:layout_option + \ . ale#Pad(ale#Var(a:buffer, 'fortran_gcc_options')) + \ . ' -' endfunction call ale#linter#Define('fortran', { \ 'name': 'gcc', \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale_linters#fortran#gcc#GetExecutable', +\ 'executable_callback': ale#VarFunc('fortran_gcc_executable'), \ 'command_callback': 'ale_linters#fortran#gcc#GetCommand', \ 'callback': 'ale_linters#fortran#gcc#Handle', \}) diff --git a/ale_linters/fortran/language_server.vim b/ale_linters/fortran/language_server.vim index fd763fcf..4e5f5dc4 100644 --- a/ale_linters/fortran/language_server.vim +++ b/ale_linters/fortran/language_server.vim @@ -4,14 +4,6 @@ call ale#Set('fortran_language_server_executable', 'fortls') call ale#Set('fortran_language_server_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#fortran#language_server#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'fortran_language_server_executable') -endfunction - -function! ale_linters#fortran#language_server#GetCommand(buffer) abort - return ale#Escape(ale_linters#fortran#language_server#GetExecutable(a:buffer)) -endfunction - function! ale_linters#fortran#language_server#GetProjectRoot(buffer) abort let l:fortls_file = ale#path#FindNearestFile(a:buffer, '.fortls') @@ -21,7 +13,7 @@ endfunction call ale#linter#Define('fortran', { \ 'name': 'language_server', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#fortran#language_server#GetExecutable', -\ 'command_callback': 'ale_linters#fortran#language_server#GetCommand', +\ 'executable_callback': ale#VarFunc('fortran_language_server_executable'), +\ 'command': '%e', \ 'project_root_callback': 'ale_linters#fortran#language_server#GetProjectRoot', \}) |