Slightly better bibtex_find_bibs
This commit is contained in:
parent
7152088e22
commit
3e1043cd4a
@ -190,30 +190,30 @@ function! s:bibtex_find_bibs(...)
|
|||||||
|
|
||||||
"
|
"
|
||||||
" Search for added bibliographies
|
" Search for added bibliographies
|
||||||
|
" * Parse commands such as \bibliography{file1,file2.bib,...}
|
||||||
|
" * This also removes the .bib extensions
|
||||||
"
|
"
|
||||||
let bibliography_cmds = [
|
let bibsearch = '''\v\C\\'
|
||||||
\ '\\bibliography',
|
let bibsearch .= '(bibliography|add(bibresource|globalbib|sectionbib))'
|
||||||
\ '\\addbibresource',
|
let bibsearch .= '\m\s*{\zs[^}]\+\ze}'''
|
||||||
\ '\\addglobalbib',
|
for entry in map(filter(copy(lines),
|
||||||
\ '\\addsectionbib',
|
\ 'v:val =~ ' . bibsearch),
|
||||||
\ ]
|
\ 'matchstr(v:val, ' . bibsearch . ')')
|
||||||
for cmd in bibliography_cmds
|
let bibdata_list += map(split(entry, ','), 'fnamemodify(v:val, '':r'')')
|
||||||
let filter = 'v:val =~ ''\C' . cmd . '\s*{[^}]\+}'''
|
|
||||||
let map = 'matchstr(v:val, ''\C' . cmd . '\s*{\zs[^}]\+\ze}'')'
|
|
||||||
let bibdata_list += map(filter(copy(lines), filter), map)
|
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
"
|
"
|
||||||
" Also search included files
|
" Recursively search included files
|
||||||
"
|
"
|
||||||
for input in filter(lines, 'v:val =~ ''\C\\\%(input\|include\)\s*{[^}]\+}''')
|
let incsearch = '''\C\\'
|
||||||
let bibdata_list += s:bibtex_find_bibs(latex#util#kpsewhich(
|
let incsearch .= '\%(input\|include\)'
|
||||||
\ matchstr(input, '\C\\\%(input\|include\)\s*{\zs[^}]\+\ze}')))
|
let incsearch .= '\s*{\zs[^}]\+\ze}'''
|
||||||
|
for entry in map(filter(lines,
|
||||||
|
\ 'v:val =~ ' . incsearch),
|
||||||
|
\ 'matchstr(v:val, ' . incsearch . ')')
|
||||||
|
let bibdata_list += s:bibtex_find_bibs(latex#util#kpsewhich(entry))
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
"
|
|
||||||
" Make all entries full paths
|
|
||||||
"
|
|
||||||
return bibdata_list
|
return bibdata_list
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user