diff options
author | Ty Coghlan <Coghlan.Ty@gmail.com> | 2018-08-27 01:12:56 -0400 |
---|---|---|
committer | Ty Coghlan <Coghlan.Ty@gmail.com> | 2018-08-30 22:10:38 -0400 |
commit | 8e3bf10592b52ba96ce94c5819a19ee8de6f0899 (patch) | |
tree | 86f17f793726520f886211466c18fd53fb3182d7 /ale_linters | |
parent | ea01cc708b4beed3831a10065664c84dba68b5dc (diff) | |
download | ale-8e3bf10592b52ba96ce94c5819a19ee8de6f0899.zip |
added sbtserver linter
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/scala/sbtserver.vim | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ale_linters/scala/sbtserver.vim b/ale_linters/scala/sbtserver.vim new file mode 100644 index 00000000..3092dc13 --- /dev/null +++ b/ale_linters/scala/sbtserver.vim @@ -0,0 +1,37 @@ +" Author: ophirr33 <coghlan.ty@gmail.com> +" Description: TCP lsp client for sbt Server + +call ale#Set('scala_sbtserver_address', '') +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') + if l:address is? '' + let l:project_root = ale_linters#scala#sbtserver#GetProjectRoot(a:buffer) + let l:active_file = l:project_root . '/project/target/active.json' + if !empty(glob(l:active_file)) + let l:active = json_decode(join(readfile(l:project_root . '/project/target/active.json'))) + if has_key(l:active, 'uri') + return substitute(l:active.uri, 'tcp://', '', '') + endif + endif + endif + 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', +\}) |