summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/gnatpp.vim17
-rw-r--r--doc/ale-ada.txt11
-rw-r--r--doc/ale-supported-languages-and-tools.txt1
-rw-r--r--doc/ale.txt1
-rw-r--r--supported-tools.md1
-rw-r--r--test/ada_files/testfile.adb0
-rw-r--r--test/fixers/test_gnatpp_fixer_callback.vader28
8 files changed, 64 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index c5ef1544..3850d782 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -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.
diff --git a/autoload/ale/fixers/gnatpp.vim b/autoload/ale/fixers/gnatpp.vim
new file mode 100644
index 00000000..bf3d484e
--- /dev/null
+++ b/autoload/ale/fixers/gnatpp.vim
@@ -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
diff --git a/doc/ale-ada.txt b/doc/ale-ada.txt
index 93e3261a..2ac30c0a 100644
--- a/doc/ale-ada.txt
+++ b/doc/ale-ada.txt
@@ -22,4 +22,15 @@ g:ale_ada_gcc_options *g:ale_ada_gcc_options*
===============================================================================
+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:
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index d39aaf7e..1a664450 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -14,6 +14,7 @@ Notes:
* Ada
* `gcc`
+ * `gnatpp`
* Ansible
* `ansible-lint`
* API Blueprint
diff --git a/doc/ale.txt b/doc/ale.txt
index a54bc8bb..6d8c6a45 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -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|
diff --git a/supported-tools.md b/supported-tools.md
index 6cb9f418..6e3a6f6e 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -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
diff --git a/test/ada_files/testfile.adb b/test/ada_files/testfile.adb
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/ada_files/testfile.adb
diff --git a/test/fixers/test_gnatpp_fixer_callback.vader b/test/fixers/test_gnatpp_fixer_callback.vader
new file mode 100644
index 00000000..a2bf898e
--- /dev/null
+++ b/test/fixers/test_gnatpp_fixer_callback.vader
@@ -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,
+ \ }