Merge pull request #1847 from hsanson/1846-support-solargraph-lsp
1846 support solargraph lsp
This commit is contained in:
commit
09e43ab16b
@ -167,7 +167,7 @@ formatting.
|
|||||||
| reStructuredText | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [rstcheck](https://github.com/myint/rstcheck), [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) |
|
| reStructuredText | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [rstcheck](https://github.com/myint/rstcheck), [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) |
|
||||||
| Re:VIEW | [redpen](http://redpen.cc/) |
|
| Re:VIEW | [redpen](http://redpen.cc/) |
|
||||||
| RPM spec | [rpmlint](https://github.com/rpm-software-management/rpmlint) (disabled by default; see `:help ale-integration-spec`) |
|
| RPM spec | [rpmlint](https://github.com/rpm-software-management/rpmlint) (disabled by default; see `:help ale-integration-spec`) |
|
||||||
| Ruby | [brakeman](http://brakemanscanner.org/) !!, [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) !!, [reek](https://github.com/troessner/reek), [rubocop](https://github.com/bbatsov/rubocop), [ruby](https://www.ruby-lang.org), [rufo](https://github.com/ruby-formatter/rufo) |
|
| Ruby | [brakeman](http://brakemanscanner.org/) !!, [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) !!, [reek](https://github.com/troessner/reek), [rubocop](https://github.com/bbatsov/rubocop), [ruby](https://www.ruby-lang.org), [rufo](https://github.com/ruby-formatter/rufo), [solargraph]([solargraph](https://solargraph.org) |
|
||||||
| Rust | cargo !! (see `:help ale-integration-rust` for configuration instructions), [rls](https://github.com/rust-lang-nursery/rls), [rustc](https://www.rust-lang.org/), [rustfmt](https://github.com/rust-lang-nursery/rustfmt) |
|
| Rust | cargo !! (see `:help ale-integration-rust` for configuration instructions), [rls](https://github.com/rust-lang-nursery/rls), [rustc](https://www.rust-lang.org/), [rustfmt](https://github.com/rust-lang-nursery/rustfmt) |
|
||||||
| SASS | [sass-lint](https://www.npmjs.com/package/sass-lint), [stylelint](https://github.com/stylelint/stylelint) |
|
| SASS | [sass-lint](https://www.npmjs.com/package/sass-lint), [stylelint](https://github.com/stylelint/stylelint) |
|
||||||
| SCSS | [prettier](https://github.com/prettier/prettier), [sass-lint](https://www.npmjs.com/package/sass-lint), [scss-lint](https://github.com/brigade/scss-lint), [stylelint](https://github.com/stylelint/stylelint) |
|
| SCSS | [prettier](https://github.com/prettier/prettier), [sass-lint](https://www.npmjs.com/package/sass-lint), [scss-lint](https://github.com/brigade/scss-lint), [stylelint](https://github.com/stylelint/stylelint) |
|
||||||
|
19
ale_linters/ruby/solargraph.vim
Normal file
19
ale_linters/ruby/solargraph.vim
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
" Author: Horacio Sanson - https://github.com/hsanson
|
||||||
|
" Description: Solargraph Language Server https://solargraph.org/
|
||||||
|
|
||||||
|
call ale#Set('ruby_solargraph_host', '127.0.0.1')
|
||||||
|
call ale#Set('ruby_solargraph_port', '7658')
|
||||||
|
|
||||||
|
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
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('ruby', {
|
||||||
|
\ 'name': 'solargraph',
|
||||||
|
\ 'lsp': 'socket',
|
||||||
|
\ 'address_callback': 'ale_linters#ruby#solargraph#GetAddress',
|
||||||
|
\ 'language': 'ruby',
|
||||||
|
\ 'project_root_callback': 'ale#ruby#FindProjectRoot'
|
||||||
|
\})
|
@ -101,6 +101,14 @@ function! ale#assert#LSPProject(expected_root) abort
|
|||||||
AssertEqual a:expected_root, l:root
|
AssertEqual a:expected_root, l:root
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! ale#assert#LSPAddress(expected_address) abort
|
||||||
|
let l:buffer = bufnr('')
|
||||||
|
let l:linter = s:GetLinter()
|
||||||
|
let l:address = ale#util#GetFunction(l:linter.address_callback)(l:buffer)
|
||||||
|
|
||||||
|
AssertEqual a:expected_address, l:address
|
||||||
|
endfunction
|
||||||
|
|
||||||
" A dummy function for making sure this module is loaded.
|
" A dummy function for making sure this module is loaded.
|
||||||
function! ale#assert#SetUpLinterTest(filetype, name) abort
|
function! ale#assert#SetUpLinterTest(filetype, name) abort
|
||||||
" Set up a marker so ALE doesn't create real random temporary filenames.
|
" Set up a marker so ALE doesn't create real random temporary filenames.
|
||||||
@ -141,6 +149,7 @@ function! ale#assert#SetUpLinterTest(filetype, name) abort
|
|||||||
command! -nargs=+ AssertLSPOptions :call ale#assert#LSPOptions(<args>)
|
command! -nargs=+ AssertLSPOptions :call ale#assert#LSPOptions(<args>)
|
||||||
command! -nargs=+ AssertLSPLanguage :call ale#assert#LSPLanguage(<args>)
|
command! -nargs=+ AssertLSPLanguage :call ale#assert#LSPLanguage(<args>)
|
||||||
command! -nargs=+ AssertLSPProject :call ale#assert#LSPProject(<args>)
|
command! -nargs=+ AssertLSPProject :call ale#assert#LSPProject(<args>)
|
||||||
|
command! -nargs=+ AssertLSPAddress :call ale#assert#LSPAddress(<args>)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#assert#TearDownLinterTest() abort
|
function! ale#assert#TearDownLinterTest() abort
|
||||||
@ -171,6 +180,10 @@ function! ale#assert#TearDownLinterTest() abort
|
|||||||
delcommand AssertLSPProject
|
delcommand AssertLSPProject
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if exists(':AssertLSPAddress')
|
||||||
|
delcommand AssertLSPAddress
|
||||||
|
endif
|
||||||
|
|
||||||
if exists('g:dir')
|
if exists('g:dir')
|
||||||
call ale#test#RestoreDirectory()
|
call ale#test#RestoreDirectory()
|
||||||
endif
|
endif
|
||||||
|
@ -20,3 +20,25 @@ function! ale#ruby#FindRailsRoot(buffer) abort
|
|||||||
|
|
||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Find the nearest dir containing a potential ruby project.
|
||||||
|
function! ale#ruby#FindProjectRoot(buffer) abort
|
||||||
|
let l:dir = ale#ruby#FindRailsRoot(a:buffer)
|
||||||
|
|
||||||
|
if isdirectory(l:dir)
|
||||||
|
return l:dir
|
||||||
|
endif
|
||||||
|
|
||||||
|
for l:name in ['Rakefile', 'Gemfile']
|
||||||
|
let l:dir = fnamemodify(
|
||||||
|
\ ale#path#FindNearestFile(a:buffer, l:name),
|
||||||
|
\ ':h'
|
||||||
|
\)
|
||||||
|
|
||||||
|
if l:dir isnot# '.' && isdirectory(l:dir)
|
||||||
|
return l:dir
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
@ -307,6 +307,7 @@ given the above setup are as follows.
|
|||||||
`AssertLSPLanguage language` - Check the language given to an LSP server.
|
`AssertLSPLanguage language` - Check the language given to an LSP server.
|
||||||
`AssertLSPOptions options_dict` - Check the options given to an LSP server.
|
`AssertLSPOptions options_dict` - Check the options given to an LSP server.
|
||||||
`AssertLSPProject project_root` - Check the root given to an LSP server.
|
`AssertLSPProject project_root` - Check the root given to an LSP server.
|
||||||
|
`AssertLSPAddress address` - Check the address to an LSP server.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
|
@ -98,5 +98,23 @@ g:ale_ruby_rufo_executable *g:ale_ruby_rufo_executable*
|
|||||||
binstubs or a bundle.
|
binstubs or a bundle.
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
solargraph *ale-ruby-solargraph*
|
||||||
|
|
||||||
|
g:ale_ruby_solargraph_host *g:ale_ruby_solargraph_host*
|
||||||
|
*b:ale_ruby_solargraph_host*
|
||||||
|
Type: String
|
||||||
|
Default: `'127.0.0.1'`
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
|
@ -237,6 +237,7 @@ CONTENTS *ale-contents*
|
|||||||
rubocop.............................|ale-ruby-rubocop|
|
rubocop.............................|ale-ruby-rubocop|
|
||||||
ruby................................|ale-ruby-ruby|
|
ruby................................|ale-ruby-ruby|
|
||||||
rufo................................|ale-ruby-rufo|
|
rufo................................|ale-ruby-rufo|
|
||||||
|
solargraph..........................|ale-ruby-solargraph|
|
||||||
rust..................................|ale-rust-options|
|
rust..................................|ale-rust-options|
|
||||||
cargo...............................|ale-rust-cargo|
|
cargo...............................|ale-rust-cargo|
|
||||||
rls.................................|ale-rust-rls|
|
rls.................................|ale-rust-rls|
|
||||||
@ -422,7 +423,7 @@ Notes:
|
|||||||
* reStructuredText: `alex`!!, `proselint`, `redpen`, `rstcheck`, `vale`, `write-good`
|
* reStructuredText: `alex`!!, `proselint`, `redpen`, `rstcheck`, `vale`, `write-good`
|
||||||
* Re:VIEW: `redpen`
|
* Re:VIEW: `redpen`
|
||||||
* RPM spec: `rpmlint`
|
* RPM spec: `rpmlint`
|
||||||
* Ruby: `brakeman`, `rails_best_practices`!!, `reek`, `rubocop`, `ruby`, `rufo`
|
* Ruby: `brakeman`, `rails_best_practices`!!, `reek`, `rubocop`, `ruby`, `rufo`, `solargraph`
|
||||||
* Rust: `cargo`!!, `rls`, `rustc` (see |ale-integration-rust|), `rustfmt`
|
* Rust: `cargo`!!, `rls`, `rustc` (see |ale-integration-rust|), `rustfmt`
|
||||||
* SASS: `sass-lint`, `stylelint`
|
* SASS: `sass-lint`, `stylelint`
|
||||||
* SCSS: `prettier`, `sass-lint`, `scss-lint`, `stylelint`
|
* SCSS: `prettier`, `sass-lint`, `scss-lint`, `stylelint`
|
||||||
|
29
test/command_callback/test_ruby_solargraph.vader
Normal file
29
test/command_callback/test_ruby_solargraph.vader
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
" Author: Horacio Sanson <https://github.com/hsanson>
|
||||||
|
" Description: Tests for solargraph lsp linter.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
call ale#assert#SetUpLinterTest('ruby', 'solargraph')
|
||||||
|
|
||||||
|
After:
|
||||||
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
|
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'
|
0
test/ruby_fixtures/valid_ruby_app1/Rakefile
Normal file
0
test/ruby_fixtures/valid_ruby_app1/Rakefile
Normal file
0
test/ruby_fixtures/valid_ruby_app1/lib/file.rb
Normal file
0
test/ruby_fixtures/valid_ruby_app1/lib/file.rb
Normal file
0
test/ruby_fixtures/valid_ruby_app2/Gemfile
Normal file
0
test/ruby_fixtures/valid_ruby_app2/Gemfile
Normal file
0
test/ruby_fixtures/valid_ruby_app2/lib/file.rb
Normal file
0
test/ruby_fixtures/valid_ruby_app2/lib/file.rb
Normal file
Loading…
Reference in New Issue
Block a user