Don't assume src/ in Leiningen projects

Fun fact: it's impossible to reliably predict whether a given
project.clj is a Leiningen project file or not.

Closes #51.
This commit is contained in:
Tim Pope 2013-02-10 11:48:48 -05:00
parent eff7bcec61
commit 9749177034

View File

@ -1112,14 +1112,14 @@ endfunction
" }}}1
" Leiningen {{{1
function! s:hunt(start, anchor) abort
function! s:hunt(start, anchor, pattern) abort
let root = simplify(fnamemodify(a:start, ':p:s?[\/]$??'))
if !isdirectory(fnamemodify(root, ':h'))
return ''
endif
let previous = ""
while root !=# previous
if filereadable(root . '/' . a:anchor) && isdirectory(root . '/src')
if filereadable(root . '/' . a:anchor) && join(readfile(root . '/' . a:anchor, '', 50)) =~# a:pattern
return root
endif
let previous = root
@ -1151,7 +1151,7 @@ endfunction
function! s:leiningen_init() abort
if !exists('b:leiningen_root')
let root = s:hunt(expand('%:p'), 'project.clj')
let root = s:hunt(expand('%:p'), 'project.clj', '(\s*defproject')
if root !=# ''
let b:leiningen_root = root
endif