summaryrefslogtreecommitdiff
path: root/ale_linters/kotlin
diff options
context:
space:
mode:
authorMTDL9 <40929090+MTDL9@users.noreply.github.com>2018-07-15 19:54:18 +0200
committerw0rp <w0rp@users.noreply.github.com>2018-07-15 18:54:18 +0100
commit5df735555cec5ab87f3cc74b9870482f921b0fbb (patch)
tree1b984ed59ea3419407107f4016011e8cc19b271c /ale_linters/kotlin
parenta42999a639b2916b769a85f37d037be314d9d61b (diff)
downloadale-5df735555cec5ab87f3cc74b9870482f921b0fbb.zip
Add kotlin language server support (#1725)
* Add kotlin languageserver linter definition * Added kotlin languageserver references in docs, fix missing !! on other linters * Added Vader tests for root path detection in Kotlin Language Server
Diffstat (limited to 'ale_linters/kotlin')
-rw-r--r--ale_linters/kotlin/languageserver.vim38
1 files changed, 38 insertions, 0 deletions
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',
+\})