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
1 changed files with 3 additions and 3 deletions

View File

@ -1112,14 +1112,14 @@ endfunction
" }}}1 " }}}1
" Leiningen {{{1 " Leiningen {{{1
function! s:hunt(start, anchor) abort function! s:hunt(start, anchor, pattern) abort
let root = simplify(fnamemodify(a:start, ':p:s?[\/]$??')) let root = simplify(fnamemodify(a:start, ':p:s?[\/]$??'))
if !isdirectory(fnamemodify(root, ':h')) if !isdirectory(fnamemodify(root, ':h'))
return '' return ''
endif endif
let previous = "" let previous = ""
while root !=# 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 return root
endif endif
let previous = root let previous = root
@ -1151,7 +1151,7 @@ endfunction
function! s:leiningen_init() abort function! s:leiningen_init() abort
if !exists('b:leiningen_root') 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 !=# '' if root !=# ''
let b:leiningen_root = root let b:leiningen_root = root
endif endif