Add gnatpp fixer for Ada

This commit is contained in:
Tim Lagnese 2019-07-01 20:49:12 -04:00
parent 6feeca793a
commit 221aceb6db
8 changed files with 64 additions and 0 deletions

View file

@ -315,6 +315,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['python'],
\ 'description': 'Sort Python imports with reorder-python-imports.',
\ },
\ 'gnatpp': {
\ 'function': 'ale#fixers#gnatpp#Fix',
\ 'suggested_filetypes': ['ada'],
\ 'description': 'Format Ada files with gnatpp.',
\ },
\}
" Reset the function registry to the default entries.

View file

@ -0,0 +1,17 @@
" Author: tim <tim@inept.tech>
" Description: Fix files with gnatpp.
call ale#Set('ada_gnatpp_executable', 'gnatpp')
call ale#Set('ada_gnatpp_options', '')
function! ale#fixers#gnatpp#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'ada_gnatpp_executable')
let l:options = ale#Var(a:buffer, 'ada_gnatpp_options')
return {
\ 'command': ale#Escape(l:executable)
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' %t',
\ 'read_temporary_file': 1,
\}
endfunction

View file

@ -21,5 +21,16 @@ g:ale_ada_gcc_options *g:ale_ada_gcc_options*
This variable can be set to pass additional options to gcc.
===============================================================================
gnatpp *ale-ada-gnatpp*
g:ale_ada_gnatpp_options *g:ale_ada_gnatpp_options*
*b:ale_ada_gnatpp_options*
Type: |String|
Default: `''`
This variable can be set to pass extra options to the gnatpp fixer.
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View file

@ -14,6 +14,7 @@ Notes:
* Ada
* `gcc`
* `gnatpp`
* Ansible
* `ansible-lint`
* API Blueprint

View file

@ -1927,6 +1927,7 @@ documented in additional help files.
ada.....................................|ale-ada-options|
gcc...................................|ale-ada-gcc|
gnatpp................................|ale-ada-gnatpp|
ansible.................................|ale-ansible-options|
ansible-lint..........................|ale-ansible-ansible-lint|
asciidoc................................|ale-asciidoc-options|

View file

@ -23,6 +23,7 @@ formatting.
* Ada
* [gcc](https://gcc.gnu.org)
* [gnatpp](https://docs.adacore.com/gnat_ugn-docs/html/gnat_ugn/gnat_ugn/gnat_utility_programs.html#the-gnat-pretty-printer-gnatpp) :floppy_disk:
* Ansible
* [ansible-lint](https://github.com/willthames/ansible-lint)
* API Blueprint

View file

View file

@ -0,0 +1,28 @@
Before:
call ale#assert#SetUpFixerTest('ada', 'gnatpp')
After:
" Reset fixers, variables, etc.
"
" Vader's 'Restore' command will be called here.
call ale#assert#TearDownFixerTest()
Execute(The default command should be correct):
call ale#test#SetFilename('../ada_files/testfile.adb')
AssertFixer
\ {
\ 'command': ale#Escape(g:ale_ada_gnatpp_executable) .' %t',
\ 'read_temporary_file': 1,
\ }
Execute(The version check should be correct):
call ale#test#SetFilename('../ada_files/testfile.adb')
let g:ale_ada_gnatpp_options = '--no-alignment'
AssertFixer
\ {
\ 'command': ale#Escape(g:ale_ada_gnatpp_executable)
\ . ' --no-alignment %t',
\ 'read_temporary_file': 1,
\ }