summaryrefslogtreecommitdiff
path: root/ale_linters/scala/sbtserver.vim
blob: 694241d780ae37a56efe8886452f7946b0c17c9f (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
30
31
" Author: ophirr33 <coghlan.ty@gmail.com>
" Description: TCP lsp client for sbt Server

call ale#Set('scala_sbtserver_address', '127.0.0.1:4273')
call ale#Set('scala_sbtserver_project_root', '')

function! ale_linters#scala#sbtserver#GetProjectRoot(buffer) abort
    let l:project_root = ale#Var(a:buffer, 'scala_sbtserver_project_root')

    if l:project_root is? ''
        let l:project_root = ale#path#FindNearestFile(a:buffer, 'build.sbt')

        return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
    endif

    return l:project_root
endfunction

function! ale_linters#scala#sbtserver#GetAddress(buffer) abort
    let l:address = ale#Var(a:buffer, 'scala_sbtserver_address')

    return l:address
endfunction

call ale#linter#Define('scala', {
\   'name': 'sbtserver',
\   'lsp': 'socket',
\   'address_callback': 'ale_linters#scala#sbtserver#GetAddress',
\   'language': 'scala',
\   'project_root_callback': 'ale_linters#scala#sbtserver#GetProjectRoot',
\})