summaryrefslogtreecommitdiff
path: root/ale_linters/kotlin/kotlinc.vim
diff options
context:
space:
mode:
authorMichael Pardo <kensuke155@gmail.com>2017-07-10 18:03:36 -0400
committerw0rp <w0rp@users.noreply.github.com>2017-07-10 23:03:36 +0100
commitd787050fa8a82eec26962055829af1f33bd70bbf (patch)
tree3170738787b73d0092f747648a2ea31851d2b2a9 /ale_linters/kotlin/kotlinc.vim
parent29d0a20dc3657d046b98cbbfe08014a38f5fc378 (diff)
downloadale-d787050fa8a82eec26962055829af1f33bd70bbf.zip
Kotlin and general Gradle support. (#745)
Diffstat (limited to 'ale_linters/kotlin/kotlinc.vim')
-rw-r--r--ale_linters/kotlin/kotlinc.vim21
1 files changed, 17 insertions, 4 deletions
diff --git a/ale_linters/kotlin/kotlinc.vim b/ale_linters/kotlin/kotlinc.vim
index 525202cf..ebaf4456 100644
--- a/ale_linters/kotlin/kotlinc.vim
+++ b/ale_linters/kotlin/kotlinc.vim
@@ -12,17 +12,21 @@ let g:ale_kotlin_kotlinc_module_filename = get(g:, 'ale_kotlin_kotlinc_module_fi
let s:classpath_sep = has('unix') ? ':' : ';'
function! ale_linters#kotlin#kotlinc#GetImportPaths(buffer) abort
- " exec maven only if classpath is not set
+ " exec maven/gradle only if classpath is not set
if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') !=# ''
return ''
else
let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml')
-
if !empty(l:pom_path) && executable('mvn')
return ale#path#CdString(fnamemodify(l:pom_path, ':h'))
\ . 'mvn dependency:build-classpath'
endif
+ let l:classpath_command = ale#gradle#BuildClasspathCommand(a:buffer)
+ if !empty(l:classpath_command)
+ return l:classpath_command
+ endif
+
return ''
endif
endfunction
@@ -69,7 +73,7 @@ function! ale_linters#kotlin#kotlinc#GetCommand(buffer, import_paths) abort
if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') !=# ''
let l:kotlinc_opts .= ' -cp ' . ale#Var(a:buffer, 'kotlin_kotlinc_classpath')
else
- " get classpath from maven
+ " get classpath from maven/gradle
let l:kotlinc_opts .= s:BuildClassPathOption(a:buffer, a:import_paths)
endif
@@ -78,7 +82,15 @@ function! ale_linters#kotlin#kotlinc#GetCommand(buffer, import_paths) abort
let l:fname .= expand(ale#Var(a:buffer, 'kotlin_kotlinc_sourcepath'), 1) . ' '
else
" Find the src directory for files in this project.
- let l:src_dir = ale#path#FindNearestDirectory(a:buffer, 'src/main/java')
+
+ let l:project_root = ale#gradle#FindProjectRoot(a:buffer)
+ if !empty(l:project_root)
+ let l:src_dir = l:project_root
+ else
+ let l:src_dir = ale#path#FindNearestDirectory(a:buffer, 'src/main/java')
+ \ . ' ' . ale#path#FindNearestDirectory(a:buffer, 'src/main/kotlin')
+ endif
+
let l:fname .= expand(l:src_dir, 1) . ' '
endif
let l:fname .= ale#Escape(expand('#' . a:buffer . ':p'))
@@ -155,3 +167,4 @@ call ale#linter#Define('kotlin', {
\ 'callback': 'ale_linters#kotlin#kotlinc#Handle',
\ 'lint_file': 1,
\})
+