Solargraph stdio

This commit is contained in:
Devon Meunier 2018-09-18 10:33:22 -04:00
parent ddb3e6d57a
commit 4025030d86
No known key found for this signature in database
GPG Key ID: 06F46EF9E8E8F944
3 changed files with 22 additions and 25 deletions

View File

@ -1,20 +1,20 @@
" Author: Horacio Sanson - https://github.com/hsanson " Author: Horacio Sanson - https://github.com/hsanson
" Description: Solargraph Language Server https://solargraph.org/ " Description: Solargraph Language Server https://solargraph.org/
"
" Author: Devon Meunier <devon.meunier@gmail.com>
" Description: updated to use stdio
call ale#Set('ruby_solargraph_host', '127.0.0.1') call ale#Set('ruby_solargraph_executable', 'solargraph')
call ale#Set('ruby_solargraph_port', '7658')
function! ale_linters#ruby#solargraph#GetAddress(buffer) abort function! ale_linters#ruby#solargraph#GetCommand(buffer) abort
let l:host = ale#Var(a:buffer, 'ruby_solargraph_host') return '%e' . ale#Pad('stdio')
let l:port = ale#Var(a:buffer, 'ruby_solargraph_port')
return l:host . ':' . l:port
endfunction endfunction
call ale#linter#Define('ruby', { call ale#linter#Define('ruby', {
\ 'name': 'solargraph', \ 'name': 'solargraph',
\ 'lsp': 'socket', \ 'lsp': 'stdio',
\ 'address_callback': 'ale_linters#ruby#solargraph#GetAddress',
\ 'language': 'ruby', \ 'language': 'ruby',
\ 'project_root_callback': 'ale#ruby#FindProjectRoot' \ 'executable_callback': ale#VarFunc('ruby_solargraph_executable'),
\ 'command_callback': 'ale_linters#ruby#solargraph#GetCommand',
\ 'project_root_callback': 'ale#ruby#FindProjectRoot',
\}) \})

View File

@ -120,19 +120,13 @@ g:ale_ruby_rufo_executable *g:ale_ruby_rufo_executable*
=============================================================================== ===============================================================================
solargraph *ale-ruby-solargraph* solargraph *ale-ruby-solargraph*
g:ale_ruby_solargraph_host *g:ale_ruby_solargraph_host* g:ale_ruby_solargraph_executable *g:ale_ruby_solargraph_executable*
*b:ale_ruby_solargraph_host* *b:ale_ruby_solargraph_executable*
Type: String Type: String
Default: `'127.0.0.1'` Default: `'solargraph'`
The host/ip where the solargraph language server is running. Override the invoked solargraph binary. This is useful for running rufo from
binstubs or a bundle.
g:ale_ruby_solargraph_port *g:ale_ruby_solargraph_port*
*b:ale_ruby_solargraph_port*
Type: String
Default: `'7658'`
The listening port where the solargraph language server is running.
=============================================================================== ===============================================================================

View File

@ -7,30 +7,33 @@ Before:
After: After:
call ale#assert#TearDownLinterTest() call ale#assert#TearDownLinterTest()
Execute(command callback should return default string):
AssertLinter 'solargraph', ale#Escape('solargraph') . ' stdio'
Execute(command callback executable can be overridden):
let g:ale_ruby_solargraph_executable = 'foobar'
AssertLinter 'foobar', ale#Escape('foobar') . ' stdio'
Execute(should set solargraph for rails app): Execute(should set solargraph for rails app):
call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/models/thing.rb') call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/models/thing.rb')
AssertLSPLanguage 'ruby' AssertLSPLanguage 'ruby'
AssertLSPOptions {} AssertLSPOptions {}
AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_rails_app') AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_rails_app')
AssertLSPAddress '127.0.0.1:7658'
Execute(should set solargraph for ruby app1): Execute(should set solargraph for ruby app1):
call ale#test#SetFilename('../ruby_fixtures/valid_ruby_app1/lib/file.rb') call ale#test#SetFilename('../ruby_fixtures/valid_ruby_app1/lib/file.rb')
AssertLSPLanguage 'ruby' AssertLSPLanguage 'ruby'
AssertLSPOptions {} AssertLSPOptions {}
AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_ruby_app1') AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_ruby_app1')
AssertLSPAddress '127.0.0.1:7658'
Execute(should set solargraph for ruby app2): Execute(should set solargraph for ruby app2):
call ale#test#SetFilename('../ruby_fixtures/valid_ruby_app2/lib/file.rb') call ale#test#SetFilename('../ruby_fixtures/valid_ruby_app2/lib/file.rb')
AssertLSPLanguage 'ruby' AssertLSPLanguage 'ruby'
AssertLSPOptions {} AssertLSPOptions {}
AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_ruby_app2') AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_ruby_app2')
AssertLSPAddress '127.0.0.1:7658'
Execute(should set solargraph for ruby app3): Execute(should set solargraph for ruby app3):
call ale#test#SetFilename('../ruby_fixtures/valid_ruby_app3/lib/file.rb') call ale#test#SetFilename('../ruby_fixtures/valid_ruby_app3/lib/file.rb')
AssertLSPLanguage 'ruby' AssertLSPLanguage 'ruby'
AssertLSPOptions {} AssertLSPOptions {}
AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_ruby_app3') AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_ruby_app3')
AssertLSPAddress '127.0.0.1:7658'