diff options
-rw-r--r-- | ale_linters/ruby/solargraph.vim | 20 | ||||
-rw-r--r-- | doc/ale-ruby.txt | 16 | ||||
-rw-r--r-- | test/command_callback/test_ruby_solargraph.vader | 11 |
3 files changed, 22 insertions, 25 deletions
diff --git a/ale_linters/ruby/solargraph.vim b/ale_linters/ruby/solargraph.vim index 2aad3af6..7ca0399f 100644 --- a/ale_linters/ruby/solargraph.vim +++ b/ale_linters/ruby/solargraph.vim @@ -1,20 +1,20 @@ " Author: Horacio Sanson - https://github.com/hsanson " 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_port', '7658') +call ale#Set('ruby_solargraph_executable', 'solargraph') -function! ale_linters#ruby#solargraph#GetAddress(buffer) abort - let l:host = ale#Var(a:buffer, 'ruby_solargraph_host') - let l:port = ale#Var(a:buffer, 'ruby_solargraph_port') - - return l:host . ':' . l:port +function! ale_linters#ruby#solargraph#GetCommand(buffer) abort + return '%e' . ale#Pad('stdio') endfunction call ale#linter#Define('ruby', { \ 'name': 'solargraph', -\ 'lsp': 'socket', -\ 'address_callback': 'ale_linters#ruby#solargraph#GetAddress', +\ 'lsp': 'stdio', \ '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', \}) diff --git a/doc/ale-ruby.txt b/doc/ale-ruby.txt index 810a1d45..c0e521c3 100644 --- a/doc/ale-ruby.txt +++ b/doc/ale-ruby.txt @@ -120,19 +120,13 @@ g:ale_ruby_rufo_executable *g:ale_ruby_rufo_executable* =============================================================================== solargraph *ale-ruby-solargraph* -g:ale_ruby_solargraph_host *g:ale_ruby_solargraph_host* - *b:ale_ruby_solargraph_host* +g:ale_ruby_solargraph_executable *g:ale_ruby_solargraph_executable* + *b:ale_ruby_solargraph_executable* Type: String - Default: `'127.0.0.1'` + Default: `'solargraph'` - The host/ip where the solargraph language server is running. - -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. + Override the invoked solargraph binary. This is useful for running rufo from + binstubs or a bundle. =============================================================================== diff --git a/test/command_callback/test_ruby_solargraph.vader b/test/command_callback/test_ruby_solargraph.vader index b9dd46d8..b39f686e 100644 --- a/test/command_callback/test_ruby_solargraph.vader +++ b/test/command_callback/test_ruby_solargraph.vader @@ -7,30 +7,33 @@ Before: After: 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): call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/models/thing.rb') AssertLSPLanguage 'ruby' AssertLSPOptions {} 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): call ale#test#SetFilename('../ruby_fixtures/valid_ruby_app1/lib/file.rb') AssertLSPLanguage 'ruby' AssertLSPOptions {} 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): call ale#test#SetFilename('../ruby_fixtures/valid_ruby_app2/lib/file.rb') AssertLSPLanguage 'ruby' AssertLSPOptions {} 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): call ale#test#SetFilename('../ruby_fixtures/valid_ruby_app3/lib/file.rb') AssertLSPLanguage 'ruby' AssertLSPOptions {} AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_ruby_app3') - AssertLSPAddress '127.0.0.1:7658' |