summaryrefslogtreecommitdiff
path: root/autoload/ale/ruby.vim
diff options
context:
space:
mode:
Diffstat (limited to 'autoload/ale/ruby.vim')
-rw-r--r--autoload/ale/ruby.vim22
1 files changed, 22 insertions, 0 deletions
diff --git a/autoload/ale/ruby.vim b/autoload/ale/ruby.vim
index b981ded6..5f0aa50d 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 ['.solargraph.yml', '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