summaryrefslogtreecommitdiff
path: root/ale_linters/kotlin/languageserver.vim
blob: af78c0e0bd6acbd241a26c6c87cc3ef2b8ed8713 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
" 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#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': {b -> ale#Var(b, 'kotlin_languageserver_executable')},
\   'command': '%e',
\   'language': 'kotlin',
\   'project_root': function('ale_linters#kotlin#languageserver#GetProjectRoot'),
\})