[Vim-latex-cvs] vimfiles/ftplugin/tex texviewer.vim,1.4,1.5
Brought to you by:
srinathava,
tmaas
|
From: <mi...@us...> - 2003-04-04 23:24:50
|
Update of /cvsroot/vim-latex/vimfiles/ftplugin/tex
In directory sc8-pr-cvs1:/tmp/cvs-serv29635
Modified Files:
texviewer.vim
Log Message:
handling of includegraphics, bibliography commands; introduction of explorer-completion; more info in latex-suite.txt - latex-completion
Index: texviewer.vim
===================================================================
RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/tex/texviewer.vim,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** texviewer.vim 3 Apr 2003 17:37:38 -0000 1.4
--- texviewer.vim 4 Apr 2003 23:24:46 -0000 1.5
***************
*** 8,19 ****
" ============================================================================
! if exists("g:Tex_Viewer")
finish
endif
! inoremap <silent> <Plug>Tex_Viewer <Esc>:call Tex_viewer("default","text")<CR>
! if !hasmapto('<Plug>Tex_Viewer', 'i')
! imap <buffer> <silent> <buffer> <F9> <Plug>Tex_Viewer
endif
--- 8,19 ----
" ============================================================================
! if exists("g:Tex_Completion")
finish
endif
! inoremap <silent> <Plug>Tex_Completion <Esc>:call Tex_completion("default","text")<CR>
! if !hasmapto('<Plug>Tex_Completion', 'i')
! imap <buffer> <silent> <F9> <Plug>Tex_Completion
endif
***************
*** 23,35 ****
function! s:Tex_lookall(what)
! call Tex_viewer(a:what, "all")
endfunction
function! s:Tex_lookbib(what)
! call Tex_viewer(a:what, "bib")
endfunction
function! s:Tex_look(what)
! call Tex_viewer(a:what, "tex")
endfunction
--- 23,35 ----
function! s:Tex_lookall(what)
! call Tex_completion(a:what, "all")
endfunction
function! s:Tex_lookbib(what)
! call Tex_completion(a:what, "bib")
endfunction
function! s:Tex_look(what)
! call Tex_completion(a:what, "tex")
endfunction
***************
*** 43,47 ****
" Description:
"
! function! Tex_viewer(what, where)
" Get info about current window and position of cursor in file
--- 43,47 ----
" Description:
"
! function! Tex_completion(what, where)
" Get info about current window and position of cursor in file
***************
*** 52,56 ****
if a:where == "text"
" What to do after <F9> depending on context
! let s:curline = strpart(getline('.'), col('.') - 20, 20)
let s:prefix = matchstr(s:curline, '{\zs.\{-}$')
let s:type = matchstr(s:curline, '\\\zs.\{-}\ze{.\{-}$')
--- 52,56 ----
if a:where == "text"
" What to do after <F9> depending on context
! let s:curline = strpart(getline('.'), col('.') - 40, 40)
let s:prefix = matchstr(s:curline, '{\zs.\{-}$')
let s:type = matchstr(s:curline, '\\\zs.\{-}\ze{.\{-}$')
***************
*** 66,71 ****
--- 66,95 ----
call <SID>Tex_c_window_setup()
+ elseif exists("s:type") && s:type =~ 'includegraphics'
+ let s:storehidefiles = g:explHideFiles
+ let g:explHideFiles = '^\.,\.tex$,\.bib$,\.bbl$,\.zip$,\.gz$$'
+ let s:curfile = expand("%:p")
+ exe 'silent! Sexplore '.s:search_directory.g:Tex_ImageDir
+ call <SID>Tex_explore_window("includegraphics")
+
+ elseif exists("s:type") && s:type =~ 'bibliography'
+ let s:storehidefiles = g:explHideFiles
+ let g:explHideFiles = '^\.,\.tex$,\.pdf$,\.eps$,\.zip$,\.gz$'
+ let s:curfile = expand("%:p")
+ exe 'silent! Sexplore '.s:search_directory
+ call <SID>Tex_explore_window("bibliography")
+
else
let s:word = matchstr(s:curline, '\zs\k\{-}$')
+ if s:word == ''
+ if col('.') == strlen(getline('.'))
+ startinsert!
+ return
+ else
+ normal! l
+ startinsert
+ return
+ endif
+ endif
exe 'silent! grep! "\<' . s:word . '" '.s:search_directory.'*.tex'
call <SID>Tex_c_window_setup()
***************
*** 110,115 ****
" Change behaviour of <cr> only for 'ref' and 'cite' context.
! if exists("s:type") && s:type =~ 'ref\|cite'
! nnoremap <buffer> <silent> <cr> :call <SID>CompleteName()<CR>
else
--- 134,142 ----
" Change behaviour of <cr> only for 'ref' and 'cite' context.
! if exists("s:type") && s:type =~ 'ref'
! nnoremap <buffer> <silent> <cr> :silent! call <SID>CompleteName("ref")<CR>
!
! elseif exists("s:type") && s:type =~ 'cite'
! nnoremap <buffer> <silent> <cr> :silent! call <SID>CompleteName("cite")<CR>
else
***************
*** 126,129 ****
--- 153,169 ----
endfunction " }}}
+ " Tex_explore_window: settings for completion of filenames {{{
+ " Description:
+ "
+ function! s:Tex_explore_window(type)
+
+ exe g:Tex_ExplorerHeight.' wincmd _'
+ if a:type == 'includegraphics'
+ nnoremap <silent> <buffer> <cr> :silent! call <SID>CompleteName("includegraphics")<CR>
+ elseif a:type == 'bibliography'
+ nnoremap <silent> <buffer> <cr> :silent! call <SID>CompleteName("bibliography")<CR>
+ endif
+
+ endfunction " }}}
" UpdateViewerWindow: update error and preview window {{{
" Description: Usually quickfix engine takes care about most of these things
***************
*** 195,201 ****
" Description: handle completion of items depending on current context
"
! function! s:CompleteName()
! if s:type =~ 'cite'
if getline('.') =~ '\\bibitem{'
let bibkey = matchstr(getline('.'), '\\bibitem{\zs.\{-}\ze}')
--- 235,241 ----
" Description: handle completion of items depending on current context
"
! function! s:CompleteName(type)
! if a:type =~ 'cite'
if getline('.') =~ '\\bibitem{'
let bibkey = matchstr(getline('.'), '\\bibitem{\zs.\{-}\ze}')
***************
*** 205,219 ****
let completeword = strpart(bibkey, strlen(s:prefix))
! elseif s:type =~ 'ref'
let label = matchstr(getline('.'), '\\label{\zs.\{-}\ze}')
let completeword = strpart(label, strlen(s:prefix))
endif
" Return to proper place in main window, close small windows
! exe s:winnum.' wincmd w'
! pclose!
! cclose
! exe s:pos
" Complete word, check if add closing }
--- 245,286 ----
let completeword = strpart(bibkey, strlen(s:prefix))
! elseif a:type =~ 'ref'
let label = matchstr(getline('.'), '\\label{\zs.\{-}\ze}')
let completeword = strpart(label, strlen(s:prefix))
+
+ elseif a:type =~ 'includegraphics\|bibliography'
+ let line = substitute(strpart(getline('.'),0,b:maxFileLen),'\s\+$','','')
+ if isdirectory(b:completePath.line)
+ call EditEntry("", "edit")
+ exe 'nnoremap <silent> <buffer> <cr> :silent! call <SID>CompleteName("'.a:type.'")<CR>'
+ let g:explHideFiles = s:storehidefiles
+ return
+
+ else
+ let ifile = substitute(line, '\..\{-}$', '', '')
+ let filename = b:completePath.ifile
+
+ if g:Tex_ImageDir != '' && a:type =~ 'includegraphics'
+ let imagedir = s:curfile . g:Tex_ImageDir
+ let completeword = <SID>Tex_RelPath(filename, imagedir)
+ else
+ let completeword = <SID>Tex_RelPath(filename, s:curfile)
+ endif
+
+ let g:explHideFiles = s:storehidefiles
+ endif
endif
" Return to proper place in main window, close small windows
! if s:type =~ 'cite\|ref'
! exe s:winnum.' wincmd w'
! pclose!
! cclose
! exe s:pos
! elseif s:type =~ 'includegraphics\|bibliography'
! wincmd q
! exe s:pos
! endif
" Complete word, check if add closing }
***************
*** 246,250 ****
endfunction " }}}
! let g:Tex_Viewer = 1
" this statement has to be at the end.
let s:doneOnce = 1
--- 313,350 ----
endfunction " }}}
! " Tex_Common: common part of strings {{{
! function! s:Tex_Common(path1, path2)
! " Assume the caller handles 'ignorecase'
! if a:path1 == a:path2
! return a:path1
! endif
! let n = 0
! while a:path1[n] == a:path2[n]
! let n = n+1
! endwhile
! return strpart(a:path1, 0, n)
! endfunction " }}}
! " Tex_RelPath: ultimate file name {{{
! function! s:Tex_RelPath(explfilename,texfilename)
! let path1 = a:explfilename
! let path2 = a:texfilename
! if has("win32")
! let path1 = substitute(path1, '\\', '/', 'ge')
! let path2 = substitute(path2, '\\', '/', 'ge')
! endif
! let n = matchend(<SID>Tex_Common(path1, path2), '.*/')
! let path1 = strpart(path1, n)
! let path2 = strpart(path2, n)
! if path2 !~ '/'
! let subrelpath = ''
! else
! let subrelpath = substitute(path2, '[^/]\{-}/', '../', 'ge')
! let subrelpath = substitute(subrelpath, '[^/]*$', '', 'ge')
! endif
! let relpath = subrelpath.path1
! return relpath
! endfunction " }}}
!
! let g:Tex_Completion = 1
" this statement has to be at the end.
let s:doneOnce = 1
|