Merge pull request #2631 from timlag1305/feat/ada-gnatpp
Add gnatpp fixer for Ada
This commit is contained in:
commit
ddb559b3be
8 changed files with 64 additions and 0 deletions
|
@ -325,6 +325,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.
|
||||
|
|
17
autoload/ale/fixers/gnatpp.vim
Normal file
17
autoload/ale/fixers/gnatpp.vim
Normal 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
|
|
@ -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:
|
||||
|
|
|
@ -14,6 +14,7 @@ Notes:
|
|||
|
||||
* Ada
|
||||
* `gcc`
|
||||
* `gnatpp`
|
||||
* Ansible
|
||||
* `ansible-lint`
|
||||
* API Blueprint
|
||||
|
|
|
@ -1992,6 +1992,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|
|
||||
|
|
|
@ -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
|
||||
|
|
0
test/ada_files/testfile.adb
Normal file
0
test/ada_files/testfile.adb
Normal file
28
test/fixers/test_gnatpp_fixer_callback.vader
Normal file
28
test/fixers/test_gnatpp_fixer_callback.vader
Normal 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,
|
||||
\ }
|
Reference in a new issue