mirror of https://github.com/dense-analysis/ale
Add solargraph LSP linter.
This commit is contained in:
parent
3c85c7ef65
commit
1980245b94
|
@ -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) |
|
||||
| Re:VIEW | [redpen](http://redpen.cc/) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
|
|
|
@ -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
|
||||
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.
|
||||
function! ale#assert#SetUpLinterTest(filetype, name) abort
|
||||
" 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=+ AssertLSPLanguage :call ale#assert#LSPLanguage(<args>)
|
||||
command! -nargs=+ AssertLSPProject :call ale#assert#LSPProject(<args>)
|
||||
command! -nargs=+ AssertLSPAddress :call ale#assert#LSPAddress(<args>)
|
||||
endfunction
|
||||
|
||||
function! ale#assert#TearDownLinterTest() abort
|
||||
|
@ -171,6 +180,10 @@ function! ale#assert#TearDownLinterTest() abort
|
|||
delcommand AssertLSPProject
|
||||
endif
|
||||
|
||||
if exists(':AssertLSPAddress')
|
||||
delcommand AssertLSPAddress
|
||||
endif
|
||||
|
||||
if exists('g:dir')
|
||||
call ale#test#RestoreDirectory()
|
||||
endif
|
||||
|
|
|
@ -20,3 +20,25 @@ function! ale#ruby#FindRailsRoot(buffer) abort
|
|||
|
||||
return ''
|
||||
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.
|
||||
`AssertLSPOptions options_dict` - Check the options 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:
|
||||
|
|
|
@ -98,5 +98,23 @@ g:ale_ruby_rufo_executable *g:ale_ruby_rufo_executable*
|
|||
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:
|
||||
|
|
|
@ -237,6 +237,7 @@ CONTENTS *ale-contents*
|
|||
rubocop.............................|ale-ruby-rubocop|
|
||||
ruby................................|ale-ruby-ruby|
|
||||
rufo................................|ale-ruby-rufo|
|
||||
solargraph..........................|ale-ruby-solargraph|
|
||||
rust..................................|ale-rust-options|
|
||||
cargo...............................|ale-rust-cargo|
|
||||
rls.................................|ale-rust-rls|
|
||||
|
@ -422,7 +423,7 @@ Notes:
|
|||
* reStructuredText: `alex`!!, `proselint`, `redpen`, `rstcheck`, `vale`, `write-good`
|
||||
* Re:VIEW: `redpen`
|
||||
* 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`
|
||||
* SASS: `sass-lint`, `stylelint`
|
||||
* SCSS: `prettier`, `sass-lint`, `scss-lint`, `stylelint`
|
||||
|
|
|
@ -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'
|
Loading…
Reference in New Issue