Update of /cvsroot/vim-latex/vimfiles/ftplugin/tex
In directory sc8-pr-cvs1:/tmp/cvs-serv3456
Modified Files:
texviewer.vim
Log Message:
completion is now pluginable through PromptFor mechanism, added completion for addcontentsline, addtocontents, bibliographystyle
Index: texviewer.vim
===================================================================
RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/tex/texviewer.vim,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** texviewer.vim 11 Apr 2003 11:27:25 -0000 1.8
--- texviewer.vim 11 Apr 2003 16:41:50 -0000 1.9
***************
*** 40,43 ****
--- 40,50 ----
endif
+ " CompletionVars: similar variables can be set in package files
+ let g:Tex_completion_bibliographystyle = 'abbr,alpha,plain,unsrt'
+ let g:Tex_completion_addtocontents = 'lof}{,lot}{,toc}{'
+ let g:Tex_completion_addcontentsline = 'lof}{figure}{,lot}{table}{,toc}{chapter}{,toc}{part}{,'.
+ \ 'toc}{section}{,toc}{subsection}{,toc}{paragraph}{,'.
+ \ 'toc}{subparagraph}{'
+
" Tex_viewer: main function {{{
" Description:
***************
*** 55,58 ****
--- 62,66 ----
let s:prefix = matchstr(s:curline, '{\zs.\{-}$')
let s:type = matchstr(s:curline, '\\\zs.\{-}\ze{.\{-}$')
+ let g:type1 = s:type
if exists("s:type") && s:type =~ 'ref'
***************
*** 81,87 ****
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
--- 89,95 ----
call <SID>Tex_explore_window("includegraphics")
! elseif exists("s:type") && s:type == 'bibliography'
let s:storehidefiles = g:explHideFiles
! let g:explHideFiles = '^\.,\.[^b]..$'
let s:curfile = expand("%:p")
exe 'silent! Sexplore '.s:search_directory
***************
*** 100,103 ****
--- 108,115 ----
call <SID>Tex_explore_window("input")
+ elseif exists("g:Tex_completion_{s:type}")
+ let g:type = s:type
+ call <SID>CompleteName('plugin_'.s:type)
+
else
let s:word = matchstr(s:curline, '\zs\k\{-}$')
***************
*** 275,279 ****
let completeword = strpart(label, strlen(s:prefix))
! elseif a:type =~ 'includegraphics\|bibliography\|includefile\|input'
let line = substitute(strpart(getline('.'),0,b:maxFileLen),'\s\+$','','')
if isdirectory(b:completePath.line)
--- 287,291 ----
let completeword = strpart(label, strlen(s:prefix))
! elseif a:type =~ 'includegraphics\|\<bibliography\>\|includefile\|\<input\>'
let line = substitute(strpart(getline('.'),0,b:maxFileLen),'\s\+$','','')
if isdirectory(b:completePath.line)
***************
*** 300,303 ****
--- 312,320 ----
let g:explHideFiles = s:storehidefiles
endif
+
+ elseif a:type =~ '^plugin_'
+ let type = substitute(a:type, '^plugin_', '', '')
+ let completeword = Tex_DoCompletion(type)
+ let g:comp = completeword
endif
***************
*** 308,321 ****
pclose!
cclose
! exe s:pos
! elseif s:type =~ 'bibliography\|include\|input'
wincmd q
- exe s:pos
endif
" Complete word, check if add closing }
exe 'normal! a'.completeword."\<Esc>"
! if getline('.')[col('.')] != '}'
exe "normal! a}\<Esc>"
endif
--- 325,340 ----
pclose!
cclose
! elseif s:type =~ '\<bibliography\>\|include\|input'
wincmd q
endif
+ exe s:pos
+
" Complete word, check if add closing }
exe 'normal! a'.completeword."\<Esc>"
+ let g:cword = completeword
+ let g:cwlast = getline('.')[col('.')-1]
! if getline('.')[col('.')-1] !~ '{' && getline('.')[col('.')] !~ '}'
exe "normal! a}\<Esc>"
endif
***************
*** 405,408 ****
--- 424,455 ----
endfunction " }}}
+ " PromptForCompletion: prompts for a completion {{{
+ " Description:
+ function! PromptForCompletion(texcommand,ask)
+
+ let common_completion_prompt =
+ \ Tex_CreatePrompt(g:Tex_completion_{a:texcommand}, 2, ',') . "\n" .
+ \ 'Enter number or completion : '
+
+ let inp = input(a:ask."\n".common_completion_prompt)
+ if inp =~ '^[0-9]\+$'
+ let completion = Tex_Strntok(g:Tex_completion_{a:texcommand}, ',', inp)
+ else
+ let completion = inp
+ endif
+
+ return completion
+ endfunction " }}}
+ " Tex_DoCompletion: fast insertion of completion {{{
+ " Description:
+ "
+ function! Tex_DoCompletion(texcommand)
+ let completion = PromptForCompletion(a:texcommand,'Choose a completion to insert: ')
+ if completion != ''
+ return completion
+ else
+ return ''
+ endif
+ endfunction " }}}
" Tex_Common: common part of strings {{{
|