diff options
author | Andrew Lee <andrew.lambda@tuta.io> | 2019-06-03 12:30:18 -0700 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2019-06-03 20:30:18 +0100 |
commit | c6a5cbb3c737261bc46477733b3aa26203eb63d9 (patch) | |
tree | 1b2cc8bf9b6eefd280df998bbb48d209dcf82708 /autoload | |
parent | a76f056bd976a52d3d49f07726a067ac4dba2e6e (diff) | |
download | ale-c6a5cbb3c737261bc46477733b3aa26203eb63d9.zip |
Feature/add ant support (#2539)
Use ant files to load Java settings too.
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/ant.vim | 41 | ||||
-rw-r--r-- | autoload/ale/java.vim | 6 |
2 files changed, 47 insertions, 0 deletions
diff --git a/autoload/ale/ant.vim b/autoload/ale/ant.vim new file mode 100644 index 00000000..689b444b --- /dev/null +++ b/autoload/ale/ant.vim @@ -0,0 +1,41 @@ +" Author: Andrew Lee <andrewl@mbda.fun>. +" Inspired by ale/gradle.vim by Michael Pardo <michael@michaelpardo.com> +" Description: Functions for working with Ant projects. + +" Given a buffer number, find an Ant project root +function! ale#ant#FindProjectRoot(buffer) abort + let l:build_xml_path = ale#path#FindNearestFile(a:buffer, 'build.xml') + + if !empty(l:build_xml_path) + return fnamemodify(l:build_xml_path, ':h') + endif + + return '' +endfunction + +" Given a buffer number, find the path to the `ant` executable. Returns an empty +" string if cannot find the executable. +function! ale#ant#FindExecutable(buffer) abort + if executable('ant') + return 'ant' + endif + + return '' +endfunction + +" Given a buffer number, build a command to print the classpath of the root +" project. Returns an empty string if cannot build the command. +function! ale#ant#BuildClasspathCommand(buffer) abort + let l:executable = ale#ant#FindExecutable(a:buffer) + let l:project_root = ale#ant#FindProjectRoot(a:buffer) + + if !empty(l:executable) && !empty(l:project_root) + return ale#path#CdString(l:project_root) + \ . ale#Escape(l:executable) + \ . ' classpath' + \ . ' -S' + \ . ' -q' + endif + + return '' +endfunction diff --git a/autoload/ale/java.vim b/autoload/ale/java.vim index b7fd10bd..e641ac6c 100644 --- a/autoload/ale/java.vim +++ b/autoload/ale/java.vim @@ -16,5 +16,11 @@ function! ale#java#FindProjectRoot(buffer) abort return fnamemodify(l:maven_pom_file, ':h') endif + let l:ant_root = ale#ant#FindProjectRoot(a:buffer) + + if !empty(l:ant_root) + return l:ant_root + endif + return '' endfunction |