Changed sbtserver to just work off of the address variable
This commit is contained in:
parent
8e3bf10592
commit
3d016f1697
@ -1,7 +1,7 @@
|
|||||||
" Author: ophirr33 <coghlan.ty@gmail.com>
|
" Author: ophirr33 <coghlan.ty@gmail.com>
|
||||||
" Description: TCP lsp client for sbt Server
|
" Description: TCP lsp client for sbt Server
|
||||||
|
|
||||||
call ale#Set('scala_sbtserver_address', '')
|
call ale#Set('scala_sbtserver_address', '127.0.0.1:4273')
|
||||||
call ale#Set('scala_sbtserver_project_root', '')
|
call ale#Set('scala_sbtserver_project_root', '')
|
||||||
|
|
||||||
function! ale_linters#scala#sbtserver#GetProjectRoot(buffer) abort
|
function! ale_linters#scala#sbtserver#GetProjectRoot(buffer) abort
|
||||||
@ -15,16 +15,6 @@ endfunction
|
|||||||
|
|
||||||
function! ale_linters#scala#sbtserver#GetAddress(buffer) abort
|
function! ale_linters#scala#sbtserver#GetAddress(buffer) abort
|
||||||
let l:address = ale#Var(a:buffer, 'scala_sbtserver_address')
|
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
|
return l:address
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ function! ale#linter#PreProcess(filetype, linter) abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if index(['', 'socket', 'stdio', 'tsserver'], l:obj.lsp) < 0
|
if index(['', 'socket', 'stdio', 'tsserver'], l:obj.lsp) < 0
|
||||||
throw '`lsp` must be either `''lsp''`, `''stdio''` or `''tsserver''` if defined'
|
throw '`lsp` must be either `''lsp''`, `''stdio''`, `''socket''` or `''tsserver''` if defined'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !l:needs_executable
|
if !l:needs_executable
|
||||||
|
@ -5,20 +5,24 @@ ALE Scala Integration *ale-scala-options*
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
sbtserver *ale-scala-sbtserver*
|
sbtserver *ale-scala-sbtserver*
|
||||||
|
|
||||||
`sbtserver` requires a running ^1.1.x sbt shell to connect to. It will look
|
`sbtserver` requires a running ^1.1.x sbt shell to connect to. It will attempt
|
||||||
for this shell by searching upwards from the current working directory for
|
to connect via TCP to the address defined in `g:ale_scala_sbtserver_address`.
|
||||||
the `project/target/active.json` file. This will only work when `sbtserver` is
|
As `sbt` defaults to listening via unix sockets, place these settings into
|
||||||
configured to listen via tcp. An easy way to accomplish that is to put
|
your `~/.sbt/1.0/global.sbt` to ensure that ale will always attempt to connect
|
||||||
`serverConnectionType := ConnectionType.Tcp` in `~/.sbt/1.0/global.sbt`.
|
to the right socket:
|
||||||
|
|
||||||
|
`serverConnectionType := ConnectionType.Tcp` and `serverPort := 4273`
|
||||||
|
|
||||||
|
|
||||||
g:ale_scala_sbtserver_address *g:ale_scala_sbtserver_address*
|
g:ale_scala_sbtserver_address *g:ale_scala_sbtserver_address*
|
||||||
*b:ale_scala_sbtserver_address*
|
*b:ale_scala_sbtserver_address*
|
||||||
Type: |String|
|
Type: |String|
|
||||||
Default: `''`
|
Default: `'127.0.0.1:4273'`
|
||||||
|
|
||||||
By default the address is found by parsing `active.json`. If the server is
|
By default the address is found by parsing `active.json`, however, reading a
|
||||||
running elsewhere, you can override the address here to `host:port`.
|
file is a blocking operation which should be avoided in ale. The easy way
|
||||||
|
around this is to configure sbt to always connect to the same port, which
|
||||||
|
the instructions above describe.
|
||||||
|
|
||||||
|
|
||||||
g:ale_scala_sbtserver_project_root *g:ale_scala_sbtserver_project_root*
|
g:ale_scala_sbtserver_project_root *g:ale_scala_sbtserver_project_root*
|
||||||
@ -26,7 +30,7 @@ g:ale_scala_sbtserver_project_root *g:ale_scala_sbtserver_project_root*
|
|||||||
Type: |String|
|
Type: |String|
|
||||||
Default: `''`
|
Default: `''`
|
||||||
|
|
||||||
By default the project root is found by searching upwards for `active.json`.
|
By default the project root is found by searching upwards for `build.sbt`.
|
||||||
If the project root is elsewhere, you can override the project root
|
If the project root is elsewhere, you can override the project root
|
||||||
directory.
|
directory.
|
||||||
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
rm -rf ~/.vim/plugged/ale
|
|
||||||
cp -r . ~/.vim/plugged/ale
|
|
@ -5,21 +5,15 @@ Before:
|
|||||||
call ale#assert#SetUpLinterTest('scala', 'sbtserver')
|
call ale#assert#SetUpLinterTest('scala', 'sbtserver')
|
||||||
After:
|
After:
|
||||||
call ale#assert#TearDownLinterTest()
|
call ale#assert#TearDownLinterTest()
|
||||||
Execute(should set sbtserver for sbt project with active.json):
|
Execute(should set sbtserver for sbt project with build.sbt):
|
||||||
call ale#test#SetFilename('../scala_fixtures/valid_sbt_project/Main.scala')
|
call ale#test#SetFilename('../scala_fixtures/valid_sbt_project/Main.scala')
|
||||||
AssertLSPLanguage 'scala'
|
AssertLSPLanguage 'scala'
|
||||||
AssertLSPOptions {}
|
AssertLSPOptions {}
|
||||||
AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../scala_fixtures/valid_sbt_project')
|
AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../scala_fixtures/valid_sbt_project')
|
||||||
AssertLSPAddress '127.0.0.1:5211'
|
AssertLSPAddress '127.0.0.1:4273'
|
||||||
Execute(should not set sbtserver for sbt project without active.json):
|
|
||||||
call ale#test#SetFilename('../scala_fixtures/no_active_sbt_project/Main.scala')
|
|
||||||
AssertLSPLanguage 'scala'
|
|
||||||
AssertLSPOptions {}
|
|
||||||
AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../scala_fixtures/no_active_sbt_project')
|
|
||||||
AssertLSPAddress ''
|
|
||||||
Execute(should not set sbtserver for sbt project without build.sbt):
|
Execute(should not set sbtserver for sbt project without build.sbt):
|
||||||
call ale#test#SetFilename('../scala_fixtures/invalid_sbt_project/Main.scala')
|
call ale#test#SetFilename('../scala_fixtures/invalid_sbt_project/Main.scala')
|
||||||
AssertLSPLanguage 'scala'
|
AssertLSPLanguage 'scala'
|
||||||
AssertLSPOptions {}
|
AssertLSPOptions {}
|
||||||
AssertLSPProject ''
|
AssertLSPProject ''
|
||||||
AssertLSPAddress ''
|
AssertLSPAddress '127.0.0.1:4273'
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
object HelloAle {
|
|
||||||
def main(args: Array[String]): Int = {
|
|
||||||
println("Hello, ale!")
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
sbt.version=1.2.1
|
|
@ -1 +0,0 @@
|
|||||||
{"uri":"tcp://127.0.0.1:5211"}
|
|
@ -1,5 +0,0 @@
|
|||||||
object HelloAle {
|
|
||||||
def main(args: Array[String]): Int = {
|
|
||||||
println("Hello, ale!")
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
name := "ale-scala-valid"
|
|
||||||
version := "1.0"
|
|
||||||
scalaVersion := "2.12.6"
|
|
@ -1 +0,0 @@
|
|||||||
sbt.version=1.2.1
|
|
@ -1,5 +0,0 @@
|
|||||||
object HelloAle {
|
|
||||||
def main(args: Array[String]): Int = {
|
|
||||||
println("Hello, ale!")
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
name := "ale-scala-valid"
|
|
||||||
version := "1.0"
|
|
||||||
scalaVersion := "2.12.6"
|
|
@ -1 +0,0 @@
|
|||||||
sbt.version=1.2.1
|
|
@ -1 +0,0 @@
|
|||||||
{"uri":"tcp://127.0.0.1:5211"}
|
|
Loading…
Reference in New Issue
Block a user