summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2016-10-23 13:04:41 +0100
committerw0rp <devw0rp@gmail.com>2016-10-23 13:04:41 +0100
commit36461b69d7dbf0abe494cd450dd9233eed7b672f (patch)
treef1e7ea352041889d94df362f77474c9b083998f0 /autoload
parentf94865c4ce2a61e304faf5aa99d643b44260fde5 (diff)
downloadale-36461b69d7dbf0abe494cd450dd9233eed7b672f.zip
Support loading eslint from node_modules, re issue #118.
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/util.vim15
1 files changed, 15 insertions, 0 deletions
diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim
index 82bed85a..969e1e30 100644
--- a/autoload/ale/util.vim
+++ b/autoload/ale/util.vim
@@ -44,6 +44,21 @@ function! ale#util#FindNearestFile(buffer, filename) abort
return ''
endfunction
+" Given a buffer, a string to search for, an a global fallback for when
+" the search fails, look for a file in parent paths, and if that fails,
+" use the global fallback path instead.
+function! ale#util#ResolveLocalPath(buffer, search_string, global_fallback) abort
+ " Search for a locally installed file first.
+ let l:path = ale#util#FindNearestFile(a:buffer, a:search_string)
+
+ " If the serach fails, try the global executable instead.
+ if empty(l:path)
+ let l:path = a:global_fallback
+ endif
+
+ return l:path
+endfunction
+
function! ale#util#GetFunction(string_or_ref) abort
if type(a:string_or_ref) == type('')
return function(a:string_or_ref)