summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2018-08-28 21:52:18 +0100
committerGitHub <noreply@github.com>2018-08-28 21:52:18 +0100
commit09e43ab16bc8fe7d5ddc72e904b05682587fd335 (patch)
tree74c11f647694c42f7f7d81a995f9bc7e49c3930b /autoload
parent339930ad68a16e8298b8b84ef0ab428bf7061c5f (diff)
parent1980245b94d7b997c6ba376d8a2644397afe02d6 (diff)
downloadale-09e43ab16bc8fe7d5ddc72e904b05682587fd335.zip
Merge pull request #1847 from hsanson/1846-support-solargraph-lsp
1846 support solargraph lsp
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/assert.vim13
-rw-r--r--autoload/ale/ruby.vim22
2 files changed, 35 insertions, 0 deletions
diff --git a/autoload/ale/assert.vim b/autoload/ale/assert.vim
index 87798520..a1bfd0b7 100644
--- a/autoload/ale/assert.vim
+++ b/autoload/ale/assert.vim
@@ -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
diff --git a/autoload/ale/ruby.vim b/autoload/ale/ruby.vim
index b981ded6..f0d84296 100644
--- a/autoload/ale/ruby.vim
+++ b/autoload/ale/ruby.vim
@@ -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