summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--ale_linters/kotlin/languageserver.vim38
-rw-r--r--doc/ale-kotlin.txt15
-rw-r--r--doc/ale.txt3
-rw-r--r--test/maven-test-files/maven-kotlin-project/pom.xml1
-rw-r--r--test/maven-test-files/maven-kotlin-project/src/main/kotlin/dummy.kt1
-rw-r--r--test/test_kotlin_languageserver_path_detection.vader25
7 files changed, 83 insertions, 2 deletions
diff --git a/README.md b/README.md
index 527e4063..67602b0c 100644
--- a/README.md
+++ b/README.md
@@ -133,7 +133,7 @@ formatting.
| Java | [checkstyle](http://checkstyle.sourceforge.net), [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html), [google-java-format](https://github.com/google/google-java-format), [PMD](https://pmd.github.io/) |
| JavaScript | [eslint](http://eslint.org/), [flow](https://flowtype.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [prettier](https://github.com/prettier/prettier), [prettier-eslint](https://github.com/prettier/prettier-eslint-cli), [prettier-standard](https://github.com/sheerun/prettier-standard), [standard](http://standardjs.com/), [xo](https://github.com/sindresorhus/xo)
| JSON | [fixjson](https://github.com/rhysd/fixjson), [jsonlint](http://zaa.ch/jsonlint/), [jq](https://stedolan.github.io/jq/), [prettier](https://github.com/prettier/prettier) |
-| Kotlin | [kotlinc](https://kotlinlang.org) !!, [ktlint](https://ktlint.github.io) !! see `:help ale-integration-kotlin` for configuration instructions |
+| Kotlin | [kotlinc](https://kotlinlang.org) !!, [ktlint](https://ktlint.github.io) !!, [languageserver](https://github.com/fwcd/KotlinLanguageServer) see `:help ale-integration-kotlin` for configuration instructions |
| LaTeX | [alex](https://github.com/wooorm/alex) !!, [chktex](http://www.nongnu.org/chktex/), [lacheck](https://www.ctan.org/pkg/lacheck), [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) |
| Less | [lessc](https://www.npmjs.com/package/less), [prettier](https://github.com/prettier/prettier), [stylelint](https://github.com/stylelint/stylelint) |
| LLVM | [llc](https://llvm.org/docs/CommandGuide/llc.html) |
diff --git a/ale_linters/kotlin/languageserver.vim b/ale_linters/kotlin/languageserver.vim
new file mode 100644
index 00000000..0ab673ec
--- /dev/null
+++ b/ale_linters/kotlin/languageserver.vim
@@ -0,0 +1,38 @@
+" Author: MTDL9 <https://github.com/MTDL9>
+" Description: Support for the Kotlin language server https://github.com/fwcd/KotlinLanguageServer
+
+call ale#Set('kotlin_languageserver_executable', 'kotlin-language-server')
+
+function! ale_linters#kotlin#languageserver#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'kotlin_languageserver_executable')
+endfunction
+
+function! ale_linters#kotlin#languageserver#GetCommand(buffer) abort
+ let l:executable = ale_linters#kotlin#languageserver#GetExecutable(a:buffer)
+ return ale#Escape(l:executable)
+endfunction
+
+function! ale_linters#kotlin#languageserver#GetProjectRoot(buffer) abort
+ let l:gradle_root = ale#gradle#FindProjectRoot(a:buffer)
+
+ if !empty(l:gradle_root)
+ return l:gradle_root
+ endif
+
+ let l:maven_pom_file = ale#path#FindNearestFile(a:buffer, 'pom.xml')
+
+ if !empty(l:maven_pom_file)
+ return fnamemodify(l:maven_pom_file, ':h')
+ endif
+
+ return ''
+endfunction
+
+call ale#linter#Define('kotlin', {
+\ 'name': 'languageserver',
+\ 'lsp': 'stdio',
+\ 'executable_callback': 'ale_linters#kotlin#languageserver#GetExecutable',
+\ 'command_callback': 'ale_linters#kotlin#languageserver#GetCommand',
+\ 'language': 'kotlin',
+\ 'project_root_callback': 'ale_linters#kotlin#languageserver#GetProjectRoot',
+\})
diff --git a/doc/ale-kotlin.txt b/doc/ale-kotlin.txt
index 571d2bac..9f9fd16e 100644
--- a/doc/ale-kotlin.txt
+++ b/doc/ale-kotlin.txt
@@ -87,4 +87,19 @@ g:ale_kotlin_ktlint_rulesets *g:ale_kotlin_ktlint_rulesets*
let g:ale_kotlin_ktlint_rulesets = ['/path/to/custom-rulset.jar',
'com.ktlint.rulesets:mycustomrule:1.0.0']
+
+===============================================================================
+languageserver *ale-kotlin-languageserver*
+
+g:ale_kotlin_languageserver_executable *g:ale_kotlin_languageserver_executable*
+ Type: |String|
+ Default: `''`
+
+ The kotlin-language-server executable.
+
+ Executables are located inside the bin/ folder of the language server
+ release.
+
+
+===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale.txt b/doc/ale.txt
index 75a37533..276c6c29 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -131,6 +131,7 @@ CONTENTS *ale-contents*
kotlin................................|ale-kotlin-options|
kotlinc.............................|ale-kotlin-kotlinc|
ktlint..............................|ale-kotlin-ktlint|
+ languageserver......................|ale-kotlin-languageserver|
latex.................................|ale-latex-options|
write-good..........................|ale-latex-write-good|
less..................................|ale-less-options|
@@ -368,7 +369,7 @@ Notes:
* Java: `checkstyle`, `javac`, `google-java-format`, `PMD`
* JavaScript: `eslint`, `flow`, `jscs`, `jshint`, `prettier`, `prettier-eslint`, `prettier-standard`, `standard`, `xo`
* JSON: `fixjson`, `jsonlint`, `jq`, `prettier`
-* Kotlin: `kotlinc`, `ktlint`
+* Kotlin: `kotlinc`!!, `ktlint`!!, `languageserver`
* LaTeX (tex): `alex`!!, `chktex`, `lacheck`, `proselint`, `redpen`, `vale`, `write-good`
* Less: `lessc`, `prettier`, `stylelint`
* LLVM: `llc`
diff --git a/test/maven-test-files/maven-kotlin-project/pom.xml b/test/maven-test-files/maven-kotlin-project/pom.xml
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/test/maven-test-files/maven-kotlin-project/pom.xml
@@ -0,0 +1 @@
+
diff --git a/test/maven-test-files/maven-kotlin-project/src/main/kotlin/dummy.kt b/test/maven-test-files/maven-kotlin-project/src/main/kotlin/dummy.kt
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/test/maven-test-files/maven-kotlin-project/src/main/kotlin/dummy.kt
@@ -0,0 +1 @@
+
diff --git a/test/test_kotlin_languageserver_path_detection.vader b/test/test_kotlin_languageserver_path_detection.vader
new file mode 100644
index 00000000..36e6368e
--- /dev/null
+++ b/test/test_kotlin_languageserver_path_detection.vader
@@ -0,0 +1,25 @@
+Before:
+ call ale#test#SetDirectory('/testplugin/test')
+ runtime ale_linters/kotlin/languageserver.vim
+
+After:
+ call ale#test#RestoreDirectory()
+ call ale#linter#Reset()
+
+Execute(Detect root of gradle project with build.gradle correctly):
+ call ale#test#SetFilename('gradle-test-files/build-gradle-project/src/main/kotlin/dummy.kt')
+ AssertEqual
+ \ ale#path#Simplify(g:dir . '/gradle-test-files/build-gradle-project'),
+ \ ale_linters#kotlin#languageserver#GetProjectRoot(bufnr(''))
+
+Execute(Detect root of maven project with pom.xml correctly):
+ call ale#test#SetFilename('maven-test-files/maven-kotlin-project/src/main/kotlin/dummy.kt')
+ AssertEqual
+ \ ale#path#Simplify(g:dir . '/maven-test-files/maven-kotlin-project'),
+ \ ale_linters#kotlin#languageserver#GetProjectRoot(bufnr(''))
+
+Execute(Detect no root in case of non maven/gradle project):
+ call ale#test#SetFilename('gradle-test-files/non-gradle-project/src/main/kotlin/dummy.kt')
+ AssertEqual
+ \ '',
+ \ ale_linters#kotlin#languageserver#GetProjectRoot(bufnr(''))