diff options
Diffstat (limited to 'ftplugin')
23 files changed, 8700 insertions, 0 deletions
diff --git a/ftplugin/bib_latexSuite.vim b/ftplugin/bib_latexSuite.vim new file mode 100644 index 00000000..7a8d47d1 --- /dev/null +++ b/ftplugin/bib_latexSuite.vim @@ -0,0 +1,15 @@ +" File: bib_latexSuite.vim +" Author: Srinath Avadhanula +" License: Vim Charityware License +" Description: +" This file sources the bibtex.vim file distributed as part of latex-suite. +" That file sets up 3 maps BBB, BAS, and BBA which are easy wasy to type in +" bibliographic entries. +" + +" source main.vim because we need a few functions from it. +runtime ftplugin/latex-suite/main.vim +" Disable smart-quotes because we need to enter real quotes in bib files. +runtime ftplugin/latex-suite/bibtex.vim + +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4:nowrap diff --git a/ftplugin/latex-suite/bibtex.vim b/ftplugin/latex-suite/bibtex.vim new file mode 100644 index 00000000..2cc81995 --- /dev/null +++ b/ftplugin/latex-suite/bibtex.vim @@ -0,0 +1,265 @@ +"============================================================================= +" File: bibtex.vim +" Function: BibT +" Author: Alan G Isaac <aisaac@american.edu> +" modified by Srinath Avadhanula for latex-suite. +" License: Vim Charityware license. +"============================================================================= + +" Fields: +" Define what field type each letter denotes {{{ +" +let s:w_standsfor = 'address' +let s:a_standsfor = 'author' +let s:b_standsfor = 'booktitle' +let s:c_standsfor = 'chapter' +let s:d_standsfor = 'edition' +let s:e_standsfor = 'editor' +let s:h_standsfor = 'howpublished' +let s:i_standsfor = 'institution' +let s:k_standsfor = 'isbn' +let s:j_standsfor = 'journal' +let s:m_standsfor = 'month' +let s:n_standsfor = 'number' +let s:o_standsfor = 'organization' +let s:p_standsfor = 'pages' +let s:q_standsfor = 'publisher' +let s:r_standsfor = 'school' +let s:s_standsfor = 'series' +let s:t_standsfor = 'title' +let s:u_standsfor = 'type' +let s:v_standsfor = 'volume' +let s:y_standsfor = 'year' +let s:z_standsfor = 'note' + +" }}} +" Define the fields required for the various entry types {{{ +" +" s:{type}_required defines the required fields +" s:{type}_optional1 defines common optional fields +" s:{type}_optional2 defines uncommmon optional fields +" s:{type}_retval defines the first line of the formatted bib entry. +" +let s:key='<+key+>' + +let s:{'article'}_required="atjy" +let s:{'article'}_optional1="vnpm" +let s:{'article'}_optional2="z" " z is note +let s:{'article'}_retval = '@ARTICLE{' . s:key . ','."\n" + +let s:{'book'}_required="aetqy" " requires author *or* editor +let s:{'book'}_optional1="wd" +let s:{'book'}_optional2="vnsmz" " w is address, d is edition +let s:{'book'}_extras="k" " isbn +let s:{'book'}_retval = '@BOOK{' . s:key . ','."\n" + +let s:{'booklet'}_required="t" +let s:{'booklet'}_optional1="ahy" +let s:{'booklet'}_optional2="wmz" " w is address +let s:{'booklet'}_retval = '@BOOKLET{' . s:key . ','."\n" + +let s:{'inbook'}_required="aetcpqy" +let s:{'inbook'}_optional1="w" " w is address +let s:{'inbook'}_optional2="vnsudmz" " d is edition +let s:{'inbook'}_extras="k" " isbn +let s:{'inbook'}_retval = '@INBOOK{' . s:key . ','."\n" + +let s:{'incollection'}_required="atbqy" " b is booktitle +let s:{'incollection'}_optional1="cpw" " w is address, c is chapter +let s:{'incollection'}_optional2="evnsudmz" " d is edition +let s:{'incollection'}_extras="k" " isbn +let s:{'incollection'}_retval = '@INCOLLECTION{' . s:key . ','."\n" + +let s:{'inproceedings'}_required="atby" " b is booktitle +let s:{'inproceedings'}_optional1="epwoq" " w is address, q is publisher +let s:{'inproceedings'}_optional2="vnsmz" +let s:{'inproceedings'}_extras="k" " isbn +let s:{'inproceedings'}_retval = '@INPROCEEDINGS{' . s:key . ','."\n" + +let s:{'conference'}_required="atby" " b is booktitle +let s:{'conference'}_optional1="epwoq" " w is address, q is publisher +let s:{'conference'}_optional2="vnsmz" +let s:{'conference'}_extras="k" " isbn +let s:{'conference'}_retval = '@CONFERENCE{' . s:key . ','."\n" + +let s:{'manual'}_required="t" +let s:{'manual'}_optional1="ow" +let s:{'manual'}_optional2="admyz" " w is address +let s:{'manual'}_retval = '@MANUAL{' . s:key . ','."\n" + +let s:{'msthesis'}_required="atry" " r is school +let s:{'msthesis'}_optional1="w" " w is address +let s:{'msthesis'}_optional2="umz" " u is type, w is address +let s:{'msthesis'}_retval = '@MASTERSTHESIS{' . s:key . ','."\n" + +let s:{'misc'}_required="" +let s:{'misc'}_optional1="ath" +let s:{'misc'}_optional2="myz" +let s:{'misc'}_retval = '@MISC{' . s:key . ','."\n" + +let s:{'phdthesis'}_required="atry" " r is school +let s:{'phdthesis'}_optional1="w" " w is address +let s:{'phdthesis'}_optional2="umz" " u is type +let s:{'phdthesis'}_retval = '@PHDTHESIS{' . s:key . ','."\n" + +let s:{'proceedings'}_required="ty" +let s:{'proceedings'}_optional1="ewo" " w is address +let s:{'proceedings'}_optional2="vnsmqz" " q is publisher +let s:{'proceedings'}_retval = '@PROCEEDINGS{' . s:key . ','."\n" + +let s:{'techreport'}_required="atiy" +let s:{'techreport'}_optional1="unw" " u is type, w is address +let s:{'techreport'}_optional2="mz" +let s:{'techreport'}_retval = '@TECHREPORT{' . s:key . ','."\n" + +let s:{'unpublished'}_required="atz" +let s:{'unpublished'}_optional1="y" +let s:{'unpublished'}_optional2="m" +let s:{'unpublished'}_retval = '@UNPUBLISHED{' . s:key . ','."\n" + +" }}} + +if exists('s:done') + finish +endif +let s:done = 1 + +call IMAP ('BBB', "\<C-r>=BibT('', '', 0)\<CR>", 'bib') +call IMAP ('BBL', "\<C-r>=BibT('', 'o', 0)\<CR>", 'bib') +call IMAP ('BBH', "\<C-r>=BibT('', 'O', 0)\<CR>", 'bib') +call IMAP ('BBX', "\<C-r>=BibT('', 'Ox', 0)\<CR>", 'bib') + +" BibT: function to generate a formatted bibtex entry {{{ +" three sample usages: +" :call BibT() will request type choice +" :call BibT("article") preferred, provides most common fields +" :call BibT("article","ox") more optional fields (o) and extras (x) +" +" Input Arguments: +" type: is one of the types listed above. (this should be a complete name, not +" the acronym). +" options: a string containing 0 or more of the letters 'oOx' +" where +" o: include a bib entry with first set of options +" O: include a bib entry with extended options +" x: incude bib entry with extra options +" prompt: whether the fields are asked to be filled on the command prompt or +" whether place-holders are used. when prompt == 1, then comman line +" questions are used. +" +" Returns: +" a string containing a formatted bib entry +function BibT(type, options, prompt) + if a:type != '' + let choosetype = a:type + else + let types = + \ 'article'."\n". + \ 'booklet'."\n". + \ 'book'."\n". + \ 'conference'."\n". + \ 'inbook'."\n". + \ 'incollection'."\n". + \ 'inproceedings'."\n". + \ 'manual'."\n". + \ 'msthesis'."\n". + \ 'misc'."\n". + \ 'phdthesis'."\n". + \ 'proceedings'."\n". + \ 'techreport'."\n". + \ 'unpublished' + let choosetype = Tex_ChooseFromPrompt( + \ "Choose the type of bibliographic entry: \n" . + \ Tex_CreatePrompt(types, 3, "\n") . + \ "\nEnter number or filename :", + \ types, "\n") + if choosetype == '' + let choosetype = 'article' + endif + if types !~ '^\|\n'.choosetype.'$\|\n' + echomsg 'Please choose only one of the given types' + return + endif + endif + if a:options != '' + let options = a:options + else + let options = "" + endif + + let fields = '' + let extras="" + let retval = "" + + " define fields + let fields = s:{choosetype}_required + if options =~ 'o' && exists('s:'.choosetype.'_optional1') + let fields = fields . s:{choosetype}_optional1 + endif + if options =~ "O" && exists('s:'.choosetype.'_optional2') + if options !~ 'o'&& exists('s:'.choosetype.'_optional1') + let fields = fields . s:{choosetype}_optional1 + endif + let fields = fields . s:{choosetype}_optional2 + endif + if options =~ "x" && exists('s:'.choosetype.'_extras') + let fields = fields . extras + endif + if exists('g:Bib_'.choosetype.'_options') + let fields = fields . g:Bib_{choosetype}_options + endif + + let retval = s:{choosetype}_retval + + let i = 0 + while i < strlen(fields) + let field = strpart(fields, i, 1) + + if exists('s:'.field.'_standsfor') + let field_name = s:{field}_standsfor + let retval = retval.field_name." = {<++>},\n" + endif + + let i = i + 1 + endwhile + + " If the user wants even more fine-tuning... + if Tex_GetVarValue('Bib_'.choosetype.'_extrafields') != '' + + let extrafields = Tex_GetVarValue('Bib_'.choosetype.'_extrafields') + + let i = 1 + while 1 + let field_name = Tex_Strntok(extrafields, "\n", i) + if field_name == '' + break + endif + + let retval = retval.field_name." = {<++>},\n" + + let i = i + 1 + endwhile + + endif + + let retval = retval.'otherinfo = {<++>}'."\n" + let retval = retval."}<++>"."\n" + + return IMAP_PutTextWithMovement(retval) +endfunction + +" }}} +function! s:Input(prompt, ask) " {{{ + if a:ask == 1 + let retval = input(a:prompt) + if retval == '' + return "<++>" + endif + else + return "<++>" + endif +endfunction + +" }}} + +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4 diff --git a/ftplugin/latex-suite/brackets.vim b/ftplugin/latex-suite/brackets.vim new file mode 100644 index 00000000..e1d69ae7 --- /dev/null +++ b/ftplugin/latex-suite/brackets.vim @@ -0,0 +1,144 @@ +" ============================================================================== +" History: This was originally part of auctex.vim by Carl Mueller. +" Srinath Avadhanula incorporated it into latex-suite with +" significant modifications. +" Parts of this file may be copyrighted by others as noted. +" Description: +" This ftplugin provides the following maps: +" . <M-b> encloses the previous character in \mathbf{} +" . <M-c> is polymorphic as follows: +" Insert mode: +" 1. If the previous character is a letter or number, then capitalize it and +" enclose it in \mathcal{} +" 2. otherwise insert \cite{} +" Visual Mode: +" 1. Enclose selection in \mathcal{} +" . <M-l> is also polymorphic as follows: +" If the character before typing <M-l> is one of '([{|<q', then do the +" following: +" 1. (<M-l> \left(\right +" similarly for [, | +" {<M-l> \left\{\right\} +" 2. <<M-l> \langle\rangle +" 3. q<M-l> \lefteqn{} +" otherwise insert \label{} +" . <M-i> inserts \item commands at the current cursor location depending on +" the surrounding environment. For example, inside itemize, it will +" insert a simple \item, but within a description, it will insert +" \item[<+label+>] etc. +" +" These functions make it extremeley easy to do all the \left \right stuff in +" latex. +" ============================================================================== + +" Avoid reinclusion. +if exists('b:did_brackets') + finish +endif +let b:did_brackets = 1 + +" define the funtions only once. +if exists('*Tex_MathBF') + finish +endif + +" Tex_MathBF: encloses te previous letter/number in \mathbf{} {{{ +" Description: +function! Tex_MathBF() + return "\<Left>\\mathbf{\<Right>}" +endfunction " }}} +" Tex_MathCal: enclose the previous letter/number in \mathcal {{{ +" Description: +" if the last character is not a letter/number, then insert \cite{} +function! Tex_MathCal() + let line = getline(line(".")) + let char = line[col(".")-2] + + if char =~ '[a-zA-Z0-9]' + return "\<BS>".'\mathcal{'.toupper(char).'}' + else + return IMAP_PutTextWithMovement('\cite{<++>}<++>') + endif +endfunction +" }}} +" Tex_LeftRight: maps <M-l> in insert mode. {{{ +" Description: +" This is a polymorphic function, which maps the behaviour of <M-l> in the +" following way: +" If the character before typing <M-l> is one of '([{|<q', then do the +" following: +" 1. (<M-l> \left(<++>\right<++> +" similarly for [, | +" {<M-l> \left\{<++>\right\}<++> +" 2. <<M-l> \langle<++>\rangle<++> +" 3. q<M-l> \lefteqn{<++>}<++> +" otherwise insert \label{<++>}<++> +function! Tex_LeftRight() + let line = getline(line(".")) + let char = line[col(".")-2] + let previous = line[col(".")-3] + + let matchedbrackets = '()[]{}||' + if char =~ '(\|\[\|{\||' + let add = '' + if char =~ '{' + let add = "\\" + endif + let rhs = matchstr(matchedbrackets, char.'\zs.\ze') + return "\<BS>".IMAP_PutTextWithMovement('\left'.add.char.'<++>\right'.add.rhs.'<++>') + elseif char == '<' + return "\<BS>".IMAP_PutTextWithMovement('\langle <++>\rangle<++>') + elseif char == 'q' + return "\<BS>".IMAP_PutTextWithMovement('\lefteqn{<++>}<++>') + else + return IMAP_PutTextWithMovement('\label{<++>}<++>') + endif +endfunction " }}} +" Tex_PutLeftRight: maps <M-l> in normal mode {{{ +" Description: +" Put \left...\right in front of the matched brackets. +function! Tex_PutLeftRight() + let previous = getline(line("."))[col(".") - 2] + let char = getline(line("."))[col(".") - 1] + if previous == '\' + if char == '{' + exe "normal ileft\\\<Esc>l%iright\\\<Esc>l%" + elseif char == '}' + exe "normal iright\\\<Esc>l%ileft\\\<Esc>l%" + endif + elseif char =~ '\[\|(' + exe "normal i\\left\<Esc>l%i\\right\<Esc>l%" + elseif char =~ '\]\|)' + exe "normal i\\right\<Esc>l%i\\left\<Esc>l%" + endif +endfunction " }}} + +" Provide <plug>'d mapping for easy user customization. {{{ +inoremap <silent> <Plug>Tex_MathBF <C-r>=Tex_MathBF()<CR> +inoremap <silent> <Plug>Tex_MathCal <C-r>=Tex_MathCal()<CR> +inoremap <silent> <Plug>Tex_LeftRight <C-r>=Tex_LeftRight()<CR> +vnoremap <silent> <Plug>Tex_MathBF <C-C>`>a}<Esc>`<i\mathbf{<Esc> +vnoremap <silent> <Plug>Tex_MathCal <C-C>`>a}<Esc>`<i\mathcal{<Esc> +nnoremap <silent> <Plug>Tex_LeftRight :call Tex_PutLeftRight()<CR> + +" }}} +" Tex_SetBracketingMaps: create mappings for the current buffer {{{ +function! <SID>Tex_SetBracketingMaps() + + call Tex_MakeMap('<M-b>', '<Plug>Tex_MathBF', 'i', '<buffer> <silent>') + call Tex_MakeMap('<M-c>', '<Plug>Tex_MathCal', 'i', '<buffer> <silent>') + call Tex_MakeMap('<M-l>', '<Plug>Tex_LeftRight', 'i', '<buffer> <silent>') + call Tex_MakeMap('<M-b>', '<Plug>Tex_MathBF', 'v', '<buffer> <silent>') + call Tex_MakeMap('<M-c>', '<Plug>Tex_MathCal', 'v', '<buffer> <silent>') + call Tex_MakeMap('<M-l>', '<Plug>Tex_LeftRight', 'n', '<buffer> <silent>') + +endfunction +" }}} + +augroup LatexSuite + au LatexSuite User LatexSuiteFileType + \ call Tex_Debug('brackets.vim: Catching LatexSuiteFileType event', 'brak') | + \ call <SID>Tex_SetBracketingMaps() +augroup END + +" vim:fdm=marker diff --git a/ftplugin/latex-suite/compiler.vim b/ftplugin/latex-suite/compiler.vim new file mode 100644 index 00000000..28213fab --- /dev/null +++ b/ftplugin/latex-suite/compiler.vim @@ -0,0 +1,874 @@ +"============================================================================= +" File: compiler.vim +" Author: Srinath Avadhanula +" Created: Tue Apr 23 05:00 PM 2002 PST +" +" Description: functions for compiling/viewing/searching latex documents +"============================================================================= + +" Tex_SetTeXCompilerTarget: sets the 'target' for the next call to Tex_RunLaTeX() {{{ +function! Tex_SetTeXCompilerTarget(type, target) + call Tex_Debug("+Tex_SetTeXCompilerTarget: setting target to [".a:target."] for ".a:type."r", "comp") + + if a:target == '' + let target = Tex_GetVarValue('Tex_DefaultTargetFormat') + let target = input('Enter the target format for '.a:type.'r: ', target) + else + let target = a:target + endif + if target == '' + let target = 'dvi' + endif + + let targetRule = Tex_GetVarValue('Tex_'.a:type.'Rule_'.target) + + if targetRule != '' + if a:type == 'Compile' + let &l:makeprg = escape(targetRule, Tex_GetVarValue('Tex_EscapeChars')) + elseif a:type == 'View' + let s:viewer = targetRule + endif + let s:target = target + + elseif Tex_GetVarValue('Tex_'.a:type.'RuleComplete_'.target) != '' + let s:target = target + + elseif a:type == 'View' && has('macunix') + " On the mac, we can have empty view rules, so do not complain when + " both Tex_ViewRule_target and Tex_ViewRuleComplete_target are + " empty. On other platforms, we will complain... see below. + let s:target = target + + else + let s:origdir = fnameescape(getcwd()) + exe 'cd '.fnameescape(expand('%:p:h')) + if !Tex_GetVarValue('Tex_UseMakefile') || (glob('makefile*') == '' && glob('Makefile*') == '') + if has('gui_running') + call confirm( + \'No '.a:type.' rule defined for target '.target."\n". + \'Please specify a rule in $VIMRUNTIME/ftplugin/tex/texrc'."\n". + \' :help Tex_'.a:type.'Rule_format'."\n". + \'for more information', + \"&ok", 1, 'Warning') + else + call input( + \'No '.a:type.' rule defined for target '.target."\n". + \'Please specify a rule in $VIMRUNTIME/ftplugin/tex/texrc'."\n". + \' :help Tex_'.a:type.'Rule_format'."\n". + \'for more information' + \) + endif + else + echomsg 'Assuming target is for makefile' + let s:target = target + endif + exe 'cd '.s:origdir + endif +endfunction + +function! SetTeXTarget(...) + if a:0 < 1 + let target = Tex_GetVarValue('Tex_DefaultTargetFormat') + let target = input('Enter the target format for compiler and viewer: ', target) + else + let target = a:1 + endif + if target == '' + let target = 'dvi' + endif + + call Tex_SetTeXCompilerTarget('Compile', target) + call Tex_SetTeXCompilerTarget('View', target) +endfunction + +com! -nargs=1 TCTarget :call Tex_SetTeXCompilerTarget('Compile', <f-args>) +com! -nargs=1 TVTarget :call Tex_SetTeXCompilerTarget('View', <f-args>) +com! -nargs=? TTarget :call SetTeXTarget(<f-args>) + +" }}} +" Tex_CompileLatex: compiles the present file. {{{ +" Description: +function! Tex_CompileLatex() + if &ft != 'tex' + echo "calling Tex_RunLaTeX from a non-tex file" + return + end + + " close any preview windows left open. + pclose! + + let s:origdir = fnameescape(getcwd()) + + " Find the main file corresponding to this file. Always cd to the + " directory containing the file to avoid problems with the directory + " containing spaces. + " Latex on linux seems to be unable to handle file names with spaces at + " all! Therefore for the moment, do not attempt to handle spaces in the + " file name. + if exists('b:fragmentFile') + let mainfname = expand('%:p:t') + call Tex_CD(expand('%:p:h')) + else + let mainfname = Tex_GetMainFileName(':p:t') + call Tex_CD(Tex_GetMainFileName(':p:h')) + end + + call Tex_Debug('Tex_CompileLatex: getting mainfname = ['.mainfname.'] from Tex_GetMainFileName', 'comp') + + " if a makefile exists and the user wants to use it, then use that + " irrespective of whether *.latexmain exists or not. mainfname is still + " extracted from *.latexmain (if possible) log file name depends on the + " main file which will be compiled. + if Tex_GetVarValue('Tex_UseMakefile') && (glob('makefile') != '' || glob('Makefile') != '') + let _makeprg = &l:makeprg + call Tex_Debug("Tex_CompileLatex: using the makefile in the current directory", "comp") + let &l:makeprg = 'make $*' + if exists('s:target') + call Tex_Debug('Tex_CompileLatex: execing [make! '.s:target.']', 'comp') + exec 'make! '.s:target + else + call Tex_Debug('Tex_CompileLatex: execing [make!]', 'comp') + exec 'make!' + endif + let &l:makeprg = _makeprg + else + " If &makeprg has something like "$*.ps", it means that it wants the + " file-name without the extension... Therefore remove it. + if &makeprg =~ '\$\*\.\w\+' + let mainfname = fnamemodify(mainfname, ':r') + endif + call Tex_Debug('Tex_CompileLatex: execing [make! '.mainfname.']', 'comp') + exec 'make! '.mainfname + endif + redraw! + + exe 'cd '.s:origdir +endfunction " }}} +" Tex_RunLaTeX: compilation function {{{ +" this function runs the latex command on the currently open file. often times +" the file being currently edited is only a fragment being \input'ed into some +" master tex file. in this case, make a file called mainfile.latexmain in the +" directory containig the file. in other words, if the current file is +" ~/thesis/chapter.tex +" so that doing "latex chapter.tex" doesnt make sense, then make a file called +" main.tex.latexmain +" in the ~/thesis directory. this will then run "latex main.tex" when +" Tex_RunLaTeX() is called. +function! Tex_RunLaTeX() + call Tex_Debug('+Tex_RunLaTeX, b:fragmentFile = '.exists('b:fragmentFile'), 'comp') + + let dir = expand("%:p:h").'/' + let s:origdir = fnameescape(getcwd()) + call Tex_CD(expand("%:p:h")) + + let initTarget = s:target + + " first get the dependency chain of this format. + call Tex_Debug("Tex_RunLaTeX: compiling to target [".s:target."]", "comp") + + if Tex_GetVarValue('Tex_FormatDependency_'.s:target) != '' + let dependency = Tex_GetVarValue('Tex_FormatDependency_'.s:target) + if dependency !~ ','.s:target.'$' + let dependency = dependency.','.s:target + endif + else + let dependency = s:target + endif + + call Tex_Debug('Tex_RunLaTeX: getting dependency chain = ['.dependency.']', 'comp') + + " now compile to the final target format via each dependency. + let i = 1 + while Tex_Strntok(dependency, ',', i) != '' + let s:target = Tex_Strntok(dependency, ',', i) + + call Tex_SetTeXCompilerTarget('Compile', s:target) + call Tex_Debug('Tex_RunLaTeX: setting target to '.s:target, 'comp') + + if Tex_GetVarValue('Tex_MultipleCompileFormats') =~ '\<'.s:target.'\>' + call Tex_Debug("Tex_RunLaTeX: compiling file multiple times via Tex_CompileMultipleTimes", "comp") + call Tex_CompileMultipleTimes() + else + call Tex_Debug("Tex_RunLaTeX: compiling file once via Tex_CompileLatex", "comp") + call Tex_CompileLatex() + endif + + let errlist = Tex_GetErrorList() + call Tex_Debug("Tex_RunLaTeX: errlist = [".errlist."]", "comp") + + " If there are any errors, then break from the rest of the steps + if errlist =~ '\v(error|warning)' + call Tex_Debug('Tex_RunLaTeX: There were errors in compiling, breaking chain...', 'comp') + break + endif + + let i = i + 1 + endwhile + + let s:target = initTarget + let s:origwinnum = winnr() + call Tex_SetupErrorWindow() + + exe 'cd '.s:origdir + call Tex_Debug("-Tex_RunLaTeX", "comp") +endfunction + +" }}} +" Tex_ViewLaTeX: opens viewer {{{ +" Description: opens the DVI viewer for the file being currently edited. +" Again, if the current file is a \input in a master file, see text above +" Tex_RunLaTeX() to see how to set this information. +function! Tex_ViewLaTeX() + if &ft != 'tex' + echo "calling Tex_ViewLaTeX from a non-tex file" + return + end + + let s:origdir = fnameescape(getcwd()) + + " If b:fragmentFile is set, it means this file was compiled as a fragment + " using Tex_PartCompile, which means that we want to ignore any + " *.latexmain or makefile's. + if !exists('b:fragmentFile') + " cd to the location of the file to avoid having to deal with spaces + " in the directory name. + let mainfname = Tex_GetMainFileName(':p:t:r') + call Tex_CD(Tex_GetMainFileName(':p:h')) + else + let mainfname = expand("%:p:t:r") + call Tex_CD(expand("%:p:h")) + endif + + if Tex_GetVarValue('Tex_ViewRuleComplete_'.s:target) != '' + + let execString = Tex_GetVarValue('Tex_ViewRuleComplete_'.s:target) + let execString = substitute(execString, '{v:servername}', v:servername, 'g') + + elseif has('win32') + " unfortunately, yap does not allow the specification of an external + " editor from the command line. that would have really helped ensure + " that this particular vim and yap are connected. + let execString = 'start '.s:viewer.' "$*.'.s:target.'"' + + elseif (has('macunix') && Tex_GetVarValue('Tex_TreatMacViewerAsUNIX') != 1) + + if strlen(s:viewer) + let appOpt = '-a ' + else + let appOpt = '' + endif + let execString = 'open '.appOpt.s:viewer.' $*.'.s:target + + else + " taken from Dimitri Antoniou's tip on vim.sf.net (tip #225). + " slight change to actually use the current servername instead of + " hardcoding it as xdvi. + " Using an option for specifying the editor in the command line + " because that seems to not work on older bash'es. + if s:target == 'dvi' + + if Tex_GetVarValue('Tex_UseEditorSettingInDVIViewer') == 1 && + \ v:servername != '' && + \ s:viewer =~ '^ *xdvik\?\( \|$\)' + + let execString = s:viewer.' -editor "gvim --servername '.v:servername. + \ ' --remote-silent +\%l \%f" $*.dvi' + + elseif Tex_GetVarValue('Tex_UseEditorSettingInDVIViewer') == 1 && + \ s:viewer =~ '^ *kdvi\( \|$\)' + + let execString = s:viewer.' --unique $*.dvi' + + else + + let execString = s:viewer.' $*.dvi' + + endif + + else + + let execString = s:viewer.' $*.'.s:target + + endif + + if( Tex_GetVarValue('Tex_ExecuteUNIXViewerInForeground') != 1 ) + let execString = execString.' &' + endif + + end + + let execString = substitute(execString, '\V$*', mainfname, 'g') + call Tex_Debug("Tex_ViewLaTeX: execString = ".execString, "comp") + + exec 'silent! !'.execString + + if !has('gui_running') + redraw! + endif + + exe 'cd '.s:origdir +endfunction + +" }}} +" Tex_ForwardSearchLaTeX: searches for current location in dvi file. {{{ +" Description: if the DVI viewer is compatible, then take the viewer to that +" position in the dvi file. see docs for Tex_RunLaTeX() to set a +" master file if this is an \input'ed file. +" Tip: With YAP on Windows, it is possible to do forward and inverse searches +" on DVI files. to do forward search, you'll have to compile the file +" with the --src-specials option. then set the following as the command +" line in the 'view/options/inverse search' dialog box: +" gvim --servername LATEX --remote-silent +%l "%f" +" For inverse search, if you are reading this, then just pressing \ls +" will work. +function! Tex_ForwardSearchLaTeX() + if &ft != 'tex' + echo "calling Tex_ForwardSeachLaTeX from a non-tex file" + return + end + + if Tex_GetVarValue('Tex_ViewRule_'.s:target) == '' + return + endif + let viewer = Tex_GetVarValue('Tex_ViewRule_'.s:target) + + let s:origdir = fnameescape(getcwd()) + + let mainfname = Tex_GetMainFileName(':t') + let mainfnameRoot = fnamemodify(Tex_GetMainFileName(), ':t:r') + let mainfnameFull = Tex_GetMainFileName(':p:r') + " cd to the location of the file to avoid problems with directory name + " containing spaces. + call Tex_CD(Tex_GetMainFileName(':p:h')) + + " inverse search tips taken from Dimitri Antoniou's tip and Benji Fisher's + " tips on vim.sf.net (vim.sf.net tip #225) + if (has('win32') && (viewer =~? '^ *yap\( \|$\)')) + + let execString = 'silent! !start '. viewer.' -s '.line('.').expand('%').' '.mainfnameRoot + + + elseif (has('macunix') && (viewer =~ '^ *\(Skim\|PDFView\|TeXniscope\)\( \|$\)')) + " We're on a Mac using a traditional Mac viewer + + if viewer =~ '^ *Skim' + + let execString = 'silent! !/Applications/Skim.app/Contents/SharedSupport/displayline '. + \ line('.').' "'.mainfnameFull.'.'.s:target.'" "'.expand("%:p").'"' + + elseif viewer =~ '^ *PDFView' + + let execString = 'silent! !/Applications/PDFView.app/Contents/MacOS/gotoline.sh '. + \ line('.').' "'.mainfnameFull.'.'.s:target.'" "'.expand("%:p").'"' + + elseif viewer =~ '^ *TeXniscope' + + let execString = 'silent! !/Applications/TeXniscope.app/Contents/Resources/forward-search.sh '. + \ line('.').' "'.expand("%:p").'" "'.mainfnameFull.'.'.s:target.'"' + + endif + + else + " We're either UNIX or Mac and using a UNIX-type viewer + + " Check for the special DVI viewers first + if viewer =~ '^ *\(xdvi\|xdvik\|kdvi\|okular\)\( \|$\)' + + if Tex_GetVarValue('Tex_UseEditorSettingInDVIViewer') == 1 && + \ exists('v:servername') && + \ viewer =~ '^ *xdvik\?\( \|$\)' + + let execString = 'silent! !'.viewer.' -name xdvi -sourceposition "'.line('.').' '.expand("%").'"'. + \ ' -editor "gvim --servername '.v:servername.' --remote-silent +\%l \%f" '. + \ mainfnameRoot.'.dvi' + + elseif viewer =~ '^ *kdvi' + + let execString = 'silent! !'.viewer.' --unique file:'.mainfnameRoot.'.dvi\#src:'.line('.').expand("%") + + elseif viewer =~ '^ *xdvik\?\( \|$\)' + + let execString = 'silent! !'.viewer.' -name xdvi -sourceposition "'.line('.').' '.expand("%").'" '.mainfnameRoot.'.dvi' + + elseif viewer =~ '^ *okular' + + let execString = 'silent! !'.viewer.' --unique '.mainfnameRoot.'.'.s:target.'\#src:'.line('.').expand("%:p") + + endif + + else + " We must be using a generic UNIX viewer + " syntax is: viewer TARGET_FILE LINE_NUMBER SOURCE_FILE + + let execString = 'silent! !'.viewer.' "'.mainfnameRoot.'.'.s:target.'" '.line('.').' "'.expand('%').'"' + + endif + + " See if we should add &. On Mac (at least in MacVim), it seems + " like this should NOT be added... + if( Tex_GetVarValue('Tex_ExecuteUNIXViewerInForeground') != 1 ) + let execString = execString.' &' + endif + + endif + + call Tex_Debug("Tex_ForwardSearchLaTeX: execString = ".execString, "comp") + execute execString + if !has('gui_running') + redraw! + endif + + exe 'cd '.s:origdir +endfunction + +" }}} + +" ============================================================================== +" Functions for compiling parts of a file. +" ============================================================================== +" Tex_PartCompile: compiles selected fragment {{{ +" Description: creates a temporary file from the selected fragment of text +" prepending the preamble and \end{document} and then asks Tex_RunLaTeX() to +" compile it. +function! Tex_PartCompile() range + call Tex_Debug('+Tex_PartCompile', 'comp') + + " Get a temporary file in the same directory as the file from which + " fragment is being extracted. This is to enable the use of relative path + " names in the fragment. + let tmpfile = Tex_GetTempName(expand('%:p:h')) + + " Remember all the temp files and for each temp file created, remember + " where the temp file came from. + let s:Tex_NumTempFiles = (exists('s:Tex_NumTempFiles') ? s:Tex_NumTempFiles + 1 : 1) + let s:Tex_TempFiles = (exists('s:Tex_TempFiles') ? s:Tex_TempFiles : '') + \ . tmpfile."\n" + let s:Tex_TempFile_{s:Tex_NumTempFiles} = tmpfile + " TODO: For a function Tex_RestoreFragment which restores a temp file to + " its original location. + let s:Tex_TempFileOrig_{s:Tex_NumTempFiles} = expand('%:p') + let s:Tex_TempFileRange_{s:Tex_NumTempFiles} = a:firstline.','.a:lastline + + " Set up an autocmd to clean up the temp files when Vim exits. + if Tex_GetVarValue('Tex_RemoveTempFiles') + augroup RemoveTmpFiles + au! + au VimLeave * :call Tex_RemoveTempFiles() + augroup END + endif + + " If mainfile exists open it in tiny window and extract preamble there, + " otherwise do it from current file + let mainfile = Tex_GetMainFileName(":p") + exe 'bot 1 split '.escape(mainfile, ' ') + exe '1,/\s*\\begin{document}/w '.tmpfile + wincmd q + + exe a:firstline.','.a:lastline."w! >> ".tmpfile + + " edit the temporary file + exec 'drop '.tmpfile + + " append the \end{document} line. + $ put ='\end{document}' + w + + " set this as a fragment file. + let b:fragmentFile = 1 + + silent! call Tex_RunLaTeX() +endfunction " }}} +" Tex_RemoveTempFiles: cleans up temporary files created during part compilation {{{ +" Description: During part compilation, temporary files containing the +" visually selected text are created. These files need to be +" removed when Vim exits to avoid "file leakage". +function! Tex_RemoveTempFiles() + if !exists('s:Tex_NumTempFiles') || !Tex_GetVarValue('Tex_RemoveTempFiles') + return + endif + let i = 1 + while i <= s:Tex_NumTempFiles + let tmpfile = s:Tex_TempFile_{i} + " Remove the tmp file and all other associated files such as the + " .log files etc. + call Tex_DeleteFile(fnamemodify(tmpfile, ':p:r').'.*') + let i = i + 1 + endwhile +endfunction " }}} + +" ============================================================================== +" Compiling a file multiple times to resolve references/citations etc. +" ============================================================================== +" Tex_CompileMultipleTimes: The main function {{{ +" Description: compiles a file multiple times to get cross-references right. +function! Tex_CompileMultipleTimes() + " Just extract the root without any extension because we want to construct + " the log file names etc from it. + let s:origdir = fnameescape(getcwd()) + let mainFileName_root = Tex_GetMainFileName(':p:t:r') + call Tex_CD(Tex_GetMainFileName(':p:h')) + + " First ignore undefined references and the + " "rerun to get cross-references right" message from + " the compiler output. + let origlevel = Tex_GetVarValue('Tex_IgnoreLevel') + let origpats = Tex_GetVarValue('Tex_IgnoredWarnings') + + let g:Tex_IgnoredWarnings = g:Tex_IgnoredWarnings."\n" + \ . 'Reference %.%# undefined'."\n" + \ . 'Rerun to get cross-references right' + TCLevel 1000 + + let idxFileName = mainFileName_root.'.idx' + let auxFileName = mainFileName_root.'.aux' + + let runCount = 0 + let needToRerun = 1 + while needToRerun == 1 && runCount < 5 + " assume we need to run only once. + let needToRerun = 0 + + let idxlinesBefore = Tex_CatFile(idxFileName) + let auxlinesBefore = Tex_GetAuxFile(auxFileName) + + " first run latex. + echomsg "latex run number : ".(runCount+1) + call Tex_Debug("Tex_CompileMultipleTimes: latex run number : ".(runCount+1), "comp") + silent! call Tex_CompileLatex() + + " If there are errors in any latex compilation step, immediately + " return. For now, do not bother with warnings because those might go + " away after compiling again or after bibtex is run etc. + let errlist = Tex_GetErrorList() + call Tex_Debug("Tex_CompileMultipleTimes: errors = [".errlist."]", "comp") + + if errlist =~ 'error' + let g:Tex_IgnoredWarnings = origpats + exec 'TCLevel '.origlevel + + return + endif + + let idxlinesAfter = Tex_CatFile(idxFileName) + + " If .idx file changed, then run makeindex to generate the new .ind + " file and remember to rerun latex. + if runCount == 0 && glob(idxFileName) != '' && idxlinesBefore != idxlinesAfter + echomsg "Running makeindex..." + let temp_mp = &mp | let &mp = Tex_GetVarValue('Tex_MakeIndexFlavor') + exec 'silent! make '.mainFileName_root + let &mp = temp_mp + + let needToRerun = 1 + endif + + " The first time we see if we need to run bibtex and if the .bbl file + " changes, we will rerun latex. + if runCount == 0 && Tex_IsPresentInFile('\\bibdata', mainFileName_root.'.aux') + let bibFileName = mainFileName_root.'.bbl' + + let biblinesBefore = Tex_CatFile(bibFileName) + + echomsg "Running '".Tex_GetVarValue('Tex_BibtexFlavor')."' ..." + let temp_mp = &mp | let &mp = Tex_GetVarValue('Tex_BibtexFlavor') + exec 'silent! make '.mainFileName_root + let &mp = temp_mp + + let biblinesAfter = Tex_CatFile(bibFileName) + + " If the .bbl file changed after running bibtex, we need to + " latex again. + if biblinesAfter != biblinesBefore + echomsg 'Need to rerun because bibliography file changed...' + call Tex_Debug('Tex_CompileMultipleTimes: Need to rerun because bibliography file changed...', 'comp') + let needToRerun = 1 + endif + endif + + " check if latex asks us to rerun + let auxlinesAfter = Tex_GetAuxFile(auxFileName) + if auxlinesAfter != auxlinesBefore + echomsg "Need to rerun because the AUX file changed..." + call Tex_Debug("Tex_CompileMultipleTimes: Need to rerun to get cross-references right...", 'comp') + let needToRerun = 1 + endif + + let runCount = runCount + 1 + endwhile + + redraw! + call Tex_Debug("Tex_CompileMultipleTimes: Ran latex ".runCount." time(s)", "comp") + echomsg "Ran latex ".runCount." time(s)" + + let g:Tex_IgnoredWarnings = origpats + exec 'TCLevel '.origlevel + " After all compiler calls are done, reparse the .log file for + " errors/warnings to handle the situation where the clist might have been + " emptied because of bibtex/makeindex being run as the last step. + exec 'silent! cfile '.mainFileName_root.'.log' + + exe 'cd '.s:origdir +endfunction " }}} +" Tex_GetAuxFile: get the contents of the AUX file {{{ +" Description: get the contents of the AUX file recursively including any +" @\input'ted AUX files. +function! Tex_GetAuxFile(auxFile) + if !filereadable(a:auxFile) + return '' + endif + + let auxContents = Tex_CatFile(a:auxFile) + let pattern = '@\input{\(.\{-}\)}' + + let auxContents = substitute(auxContents, pattern, '\=Tex_GetAuxFile(submatch(1))', 'g') + + return auxContents +endfunction " }}} + +" ============================================================================== +" Helper functions for +" . viewing the log file in preview mode. +" . syncing the display between the quickfix window and preview window +" . going to the correct line _and column_ number from from the quick fix +" window. +" ============================================================================== +" Tex_SetupErrorWindow: sets up the cwindow and preview of the .log file {{{ +" Description: +function! Tex_SetupErrorWindow() + let mainfname = Tex_GetMainFileName() + + let winnum = winnr() + + " close the quickfix window before trying to open it again, otherwise + " whether or not we end up in the quickfix window after the :cwindow + " command is not fixed. + cclose + cwindow + " create log file name from mainfname + let mfnlog = fnamemodify(mainfname, ":t:r").'.log' + call Tex_Debug('Tex_SetupErrorWindow: mfnlog = '.mfnlog, 'comp') + " if we moved to a different window, then it means we had some errors. + if winnum != winnr() + if Tex_GetVarValue('Tex_ShowErrorContext') + call Tex_UpdatePreviewWindow(mfnlog) + exe 'nnoremap <buffer> <silent> j j:call Tex_UpdatePreviewWindow("'.mfnlog.'")<CR>' + exe 'nnoremap <buffer> <silent> k k:call Tex_UpdatePreviewWindow("'.mfnlog.'")<CR>' + exe 'nnoremap <buffer> <silent> <up> <up>:call Tex_UpdatePreviewWindow("'.mfnlog.'")<CR>' + exe 'nnoremap <buffer> <silent> <down> <down>:call Tex_UpdatePreviewWindow("'.mfnlog.'")<CR>' + endif + exe 'nnoremap <buffer> <silent> <enter> :call Tex_GotoErrorLocation("'.mfnlog.'")<CR>' + + setlocal nowrap + + " resize the window to just fit in with the number of lines. + exec ( line('$') < 4 ? line('$') : 4 ).' wincmd _' + if Tex_GetVarValue('Tex_GotoError') == 1 + call Tex_GotoErrorLocation(mfnlog) + else + exec s:origwinnum.' wincmd w' + endif + endif + +endfunction " }}} +" Tex_PositionPreviewWindow: positions the preview window correctly. {{{ +" Description: +" The purpose of this function is to count the number of times an error +" occurs on the same line. or in other words, if the current line is +" something like |10 error|, then we want to count the number of +" lines in the quickfix window before this line which also contain lines +" like |10 error|. +" +function! Tex_PositionPreviewWindow(filename) + + if getline('.') !~ '|\d\+ \(error\|warning\)|' + if !search('|\d\+ \(error\|warning\)|') + call Tex_Debug("not finding error pattern anywhere in quickfix window :".bufname(bufnr('%')), + \ 'comp') + pclose! + return + endif + endif + + " extract the error pattern (something like 'file.tex|10 error|') on the + " current line. + let errpat = matchstr(getline('.'), '^\f*|\d\+ \(error\|warning\)|\ze') + let errfile = matchstr(getline('.'), '^\f*\ze|\d\+ \(error\|warning\)|') + " extract the line number from the error pattern. + let linenum = matchstr(getline('.'), '|\zs\d\+\ze \(error\|warning\)|') + + " if we are on an error, then count the number of lines before this in the + " quickfix window with an error on the same line. + if errpat =~ 'error|$' + " our location in the quick fix window. + let errline = line('.') + + " goto the beginning of the quickfix window and begin counting the lines + " which show an error on the same line. + 0 + let numrep = 0 + while 1 + " if we are on the same kind of error line, then means we have another + " line containing the same error pattern. + if getline('.') =~ errpat + let numrep = numrep + 1 + normal! 0 + endif + " if we have reached the original location in the quick fix window, + " then break. + if line('.') == errline + break + else + " otherwise, search for the next line which contains the same + " error pattern again. goto the end of the current line so we + " dont count this line again. + normal! $ + call search(errpat, 'W') + endif + endwhile + else + let numrep = 1 + endif + + if getline('.') =~ '|\d\+ warning|' + let searchpat = escape(matchstr(getline('.'), '|\d\+ warning|\s*\zs.*'), '\ ') + else + let searchpat = 'l\.'.linenum + endif + + " We first need to be in the scope of the correct file in the .log file. + " This is important for example, when a.tex and b.tex both have errors on + " line 9 of the file and we want to go to the error of b.tex. Merely + " searching forward from the beginning of the log file for l.9 will always + " land us on the error in a.tex. + if errfile != '' + exec 'silent! bot pedit +/(\\(\\f\\|\\[\\|\]\\|\\s\\)*'.errfile.'/ '.a:filename + else + exec 'bot pedit +0 '.a:filename + endif + " Goto the preview window + " TODO: This is not robust enough. Check that a wincmd j actually takes + " us to the preview window. + wincmd j + " now search forward from this position in the preview window for the + " numrep^th error of the current line in the quickfix window. + while numrep > 0 + call search(searchpat, 'W') + let numrep = numrep - 1 + endwhile + normal! z. + +endfunction " }}} +" Tex_UpdatePreviewWindow: updates the view of the log file {{{ +" Description: +" This function should be called when focus is in a quickfix window. +" It opens the log file in a preview window and makes it display that +" part of the log file which corresponds to the error which the user is +" currently on in the quickfix window. Control returns to the quickfix +" window when the function returns. +" +function! Tex_UpdatePreviewWindow(filename) + call Tex_PositionPreviewWindow(a:filename) + + if &previewwindow + 6 wincmd _ + wincmd p + endif +endfunction " }}} +" Tex_GotoErrorLocation: goes to the correct location of error in the tex file {{{ +" Description: +" This function should be called when focus is in a quickfix window. This +" function will first open the preview window of the log file (if it is not +" already open), position the display of the preview to coincide with the +" current error under the cursor and then take the user to the file in +" which this error has occured. +" +" The position is both the correct line number and the column number. +function! Tex_GotoErrorLocation(filename) + + " first use vim's functionality to take us to the location of the error + " accurate to the line (not column). This lets us go to the correct file + " without applying any logic. + exec "normal! \<enter>" + " If the log file is not found, then going to the correct line number is + " all we can do. + if glob(a:filename) == '' + return + endif + + let winnum = winnr() + " then come back to the quickfix window + wincmd w + + " find out where in the file we had the error. + let linenum = matchstr(getline('.'), '|\zs\d\+\ze \(warning\|error\)|') + call Tex_PositionPreviewWindow(a:filename) + + if getline('.') =~ 'l.\d\+' + + let brokenline = matchstr(getline('.'), 'l.'.linenum.' \zs.*\ze') + " If the line is of the form + " l.10 ...and then there was some error + " it means (most probably) that only part of the erroneous line is + " shown. In this case, finding the length of the broken line is not + " correct. Instead goto the beginning of the line and search forward + " for the part which is displayed and then go to its end. + if brokenline =~ '^\M...' + let partline = matchstr(brokenline, '^\M...\m\zs.*') + let normcmd = "0/\\V".escape(partline, "\\")."/e+1\<CR>" + else + let column = strlen(brokenline) + 1 + let normcmd = column.'|' + endif + + elseif getline('.') =~ 'LaTeX Warning: \(Citation\|Reference\) `.*' + + let ref = matchstr(getline('.'), "LaTeX Warning: \\(Citation\\|Reference\\) `\\zs[^']\\+\\ze'") + let normcmd = '0/'.ref."\<CR>" + + else + + let normcmd = '0' + + endif + + " go back to the window where we came from. + exec winnum.' wincmd w' + exec 'silent! '.linenum.' | normal! '.normcmd + + if !Tex_GetVarValue('Tex_ShowErrorContext') + pclose! + endif +endfunction " }}} +" Tex_SetCompilerMaps: sets maps for compiling/viewing/searching {{{ +" Description: +function! <SID>Tex_SetCompilerMaps() + if exists('b:Tex_doneCompilerMaps') + return + endif + let s:ml = '<Leader>' + + nnoremap <buffer> <Plug>Tex_Compile :call Tex_RunLaTeX()<cr> + vnoremap <buffer> <Plug>Tex_Compile :call Tex_PartCompile()<cr> + nnoremap <buffer> <Plug>Tex_View :call Tex_ViewLaTeX()<cr> + nnoremap <buffer> <Plug>Tex_ForwardSearch :call Tex_ForwardSearchLaTeX()<cr> + + call Tex_MakeMap(s:ml."ll", "<Plug>Tex_Compile", 'n', '<buffer>') + call Tex_MakeMap(s:ml."ll", "<Plug>Tex_Compile", 'v', '<buffer>') + call Tex_MakeMap(s:ml."lv", "<Plug>Tex_View", 'n', '<buffer>') + call Tex_MakeMap(s:ml."ls", "<Plug>Tex_ForwardSearch", 'n', '<buffer>') +endfunction +" }}} + +augroup LatexSuite + au LatexSuite User LatexSuiteFileType + \ call Tex_Debug('compiler.vim: Catching LatexSuiteFileType event', 'comp') | + \ call <SID>Tex_SetCompilerMaps() +augroup END + +command! -nargs=0 -range=% TPartCompile :<line1>, <line2> silent! call Tex_PartCompile() +" Setting b:fragmentFile = 1 makes Tex_CompileLatex consider the present file +" the _main_ file irrespective of the presence of a .latexmain file. +command! -nargs=0 TCompileThis let b:fragmentFile = 1 +command! -nargs=0 TCompileMainFile let b:fragmentFile = 0 + +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4 diff --git a/ftplugin/latex-suite/custommacros.vim b/ftplugin/latex-suite/custommacros.vim new file mode 100644 index 00000000..a8482abb --- /dev/null +++ b/ftplugin/latex-suite/custommacros.vim @@ -0,0 +1,255 @@ +"============================================================================= +" File: custommacros.vim +" Author: Mikolaj Machowski +" Version: 1.0 +" Created: Tue Apr 23 05:00 PM 2002 PST +" +" Description: functions for processing custom macros in the +" latex-suite/macros directory +"============================================================================= + +let s:path = expand('<sfile>:p:h') + +" Set path to macros dir dependent on OS {{{ +if has("unix") || has("macunix") + let s:macrodirpath = $HOME."/.vim/ftplugin/latex-suite/macros/" +elseif has("win32") + if exists("$HOME") + let s:macrodirpath = $HOME."/vimfiles/ftplugin/latex-suite/macros/" + else + let s:macrodirpath = $VIM."/vimfiles/ftplugin/latex-suite/macros/" + endif +endif + +" }}} +" SetCustomMacrosMenu: sets up the menu for Macros {{{ +function! <SID>SetCustomMacrosMenu() + let flist = Tex_FindInRtp('', 'macros') + exe 'amenu '.g:Tex_MacrosMenuLocation.'&New :call <SID>NewMacro("FFFromMMMenu")<CR>' + exe 'amenu '.g:Tex_MacrosMenuLocation.'&Redraw :call RedrawMacro()<CR>' + + let i = 1 + while 1 + let fname = Tex_Strntok(flist, ',', i) + if fname == '' + break + endif + exe "amenu ".g:Tex_MacrosMenuLocation."&Delete.&".i.":<tab>".fname." :call <SID>DeleteMacro('".fname."')<CR>" + exe "amenu ".g:Tex_MacrosMenuLocation."&Edit.&".i.":<tab>".fname." :call <SID>EditMacro('".fname."')<CR>" + exe "imenu ".g:Tex_MacrosMenuLocation."&".i.":<tab>".fname." <C-r>=<SID>ReadMacro('".fname."')<CR>" + exe "nmenu ".g:Tex_MacrosMenuLocation."&".i.":<tab>".fname." i<C-r>=<SID>ReadMacro('".fname."')<CR>" + let i = i + 1 + endwhile +endfunction + +if g:Tex_Menus + call <SID>SetCustomMacrosMenu() +endif + +" }}} +" NewMacro: opens new file in macros directory {{{ +function! <SID>NewMacro(...) + " Allow for calling :TMacroNew without argument or from menu and prompt + " for name. + if a:0 > 0 + let newmacroname = a:1 + else + let newmacroname = input("Name of new macro: ") + if newmacroname == '' + return + endif + endif + + if newmacroname == "FFFromMMMenu" + " Check if NewMacro was called from menu and prompt for insert macro + " name + let newmacroname = input("Name of new macro: ") + if newmacroname == '' + return + endif + elseif Tex_FindInRtp(newmacroname, 'macros') != '' + " If macro with this name already exists, prompt for another name. + exe "echomsg 'Macro ".newmacroname." already exists. Try another name.'" + let newmacroname = input("Name of new macro: ") + if newmacroname == '' + return + endif + endif + exec 'split '.Tex_EscapeSpaces(s:macrodirpath.newmacroname) + setlocal filetype=tex +endfunction + +" }}} +" RedrawMacro: refreshes macro menu {{{ +function! RedrawMacro() + aunmenu TeX-Suite.Macros + call <SID>SetCustomMacrosMenu() +endfunction + +" }}} +" ChooseMacro: choose a macro file {{{ +" " Description: +function! s:ChooseMacro(ask) + let filelist = Tex_FindInRtp('', 'macros') + let filename = Tex_ChooseFromPrompt( + \ a:ask."\n" . + \ Tex_CreatePrompt(filelist, 2, ',') . + \ "\nEnter number or filename :", + \ filelist, ',') +endfunction + +" }}} +" DeleteMacro: deletes macro file {{{ +function! <SID>DeleteMacro(...) + if a:0 > 0 + let filename = a:1 + else + let filename = s:ChooseMacro('Choose a macro file for deletion :') + endif + + if !filereadable(s:macrodirpath.filename) + " When file is not in local directory decline to remove it. + call confirm('This file is not in your local directory: '.filename."\n". + \ 'It will not be deleted.' , '&OK', 1) + + else + let ch = confirm('Really delete '.filename.' ?', "&Yes\n&No", 2) + if ch == 1 + call delete(s:macrodirpath.filename) + endif + call RedrawMacro() + endif +endfunction + +" }}} +" EditMacro: edits macro file {{{ +function! <SID>EditMacro(...) + if a:0 > 0 + let filename = a:1 + else + let filename = s:ChooseMacro('Choose a macro file for insertion:') + endif + + if filereadable(s:macrodirpath.filename) + " If file exists in local directory open it. + exec 'split '.Tex_EscapeSpaces(s:macrodirpath.filename) + else + " But if file doesn't exist in local dir it probably is in user + " restricted area. Instead opening try to copy it to local dir. + " Pity VimL doesn't have mkdir() function :) + let ch = confirm("You are trying to edit file which is probably read-only.\n". + \ "It will be copied to your local LaTeX-Suite macros directory\n". + \ "and you will be operating on local copy with suffix -local.\n". + \ "It will succeed only if ftplugin/latex-suite/macros dir exists.\n". + \ "Do you agree?", "&Yes\n&No", 1) + if ch == 1 + " But there is possibility we already created local modification. + " Check it and offer opening this file. + if filereadable(s:macrodirpath.filename.'-local') + let ch = confirm('Local version of '.filename." already exists.\n". + \ 'Do you want to open it or overwrite with original version?', + \ "&Open\nOver&write\n&Cancel", 1) + if ch == 1 + exec 'split '.Tex_EscapeSpaces(s:macrodirpath.filename.'-local') + elseif ch == 2 + new + exe '0read '.Tex_FindInRtp(filename, 'macros') + " This is possible macro was edited before, wipe it out. + if bufexists(s:macrodirpath.filename.'-local') + exe 'bwipe '.s:macrodirpath.filename.'-local' + endif + exe 'write! '.s:macrodirpath.filename.'-local' + else + return + endif + else + " If file doesn't exist, open new file, read in system macro and + " save it in local macro dir with suffix -local + new + exe '0read '.Tex_FindInRtp(filename, 'macros') + exe 'write '.s:macrodirpath.filename.'-local' + endif + endif + + endif + setlocal filetype=tex +endfunction + +" }}} +" ReadMacro: reads in a macro from a macro file. {{{ +" allowing for placement via placeholders. +function! <SID>ReadMacro(...) + + if a:0 > 0 + let filename = a:1 + else + let filelist = Tex_FindInRtp('', 'macros') + let filename = + \ Tex_ChooseFromPrompt("Choose a macro file:\n" . + \ Tex_CreatePrompt(filelist, 2, ',') . + \ "\nEnter number or name of file :", + \ filelist, ',') + endif + + let fname = Tex_FindInRtp(filename, 'macros', ':p') + + let markerString = '<---- Latex Suite End Macro ---->' + let _a = @a + silent! call append(line('.'), markerString) + silent! exec "read ".fname + silent! exec "normal! V/^".markerString."$/-1\<CR>\"ax" + " This is kind of tricky: At this stage, we are one line after the one we + " started from with the marker text on it. We need to + " 1. remove the marker and the line. + " 2. get focus to the previous line. + " 3. not remove anything from the previous line. + silent! exec "normal! $v0k$\"_x" + + call Tex_CleanSearchHistory() + + let @a = substitute(@a, '['."\n\r\t ".']*$', '', '') + let textWithMovement = IMAP_PutTextWithMovement(@a) + let @a = _a + + return textWithMovement + +endfunction + +" }}} +" commands for macros {{{ +com! -nargs=? TMacroNew :call <SID>NewMacro(<f-args>) + +" This macros had to have 2 versions: +if v:version >= 602 + com! -complete=custom,Tex_CompleteMacroName -nargs=? TMacro + \ :let s:retVal = <SID>ReadMacro(<f-args>) <bar> normal! i<C-r>=s:retVal<CR> + com! -complete=custom,Tex_CompleteMacroName -nargs=? TMacroEdit + \ :call <SID>EditMacro(<f-args>) + com! -complete=custom,Tex_CompleteMacroName -nargs=? TMacroDelete + \ :call <SID>DeleteMacro(<f-args>) + + " Tex_CompleteMacroName: for completing names in TMacro... commands {{{ + " Description: get list of macro names with Tex_FindInRtp(), remove full path + " and return list of names separated with newlines. + " + function! Tex_CompleteMacroName(A,P,L) + " Get name of macros from all runtimepath directories + let macronames = Tex_FindInRtp('', 'macros') + " Separate names with \n not , + let macronames = substitute(macronames,',','\n','g') + return macronames + endfunction + + " }}} + +else + com! -nargs=? TMacro + \ :let s:retVal = <SID>ReadMacro(<f-args>) <bar> normal! i<C-r>=s:retVal<CR> + com! -nargs=? TMacroEdit :call <SID>EditMacro(<f-args>) + com! -nargs=? TMacroDelete :call <SID>DeleteMacro(<f-args>) + +endif + +" }}} + +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4 diff --git a/ftplugin/latex-suite/diacritics.vim b/ftplugin/latex-suite/diacritics.vim new file mode 100644 index 00000000..616d30ab --- /dev/null +++ b/ftplugin/latex-suite/diacritics.vim @@ -0,0 +1,124 @@ +"============================================================================= +" File: diacritics.vim +" Author: Lubomir Host +" Created: Tue Apr 23 07:00 PM 2002 PST +" +" Description: shortcuts for all diacritics. +"============================================================================= + +if !g:Tex_Diacritics + finish +endif + +" \'{a} {{{ +call IMAP ('=a', "\\\'{a}", 'tex') +call IMAP ('=b', "\\'{b}", 'tex') +call IMAP ('=c', "\\'{c}", 'tex') +call IMAP ('=d', "\\'{d}", 'tex') +call IMAP ('=e', "\\'{e}", 'tex') +call IMAP ('=f', "\\'{f}", 'tex') +call IMAP ('=g', "\\'{g}", 'tex') +call IMAP ('=h', "\\'{h}", 'tex') +call IMAP ('=i', "\\'{\i}", 'tex') +call IMAP ('=j', "\\'{j}", 'tex') +call IMAP ('=k', "\\'{k}", 'tex') +call IMAP ('=l', "\\'{l}", 'tex') +call IMAP ('=m', "\\'{m}", 'tex') +call IMAP ('=n', "\\'{n}", 'tex') +call IMAP ('=o', "\\'{o}", 'tex') +call IMAP ('=p', "\\'{p}", 'tex') +call IMAP ('=q', "\\'{q}", 'tex') +call IMAP ('=r', "\\'{r}", 'tex') +call IMAP ('=s', "\\'{s}", 'tex') +call IMAP ('=t', "\\'{t}", 'tex') +call IMAP ('=u', "\\'{u}", 'tex') +call IMAP ('=v', "\\'{v}", 'tex') +call IMAP ('=w', "\\'{w}", 'tex') +call IMAP ('=x', "\\'{x}", 'tex') +call IMAP ('=y', "\\'{y}", 'tex') +call IMAP ('=z', "\\'{z}", 'tex') +call IMAP ('=A', "\\'{A}", 'tex') +call IMAP ('=B', "\\'{B}", 'tex') +call IMAP ('=C', "\\'{C}", 'tex') +call IMAP ('=D', "\\'{D}", 'tex') +call IMAP ('=E', "\\'{E}", 'tex') +call IMAP ('=F', "\\'{F}", 'tex') +call IMAP ('=G', "\\'{G}", 'tex') +call IMAP ('=H', "\\'{H}", 'tex') +call IMAP ('=I', "\\'{\I}", 'tex') +call IMAP ('=J', "\\'{J}", 'tex') +call IMAP ('=K', "\\'{K}", 'tex') +call IMAP ('=L', "\\'{L}", 'tex') +call IMAP ('=M', "\\'{M}", 'tex') +call IMAP ('=N', "\\'{N}", 'tex') +call IMAP ('=O', "\\'{O}", 'tex') +call IMAP ('=P', "\\'{P}", 'tex') +call IMAP ('=Q', "\\'{Q}", 'tex') +call IMAP ('=R', "\\'{R}", 'tex') +call IMAP ('=S', "\\'{S}", 'tex') +call IMAP ('=T', "\\'{T}", 'tex') +call IMAP ('=U', "\\'{U}", 'tex') +call IMAP ('=V', "\\'{V}", 'tex') +call IMAP ('=W', "\\'{W}", 'tex') +call IMAP ('=X', "\\'{X}", 'tex') +call IMAP ('=Y', "\\'{Y}", 'tex') +call IMAP ('=Z', "\\'{Z}", 'tex') +" }}} +" \v{a} {{{ +call IMAP ('+a', "\\v{a}", 'tex') +call IMAP ('+b', "\\v{b}", 'tex') +call IMAP ('+c', "\\v{c}", 'tex') +call IMAP ('+d', "\\v{d}", 'tex') +call IMAP ('+e', "\\v{e}", 'tex') +call IMAP ('+f', "\\v{f}", 'tex') +call IMAP ('+g', "\\v{g}", 'tex') +call IMAP ('+h', "\\v{h}", 'tex') +call IMAP ('+i', "\\v{\i}", 'tex') +call IMAP ('+j', "\\v{j}", 'tex') +call IMAP ('+k', "\\v{k}", 'tex') +call IMAP ('+l', "\\q l", 'tex') +call IMAP ('+m', "\\v{m}", 'tex') +call IMAP ('+n', "\\v{n}", 'tex') +call IMAP ('+o', "\\v{o}", 'tex') +call IMAP ('+p', "\\v{p}", 'tex') +call IMAP ('+q', "\\v{q}", 'tex') +call IMAP ('+r', "\\v{r}", 'tex') +call IMAP ('+s', "\\v{s}", 'tex') +call IMAP ('+t', "\\q t", 'tex') +call IMAP ('+u', "\\v{u}", 'tex') +call IMAP ('+v', "\\v{v}", 'tex') +call IMAP ('+w', "\\v{w}", 'tex') +call IMAP ('+x', "\\v{x}", 'tex') +call IMAP ('+y', "\\v{y}", 'tex') +call IMAP ('+z', "\\v{z}", 'tex') +call IMAP ('+A', "\\v{A}", 'tex') +call IMAP ('+B', "\\v{B}", 'tex') +call IMAP ('+C', "\\v{C}", 'tex') +call IMAP ('+D', "\\v{D}", 'tex') +call IMAP ('+E', "\\v{E}", 'tex') +call IMAP ('+F', "\\v{F}", 'tex') +call IMAP ('+G', "\\v{G}", 'tex') +call IMAP ('+H', "\\v{H}", 'tex') +call IMAP ('+I', "\\v{\I}", 'tex') +call IMAP ('+J', "\\v{J}", 'tex') +call IMAP ('+K', "\\v{K}", 'tex') +call IMAP ('+L', "\\v{L}", 'tex') +call IMAP ('+M', "\\v{M}", 'tex') +call IMAP ('+N', "\\v{N}", 'tex') +call IMAP ('+O', "\\v{O}", 'tex') +call IMAP ('+P', "\\v{P}", 'tex') +call IMAP ('+Q', "\\v{Q}", 'tex') +call IMAP ('+R', "\\v{R}", 'tex') +call IMAP ('+S', "\\v{S}", 'tex') +call IMAP ('+T', "\\v{T}", 'tex') +call IMAP ('+U', "\\v{U}", 'tex') +call IMAP ('+V', "\\v{V}", 'tex') +call IMAP ('+W', "\\v{W}", 'tex') +call IMAP ('+X', "\\v{X}", 'tex') +call IMAP ('+Y', "\\v{Y}", 'tex') +call IMAP ('+Z', "\\v{Z}", 'tex') +" }}} +call IMAP ('+}', "\\\"{a}", 'tex') +call IMAP ('+:', "\\^{o}", 'tex') + +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4 diff --git a/ftplugin/latex-suite/elementmacros.vim b/ftplugin/latex-suite/elementmacros.vim new file mode 100644 index 00000000..132291a7 --- /dev/null +++ b/ftplugin/latex-suite/elementmacros.vim @@ -0,0 +1,330 @@ +"============================================================================= +" File: elementmacros.vim +" Author: Mikolaj Machowski +" Created: Tue Apr 23 06:00 PM 2002 PST +" +" Description: macros for dimensions/fonts/counters. +" and various common commands such ref/label/footnote. +"============================================================================= + +nmap <silent> <script> <plug> i +imap <silent> <script> <C-o><plug> <Nop> + +if exists('s:lastElementsLocation') && g:Tex_ElementsMenuLocation == s:lastElementsLocation + finish +endif + +if exists('s:lastElementsLocation') + exe 'aunmenu '.s:lastElementsLocation.'Font.' + exe 'aunmenu '.s:lastElementsLocation.'Dimension.' + exe 'aunmenu '.s:lastElementsLocation.'Counters.' + exe 'aunmenu '.s:lastElementsLocation.'Various.' +endif + +let s:lastElementsLocation = g:Tex_ElementsMenuLocation + +let s:fontMenuLoc = g:Tex_ElementsMenuLocation.'Font.' +let s:dimensionMenuLoc = g:Tex_ElementsMenuLocation.'Dimension.' +let s:counterMenuLoc = g:Tex_ElementsMenuLocation.'Counters.' +let s:variousMenuLoc = g:Tex_ElementsMenuLocation.'Various.' + +" ============================================================================== +" Set up the functions the first time. +" ============================================================================== +if !exists('s:definedFuncs') " {{{ + let s:definedFuncs = 1 + + " Tex_RemoveElementMenus: remove the elements menu {{{ + function! Tex_RemoveElementMenus() + exe 'silent! aunmenu '.s:lastElementsLocation.'Font.' + exe 'silent! aunmenu '.s:lastElementsLocation.'Dimension.' + exe 'silent! aunmenu '.s:lastElementsLocation.'Counters.' + exe 'silent! aunmenu '.s:lastElementsLocation.'Various.' + endfunction " }}} + " Tex_FontFamily: sets up font menus {{{ + function! <SID>Tex_FontFamily(font,fam) + let vislhs = matchstr(tolower(a:font), '^.\zs.*') + + " avoid redoing imaps and vmaps for every reconfiguration of menus. + if !exists('s:doneOnce') && g:Tex_FontMaps + exe "vnoremap <silent> ".g:Tex_Leader.vislhs. + \" \<C-\\>\<C-N>:call VEnclose('\\text".vislhs."{', '}', '{\\".vislhs.a:fam." ', '}')<CR>" + exe 'call IMAP ("'.a:font.'", "\\text'.vislhs.'{<++>}<++>", "tex")' + endif + + " menu entry. + if g:Tex_Menus && g:Tex_FontMenus + let location = s:fontMenuLoc.substitute(a:fam, '^.', '\u&', '').'.'.vislhs.a:fam.'<tab>'.a:font.'\ ('.g:Tex_Leader.vislhs.')' + exe "amenu ".location. + \" <plug><C-r>=IMAP_PutTextWithMovement('\\text".vislhs."{<++>}<++>')<CR>" + exe "vmenu ".location. + \" \<C-\\>\<C-N>:call VEnclose('\\text".vislhs."{', '}', '{\\".vislhs.a:fam." ', '}')<CR>" + endif + + endfunction " }}} + " Tex_FontDiacritics: sets up menus for diacritics. {{{ + function! <SID>Tex_FontDiacritics(name, rhs) + let location = s:fontMenuLoc.'&Diacritics.'.a:name.'<tab>' + exe 'amenu '.location. + \" <plug><C-r>=IMAP_PutTextWithMovement('\\".a:rhs."{<++>}<++>')<CR>" + exe 'vmenu '.location. + \" \<C-\\>\<C-n>:call VEnclose('\\".a:rhs."{', '}', '', '')<CR>" + endfunction " }}} + " Tex_FontSize: sets up size fonts {{{ + function! <SID>Tex_FontSize(name) + let location = s:fontMenuLoc.'&Size.'.a:name.'<tab>' + exe 'amenu '.location." <plug>\\".a:name + exe 'vunmenu '.location + endfunction " }}} + " Tex_Fontfont: sets up the 'font' part of font menus {{{ + function! <SID>Tex_Fontfont(desc, lhs) + let location = s:fontMenuLoc.'&font.'.a:desc.'<tab>' + exe "amenu ".location." <plug><C-r>=IMAP_PutTextWithMovement('".a:lhs."')<CR>" + exe "vunmenu ".location + endfunction " }}} + " Tex_DimMenus: set up dimension menus {{{ + function! <SID>Tex_DimMenus(submenu, rhs) + let location = s:dimensionMenuLoc.a:submenu.'.'.a:rhs.'<tab>' + exe "amenu ".location." <plug>\\".a:rhs + exe "vunmenu ".location + endfunction " }}} + " Tex_CounterMenus: set up counters menus {{{ + function! <SID>Tex_CounterMenus(submenu, rhs) + let location = s:counterMenuLoc.a:submenu.'.'.a:rhs.'<tab>' + exe "amenu ".location." <plug>\\".a:rhs + exe "vunmenu ".location + endfunction " }}} + " Tex_VariousMenus: set up various menus {{{ + function! <SID>Tex_VariousMenus(desc, lhs) + let location = s:variousMenuLoc.a:desc.'<tab>' + exe "amenu ".location." <plug><C-r>=IMAP_PutTextWithMovement('".a:lhs."')<CR>" + exe "vunmenu ".location + endfunction " }}} + +endif +" }}} + +" ============================================================================== +" Fonts +" ============================================================================== +" series/family/shape {{{ +call <SID>Tex_FontFamily("FBF","series") +call <SID>Tex_FontFamily("FMD","series") + +call <SID>Tex_FontFamily("FTT","family") +call <SID>Tex_FontFamily("FSF","family") +call <SID>Tex_FontFamily("FRM","family") + +call <SID>Tex_FontFamily("FUP","shape") +call <SID>Tex_FontFamily("FSL","shape") +call <SID>Tex_FontFamily("FSC","shape") +call <SID>Tex_FontFamily("FIT","shape") + +" the \emph is special. +if g:Tex_FontMaps | exe "vnoremap <silent> ".g:Tex_Leader."em \<C-\\>\<C-N>:call VEnclose('\\emph{', '}', '{\\em', '\\/}')<CR>" | endif +if g:Tex_FontMaps | exe 'call IMAP ("FEM", "\\emph{<++>}<++>", "tex")' | endif + +" }}} +if g:Tex_Menus && g:Tex_FontMenus + " {{{ diacritics + call <SID>Tex_FontDiacritics('Acute', '"') + call <SID>Tex_FontDiacritics('Breve', 'u') + call <SID>Tex_FontDiacritics('Circle', 'r') + call <SID>Tex_FontDiacritics('Circumflex', '^') + call <SID>Tex_FontDiacritics('Umlaut', '"') + call <SID>Tex_FontDiacritics('HUmlaut', 'H') + call <SID>Tex_FontDiacritics('Dot\ over', '.') + call <SID>Tex_FontDiacritics('Grave', '`') + call <SID>Tex_FontDiacritics('Hacek', 'v') + call <SID>Tex_FontDiacritics('Makron', '=') + call <SID>Tex_FontDiacritics('Tilde', '~') + call <SID>Tex_FontDiacritics('Underline', 'b') + call <SID>Tex_FontDiacritics('Cedille', 'c') + call <SID>Tex_FontDiacritics('Dot\ under', ' ') + call <SID>Tex_FontDiacritics('Ligature', 't') + " }}} + " {{{ Si&ze. + call <SID>Tex_FontSize('tiny') + call <SID>Tex_FontSize('scriptsize') + call <SID>Tex_FontSize('footnotesize') + call <SID>Tex_FontSize('small') + call <SID>Tex_FontSize('normalsize') + call <SID>Tex_FontSize('large') + call <SID>Tex_FontSize('Large') + call <SID>Tex_FontSize('LARGE') + call <SID>Tex_FontSize('huge') + call <SID>Tex_FontSize('Huge') + " }}} + " {{{ &font. + call s:Tex_Fontfont('fontencoding{}', '\fontencoding{<++>}<++>') + call s:Tex_Fontfont('fontfamily{qtm}', '\fontfamily{<++>}<++>') + call s:Tex_Fontfont('fontseries{m\ b\ bx\ sb\ c}', '\fontseries{<++>}<++>') + call s:Tex_Fontfont('fontshape{n\ it\ sl\ sc\ ui}', '\fontshape{<++>}<++>') + call s:Tex_Fontfont('fontsize{}{}', '\fontsize{<++>}{<++>}<++>') + call s:Tex_Fontfont('selectfont', '\selectfont ') + " }}} +endif + +" ============================================================================== +" Dimensions +" ============================================================================== +if g:Tex_Menus + " {{{ Static1 + call <SID>Tex_DimMenus('Static1', 'arraycolsep') + call <SID>Tex_DimMenus('Static1', 'arrayrulewidth') + call <SID>Tex_DimMenus('Static1', 'bibindent') + call <SID>Tex_DimMenus('Static1', 'columnsep') + call <SID>Tex_DimMenus('Static1', 'columnseprule') + call <SID>Tex_DimMenus('Static1', 'columnwidth') + call <SID>Tex_DimMenus('Static1', 'doublerulesep') + call <SID>Tex_DimMenus('Static1', 'evensidemargin') + call <SID>Tex_DimMenus('Static1', 'fboxrule') + call <SID>Tex_DimMenus('Static1', 'fboxsep') + call <SID>Tex_DimMenus('Static1', 'footheight') + call <SID>Tex_DimMenus('Static1', 'footnotesep') + call <SID>Tex_DimMenus('Static1', 'footskip') + call <SID>Tex_DimMenus('Static1', 'headheight') + call <SID>Tex_DimMenus('Static1', 'headsep') + call <SID>Tex_DimMenus('Static1', 'itemindent') + call <SID>Tex_DimMenus('Static1', 'labelsep') + call <SID>Tex_DimMenus('Static1', 'labelwidth') + call <SID>Tex_DimMenus('Static1', 'leftmargin') + call <SID>Tex_DimMenus('Static1', 'leftmargini') + call <SID>Tex_DimMenus('Static1', 'leftmarginii') + call <SID>Tex_DimMenus('Static1', 'leftmarginiii') + call <SID>Tex_DimMenus('Static1', 'leftmarginiv') + call <SID>Tex_DimMenus('Static1', 'leftmarginv') + call <SID>Tex_DimMenus('Static1', 'leftmarginvi') + call <SID>Tex_DimMenus('Static1', 'linewidth') + call <SID>Tex_DimMenus('Static1', 'listparindent') + call <SID>Tex_DimMenus('Static1', 'marginparpush') + call <SID>Tex_DimMenus('Static1', 'marginparsep') + call <SID>Tex_DimMenus('Static1', 'marginparwidth') + call <SID>Tex_DimMenus('Static1', 'mathindent') + call <SID>Tex_DimMenus('Static1', 'oddsidemargin') + " }}} + " {{{ Static2 + call <SID>Tex_DimMenus('Static2', 'paperheight') + call <SID>Tex_DimMenus('Static2', 'paperwidth') + call <SID>Tex_DimMenus('Static2', 'parindent') + call <SID>Tex_DimMenus('Static2', 'rightmargin') + call <SID>Tex_DimMenus('Static2', 'tabbingsep') + call <SID>Tex_DimMenus('Static2', 'tabcolsep') + call <SID>Tex_DimMenus('Static2', 'textheight') + call <SID>Tex_DimMenus('Static2', 'textwidth') + call <SID>Tex_DimMenus('Static2', 'topmargin') + call <SID>Tex_DimMenus('Static2', 'unitlength') + " }}} + " {{{ Dynamic + call <SID>Tex_DimMenus('Dynamic', 'abovedisplayshortskip') + call <SID>Tex_DimMenus('Dynamic', 'abovedisplayskip') + call <SID>Tex_DimMenus('Dynamic', 'baselineskip') + call <SID>Tex_DimMenus('Dynamic', 'belowdisplayshortskip') + call <SID>Tex_DimMenus('Dynamic', 'belowdisplayskip') + call <SID>Tex_DimMenus('Dynamic', 'dblfloatsep') + call <SID>Tex_DimMenus('Dynamic', 'dbltextfloatsep') + call <SID>Tex_DimMenus('Dynamic', 'floatsep') + call <SID>Tex_DimMenus('Dynamic', 'intextsep') + call <SID>Tex_DimMenus('Dynamic', 'itemsep') + call <SID>Tex_DimMenus('Dynamic', 'parsep') + call <SID>Tex_DimMenus('Dynamic', 'parskip') + call <SID>Tex_DimMenus('Dynamic', 'partopsep') + call <SID>Tex_DimMenus('Dynamic', 'textfloatsep') + call <SID>Tex_DimMenus('Dynamic', 'topsep') + call <SID>Tex_DimMenus('Dynamic', 'topskip') + " }}} + " {{{ Change + call <SID>Tex_DimMenus('Change', 'setlength') + call <SID>Tex_DimMenus('Change', 'addtolength') + call <SID>Tex_DimMenus('Change', 'settoheight') + call <SID>Tex_DimMenus('Change', 'settowidth') + call <SID>Tex_DimMenus('Change', 'settolength') + " }}} +endif + +" ============================================================================== +" Counters +" ============================================================================== +if g:Tex_Menus + " Counters {{{ + call <SID>Tex_CounterMenus('Counters', 'bottomnumber') + call <SID>Tex_CounterMenus('Counters', 'chapter') + call <SID>Tex_CounterMenus('Counters', 'dbltopnumber') + call <SID>Tex_CounterMenus('Counters', 'enumi') + call <SID>Tex_CounterMenus('Counters', 'enumii') + call <SID>Tex_CounterMenus('Counters', 'enumiii') + call <SID>Tex_CounterMenus('Counters', 'enumiv') + call <SID>Tex_CounterMenus('Counters', 'equation') + call <SID>Tex_CounterMenus('Counters', 'figure') + call <SID>Tex_CounterMenus('Counters', 'footnote') + call <SID>Tex_CounterMenus('Counters', 'mpfootnote') + call <SID>Tex_CounterMenus('Counters', 'page') + call <SID>Tex_CounterMenus('Counters', 'paragraph') + call <SID>Tex_CounterMenus('Counters', 'part') + call <SID>Tex_CounterMenus('Counters', 'secnumdepth') + call <SID>Tex_CounterMenus('Counters', 'section') + call <SID>Tex_CounterMenus('Counters', 'subparagraph') + call <SID>Tex_CounterMenus('Counters', 'subsection') + call <SID>Tex_CounterMenus('Counters', 'subsubsection') + call <SID>Tex_CounterMenus('Counters', 'table') + call <SID>Tex_CounterMenus('Counters', 'tocdepth') + call <SID>Tex_CounterMenus('Counters', 'topnumber') + call <SID>Tex_CounterMenus('Counters', 'totalnumber') + " }}} + " theCounters {{{ + call <SID>Tex_CounterMenus('theCounters', 'thebottomnumber') + call <SID>Tex_CounterMenus('theCounters', 'thechapter') + call <SID>Tex_CounterMenus('theCounters', 'thedbltopnumber') + call <SID>Tex_CounterMenus('theCounters', 'theenumi') + call <SID>Tex_CounterMenus('theCounters', 'theenumii') + call <SID>Tex_CounterMenus('theCounters', 'theenumiii') + call <SID>Tex_CounterMenus('theCounters', 'theenumiv') + call <SID>Tex_CounterMenus('theCounters', 'theequation') + call <SID>Tex_CounterMenus('theCounters', 'thefigure') + call <SID>Tex_CounterMenus('theCounters', 'thefootnote') + call <SID>Tex_CounterMenus('theCounters', 'thempfootnote') + call <SID>Tex_CounterMenus('theCounters', 'thepage') + call <SID>Tex_CounterMenus('theCounters', 'theparagraph') + call <SID>Tex_CounterMenus('theCounters', 'thepart') + call <SID>Tex_CounterMenus('theCounters', 'thesecnumdepth') + call <SID>Tex_CounterMenus('theCounters', 'thesection') + call <SID>Tex_CounterMenus('theCounters', 'thesubparagraph') + call <SID>Tex_CounterMenus('theCounters', 'thesubsection') + call <SID>Tex_CounterMenus('theCounters', 'thesubsubsection') + call <SID>Tex_CounterMenus('theCounters', 'thetable') + call <SID>Tex_CounterMenus('theCounters', 'thetocdepth') + call <SID>Tex_CounterMenus('theCounters', 'thetopnumber') + call <SID>Tex_CounterMenus('theCounters', 'thetotalnumber') + " }}} + " Type {{{ + call <SID>Tex_CounterMenus('Type', 'alph') + call <SID>Tex_CounterMenus('Type', 'Alph') + call <SID>Tex_CounterMenus('Type', 'arabic') + call <SID>Tex_CounterMenus('Type', 'roman') + call <SID>Tex_CounterMenus('Type', 'Roman') + " }}} +endif + +" ============================================================================== +" Various +" ============================================================================== +if g:Tex_Menus + " Various {{{ + call <SID>Tex_VariousMenus('ref{}' , '\ref{<++>}<++>') + call <SID>Tex_VariousMenus('pageref{}' , '\pageref{<++>}<++>') + call <SID>Tex_VariousMenus('label{}' , '\label{<++>}<++>') + call <SID>Tex_VariousMenus('footnote{}' , '\footnote{<++>}<++>') + call <SID>Tex_VariousMenus('footnotemark{}', '\footnotemark{<++>}<++>') + call <SID>Tex_VariousMenus('footnotemark{}', '\footnotetext{<++>}<++>') + call <SID>Tex_VariousMenus('cite{}' , '\cite{<++>}<++>') + call <SID>Tex_VariousMenus('nocite{}' , '\nocite{<++>}<++>') + " }}} +endif + +if g:Tex_CatchVisMapErrors + exe "vnoremap ".g:Tex_Leader." :\<C-u>call ExecMap('".g:Tex_Leader."', 'v')\<CR>" +endif +" this is for avoiding reinclusion of imaps from next time on. +let s:doneOnce = 1 + +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4 diff --git a/ftplugin/latex-suite/envmacros.vim b/ftplugin/latex-suite/envmacros.vim new file mode 100644 index 00000000..edf97f79 --- /dev/null +++ b/ftplugin/latex-suite/envmacros.vim @@ -0,0 +1,1166 @@ +"============================================================================= +" File: envmacros.vim +" Author: Mikolaj Machowski +" Created: Tue Apr 23 08:00 PM 2002 PST +" CVS Header: $Id: envmacros.vim 1101 2010-01-28 23:30:56Z tmaas $ +" Description: mappings/menus for environments. +"============================================================================= + +if !g:Tex_EnvironmentMaps && !g:Tex_EnvironmentMenus + finish +endif + +exe 'so '.fnameescape(expand('<sfile>:p:h').'/wizardfuncs.vim') + +nmap <silent> <script> <plug> i +imap <silent> <script> <C-o><plug> <Nop> + +" Define environments for IMAP evaluation " {{{ +let s:figure = "\\begin{figure}[<+htpb+>]\<cr>\\centering\<cr>\\psfig{figure=<+eps file+>}\<cr>\\caption{<+caption text+>}\<cr>\\label{fig:<+label+>}\<cr>\\end{figure}<++>" +let s:figure_graphicx = "\\begin{figure}[<+htpb+>]\<cr>\\centering\<cr>\\includegraphics{<+file+>}\<cr>\\caption{<+caption text+>}\<cr>\\label{fig:<+label+>}\<cr>\\end{figure}<++>" +let s:minipage = "\\begin{minipage}[<+tb+>]{<+width+>}\<cr><++>\<cr>\\end{minipage}<++>" +let s:picture = "\\begin{picture}(<+width+>, <+height+>)(<+xoff+>,<+yoff+>)\<cr>\\put(<+xoff+>,<+yoff+>){\\framebox(<++>,<++>){<++>}}\<cr>\\end{picture}<++>" +let s:list = "\\begin{list}{<+label+>}{<+spacing+>}\<cr>\\item <++>\<cr>\\end{list}<++>" +let s:table = "\\begin{table}\<cr>\\centering\<cr>\\begin{tabular}{<+dimensions+>}\<cr><++>\<cr>\\end{tabular}\<cr>\\caption{<+Caption text+>}\<cr>\\label{tab:<+label+>}\<cr>\\end{table}<++>" +let s:array = "\\left<++>\<cr>\\begin{array}{<+dimension+>}\<cr><+elements+>\<cr>\\end{array}\<cr>\\right<++>" +let s:description ="\\begin{description}\<cr>\\item[<+label+>]<++>\<cr>\\end{description}<++>" +let s:document = "\\documentclass[<+options+>]{<+class+>}\<cr>\<cr>\\begin{document}\<cr><++>\<cr>\\end{document}" +let s:tabular = "\\begin{tabular}[<+hbtp+>]{<+format+>}\<cr><++>\<cr>\\end{tabular}" +let s:tabular_star = "\\begin{tabular*}[<+hbtp+>]{<+format+>}\<cr><++>\<cr>\\end{tabular*}" + +" }}} +" define environments with special behavior in line wise selection. {{{ +if !exists('s:vis_center_left') + let s:vis_center_left = '\centerline{' + let s:vis_center_right = '}' + + let s:vis_verbatim_left = '\verb\|' + let s:vis_verbatim_right = '\|' + + let s:vis_flushright_left = '{\raggedright ' + let s:vis_flushright_right = '}' + + let s:vis_fushleft_left = '{\raggedleft ' + let s:vis_fushleft_right = '}' + + let s:vis_lrbox_left = '\sbox{' + let s:vis_lrbox_right = '}' +endif +" }}} +" Tex_EnvMacros: sets up maps and menus for environments {{{ +" Description: +function! <SID>Tex_EnvMacros(lhs, submenu, name) + + let extra = '' + if a:submenu =~ 'Lists' + let extra = '\item ' + endif + + let vright = '' + let vleft = '' + if exists('s:vis_'.a:name.'_right') + let vright = s:vis_{a:name}_right + let vleft = s:vis_{a:name}_left + endif + let vrhs = "\<C-\\>\<C-N>:call VEnclose('".vleft."', '".vright."', '\\begin{".a:name."}', '\\end{".a:name."}')\<CR>" + let location = g:Tex_EnvMenuLocation.a:submenu.a:name.'<tab>' + + if a:lhs != '' + + let vlhs = g:Tex_Leader2.substitute(tolower(a:lhs), '^.', '', '') + let location = location.a:lhs.'\ ('.vlhs.')' + + if g:Tex_EnvironmentMaps && !exists('s:doneOnce') + call IMAP(a:lhs, "\<C-r>=Tex_PutEnvironment('".a:name."')\<CR>", 'tex') + exec 'vnoremap <silent> '.vlhs.' '.vrhs + endif + + endif + + if g:Tex_Menus && g:Tex_EnvironmentMenus && has("gui_running") + exe 'amenu '.location.' <plug><C-r>=Tex_DoEnvironment("'.a:name.'")<CR>' + exe 'vmenu '.location.' '.vrhs + endif + +endfunction + +" }}} +" Tex_SpecialMacros: macros with special right hand sides {{{ +" Description: +function! <SID>Tex_SpecialMacros(lhs, submenu, name, irhs, ...) + + let wiz = 1 + if a:0 > 0 && a:1 == 0 + let wiz = 0 + endif + + let location = g:Tex_EnvMenuLocation.a:submenu.a:name + + let vright = '' + let vleft = '' + if exists('s:vis_'.a:name.'_right') + let vright = s:vis_{a:name}_right + let vleft = s:vis_{a:name}_left + endif + let vrhs = "\<C-\\>\<C-N>:call VEnclose('".vleft."', '".vright."', '\\begin{".a:name."}', '\\end{".a:name."}')\<CR>" + + if a:lhs != '' + + let vlhs = g:Tex_Leader2.substitute(tolower(a:lhs), '^.', '', '') + let location = location.'<tab>'.a:lhs.'\ ('.vlhs.')' + + if g:Tex_EnvironmentMaps && !exists('s:doneOnce') + call IMAP(a:lhs, a:irhs, 'tex') + exec 'vnoremap '.vlhs.' '.vrhs + endif + + endif + + if g:Tex_Menus && g:Tex_EnvironmentMenus + if wiz + exe 'amenu '.location.' <plug><C-r>=Tex_DoEnvironment("'.a:name.'")<CR>' + else + exe 'amenu '.location." <plug><C-r>=IMAP_PutTextWithMovement('".a:irhs."')<CR>" + endif + exe 'vmenu '.location.' '.vrhs + endif + +endfunction " }}} +" Tex_SectionMacros: creates section maps and menus {{{ +" Description: +function! <SID>Tex_SectionMacros(lhs, name) + + let vlhs = g:Tex_Leader2.substitute(tolower(a:lhs), '^.', '', '') + let vrhs = "\<C-\\>\<C-N>:call VEnclose('\\".a:name."{', '}', '', '')<CR>" + + if g:Tex_SectionMaps && !exists('s:doneOnce') + exe 'vnoremap '.vlhs.' '.vrhs + call IMAP (a:lhs, "\\".a:name.'{<++>}<++>', 'tex') + endif + + if g:Tex_Menus && g:Tex_SectionMenus + let location = g:Tex_EnvMenuLocation.'Sections.'.a:name.'<tab>'.a:lhs.'\ ('.vlhs.')' + let advlocation = g:Tex_EnvMenuLocation.'Sections.Advanced.'.a:name + + let irhs = "\<C-r>=IMAP_PutTextWithMovement('\\".a:name."{<++>}<++>')\<CR>" + + let advirhs = "\<C-r>=Tex_InsSecAdv('".a:name."')\<CR>" + let advvrhs = "\<C-\\>\<C-N>:call Tex_VisSecAdv('".a:name."')\<CR>" + + exe 'amenu '.advlocation.' <plug>'.advirhs + exe 'vnoremenu '.advlocation." ".advvrhs + + exe 'amenu '.location.' <plug>'.irhs + exe 'vnoremenu '.location." ".vrhs + endif +endfunction " }}} + +" NewEnvironments {{{ +call s:Tex_SpecialMacros('', '', 'newenvironment', '\newenvironment{<++>}[<++>][<++>]{<++>}{<++>}<++>', 0) +call s:Tex_SpecialMacros('', '', 'newenvironment*', '\newenvironment*{<++>}[<++>][<++>]{<++>}{<++>}<++>', 0) +call s:Tex_SpecialMacros('', '', 'renewenvironment', '\renewenvironment{<++>}[<++>][<++>]{<++>}{<++>}<++>', 0) +call s:Tex_SpecialMacros('', '', 'renewenvironment*', '\renewenvironment*{<++>}[<++>][<++>]{<++>}{<++>}<++>', 0) +call s:Tex_SpecialMacros('', '', '-sepenv0-', ' :', 0) +" }}} +" Environments specific commands {{{ +call s:Tex_SpecialMacros('', 'Env&Commands.&Lists.', '&item', '\item', 0) +call s:Tex_SpecialMacros('', 'Env&Commands.&Lists.', 'i&tem[]', '\item[<++>]<++>', 0) +call s:Tex_SpecialMacros('', 'Env&Commands.&Lists.', '&bibitem{}', '\bibitem{<++>}<++>', 0) +call s:Tex_SpecialMacros('', 'Env&Commands.&Tabbing.', '\\&=', '\=', 0) +call s:Tex_SpecialMacros('', 'Env&Commands.&Tabbing.', '\\&>', '\>', 0) +call s:Tex_SpecialMacros('', 'Env&Commands.&Tabbing.', '&\\\\', '\\', 0) +call s:Tex_SpecialMacros('', 'Env&Commands.&Tabbing.', '\\&+', '\+', 0) +call s:Tex_SpecialMacros('', 'Env&Commands.&Tabbing.', '\\&-', '\-', 0) +call s:Tex_SpecialMacros('', 'Env&Commands.&Tabbing.', "\\\'", "\\\'", 0) +call s:Tex_SpecialMacros('', 'Env&Commands.&Tabbing.', '\\&`', '\`', 0) +call s:Tex_SpecialMacros('', 'Env&Commands.&Tabbing.', '\\&kill', '\kill', 0) +call s:Tex_SpecialMacros('', 'Env&Commands.&Tabbing.', '&makron\ \\CHAR=', '\<++>=<++>', 0) +call s:Tex_SpecialMacros('', 'Env&Commands.&Tabbing.', "&aigu\ \\CHAR\'", "\\<++>\'<++>", 0) +call s:Tex_SpecialMacros('', 'Env&Commands.&Tabbing.', '&grave\ \\CHAR`', '\<++>`<++>', 0) +call s:Tex_SpecialMacros('', 'Env&Commands.&Tabbing.', 'p&ushtabs', '\pushtabs', 0) +call s:Tex_SpecialMacros('', 'Env&Commands.&Tabbing.', 'p&optabs', '\poptabs', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.&Tabular.', '&hline', '\hline', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.&Tabular.', '&cline', '\cline', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.&Tabular.', '&\&', '&', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.&Tabular.', '&\\\\', '\\', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.&Tabular.', '&multicolumn{}{}{}', '\multicolumn{<++>}{<++>}{<++>}<++>', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.Le&tter.', '&makelabels', '\makelabels', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.Le&tter.', '&address', '\address', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.Le&tter.', '&signature', '\signature', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.Le&tter.', '&date', '\date', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.Le&tter.', '-sepenva4-', ' :', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.Le&tter.', '&opening{}', '\opening{<++>}<++>', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.Le&tter.', '&closing{}', '\closing{<++>}<++>', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.Le&tter.', '&ps{}', '\ps{<++>}<++>', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.Le&tter.', 'cc&{}', '\cc{<++>}<++>', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.&Slides.', '&onlyslides{}', '\onlyslides{<++>}<++>', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.&Slides.', '&onlynotes{}', '\onlynotes{<++>}<++>', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.&Slides.', '-sepenva5-', ' :', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.&Slides.', '&invisible', '\invisible', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.&Slides.', '&visible', '\visible', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.&Slides.', '&settime', '\settime', 0) +call s:Tex_SpecialMacros('', 'EnvCommands.&Slides.', '&addtime', '\addtime', 0) +call s:Tex_SpecialMacros('', '', '-sepenv0-', ' :', 0) +" }}} +" Lists {{{ +call s:Tex_SpecialMacros('ELI', '&Lists.', 'list', s:list) +call s:Tex_SpecialMacros('EDE', '&Lists.', 'description', s:description) +call s:Tex_EnvMacros('EEN', '&Lists.', 'enumerate') +call s:Tex_EnvMacros('EIT', '&Lists.', 'itemize') +call s:Tex_EnvMacros('ETI', '&Lists.', 'theindex') +call s:Tex_EnvMacros('ETL', '&Lists.', 'trivlist') +" }}} +" Tables {{{ +call s:Tex_SpecialMacros('ETE', '&Tables.', 'table', s:table) +call s:Tex_EnvMacros('ETG', '&Tables.', 'tabbing') +call s:Tex_EnvMacros('', '&Tables.', 'table*') +call s:Tex_EnvMacros('', '&Tables.', 'table2') +call s:Tex_SpecialMacros('ETR', '&Tables.', 'tabular', s:tabular) +call s:Tex_SpecialMacros('', '&Tables.', 'tabular*', s:tabular_star) +" }}} +" Math {{{ +call s:Tex_EnvMacros('EAR', '&Math.', 'array') +call s:Tex_EnvMacros('EDM', '&Math.', 'displaymath') +call s:Tex_EnvMacros('EEA', '&Math.', 'eqnarray') +call s:Tex_EnvMacros('', '&Math.', 'eqnarray*') +call s:Tex_EnvMacros('EEQ', '&Math.', 'equation') +call s:Tex_EnvMacros('EMA', '&Math.', 'math') +" }}} +" Structure {{{ +call s:Tex_SpecialMacros('EAR', 'Math.', 'array', s:array) +call s:Tex_EnvMacros('EAB', '&Structure.', 'abstract') +call s:Tex_EnvMacros('EAP', '&Structure.', 'appendix') +call s:Tex_EnvMacros('ECE', '&Structure.', 'center') +call s:Tex_EnvMacros('EDO', '&Structure.', 'document') +call s:Tex_EnvMacros('EFC', '&Structure.', 'filecontents') +call s:Tex_EnvMacros('', '&Structure.', 'filecontents*') +call s:Tex_EnvMacros('EFL', '&Structure.', 'flushleft') +call s:Tex_EnvMacros('EFR', '&Structure.', 'flushright') +call s:Tex_EnvMacros('EQN', '&Structure.', 'quotation') +call s:Tex_EnvMacros('EQE', '&Structure.', 'quote') +call s:Tex_EnvMacros('ESP', '&Structure.', 'sloppypar') +call s:Tex_EnvMacros('ETI', '&Structure.', 'theindex') +call s:Tex_EnvMacros('ETP', '&Structure.', 'titlepage') +call s:Tex_EnvMacros('EVM', '&Structure.', 'verbatim') +call s:Tex_EnvMacros('', '&Structure.', 'verbatim*') +call s:Tex_EnvMacros('EVE', '&Structure.', 'verse') +call s:Tex_EnvMacros('ETB', '&Structure.', 'thebibliography') +call s:Tex_SpecialMacros('', '&Structure.', '-sepstruct0-', ':', 0) +call s:Tex_EnvMacros('ENO', '&Structure.', 'note') +call s:Tex_EnvMacros('EOV', '&Structure.', 'overlay') +call s:Tex_EnvMacros('ESL', '&Structure.', 'slide') +" }}} +" Sections {{{ +call s:Tex_SectionMacros('SPA', 'part') +call s:Tex_SectionMacros('SCH', 'chapter') +call s:Tex_SectionMacros('SSE', 'section') +call s:Tex_SectionMacros('SSS', 'subsection') +call s:Tex_SectionMacros('SS2', 'subsubsection') +call s:Tex_SectionMacros('SPG', 'paragraph') +call s:Tex_SectionMacros('SSP', 'subparagraph') +" }}} +" Miscellaneous {{{ +call s:Tex_SpecialMacros('', '', '-sepenv1-', ' :', 0) +call s:Tex_SpecialMacros('EFI', '', 'figure', "\<C-r>=Tex_PutEnvironment('figure')\<CR>") +call s:Tex_EnvMacros('', '', 'figure*') +call s:Tex_EnvMacros('ELR', '', 'lrbox') +call s:Tex_SpecialMacros('EMP', '', 'minipage', s:minipage) +call s:Tex_SpecialMacros('EPI', '', 'picture', s:picture) +" }}} + +if g:Tex_CatchVisMapErrors + exe 'vnoremap '.g:Tex_Leader2." :\<C-u>call ExecMap('".g:Tex_Leader2."', 'v')\<CR>" +endif + +" ============================================================================== +" Specialized functions for various environments +" +" All these functions are to be used as: +" +" inoremap <lhs> <C-r>=Tex_itemize('enumerate')<CR> +" nnoremap <lhs> i<C-r>=Tex_itemize('enumerate')<CR> +" +" and so on... +" ============================================================================== +" Tex_itemize: {{{ +function! Tex_itemize(env) + return IMAP_PutTextWithMovement('\begin{'.a:env."}\<cr>\\item <++>\<cr>\\end{".a:env."}<++>") +endfunction +" }}} +" Tex_description: {{{ +function! Tex_description(env) + if g:Tex_UseMenuWizard == 1 + let itlabel = input('(Optional) Item label? ') + if itlabel != '' + let itlabel = '['.itlabel.']' + endif + return IMAP_PutTextWithMovement("\\begin{description}\<cr>\\item".itlabel." <++>\<cr>\\end{description}<++>") + else + return IMAP_PutTextWithMovement(s:description) + endif +endfunction +" }}} +" Tex_figure: {{{ +function! Tex_figure(env) + if g:Tex_UseMenuWizard == 1 + let flto = input('Float to (htbp)? ') + let caption = input('Caption? ') + let center = input('Center ([y]/n)? ') + let label = input('Label (for use with \ref)? ') + " additional to AUC Tex since my pics are usually external files + let pic = input('Name of Pic-File? ') + if flto != '' + let flto = '['.flto."]\<cr>" + else + let flto = "\<cr>" + endif + if pic != '' + let pic = '\input{'.pic."}\<cr>" + else + let pic = "<++>\<cr>" + endif + if caption != '' + let caption = '\caption{'.caption."}\<cr>" + endif + if label != '' + let label = '\label{fig:'.label."}\<cr>" + endif + if center == 'y' + let centr = '\begin{center}' . "\<cr>" + let centr = centr . pic + let centr = centr . caption + let centr = centr . label + let centr = centr . '\end{center}' . "\<cr>" + else + let centr = pic + let centr = centr . caption + let centr = centr . label + endif + let figure = '\begin{'.a:env.'}'.flto + let figure = figure . centr + let figure = figure . '\end{'.a:env.'}' + return IMAP_PutTextWithMovement(figure) + else + if g:Tex_package_detected =~ '\<graphicx\>' + return IMAP_PutTextWithMovement(s:figure_graphicx) + else + return IMAP_PutTextWithMovement(s:figure) + endif + endif +endfunction +" }}} +" Tex_table: {{{ +function! Tex_table(env) + if g:Tex_UseMenuWizard == 1 + let flto = input('Float to (htbp)? ') + let caption = input('Caption? ') + let center = input('Center (y/n)? ') + let label = input('Label? ') + if flto != '' + let flto ='['.flto."]\<cr>" + else + let flto = '' + endif + let ret='\begin{table}'.flto + if center == 'y' + let ret=ret."\\begin{center}\<cr>" + endif + let foo = '\begin{tabular}' + let pos = input('(Optional) Position (t b)? ') + if pos != '' + let foo = foo.'['.pos.']' + else + let foo = foo."\<cr>" + endif + let format = input("Format ( l r c p{width} | @{text} )? ") + if format == '' + let format = '<++>' + endif + let ret = ret.foo.'{'.format."}\<cr><++>\<cr>\\end{tabular}<++>\<cr>" + if center == 'y' + let ret=ret."\\end{center}\<cr>" + endif + if caption != '' + let ret=ret.'\caption{'.caption."}\<cr>" + endif + if label != '' + let ret=ret.'\label{tab:'.label."}\<cr>" + endif + let ret=ret.'\end{table}<++>' + return IMAP_PutTextWithMovement(ret) + else + return IMAP_PutTextWithMovement(s:table) + endif +endfunction +" }}} +" Tex_tabular: {{{ +function! Tex_tabular(env) + if g:Tex_UseMenuWizard == 1 + let pos = input('(Optional) Position (t b)? ') + let format = input("Format ( l r c p{width} | @{text} )? ") + if pos != '' + let pos = '['.pos.']' + endif + if format != '' + let format = '{'.format.'}' + endif + return IMAP_PutTextWithMovement('\begin{'.a:env.'}'.pos.format."\<cr> \<cr>\\end{".a:env.'}<++>') + else + return IMAP_PutTextWithMovement('\begin{'.a:env.'}[<+position+>]{<+format+>}'."\<cr><++>\<cr>\\end{".a:env.'}<++>') + endif +endfunction +" }}} +" Tex_eqnarray: {{{ +function! Tex_eqnarray(env) + if g:Tex_UseMenuWizard == 1 + if a:env !~ '\*' + let label = input('Label? ') + if label != '' + let arrlabel = '\label{'.label."}\<cr>" + else + let arrlabel = '' + endif + else + let arrlabel = '' + endif + else + if a:env !~ '\*' + let arrlabel = "\\label{<++>}\<cr>" + else + let arrlabel = "" + endif + endif + return IMAP_PutTextWithMovement('\begin{'.a:env."}\<cr><++>\<cr>".arrlabel."\\end{".a:env."}<++>") +endfunction +" }}} +" Tex_list: {{{ +function! Tex_list(env) + if g:Tex_UseMenuWizard == 1 + let label = input('Label (for \item)? ') + if label != '' + let label = '{'.label.'}' + let addcmd = input('Additional commands? ') + if addcmd != '' + let label = label . '{'.addcmd.'}' + endif + else + let label = '' + endif + return IMAP_PutTextWithMovement('\begin{list}'.label."\<cr>\\item \<cr>\\end{list}<++>") + else + return IMAP_PutTextWithMovement(s:list) + endif +endfunction +" }}} +" Tex_document: {{{ +function! Tex_document(env) + if g:Tex_UseMenuWizard == 1 + let dstyle = input('Document style? ') + let opts = input('(Optional) Options? ') + let foo = '\documentclass' + if opts == '' + let foo = foo.'{'.dstyle.'}' + else + let foo = foo.'['.opts.']'.'{'.dstyle.'}' + endif + return IMAP_PutTextWithMovement(foo."\<cr>\<cr>\\begin{document}\<cr><++>\<cr>\\end{document}") + else + return IMAP_PutTextWithMovement(s:document) + endif +endfunction +" }}} +" Tex_minipage: {{{ +function! Tex_minipage(env) + if g:Tex_UseMenuWizard == 1 + let foo = '\begin{minipage}' + let pos = input('(Optional) Position (t b)? ') + let width = input('Width? ') + if pos == '' + let foo = foo.'{'.width.'}' + else + let foo = foo.'['.pos.']{'.width.'}' + endif + return IMAP_PutTextWithMovement(foo."\<cr><++>\<cr>\\end{minipage}<++>") + else + return IMAP_PutTextWithMovement(s:minipage) + endif +endfunction +" }}} +" Tex_thebibliography: {{{ +function! Tex_thebibliography(env) + if g:Tex_UseMenuWizard == 1 + " AUC Tex: "Label for BibItem: 99" + let indent = input('Indent for BibItem? ') + let foo = '{'.indent.'}' + let biblabel = input('(Optional) Bibitem label? ') + let key = input('Add key? ') + let bar = '\bibitem' + if biblabel != '' + let bar = bar.'['.biblabel.']' + endif + let bar = bar.'{'.key.'}' + return IMAP_PutTextWithMovement('\begin{thebibliography}'.foo."\<cr>".bar." \<cr>\\end{thebibliography}<++>\<Up>") + else + return IMAP_PutTextWithMovement( + \ "\\begin{thebibliography}\<CR>". + \ "\\bibitem[<+biblabel+>]{<+bibkey+>} <++>\<CR>". + \ "<++>\<CR>". + \ "\\end{thebibliography}<++>") + endif +endfunction +" }}} + +" ============================================================================== +" Contributions / suggestions from Carl Mueller (auctex.vim) +" ============================================================================== +" PromptForEnvironment: prompts for an environment {{{ +" Description: +function! PromptForEnvironment(ask) + return Tex_ChooseFromPrompt( + \ a:ask."\n" . + \ Tex_CreatePrompt(g:Tex_PromptedEnvironments, 2, ",") . + \ "\nEnter name or number of environment :", + \ g:Tex_PromptedEnvironments, ",") +endfunction " }}} +" Tex_DoEnvironment: fast insertion of environments {{{ +" Description: +" The menus call this function with an argument (the name of the environment +" to insert). The maps call this without any arguments. In this case, it +" prompts for an environment to enter if the current line is empty. If +" called without arguments and there is a word on the current line, then use +" that as the name of a new environment. +function! Tex_DoEnvironment(...) + if a:0 < 1 + let env = matchstr(getline('.'), '^\s*\zs\w*\*\=\ze\s*$') + " If in current line is more than one word or in visual mode + " ignore contents of line and prompt for environment + if env == '' || (exists('s:isvisual') && s:isvisual == 'yes') + let env = PromptForEnvironment('Choose which environment to insert: ') + if env != '' + return Tex_PutEnvironment(env) + else + return '' + endif + else + " delete the word on the line into the blackhole register. + normal! 0"_D + return Tex_PutEnvironment(env) + endif + else + return Tex_PutEnvironment(a:1) + endif +endfunction " }}} +" Tex_PutEnvironment: calls various specialized functions {{{ +" Description: +" Based on input argument, it calls various specialized functions. +function! Tex_PutEnvironment(env) + if exists("s:isvisual") && s:isvisual == "yes" + let s:isvisual = 'no' + if a:env == '\[' + return VEnclose('', '', '\[', '\]') + elseif a:env == '$$' + return VEnclose('', '', '$$', '$$') + endif + return VEnclose('\begin{'.a:env.'}', '\end{'.a:env.'}', '\begin{'.a:env.'}', '\end{'.a:env.'}') + else + " The user can define something like + " let g:Tex_Env_theorem = "\\begin{theorem}\<CR><++>\<CR>\\end{theorem}" + " This will effectively over-write the default definition of the + " theorem environment which uses a \label. + if exists("b:Tex_Env_{'".a:env."'}") + return IMAP_PutTextWithMovement(b:Tex_Env_{a:env}) + elseif exists("g:Tex_Env_{'".a:env."'}") + return IMAP_PutTextWithMovement(g:Tex_Env_{a:env}) + elseif a:env =~ 'equation*\|eqnarray*\|theorem\|lemma\|equation\|eqnarray\|align\*\|align\>\|multline' + let g:aa = a:env + return Tex_eqnarray(a:env) + elseif a:env =~ "enumerate\\|itemize\\|theindex\\|trivlist" + return Tex_itemize(a:env) + elseif a:env =~ "table\\|table*" + return Tex_table(a:env) + elseif a:env =~ "tabular\\|tabular*\\|array\\|array*" + return Tex_tabular(a:env) + elseif exists('*Tex_'.a:env) + exe 'return Tex_'.a:env.'(a:env)' + elseif a:env == '$$' + return IMAP_PutTextWithMovement('$$<++>$$') + elseif a:env == '\[' + return IMAP_PutTextWithMovement("\\[\<CR><++>\<CR>\\]<++>") + else + " Look in supported packages if exists template for environment + " given in the line + if exists('g:Tex_package_supported') && g:Tex_package_supported != '' + let i = 1 + while Tex_Strntok(g:Tex_package_supported, ',', i) != '' + let checkpack = Tex_Strntok(g:Tex_package_supported, ',', i) + if g:TeX_package_{checkpack} =~ 'e..:'.a:env + if a:env =~ '*' + " Don't allow * to be treated as wildcard + let aenv = substitute(a:env, '*', '\\*', '') + else + let aenv = a:env + endif + let envcommand = matchstr(g:TeX_package_{checkpack}, '\zse..:'.aenv.'[^,]\{-}\ze,') + return Tex_ProcessPackageCommand(envcommand) + endif + let i = i + 1 + endwhile + endif + endif + " If nothing before us managed to create an environment, then just + " create a bare-bones environment from the name. + return IMAP_PutTextWithMovement('\begin{'.a:env."}\<cr><++>\<cr>\\end{".a:env."}<++>") + endif +endfunction " }}} +" Mapping the <F5> key to insert/prompt for an environment/package {{{ +" and <S-F5> to prompt/replace an environment +" +" g:Tex_PromptedEnvironments is a variable containing a comma seperated list +" of environments. This list defines the prompt which latex-suite sets up when +" the user presses <F5> on an empty line. +" +" Leaving this empty is equivalent to disabling the feature. +if g:Tex_PromptedEnvironments != '' + + let b:DoubleDollars = 0 + + " Provide only <plug>s here. main.vim will create the actual maps. + inoremap <silent> <Plug>Tex_FastEnvironmentInsert <C-r>=Tex_FastEnvironmentInsert("no")<cr> + nnoremap <silent> <Plug>Tex_FastEnvironmentInsert i<C-r>=Tex_FastEnvironmentInsert("no")<cr> + vnoremap <silent> <Plug>Tex_FastEnvironmentInsert <C-\><C-N>:call Tex_FastEnvironmentInsert("yes")<CR> + inoremap <silent> <Plug>Tex_FastEnvironmentChange <C-O>:call Tex_ChangeEnvironments()<CR> + nnoremap <silent> <Plug>Tex_FastEnvironmentChange :call Tex_ChangeEnvironments()<CR> + + " Tex_FastEnvironmentInsert: maps <F5> to prompt for env and insert it " {{{ + " Description: + " This function calculates whether we are in the preamble. If we are + " then inserts a \usepackage line by either reading in a word from the + " current line or prompting to type in one. If not in the preamble, then + " inserts a environment template either by reading in a word from the + " current line or prompting the user to choose one. + " + function! Tex_FastEnvironmentInsert(isvisual) + + let start_line = line('.') + let pos = Tex_GetPos() + let s:isvisual = a:isvisual + + " decide if we are in the preamble of the document. If we are then + " insert a package, otherwise insert an environment. + " + if search('\\documentclass', 'bW') && search('\\begin{document}') + + " If there is a \documentclass line and a \begin{document} line in + " the file, then a part of the file is the preamble. + + " search for where the document begins. + let begin_line = search('\\begin{document}') + " if the document begins after where we are presently, then we are + " in the preamble. + if start_line < begin_line + " return to our original location and insert a package + " statement. + call Tex_SetPos(pos) + return Tex_package_from_line() + else + " we are after the preamble. insert an environment. + call Tex_SetPos(pos) + return Tex_DoEnvironment() + endif + + elseif search('\\documentclass') + " if there is only a \documentclass but no \begin{document}, then + " the entire file is a preamble. Put a package. + + call Tex_SetPos(pos) + return Tex_package_from_line() + + else + " no \documentclass, put an environment. + + call Tex_SetPos(pos) + return Tex_DoEnvironment() + + endif + + endfunction + + " }}} + " Tex_package_from_line: puts a \usepackage line in the current line. " {{{ + " Description: + " + function! Tex_package_from_line() + " Function Tex_PutPackage is defined in packages.vim + " Ignores <F5> in Visual mode + if s:isvisual == "yes" + return 0 + else + let l = getline(".") + let pack = matchstr(l, '^\s*\zs.*') + normal! 0"_D + return Tex_pack_one(pack) + endif + endfunction + + " }}} + " Tex_ChangeEnvironments: calls Change() to change the environment {{{ + " Description: + " Finds out which environment the cursor is positioned in and changes + " that to the chosen new environment. This function knows the changes + " which need to be made to change one env to another and calls + " Change() with the info. + " + function! Tex_ChangeEnvironments() + + let env_line = searchpair('$$\|\\[\|begin{', '', '$$\|\\]\|end{', "bn") + + if env_line != 0 + if getline(env_line) !~ 'begin{' + let env_name = '[' + else + let env_name = matchstr(getline(env_line), 'begin{\zs.\{-}\ze}') + endif + endif + + if !exists('env_name') + echomsg "You are not inside environment" + return 0 + endif + + exe 'echomsg "You are within a '.env_name.' environment."' + let change_env = PromptForEnvironment('What do you want to change it to? ') + + if change_env == 'eqnarray' + call <SID>Change('eqnarray', 1, '', env_name =~ '\*$') + elseif change_env == 'align' + call <SID>Change('align', 1, '', env_name =~ '\*$') + elseif change_env == 'eqnarray*' + call <SID>Change('eqnarray*', 0, '\\nonumber', 0) + elseif change_env == 'align*' + call <SID>Change('align*', 0, '\\nonumber', 0) + elseif change_env == 'equation*' + call <SID>Change('equation*', 0, '&\|\\lefteqn{\|\\nonumber\|\\\\', 0) + elseif change_env == '' + return 0 + else + call <SID>Change(change_env, 0, '', '') + return 0 + endif + + endfunction + + " }}} + " Change: changes the current env to the new env {{{ + " Description: + " This function needs to know the changes which need to be made while + " going from an old environment to a new one. This info, it gets from + " Tex_ChangeEnvironments + " + " env : name of the new environment. + " label : if 1, then insert a \label at the end of the environment. + " otherwise, delete any \label line found. + " delete : a pattern which is to be deleted from the original environment. + " for example, going to a eqnarray* environment means we need to + " delete \label's. + " putInNonumber : whether we need to put a \nonumber before the end of the + " environment. + function! s:Change(env, label, delete, putInNonumber) + + let start_line = line('.') + let start_col = virtcol('.') + + if a:env == '[' + if b:DoubleDollars == 0 + let first = '\\[' + let second = '\\]' + else + let first = '$$' + let second = '$$' + endif + else + let first = '\\begin{' . a:env . '}' + let second = '\\end{' . a:env . '}' + endif + + if b:DoubleDollars == 0 + let bottom = searchpair('\\\[\|\\begin{','','\\\]\|\\end{','') + s/\\\]\|\\end{.\{-}}/\=second/ + let top = searchpair('\\\[\|\\begin{','','\\\]\|\\end{','b') + s/\\\[\|\\begin{.\{-}}/\=first/ + else + let bottom = search('\$\$\|\\end{') + s/\$\$\|\\end{.\{-}}/\=second/ + let top = search('\$\$\|\\begin{','b') + s/\$\$\|\\begin{.\{-}}/\=first/ + end + if a:delete != '' + exe 'silent '. top . "," . bottom . 's/' . a:delete . '//e' + endif + + if a:putInNonumber == 1 + exe top + call search('\\end\|\\\\') + if line('.') != bottom + exe '.+1,' . bottom . 's/\\\\/\\nonumber\\\\/e' + exe (bottom-1) . 's/\s*$/ \\nonumber/' + endif + endif + + if a:label == 1 + exe top + if search("\\label", "W") > bottom + exe top + let local_label = input('Label? ') + if local_label != '' + put = '\label{'.local_label.'}' + endif + normal $ + endif + else + exe 'silent '.top . ',' . bottom . ' g/\\label/delete' + endif + + if exists('local_label') && local_label != '' + exe start_line + 1.' | normal! '.start_col.'|' + else + exe start_line.' | normal! '.start_col.'|' + endif + endfunction " }}} + +endif + +" }}} +" Map <S-F1> through <S-F4> to insert environments {{{ +if g:Tex_HotKeyMappings != '' + + " SetUpHotKeys: maps <F1> through <F4> to insert environments + " Description: + function! <SID>SetUpHotKeys() + let i = 1 + let envname = Tex_Strntok(g:Tex_HotKeyMappings, ',', i) + while envname != '' + + exec 'inoremap <silent> <buffer> <S-F'.i.'> <C-r>=Tex_PutEnvironment("'.envname.'")<CR>' + + let i = i + 1 + let envname = Tex_Strntok(g:Tex_HotKeyMappings, ',', i) + + endwhile + + endfunction + +endif + +" }}} +" Tex_SetFastEnvironmentMaps: function for setting up the <F5> and <S-F1>-<S-F4> keys {{{ +" Description: This function is made public so it can be called by the +" SetTeXOptions() function in main.vim +function! Tex_SetFastEnvironmentMaps() + if g:Tex_PromptedEnvironments != '' + call Tex_MakeMap("<F5>", "<Plug>Tex_FastEnvironmentInsert", 'i', '<silent> <buffer>') + call Tex_MakeMap("<F5>", "<Plug>Tex_FastEnvironmentInsert", 'n', '<silent> <buffer>') + call Tex_MakeMap("<F5>", "<Plug>Tex_FastEnvironmentInsert", 'v', '<silent> <buffer>') + call Tex_MakeMap("<S-F5>", "<Plug>Tex_FastEnvironmentChange", 'i', '<silent> <buffer>') + call Tex_MakeMap("<S-F5>", "<Plug>Tex_FastEnvironmentChange", 'n', '<silent> <buffer>') + endif + if g:Tex_HotKeyMappings != '' + call s:SetUpHotKeys() + endif +endfunction " }}} + +" ============================================================================== +" Contributions / Tex_InsertItem() from Johannes Tanzler +" ============================================================================== +" Tex_GetCurrentEnv: gets the current environment in which the cursor lies {{{ +" Description: handles cases such as: +" +" \begin{itemize} +" \item first item +" \item second item +" \begin{description} +" \item first desc +" \item second +" % Tex_GetCurrentEnv will return "description" when called from here +" \end{description} +" \item third item +" % Tex_GetCurrentEnv will return "itemize" when called from here +" \end{itemize} +" % Tex_GetCurrentEnv will return "" when called from here +" +" Author: Alan Schmitt +function! Tex_GetCurrentEnv() + let pos = Tex_GetPos() + let i = 0 + while 1 + let env_line = search('^[^%]*\\\%(begin\|end\){', 'bW') + if env_line == 0 + " we reached the beginning of the file, so we return the empty string + call Tex_SetPos(pos) + return '' + endif + if match(getline(env_line), '^[^%]*\\begin{') == -1 + " we found a \\end, so we keep searching + let i = i + 1 + continue + else + " we found a \\begin which has not been \\end'ed. we are done. + if i == 0 + let env = matchstr(getline(env_line), '\\begin{\zs.\{-}\ze}') + call Tex_SetPos(pos) + return env + else + " this \\begin closes a \\end, continue searching. + let i = i - 1 + continue + endif + endif + endwhile +endfunction +" }}} +" Tex_InsertItem: insert \item into a list {{{ +" Description: Find last \begin line, extract env name, return to the start +" position and insert proper \item, depending on env name. +" Env names are stored in g: variables it can be used by +" package files. + +TexLet g:Tex_ItemStyle_itemize = '\item ' +TexLet g:Tex_ItemStyle_enumerate = '\item ' +TexLet g:Tex_ItemStyle_theindex = '\item ' +TexLet g:Tex_ItemStyle_thebibliography = '\bibitem[<+biblabel+>]{<+bibkey+>} <++>' +TexLet g:Tex_ItemStyle_description = '\item[<+label+>] <++>' + +function! Tex_InsertItem() + " Get current enclosing environment + let env = Tex_GetCurrentEnv() + + if exists('g:Tex_ItemStyle_'.env) + return IMAP_PutTextWithMovement(g:Tex_ItemStyle_{env}) + else + return '' + endif +endfunction +" }}} +" Tex_SetItemMaps: sets the \item inserting maps for current buffer {{{ + +inoremap <script> <silent> <Plug>Tex_InsertItemOnThisLine <C-r>=Tex_InsertItem()<CR> +inoremap <script> <silent> <Plug>Tex_InsertItemOnNextLine <ESC>o<C-R>=Tex_InsertItem()<CR> + +function! Tex_SetItemMaps() + if !hasmapto("<Plug>Tex_InsertItemOnThisLine", "i") + imap <buffer> <M-i> <Plug>Tex_InsertItemOnThisLine + endif + if !hasmapto("<Plug>Tex_InsertItemOnNextLine", "i") + imap <buffer> <C-CR> <Plug>Tex_InsertItemOnNextLine + endif +endfunction " }}} + +" ============================================================================== +" Implementation of Fast Environment commands for LaTeX commands +" ============================================================================== +" Define certain commonly used command definitions {{{ + +TexLet g:Tex_Com_{'newtheorem'} = '\newtheorem{<+name+>}{<+caption+>}[<+within+>]' +TexLet g:Tex_Com_{'frac'} = '\frac{<+n+>}{<+d+>}<++>' + +" }}} +" PromptForCommand: prompts for a command {{{ +" Description: +function! PromptForCommand(ask) + let common_com_prompt = + \ Tex_CreatePrompt(g:Tex_PromptedCommands, 2, ',') . "\n" . + \ "Enter number or command name :" + + let inp = input(a:ask."\n".common_com_prompt) + if inp =~ '^[0-9]\+$' + let com = Tex_Strntok(g:Tex_PromptedCommands, ',', inp) + else + let com = inp + endif + + return com +endfunction " }}} +" Tex_DoCommand: fast insertion of commands {{{ +" Description: +" +function! Tex_DoCommand(isvisual) + " If the current line is empty or if a visual selection has been made, + " prompt for a new environment. + if getline('.') == '' || a:isvisual == 'yes' + let com = PromptForCommand('Choose a command to insert: ') + if com != '' + return Tex_PutCommand(com, a:isvisual) + else + return '' + endif + else + " We want to find out the word under the cursor without issuing + " any movement commands. + let presline = getline('.') + let c = col('.') + + let wordbef = matchstr(strpart(presline, 0, c-1), '\k\+\*\?$') + let wordaft = matchstr(strpart(presline, c-1), '^\k\+\*\?') + + let word = wordbef . wordaft + call Tex_Debug("Tex_DoCommand: wordbef = [".wordbef."], wordaft = [".wordaft."], word = [".word."]", 'env') + + " We use \<Del> instead of \<Bs> because \<Bs> does not work + " unless bs=2 + if word != '' + return substitute(wordbef, '.', "\<Left>", 'g') + \ . substitute(word, '.', "\<Del>", 'g') + \ . Tex_PutCommand(word, a:isvisual) + else + let cmd = PromptForCommand('Choose a command to insert: ') + if cmd != '' + return Tex_PutCommand(cmd, a:isvisual) + else + return '' + endif + endif + endif +endfunction " }}} +" Tex_PutCommand: calls various specialized functions {{{ +" Description: +" Based on input argument, it calls various specialized functions. +function! Tex_PutCommand(com, isvisual) + if a:isvisual == "yes" + if a:com == '$' + return VEnclose('$', '$', '$', '$') + elseif a:com == '\\(' + return VEnclose('\\(', '\\)', '\\(', '\\)') + else + return VEnclose("\\".a:com.'{', '}', "\\".a:com.'{', '}') + endif + else + if exists('b:Tex_Com_{"'.a:com.'"}') + return IMAP_PutTextWithMovement(b:Tex_Com_{a:com}) + elseif exists('g:Tex_Com_{"'.a:com.'"}') + return IMAP_PutTextWithMovement(g:Tex_Com_{a:com}) + elseif a:com == '$' + return IMAP_PutTextWithMovement('$<++>$') + else + return IMAP_PutTextWithMovement("\\".a:com.'{<++>}<++>') + endif + endif +endfunction " }}} +" Mapping the <F7> key to prompt/insert for command {{{ +" and <S-F7> to prompt/replace command +" +" g:Tex_PromptedCommands is a variable containing a comma seperated list +" of commands. +" +" Leaving this empty is equivalent to disabling the feature. +if g:Tex_PromptedCommands != '' + + let b:DoubleDollars = 0 + + inoremap <silent> <Plug>Tex_FastCommandInsert <C-r>=Tex_DoCommand('no')<cr> + nnoremap <silent> <Plug>Tex_FastCommandInsert i<C-r>=Tex_DoCommand('no')<cr> + vnoremap <silent> <Plug>Tex_FastCommandInsert <C-\><C-N>:call Tex_DoCommand('yes')<CR> + + inoremap <silent> <Plug>Tex_FastCommandChange <C-O>:call Tex_ChangeCommand('no')<CR> + nnoremap <silent> <Plug>Tex_FastCommandChange :call Tex_ChangeCommand('no')<CR> + + " Tex_ChangeCommand: calls ChangeCommand() to change the environment {{{ + " Description: + " Finds out which environment the cursor is positioned in and changes + " that to the chosen new environment. This function knows the changes + " which need to be made to change one env to another and calls + " ChangeCommand() with the info. + " + function! Tex_ChangeCommand(isvisual) + + let pos_com = Tex_GetPos() + + let com_line = searchpair('\\\k\{-}{', '', '}', 'b') + + if com_line != 0 + normal l + let com_name = expand('<cword>') + endif + + if !exists('com_name') + echomsg "You are not inside command" + call Tex_SetPos(pos_com) + return 0 + endif + + exe 'echomsg "You are within a '.com_name.' command."' + let change_com = PromptForCommand('Do you want to change it to (number or name)? ') + + if change_com == '' + call Tex_SetPos(pos_com) + return 0 + else + call <SID>ChangeCommand(change_com) + call Tex_SetPos(pos_com) + return 0 + endif + + endfunction + + " }}} + " ChangeCommand: Changes current command according to prompt menu {{{ + " Description: + " + function! s:ChangeCommand(newcom) + + exe 'normal! ct{'.a:newcom."\<Esc>" + + endfunction + " }}} + +endif + +" }}} +" Tex_SetFastCommandMaps: function for setting up the <F7> keys {{{ +" Description: This function is made public so it can be called by the +" SetTeXOptions() function in main.vim +function! Tex_SetFastCommandMaps() + if g:Tex_PromptedCommands != '' + if !hasmapto('<Plug>Tex_FastCommandInsert', 'i') + imap <silent> <buffer> <F7> <Plug>Tex_FastCommandInsert + endif + if !hasmapto('<Plug>Tex_FastCommandInsert', 'n') + nmap <silent> <buffer> <F7> <Plug>Tex_FastCommandInsert + endif + if !hasmapto('<Plug>Tex_FastCommandChange', 'i') + imap <silent> <buffer> <S-F7> <Plug>Tex_FastCommandChange + endif + if !hasmapto('<Plug>Tex_FastCommandChange', 'n') + nmap <silent> <buffer> <S-F7> <Plug>Tex_FastCommandChange + endif + if !hasmapto('<Plug>Tex_FastCommandInsert', 'v') + vmap <silent> <buffer> <F7> <Plug>Tex_FastCommandInsert + endif + endif +endfunction " }}} + +" SetEnvMacrosOptions: sets mappings for buffers {{{ +" " Description: +function! <SID>SetEnvMacrosOptions() + if exists('b:doneTexEnvMaps') + return + endif + let b:doneTexEnvMaps = 1 + if g:Tex_PromptedEnvironments != '' || g:Tex_HotKeyMappings != '' + call Tex_SetFastEnvironmentMaps() + endif + if g:Tex_PromptedCommands != '' + call Tex_SetFastCommandMaps() + endif + call Tex_SetItemMaps() +endfunction " }}} +" Catch the Filetype event so we set maps for each buffer {{{ +augroup LatexSuite + au LatexSuite User LatexSuiteFileType + \ call Tex_Debug('envmacros.vim: Catching LatexSuiteFileType event', 'env') | + \ call s:SetEnvMacrosOptions() +augroup END +" }}} + +" this statement has to be at the end. +let s:doneOnce = 1 + +" vim:fdm=marker:nowrap:noet:ff=unix diff --git a/ftplugin/latex-suite/folding.vim b/ftplugin/latex-suite/folding.vim new file mode 100644 index 00000000..b65407c5 --- /dev/null +++ b/ftplugin/latex-suite/folding.vim @@ -0,0 +1,400 @@ +"============================================================================= +" File: folding.vim +" Author: Srinath Avadhanula +" modifications/additions by Zhang Linbo +" Created: Tue Apr 23 05:00 PM 2002 PST +" +" Description: functions to interact with Syntaxfolds.vim +"============================================================================= + +nnoremap <unique> <Plug>Tex_RefreshFolds :call MakeTexFolds(1)<cr> + +augroup LatexSuite + au LatexSuite User LatexSuiteFileType + \ call Tex_Debug('folding.vim: catching LatexSuiteFileType', 'fold') | + \ call Tex_SetFoldOptions() +augroup END + +" Tex_SetFoldOptions: sets maps for every buffer {{{ +" Description: +function! Tex_SetFoldOptions() + if exists('b:doneSetFoldOptions') + return + endif + let b:doneSetFoldOptions = 1 + + setlocal foldtext=TexFoldTextFunction() + + if g:Tex_Folding && g:Tex_AutoFolding + call MakeTexFolds(0) + endif + + let s:ml = '<Leader>' + + call Tex_MakeMap(s:ml."rf", "<Plug>Tex_RefreshFolds", 'n', '<silent> <buffer>') + +endfunction " }}} +" Tex_FoldSections: creates section folds {{{ +" Author: Zhang Linbo +" Description: +" This function takes a comma seperated list of "sections" and creates fold +" definitions for them. The first item is supposed to be the "shallowest" field +" and the last is the "deepest". See g:Tex_FoldedSections for the default +" definition of the lst input argument. +" +" **works recursively** +function! Tex_FoldSections(lst, endpat) + let i = match(a:lst, ',') + if i > 0 + let s = strpart(a:lst, 0, i) + else + let s = a:lst + endif + if s =~ '%%fakesection' + let s = '^\s*' . s + else + let pattern = '' + let prefix = '' + for label in split(s, "|") + let pattern .= prefix . '^\s*\\' . label . '\W\|^\s*%%fake' . label + let prefix = '\W\|' + endfor + let s = pattern + endif + let endpat = s . '\|' . a:endpat + if i > 0 + call Tex_FoldSections(strpart(a:lst,i+1), endpat) + endif + let endpat = '^\s*\\appendix\W\|' . endpat + call AddSyntaxFoldItem(s, endpat, 0, -1) +endfunction +" }}} +" MakeTexFolds: function to create fold items for latex. {{{ +" +" used in conjunction with MakeSyntaxFolds(). +" see ../plugin/syntaxFolds.vim for documentation +function! MakeTexFolds(force) + if exists('g:Tex_Folding') && !g:Tex_Folding + return + endif + if &ft != 'tex' + return + end + + " Setup folded items lists g:Tex_Foldedxxxx + " 1. Use default value if g:Tex_Foldedxxxxxx is not defined + " 2. prepend default value to g:Tex_Foldedxxxxxx if it starts with ',' + " 3. append default value to g:Tex_Foldedxxxxxx if it ends with ',' + + " Folding items which are not caught in any of the standard commands, + " environments or sections. + let s = 'item,slide,preamble,<<<' + if !exists('g:Tex_FoldedMisc') + let g:Tex_FoldedMisc = s + elseif g:Tex_FoldedMisc[0] == ',' + let g:Tex_FoldedMisc = s . g:Tex_FoldedMisc + elseif g:Tex_FoldedMisc =~ ',$' + let g:Tex_FoldedMisc = g:Tex_FoldedMisc . s + endif + + " By default do not fold any commands. It looks like trying to fold + " commands is a difficult problem since commands can be arbitrarily nested + " and the end patterns are not unique unlike the case of environments. + " For this to work well, we need a regexp which will match a line only if + " a command begins on that line but does not end on that line. This + " requires a regexp which will match unbalanced curly braces and that is + " apparently not doable with regexps. + let s = '' + if !exists('g:Tex_FoldedCommands') + let g:Tex_FoldedCommands = s + elseif g:Tex_FoldedCommands[0] == ',' + let g:Tex_FoldedCommands = s . g:Tex_FoldedCommands + elseif g:Tex_FoldedCommands =~ ',$' + let g:Tex_FoldedCommands = g:Tex_FoldedCommands . s + endif + + let s = 'verbatim,comment,eq,gather,align,figure,table,thebibliography,' + \. 'keywords,abstract,titlepage' + if !exists('g:Tex_FoldedEnvironments') + let g:Tex_FoldedEnvironments = s + elseif g:Tex_FoldedEnvironments[0] == ',' + let g:Tex_FoldedEnvironments = s . g:Tex_FoldedEnvironments + elseif g:Tex_FoldedEnvironments =~ ',$' + let g:Tex_FoldedEnvironments = g:Tex_FoldedEnvironments . s + endif + + if !exists('g:Tex_FoldedSections') + let g:Tex_FoldedSections = 'part,chapter,section,' + \. 'subsection,subsubsection,paragraph' + endif + + " the order in which these calls are made decides the nestedness. in + " latex, a table environment will always be embedded in either an item or + " a section etc. not the other way around. so we first fold up all the + " tables. and then proceed with the other regions. + + let b:numFoldItems = 0 + + " ======================================================================== + " How to add new folding items {{{ + " ======================================================================== + " + " Each of the following function calls defines a syntax fold region. Each + " definition consists of a call to the AddSyntaxFoldItem() function. + " + " The order in which the folds are defined is important. Juggling the + " order of the function calls will create havoc with folding. The + " "deepest" folding item needs to be called first. For example, if + " the \begin{table} environment is a subset (or lies within) the \section + " environment, then add the definition for the \table first. + " + " The AddSyntaxFoldItem() function takes either 4 or 6 arguments. When it + " is called with 4 arguments, it is equivalent to calling it with 6 + " arguments with the last two left blank (i.e as empty strings) + " + " The explanation for each argument is as follows: + " startpat: a line matching this pattern defines the beginning of a fold. + " endpat : a line matching this pattern defines the end of a fold. + " startoff: this is the offset from the starting line at which folding will + " actually start + " endoff : like startoff, but gives the offset of the actual fold end from + " the line satisfying endpat. + " startoff and endoff are necessary when the folding region does + " not have a specific end pattern corresponding to a start + " pattern. for example in latex, + " \begin{section} + " defines the beginning of a section, but its not necessary to + " have a corresponding + " \end{section} + " the section is assumed to end 1 line _before_ another section + " starts. + " startskip: a pattern which defines the beginning of a "skipped" region. + " + " For example, suppose we define a \itemize fold as follows: + " startpat = '^\s*\\item', + " endpat = '^\s*\\item\|^\s*\\end{\(enumerate\|itemize\|description\)}', + " startoff = 0, + " endoff = -1 + " + " This defines a fold which starts with a line beginning with an + " \item and ending one line before a line beginning with an + " \item or \end{enumerate} etc. + " + " Then, as long as \item's are not nested things are fine. + " However, once items begin to nest, the fold started by one + " \item can end because of an \item in an \itemize + " environment within this \item. i.e, the following can happen: + " + " \begin{itemize} + " \item Some text <------- fold will start here + " This item will contain a nested item + " \begin{itemize} <----- fold will end here because next line contains \item... + " \item Hello + " \end{itemize} <----- ... instead of here. + " \item Next item of the parent itemize + " \end{itemize} + " + " Therefore, in order to completely define a folding item which + " allows nesting, we need to also define a "skip" pattern. + " startskip and end skip do that. + " Leave '' when there is no nesting. + " endskip: the pattern which defines the end of the "skip" pattern for + " nested folds. + " + " Example: + " 1. A syntax fold region for a latex section is + " startpat = "\\section{" + " endpat = "\\section{" + " startoff = 0 + " endoff = -1 + " startskip = '' + " endskip = '' + " Note that the start and end patterns are thus the same and endoff has a + " negative value to capture the effect of a section ending one line before + " the next starts. + " 2. A syntax fold region for the \itemize environment is: + " startpat = '^\s*\\item', + " endpat = '^\s*\\item\|^\s*\\end{\(enumerate\|itemize\|description\)}', + " startoff = 0, + " endoff = -1, + " startskip = '^\s*\\begin{\(enumerate\|itemize\|description\)}', + " endskip = '^\s*\\end{\(enumerate\|itemize\|description\)}' + " Note the use of startskip and endskip to allow nesting. + " + " + " }}} + " ======================================================================== + + " {{{ comment lines + if g:Tex_FoldedMisc =~ '\<comments\>' + call AddSyntaxFoldItem ( + \ '^%\([^%]\|[^f]\|[^a]\|[^k]\|[^e]\)', + \ '^[^%]', + \ 0, + \ -1 + \ ) + endif + " }}} + + " {{{ items + if g:Tex_FoldedMisc =~ '\<item\>' + call AddSyntaxFoldItem ( + \ '^\s*\\item', + \ '^\s*\\item\|^\s*\\end{\(enumerate\|itemize\|description\)}', + \ 0, + \ -1, + \ '^\s*\\begin{\(enumerate\|itemize\|description\)}', + \ '^\s*\\end{\(enumerate\|itemize\|description\)}' + \ ) + endif + " }}} + + " {{{ title + if g:Tex_FoldedMisc =~ '\<title\>' + call AddSyntaxFoldItem ( + \ '^\s*\\title\W', + \ '^\s*\\maketitle', + \ 0, + \ 0 + \ ) + endif + " }}} + + " Commands and Environments {{{ + " Fold the commands and environments in 2 passes. + let pass = 0 + while pass < 2 + if pass == 0 + let lst = g:Tex_FoldedCommands + else + let lst = g:Tex_FoldedEnvironments + endif + while lst != '' + let i = match(lst, ',') + if i > 0 + let s = strpart(lst, 0, i) + let lst = strpart(lst, i+1) + else + let s = lst + let lst = '' + endif + if s != '' + if pass == 0 + " NOTE: This pattern ensures that a command which is + " terminated on the same line will not start a fold. + " However, it will also refuse to fold certain commands + " which have not terminated. eg: + " \commandname{something \bf{text} and + " will _not_ start a fold. + " In other words, the pattern is safe, but not exact. + call AddSyntaxFoldItem('^\s*\\'.s.'{[^{}]*$','^[^}]*}',0,0) + else + call AddSyntaxFoldItem('^\s*\\begin{'.s,'\(^\|\s\)\s*\\end{'.s,0,0) + endif + endif + endwhile + let pass = pass + 1 + endwhile + " }}} + + " Sections {{{ + if g:Tex_FoldedSections != '' + call Tex_FoldSections(g:Tex_FoldedSections, + \ '^\s*\\frontmatter\|^\s*\\mainmatter\|^\s*\\backmatter\|' + \. '^\s*\\begin{thebibliography\|>>>\|^\s*\\endinput\|' + \. '^\s*\\begin{slide\|^\s*\\end{document') + endif + " }}} + + " {{{ slide + if g:Tex_FoldedMisc =~ '\<slide\>' + call AddSyntaxFoldItem ( + \ '^\s*\\begin{slide', + \ '^\s*\\appendix\W\|^\s*\\chapter\W\|^\s*\\end{slide\|^\s*\\end{document', + \ 0, + \ 0 + \ ) + endif + " }}} + + " {{{ preamble + if g:Tex_FoldedMisc =~ '\<preamble\>' + call AddSyntaxFoldItem ( + \ '^\s*\\document\(class\|style\).*{', + \ '^\s*\\begin{document}', + \ 0, + \ -1 + \ ) + endif + " }}} + + " Manually folded regions {{{ + if g:Tex_FoldedMisc =~ '\(^\|,\)<<<\(,\|$\)' + call AddSyntaxFoldItem ( + \ '<<<', + \ '>>>', + \ 0, + \ 0 + \ ) + endif + " }}} + + call MakeSyntaxFolds(a:force) + normal! zv +endfunction + +" }}} +" TexFoldTextFunction: create fold text for folds {{{ +function! TexFoldTextFunction() + let leadingSpace = matchstr(' ', ' \{,'.indent(v:foldstart).'}') + if getline(v:foldstart) =~ '^\s*\\begin{' + let header = matchstr(getline(v:foldstart), + \ '^\s*\\begin{\zs\([:alpha:]*\)[^}]*\ze}') + let caption = '' + let label = '' + let i = v:foldstart + while i <= v:foldend + if getline(i) =~ '\\caption' + " distinguish between + " \caption{fulldesc} - fulldesc will be displayed + " \caption[shortdesc]{fulldesc} - shortdesc will be displayed + if getline(i) =~ '\\caption\[' + let caption = matchstr(getline(i), '\\caption\[\zs[^\]]*') + let caption = substitute(caption, '\zs\]{.*}[^}]*$', '', '') + else + let caption = matchstr(getline(i), '\\caption{\zs.*') + let caption = substitute(caption, '\zs}[^}]*$', '', '') + end + elseif getline(i) =~ '\\label' + let label = matchstr(getline(i), '\\label{\zs.*') + " :FIXME: this does not work when \label contains a + " newline or a }-character + let label = substitute(label, '\([^}]*\)}.*$', '\1', '') + end + + let i = i + 1 + endwhile + + let ftxto = foldtext() + " if no caption found, then use the second line. + if caption == '' + let caption = getline(v:foldstart + 1) + end + + let retText = matchstr(ftxto, '^[^:]*').': '.header. + \ ' ('.label.'): '.caption + return leadingSpace.retText + + elseif getline(v:foldstart) =~ '^%' && getline(v:foldstart) !~ '^%%fake' + let ftxto = foldtext() + return leadingSpace.substitute(ftxto, ':', ': % ', '') + elseif getline(v:foldstart) =~ '^\s*\\document\(class\|style\).*{' + let ftxto = leadingSpace.foldtext() + return substitute(ftxto, ':', ': Preamble: ', '') + else + return leadingSpace.foldtext() + end +endfunction +" }}} + +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4 diff --git a/ftplugin/latex-suite/main.vim b/ftplugin/latex-suite/main.vim new file mode 100644 index 00000000..ad27b917 --- /dev/null +++ b/ftplugin/latex-suite/main.vim @@ -0,0 +1,1042 @@ +" LaTeX filetype +" Language: LaTeX (ft=tex) +" Maintainer: Srinath Avadhanula +" URL: + +" line continuation used here. +let s:save_cpo = &cpo +set cpo&vim + +" avoiding re-inclusion {{{ +" the avoiding re-inclusion statement is not provided here because the files +" which call this file should in the normal course of events handle the +" re-inclusion stuff. + +" we definitely dont want to run through the entire file each and every time. +" only once to define the functions. for successive latex files, just set up +" the folding and mappings and quit. +if exists('s:doneFunctionDefinitions') && !exists('b:forceRedoLocalTex') + call s:SetTeXOptions() + finish +endif + +let s:doneFunctionDefinitions = 1 + +" get the place where this plugin resides for setting cpt and dict options. +" these lines need to be outside the function. +let s:path = expand('<sfile>:p:h') +" set up personal defaults. +runtime ftplugin/tex/texrc +" set up global defaults. +exe "so ".fnameescape(s:path.'/texrc') + +" }}} + +nmap <silent> <script> <plug> i +imap <silent> <script> <C-o><plug> <Nop> + +" ============================================================================== +" mappings +" ============================================================================== +" {{{ +" calculate the mapleader character. +let s:ml = '<Leader>' + +if !exists('s:doneMappings') + let s:doneMappings = 1 + " short forms for latex formatting and math elements. {{{ + " taken from auctex.vim or miktexmacros.vim + call IMAP ('__', '_{<++>}<++>', "tex") + call IMAP ('()', '(<++>)<++>', "tex") + call IMAP ('[]', '[<++>]<++>', "tex") + call IMAP ('{}', '{<++>}<++>', "tex") + call IMAP ('^^', '^{<++>}<++>', "tex") + call IMAP ('$$', '$<++>$<++>', "tex") + call IMAP ('==', '&=& ', "tex") + call IMAP ('~~', '&\approx& ', "tex") + call IMAP ('=~', '\approx', "tex") + call IMAP ('::', '\dots', "tex") + call IMAP ('((', '\left( <++> \right)<++>', "tex") + call IMAP ('[[', '\left[ <++> \right]<++>', "tex") + call IMAP ('{{', '\left\{ <++> \right\}<++>', "tex") + call IMAP (g:Tex_Leader.'^', '\hat{<++>}<++>', "tex") + call IMAP (g:Tex_Leader.'_', '\bar{<++>}<++>', "tex") + call IMAP (g:Tex_Leader.'6', '\partial', "tex") + call IMAP (g:Tex_Leader.'8', '\infty', "tex") + call IMAP (g:Tex_Leader.'/', '\frac{<++>}{<++>}<++>', "tex") + call IMAP (g:Tex_Leader.'%', '\frac{<++>}{<++>}<++>', "tex") + call IMAP (g:Tex_Leader.'@', '\circ', "tex") + call IMAP (g:Tex_Leader.'0', '^\circ', "tex") + call IMAP (g:Tex_Leader.'=', '\equiv', "tex") + call IMAP (g:Tex_Leader."\\",'\setminus', "tex") + call IMAP (g:Tex_Leader.'.', '\cdot', "tex") + call IMAP (g:Tex_Leader.'*', '\times', "tex") + call IMAP (g:Tex_Leader.'&', '\wedge', "tex") + call IMAP (g:Tex_Leader.'-', '\bigcap', "tex") + call IMAP (g:Tex_Leader.'+', '\bigcup', "tex") + call IMAP (g:Tex_Leader.'M', '\sum_{<++>}^{<++>}<++>', 'tex') + call IMAP (g:Tex_Leader.'S', '\sum_{<++>}^{<++>}<++>', 'tex') + call IMAP (g:Tex_Leader.'(', '\subset', "tex") + call IMAP (g:Tex_Leader.')', '\supset', "tex") + call IMAP (g:Tex_Leader.'<', '\le', "tex") + call IMAP (g:Tex_Leader.'>', '\ge', "tex") + call IMAP (g:Tex_Leader.',', '\nonumber', "tex") + call IMAP (g:Tex_Leader.'~', '\tilde{<++>}<++>', "tex") + call IMAP (g:Tex_Leader.';', '\dot{<++>}<++>', "tex") + call IMAP (g:Tex_Leader.':', '\ddot{<++>}<++>', "tex") + call IMAP (g:Tex_Leader.'2', '\sqrt{<++>}<++>', "tex") + call IMAP (g:Tex_Leader.'|', '\Big|', "tex") + call IMAP (g:Tex_Leader.'I', "\\int_{<++>}^{<++>}<++>", 'tex') + " }}} + " Greek Letters {{{ + call IMAP(g:Tex_Leader.'a', '\alpha', 'tex') + call IMAP(g:Tex_Leader.'b', '\beta', 'tex') + call IMAP(g:Tex_Leader.'c', '\chi', 'tex') + call IMAP(g:Tex_Leader.'d', '\delta', 'tex') + call IMAP(g:Tex_Leader.'e', '\varepsilon', 'tex') + call IMAP(g:Tex_Leader.'f', '\varphi', 'tex') + call IMAP(g:Tex_Leader.'g', '\gamma', 'tex') + call IMAP(g:Tex_Leader.'h', '\eta', 'tex') + call IMAP(g:Tex_Leader.'i', '\iota', 'tex') + call IMAP(g:Tex_Leader.'k', '\kappa', 'tex') + call IMAP(g:Tex_Leader.'l', '\lambda', 'tex') + call IMAP(g:Tex_Leader.'m', '\mu', 'tex') + call IMAP(g:Tex_Leader.'n', '\nu', 'tex') + call IMAP(g:Tex_Leader.'p', '\pi', 'tex') + call IMAP(g:Tex_Leader.'q', '\theta', 'tex') + call IMAP(g:Tex_Leader.'r', '\rho', 'tex') + call IMAP(g:Tex_Leader.'s', '\sigma', 'tex') + call IMAP(g:Tex_Leader.'t', '\tau', 'tex') + call IMAP(g:Tex_Leader.'u', '\upsilon', 'tex') + call IMAP(g:Tex_Leader.'v', '\varsigma', 'tex') + call IMAP(g:Tex_Leader.'w', '\omega', 'tex') + call IMAP(g:Tex_Leader.'w', '\wedge', 'tex') " AUCTEX style + call IMAP(g:Tex_Leader.'x', '\xi', 'tex') + call IMAP(g:Tex_Leader.'y', '\psi', 'tex') + call IMAP(g:Tex_Leader.'z', '\zeta', 'tex') + " not all capital greek letters exist in LaTeX! + " reference: http://www.giss.nasa.gov/latex/ltx-405.html + call IMAP(g:Tex_Leader.'D', '\Delta', 'tex') + call IMAP(g:Tex_Leader.'F', '\Phi', 'tex') + call IMAP(g:Tex_Leader.'G', '\Gamma', 'tex') + call IMAP(g:Tex_Leader.'Q', '\Theta', 'tex') + call IMAP(g:Tex_Leader.'L', '\Lambda', 'tex') + call IMAP(g:Tex_Leader.'X', '\Xi', 'tex') + call IMAP(g:Tex_Leader.'Y', '\Psi', 'tex') + call IMAP(g:Tex_Leader.'S', '\Sigma', 'tex') + call IMAP(g:Tex_Leader.'U', '\Upsilon', 'tex') + call IMAP(g:Tex_Leader.'W', '\Omega', 'tex') + " }}} + " ProtectLetters: sets up indentity maps for things like ``a {{{ + " " Description: If we simply do + " call IMAP('`a', '\alpha', 'tex') + " then we will never be able to type 'a' after a tex-quotation. Since + " IMAP() always uses the longest map ending in the letter, this problem + " can be avoided by creating a fake map for ``a -> ``a. + " This function sets up fake maps of the following forms: + " ``[aA] -> ``[aA] (for writing in quotations) + " \`[aA] -> \`[aA] (for writing diacritics) + " "`[aA] -> "`[aA] (for writing german quotations) + " It does this for all printable lower ascii characters just to make sure + " we dont let anything slip by. + function! s:ProtectLetters(first, last) + let i = a:first + while i <= a:last + if nr2char(i) =~ '[[:print:]]' + call IMAP('``'.nr2char(i), '``'.nr2char(i), 'tex') + call IMAP('\`'.nr2char(i), '\`'.nr2char(i), 'tex') + call IMAP('"`'.nr2char(i), '"`'.nr2char(i), 'tex') + endif + let i = i + 1 + endwhile + endfunction + call s:ProtectLetters(32, 127) + " }}} + " vmaps: enclose selected region in brackets, environments {{{ + " The action changes depending on whether the selection is character-wise + " or line wise. for example, selecting linewise and pressing \v will + " result in the region being enclosed in \begin{verbatim}, \end{verbatim}, + " whereas in characterise visual mode, the thingie is enclosed in \verb| + " and |. + exec 'vnoremap <silent> '.g:Tex_Leader."( \<C-\\>\<C-N>:call VEnclose('\\left( ', ' \\right)', '\\left(', '\\right)')\<CR>" + exec 'vnoremap <silent> '.g:Tex_Leader."[ \<C-\\>\<C-N>:call VEnclose('\\left[ ', ' \\right]', '\\left[', '\\right]')\<CR>" + exec 'vnoremap <silent> '.g:Tex_Leader."{ \<C-\\>\<C-N>:call VEnclose('\\left\\{ ', ' \\right\\}', '\\left\\{', '\\right\\}')\<CR>" + exec 'vnoremap <silent> '.g:Tex_Leader."$ \<C-\\>\<C-N>:call VEnclose('$', '$', '\\[', '\\]')\<CR>" + " }}} +end + +" }}} + +" ============================================================================== +" Helper functions for debugging +" ============================================================================== +" Tex_Debug: appends the argument into s:debugString {{{ +" Description: +" +" Do not want a memory leak! Set this to zero so that latex-suite always +" starts out in a non-debugging mode. +if !exists('g:Tex_Debug') + let g:Tex_Debug = 0 +endif +function! Tex_Debug(str, ...) + if !g:Tex_Debug + return + endif + if a:0 > 0 + let pattern = a:1 + else + let pattern = '' + endif + if !exists('s:debugString_'.pattern) + let s:debugString_{pattern} = '' + endif + let s:debugString_{pattern} = s:debugString_{pattern}.a:str."\n" + + let s:debugString_ = (exists('s:debugString_') ? s:debugString_ : '') + \ . pattern.' : '.a:str."\n" + + if Tex_GetVarValue('Tex_DebugLog') != '' + exec 'redir! >> '.Tex_GetVarValue('Tex_DebugLog') + silent! echo pattern.' : '.a:str + redir END + endif +endfunction " }}} +" Tex_PrintDebug: prings s:debugString {{{ +" Description: +" +function! Tex_PrintDebug(...) + if a:0 > 0 + let pattern = a:1 + else + let pattern = '' + endif + if exists('s:debugString_'.pattern) + echo s:debugString_{pattern} + endif +endfunction " }}} +" Tex_ClearDebug: clears the s:debugString string {{{ +" Description: +" +function! Tex_ClearDebug(...) + if a:0 > 0 + let pattern = a:1 + else + let pattern = '' + endif + if exists('s:debugString_'.pattern) + let s:debugString_{pattern} = '' + endif +endfunction " }}} +" Tex_ShowVariableValue: debugging help {{{ +" provides a way to examine script local variables from outside the script. +" very handy for debugging. +function! Tex_ShowVariableValue(...) + let i = 1 + while i <= a:0 + exe 'let arg = a:'.i + if exists('s:'.arg) || + \ exists('*s:'.arg) + exe 'let val = s:'.arg + echomsg 's:'.arg.' = '.val + end + let i = i + 1 + endwhile +endfunction + +" }}} + +" ============================================================================== +" Helper functions for grepping +" ============================================================================== +" Tex_Grep: shorthand for :grep or :vimgrep {{{ +function! Tex_Grep(string, where) + if v:version >= 700 + exec 'silent! vimgrep! /'.a:string.'/ '.a:where + else + exec 'silent! grep! '.Tex_EscapeForGrep(a:string).' '.a:where + endif +endfunction + +" }}} +" Tex_Grepadd: shorthand for :grepadd or :vimgrepadd {{{ +function! Tex_Grepadd(string, where) + if v:version >= 700 + exec 'silent! vimgrepadd! /'.a:string.'/ '.a:where + else + exec "silent! grepadd! ".Tex_EscapeForGrep(a:string).' '.a:where + endif +endfunction + +" }}} +" Tex_EscapeForGrep: escapes back-slashes and doublequotes the correct number of times {{{ +" Description: This command escapes the backslash and double quotes in a +" search pattern the correct number of times so it can be used in the ``:grep`` +" command. This command is meant to be used as:: +" +" exec "silent! grep ".Tex_EscapeForGrep(pattern)." file" +" +" The input argument to this function should be the string which you want +" the external command to finally see. For example, to search for a string +" ``'\bibitem'``, the grep command needs to be passed a string like +" ``'\\bibitem'``. Examples:: +" +" Tex_EscapeForGrep('\\bibitem') " correct +" Tex_EscapeForGrep('\bibitem') " wrong +" Tex_EscapeForGrep("\\bibitem") " wrong +" Tex_EscapeForGrep('\<word\>') " correct +" +function! Tex_EscapeForGrep(string) + let retVal = a:string + + " The shell halves the backslashes. + if &shell =~ 'sh' + let retVal = escape(retVal, "\\") + + " If shellxquote is set, then the backslashes are halved yet again. + if &shellxquote == '"' + let retVal = escape(retVal, "\"\\") + endif + + endif + " escape special characters which bash/cmd.exe might interpret + let retVal = escape(retVal, "<>") + + return retVal +endfunction " }}} + +" ============================================================================== +" Uncategorized helper functions +" ============================================================================== +" Tex_Strntok: extract the n^th token from a list {{{ +" example: Strntok('1,23,3', ',', 2) = 23 +fun! Tex_Strntok(s, tok, n) + return matchstr( a:s.a:tok[0], '\v(\zs([^'.a:tok.']*)\ze['.a:tok.']){'.a:n.'}') +endfun + +" }}} +" Tex_CreatePrompt: creates a prompt string {{{ +" Description: +" Arguments: +" promptList: This is a string of the form: +" 'item1,item2,item3,item4' +" cols: the number of columns in the resultant prompt +" sep: the list seperator token +" +" Example: +" Tex_CreatePrompt('item1,item2,item3,item4', 2, ',') +" returns +" "(1) item1\t(2)item2\n(3)item3\t(4)item4" +" +" This string can be used in the input() function. +function! Tex_CreatePrompt(promptList, cols, sep) + + let g:listSep = a:sep + let num_common = GetListCount(a:promptList) + + let i = 1 + let promptStr = "" + + while i <= num_common + + let j = 0 + while j < a:cols && i + j <= num_common + let com = Tex_Strntok(a:promptList, a:sep, i+j) + let promptStr = promptStr.'('.(i+j).') '. + \ com."\t".( strlen(com) < 4 ? "\t" : '' ) + + let j = j + 1 + endwhile + + let promptStr = promptStr."\n" + + let i = i + a:cols + endwhile + return promptStr +endfunction + +" }}} +" Tex_CleanSearchHistory: removes last search item from search history {{{ +" Description: This function needs to be globally visible because its +" called from outside the script during expansion. +function! Tex_CleanSearchHistory() + call histdel("/", -1) + let @/ = histget("/", -1) +endfunction +nmap <silent> <script> <plug>cleanHistory :call Tex_CleanSearchHistory()<CR> + +" }}} +" Tex_GetVarValue: gets the value of the variable {{{ +" Description: +" See if a window-local, buffer-local or global variable with the given name +" exists and if so, returns the corresponding value. If none exist, return +" an empty string. +function! Tex_GetVarValue(varname, ...) + if exists('w:'.a:varname) + return w:{a:varname} + elseif exists('b:'.a:varname) + return b:{a:varname} + elseif exists('g:'.a:varname) + return g:{a:varname} + elseif a:0 > 0 + return a:1 + else + return '' + endif +endfunction " }}} +" Tex_GetMainFileName: gets the name of the main file being compiled. {{{ +" Description: returns the full path name of the main file. +" This function checks for the existence of a .latexmain file +" which might point to the location of a "main" latex file. +" If .latexmain exists, then return the full path name of the +" file being pointed to by it. +" +" Otherwise, return the full path name of the current buffer. +" +" You can supply an optional "modifier" argument to the +" function, which will optionally modify the file name before +" returning. +" NOTE: From version 1.6 onwards, this function always trims +" away the .latexmain part of the file name before applying the +" modifier argument. +function! Tex_GetMainFileName(...) + if a:0 > 0 + let modifier = a:1 + else + let modifier = ':p' + endif + + " If the user wants to use his own way to specify the main file name, then + " use it straight away. + if Tex_GetVarValue('Tex_MainFileExpression') != '' + exec 'let retval = '.Tex_GetVarValue('Tex_MainFileExpression') + return retval + endif + + let s:origdir = fnameescape(getcwd()) + + let dirmodifier = '%:p:h' + let dirLast = fnameescape(expand(dirmodifier)) + exe 'cd '.dirLast + + " move up the directory tree until we find a .latexmain file. + " TODO: Should we be doing this recursion by default, or should there be a + " setting? + while glob('*.latexmain') == '' + let dirmodifier = dirmodifier.':h' + let dirNew = fnameescape(expand(dirmodifier)) + " break from the loop if we cannot go up any further. + if dirNew == dirLast + break + endif + let dirLast = dirNew + exe 'cd '.dirLast + endwhile + + let lheadfile = glob('*.latexmain') + if lheadfile != '' + " Remove the trailing .latexmain part of the filename... We never want + " that. + let lheadfile = fnamemodify(substitute(lheadfile, '\.latexmain$', '', ''), modifier) + else + " If we cannot find any main file, just modify the filename of the + " current buffer. + let lheadfile = expand('%'.modifier) + endif + + exe 'cd '.s:origdir + + " NOTE: The caller of this function needs to escape the file name with + " fnameescape() . The reason its not done here is that escaping is not + " safe if this file is to be used as part of an external command on + " certain platforms. + return lheadfile +endfunction + +" }}} +" Tex_ChooseFromPrompt: process a user input to a prompt string {{{ +" " Description: +function! Tex_ChooseFromPrompt(dialog, list, sep) + let g:Tex_ASDF = a:dialog + let inp = input(a:dialog) + if inp =~ '\d\+' + return Tex_Strntok(a:list, a:sep, inp) + else + return inp + endif +endfunction " }}} +" Tex_ChooseFile: produces a file list and prompts for choice {{{ +" Description: +function! Tex_ChooseFile(dialog) + let files = glob('*') + if files == '' + return '' + endif + let s:incnum = 0 + echo a:dialog + let filenames = substitute(files, "\\v(^|\n)", "\\=submatch(0).Tex_IncrementNumber(1).' : '", 'g') + echo filenames + let choice = input('Enter Choice : ') + let g:choice = choice + if choice == '' + return '' + endif + if choice =~ '^\s*\d\+\s*$' + let retval = Tex_Strntok(files, "\n", choice) + else + let filescomma = substitute(files, "\n", ",", "g") + let retval = GetListMatchItem(filescomma, choice) + endif + if retval == '' + return '' + endif + return retval +endfunction + +" }}} +" Tex_IncrementNumber: returns an incremented number each time {{{ +" Description: +let s:incnum = 0 +function! Tex_IncrementNumber(increm) + let s:incnum = s:incnum + a:increm + return s:incnum +endfunction + +" }}} +" Tex_ResetIncrementNumber: increments s:incnum to zero {{{ +" Description: +function! Tex_ResetIncrementNumber(val) + let s:incnum = a:val +endfunction " }}} +" Tex_FindInRtp: check if file exists in &rtp {{{ +" Description: Checks if file exists in globpath(&rtp, ...) and cuts off the +" rest of returned names. This guarantees that sourced file is +" from $HOME. +" If an optional argument is given, it specifies how to expand +" each filename found. For example, '%:p' will return a list of +" the complete paths to the files. By default returns trailing +" path-names without extenions. +" NOTE: This function is very slow when a large number of +" matches are found because of a while loop which modifies +" each filename found. Some speedup was acheived by using +" a tokenizer approach rather than using Tex_Strntok which +" would have been more obvious. +function! Tex_FindInRtp(filename, directory, ...) + " how to expand each filename. ':p:t:r' modifies each filename to its + " trailing part without extension. + let expand = (a:0 > 0 ? a:1 : ':p:t:r') + " The pattern used... An empty filename should be regarded as '*' + let pattern = (a:filename != '' ? a:filename : '*') + + let filelist = globpath(&rtp, 'ftplugin/latex-suite/'.a:directory.'/'.pattern)."\n" + + if filelist == "\n" + return '' + endif + + if a:filename != '' + return fnamemodify(Tex_Strntok(filelist, "\n", 1), expand) + endif + + " Now cycle through the files modifying each filename in the desired + " manner. + let retfilelist = '' + let i = 1 + while 1 + " Extract the portion till the next newline. Then shorten the filelist + " by removing till the newline. + let nextnewline = stridx(filelist, "\n") + if nextnewline == -1 + break + endif + let filename = strpart(filelist, 0, nextnewline) + let filelist = strpart(filelist, nextnewline+1) + + " The actual modification. + if fnamemodify(filename, expand) != '' + let retfilelist = retfilelist.fnamemodify(filename, expand)."," + endif + let i = i + 1 + endwhile + + return substitute(retfilelist, ',$', '', '') +endfunction + +" }}} +" Tex_GetErrorList: returns vim's clist {{{ +" Description: returns the contents of the error list available via the :clist +" command. +function! Tex_GetErrorList() + let _a = @a + redir @a | silent! clist | redir END + let errlist = @a + let @a = _a + + if errlist =~ 'E42: ' + let errlist = '' + endif + + return errlist +endfunction " }}} +" Tex_GetTempName: get the name of a temporary file in specified directory {{{ +" Description: Unlike vim's native tempname(), this function returns the name +" of a temporary file in the directory specified. This enables +" us to create temporary files in a specified directory. +function! Tex_GetTempName(dirname) + let prefix = 'latexSuiteTemp' + let slash = (a:dirname =~ '\\\|/$' ? '' : '/') + let i = 0 + while filereadable(a:dirname.slash.prefix.i.'.tex') && i < 1000 + let i = i + 1 + endwhile + if filereadable(a:dirname.slash.prefix.i.'.tex') + echoerr "Temporary file could not be created in ".a:dirname + return '' + endif + return expand(a:dirname.slash.prefix.i.'.tex', ':p') +endfunction +" }}} +" Tex_MakeMap: creates a mapping from lhs to rhs if rhs is not already mapped {{{ +" Description: +function! Tex_MakeMap(lhs, rhs, mode, extraargs) + if !hasmapto(a:rhs, a:mode) + exec a:mode.'map '.a:extraargs.' '.a:lhs.' '.a:rhs + endif +endfunction " }}} +" Tex_CD: cds to given directory escaping spaces if necessary {{{ +" " Description: +function! Tex_CD(dirname) + exec 'cd '.Tex_EscapeSpaces(a:dirname) +endfunction " }}} +" Tex_EscapeSpaces: escapes unescaped spaces from a path name {{{ +" Description: +function! Tex_EscapeSpaces(path) + return substitute(a:path, '[^\\]\(\\\\\)*\zs ', '\\ ', 'g') +endfunction " }}} +" Tex_FindFile: finds a file in the vim's 'path' {{{ +" Description: finds a file in vim's 'path' +function! Tex_FindFile(fname, path, suffixesadd) + if exists('*findfile') + let _suffixesadd = &suffixesadd + let &suffixesadd = a:suffixesadd + let retval = findfile(a:fname, a:path) + let &suffixesadd = _suffixesadd + else + " split a new window so we do not screw with the current buffer. We + " want to use the same filename each time so that multiple scratch + " buffers are not created. + let retval = '' + silent! split __HOPEFULLY_THIS_FILE_DOES_NOT_EXIST__ + let _suffixesadd = &suffixesadd + let _path = &path + let &suffixesadd = a:suffixesadd + let &path = a:path + exec 'silent! find '.a:fname + if bufname('%') != '__HOPEFULLY_THIS_FILE_DOES_NOT_EXIST__' + let retval = expand('%:p') + end + silent! bdelete! + let &suffixesadd = _suffixesadd + let &path = _path + endif + return retval +endfunction " }}} +" Tex_GetPos: gets position of cursor {{{ +function! Tex_GetPos() + if exists('*getpos') + return getpos('.') + else + return line('.').' | normal! '.virtcol('.').'|' + endif +endfunction " }}} +" Tex_SetPos: sets position of cursor {{{ +function! Tex_SetPos(pos) + if exists('*setpos') + call setpos('.', a:pos) + else + exec a:pos + endif +endfunction " }}} + + +" ============================================================================== +" Smart key-mappings +" ============================================================================== +" TexQuotes: inserts `` or '' instead of " {{{ +if g:Tex_SmartKeyQuote + + " TexQuotes: inserts `` or '' instead of " + " Taken from texmacro.vim by Benji Fisher <benji@e-math.AMS.org> + " TODO: Deal with nested quotes. + " The :imap that calls this function should insert a ", move the cursor to + " the left of that character, then call this with <C-R>= . + function! s:TexQuotes() + let l = line(".") + let c = col(".") + let restore_cursor = l . "G" . virtcol(".") . "|" + normal! H + let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor + execute restore_cursor + " In math mode, or when preceded by a \, just move the cursor past the + " already-inserted " character. + if synIDattr(synID(l, c, 1), "name") =~ "^texMath" + \ || (c > 1 && getline(l)[c-2] == '\') + return "\<Right>" + endif + " Find the appropriate open-quote and close-quote strings. + if exists("b:Tex_SmartQuoteOpen") + let open = b:Tex_SmartQuoteOpen + elseif exists("g:Tex_SmartQuoteOpen") + let open = g:Tex_SmartQuoteOpen + else + let open = "``" + endif + if exists("b:Tex_SmartQuoteClose") + let close = b:Tex_SmartQuoteClose + elseif exists("g:Tex_SmartQuoteClose") + let close = g:Tex_SmartQuoteClose + else + let close = "''" + endif + let boundary = '\|' + " This code seems to be obsolete, since this script variable is never + " set. The idea is that some languages use ",," as an open- or + " close-quote string, and we want to avoid confusing ordinary "," + " with a quote boundary. + if exists("s:TeX_strictquote") + if( s:TeX_strictquote == "open" || s:TeX_strictquote == "both" ) + let boundary = '\<' . boundary + endif + if( s:TeX_strictquote == "close" || s:TeX_strictquote == "both" ) + let boundary = boundary . '\>' + endif + endif + + " Eventually return q; set it to the default value now. + let q = open + let pattern = + \ escape(open, '\~') . + \ boundary . + \ escape(close, '\~') . + \ '\|^$\|"' + + while 1 " Look for preceding quote (open or close), ignoring + " math mode and '\"' . + call search(pattern, "bw") + if synIDattr(synID(line("."), col("."), 1), "name") !~ "^texMath" + \ && strpart(getline('.'), col('.')-2, 2) != '\"' + break + endif + endwhile + + " Now, test whether we actually found a _preceding_ quote; if so, is it + " an open quote? + if ( line(".") < l || line(".") == l && col(".") < c ) + if strpart(getline("."), col(".")-1) =~ '\V\^' . escape(open, '\') + if line(".") == l && col(".") + strlen(open) == c + " Insert "<++>''<++>" instead of just "''". + let q = IMAP_PutTextWithMovement("<++>".close."<++>") + else + let q = close + endif + endif + endif + + " Return to line l, column c: + execute restore_cursor + " Start with <Del> to remove the " put in by the :imap . + return "\<Del>" . q + + endfunction + +endif +" }}} +" SmartBS: smart backspacing {{{ +if g:Tex_SmartKeyBS + + " SmartBS: smart backspacing + " SmartBS lets you treat diacritic characters (those \'{a} thingies) as a + " single character. This is useful for example in the following situation: + " + " \v{s}\v{t}astn\'{y} ('happy' in Slovak language :-) ) + " If you will delete this normally (without using smartBS() function), you + " must press <BS> about 19x. With function smartBS() you must press <BS> only + " 7x. Strings like "\v{s}", "\'{y}" are considered like one character and are + " deleted with one <BS>. + let s:smartBS_pat = Tex_GetVarValue('Tex_SmartBSPattern') + + fun! s:SmartBS_pat() + return s:smartBS_pat + endfun + + " This function comes from Benji Fisher <benji@e-math.AMS.org> + " http://vim.sourceforge.net/scripts/download.php?src_id=409 + " (modified/patched by Lubomir Host 'rajo' <host8 AT keplerDOTfmphDOTuniba.sk>) + function! s:SmartBS(pat) + let init = strpart(getline("."), 0, col(".")-1) + let matchtxt = matchstr(init, a:pat) + if matchtxt != '' + let bstxt = substitute(matchtxt, '.', "\<bs>", 'g') + return bstxt + else + return "\<bs>" + endif + endfun + +endif " }}} +" SmartDots: inserts \cdots instead of ... in math mode otherwise \ldots {{{ +" if amsmath package is detected then just use \dots and let amsmath take care +" of it. +if g:Tex_SmartKeyDot + + function! <SID>SmartDots() + if strpart(getline('.'), col('.')-3, 2) == '..' && + \ g:Tex_package_detected =~ '\<amsmath\|ellipsis\>' + return "\<bs>\<bs>\\dots" + elseif synIDattr(synID(line('.'),col('.')-1,0),"name") =~ '^texMath' + \&& strpart(getline('.'), col('.')-3, 2) == '..' + return "\<bs>\<bs>\\cdots" + elseif strpart(getline('.'), col('.')-3, 2) == '..' + return "\<bs>\<bs>\\ldots" + else + return '.' + endif + endfunction + +endif +" }}} + +" source texproject.vim before other files +exe 'source '.fnameescape(s:path.'/texproject.vim') + +" source all the relevant files. +exe 'source '.fnameescape(s:path.'/texmenuconf.vim') +exe 'source '.fnameescape(s:path.'/envmacros.vim') +exe 'source '.fnameescape(s:path.'/elementmacros.vim') + +" source utf-8 or plain math menus +if exists("g:Tex_UseUtfMenus") && g:Tex_UseUtfMenus != 0 && has("gui_running") + exe 'source '.fnameescape(s:path.'/mathmacros-utf.vim') +else + exe 'source '.fnameescape(s:path.'/mathmacros.vim') +endif + +exe 'source '.fnameescape(s:path.'/multicompile.vim') +exe 'source '.fnameescape(s:path.'/compiler.vim') +exe 'source '.fnameescape(s:path.'/folding.vim') +exe 'source '.fnameescape(s:path.'/templates.vim') +exe 'source '.fnameescape(s:path.'/custommacros.vim') +exe 'source '.fnameescape(s:path.'/bibtex.vim') + +" source advanced math functions +if g:Tex_AdvancedMath == 1 + exe 'source '.fnameescape(s:path.'/brackets.vim') + exe 'source '.fnameescape(s:path.'/smartspace.vim') +endif + +if g:Tex_Diacritics != 0 + exe 'source '.fnameescape(s:path.'/diacritics.vim') +endif + +exe 'source '.fnameescape(s:path.'/texviewer.vim') +exe 'source '.fnameescape(s:path.'/version.vim') + +" ============================================================================== +" Finally set up the folding, options, mappings and quit. +" ============================================================================== +" SetTeXOptions: sets options/mappings for this file. {{{ +function! <SID>SetTeXOptions() + " Avoid reinclusion. + if exists('b:doneSetTeXOptions') + return + endif + let b:doneSetTeXOptions = 1 + + exe 'setlocal dict^='.fnameescape(s:path.'/dictionaries/dictionary') + + call Tex_Debug('SetTeXOptions: sourcing maps', 'main') + " smart functions + if g:Tex_SmartKeyQuote + inoremap <buffer> <silent> " "<Left><C-R>=<SID>TexQuotes()<CR> + endif + if g:Tex_SmartKeyBS + inoremap <buffer> <silent> <BS> <C-R>=<SID>SmartBS(<SID>SmartBS_pat())<CR> + endif + if g:Tex_SmartKeyDot + inoremap <buffer> <silent> . <C-R>=<SID>SmartDots()<CR> + endif + + " This line seems to be necessary to source our compiler/tex.vim file. + " The docs are unclear why this needs to be done even though this file is + " the first compiler plugin in 'runtimepath'. + runtime compiler/tex.vim + +endfunction + +augroup LatexSuite + au LatexSuite User LatexSuiteFileType + \ call Tex_Debug('main.vim: Catching LatexSuiteFileType event', 'main') | + \ call <SID>SetTeXOptions() +augroup END + +" }}} + +" ============================================================================== +" Settings for taglist.vim plugin +" ============================================================================== +" Sets Tlist_Ctags_Cmd for taglist.vim and regexps for ctags {{{ +if exists("g:Tex_TaglistSupport") && g:Tex_TaglistSupport == 1 + if !exists("g:tlist_tex_settings") + let g:tlist_tex_settings = 'tex;s:section;c:chapter;l:label;r:ref' + endif + + if exists("Tlist_Ctags_Cmd") + let s:tex_ctags = Tlist_Ctags_Cmd + else + let s:tex_ctags = 'ctags' " Configurable in texrc? + endif + + if exists("g:Tex_InternalTagsDefinitions") && g:Tex_InternalTagsDefinitions == 1 + let Tlist_Ctags_Cmd = s:tex_ctags ." --langdef=tex --langmap=tex:.tex.ltx.latex" + \.' --regex-tex="/\\\\begin{abstract}/Abstract/s,abstract/"' + \.' --regex-tex="/\\\\part[ \t]*\*?\{[ \t]*([^}]*)\}/\1/s,part/"' + \.' --regex-tex="/\\\\chapter[ \t]*\*?\{[ \t]*([^}]*)\}/\1/s,chapter/"' + \.' --regex-tex="/\\\\section[ \t]*\*?\{[ \t]*([^}]*)\}/\1/s,section/"' + \.' --regex-tex="/\\\\subsection[ \t]*\*?\{[ \t]*([^}]*)\}/+ \1/s,subsection/"' + \.' --regex-tex="/\\\\subsubsection[ \t]*\*?\{[ \t]*([^}]*)\}/+ \1/s,subsubsection/"' + \.' --regex-tex="/\\\\paragraph[ \t]*\*?\{[ \t]*([^}]*)\}/+ \1/s,paragraph/"' + \.' --regex-tex="/\\\\subparagraph[ \t]*\*?\{[ \t]*([^}]*)\}/+ \1/s,subparagraph/"' + \.' --regex-tex="/\\\\begin{thebibliography}/BIBLIOGRAPHY/s,thebibliography/"' + \.' --regex-tex="/\\\\tableofcontents/TABLE OF CONTENTS/s,tableofcontents/"' + \.' --regex-tex="/\\\\frontmatter/FRONTMATTER/s,frontmatter/"' + \.' --regex-tex="/\\\\mainmatter/MAINMATTER/s,mainmatter/"' + \.' --regex-tex="/\\\\backmatter/BACKMATTER/s,backmatter/"' + \.' --regex-tex="/\\\\appendix/APPENDIX/s,appendix/"' + \.' --regex-tex="/\\\\label[ \t]*\*?\{[ \t]*([^}]*)\}/\1/l,label/"' + \.' --regex-tex="/\\\\ref[ \t]*\*?\{[ \t]*([^}]*)\}/\1/r,ref/"' + endif +endif + +" }}} + +" commands to completion +let g:Tex_completion_explorer = ',' + +" Mappings defined in package files will overwrite all other +exe 'source '.fnameescape(s:path.'/packages.vim') + +" ============================================================================== +" These functions are used to immitate certain operating system type functions +" (like reading the contents of a file), which are not available in vim. For +" example, in Vim, its not possible to read the contents of a file without +" opening a buffer on it, which means that over time, lots of buffers can open +" up needlessly. +" +" If python is available (and allowed), then these functions utilize python +" library functions without making calls to external programs. +" ============================================================================== +" Tex_GotoTempFile: open a temp file. reuse from next time on {{{ +function! Tex_GotoTempFile() + if !exists('s:tempFileName') + let s:tempFileName = tempname() + endif + exec 'silent! split '.s:tempFileName +endfunction " }}} +" Tex_IsPresentInFile: finds if a string str, is present in filename {{{ +if has('python') && g:Tex_UsePython + function! Tex_IsPresentInFile(regexp, filename) + exec 'python isPresentInFile(r"'.a:regexp.'", r"'.a:filename.'")' + + return retval + endfunction +else + function! Tex_IsPresentInFile(regexp, filename) + call Tex_GotoTempFile() + + silent! 1,$ d _ + let _report = &report + let _sc = &sc + set report=9999999 nosc + exec 'silent! 0r! '.g:Tex_CatCmd.' '.a:filename + set nomod + let &report = _report + let &sc = _sc + + if search(a:regexp, 'w') + let retval = 1 + else + let retval = 0 + endif + silent! bd + return retval + endfunction +endif " }}} +" Tex_CatFile: returns the contents of a file in a <NL> seperated string {{{ +if has('*readfile') + function! Tex_CatFile(filename) + return join(readfile(filename), "\n") + endfunction +elseif has('python') && g:Tex_UsePython + function! Tex_CatFile(filename) + " catFile assigns a value to retval + exec 'python catFile("'.a:filename.'")' + + return retval + endfunction +else + function! Tex_CatFile(filename) + if glob(a:filename) == '' + return '' + endif + + call Tex_GotoTempFile() + + silent! 1,$ d _ + + let _report = &report + let _sc = &sc + set report=9999999 nosc + exec 'silent! 0r! '.g:Tex_CatCmd.' '.a:filename + + set nomod + let _a = @a + silent! normal! ggVG"ay + let retval = @a + let @a = _a + + silent! bd + let &report = _report + let &sc = _sc + return retval + endfunction +endif +" }}} +" Tex_DeleteFile: removes a file if present {{{ +" Description: +if has('python') && g:Tex_UsePython + function! Tex_DeleteFile(filename) + exec 'python deleteFile(r"'.a:filename.'")' + + if exists('retval') + return retval + endif + endfunction +else + function! Tex_DeleteFile(filename) + if filereadable(a:filename) + exec '! '.g:Tex_RmCmd.' '.a:filename + endif + endfunction +endif +" }}} + + +let &cpo = s:save_cpo + +" Define the functions in python if available. +if !has('python') || !g:Tex_UsePython + finish +endif + +exec 'pyfile '.fnameescape(expand('<sfile>:p:h')).'/pytools.py' + +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4:nowrap diff --git a/ftplugin/latex-suite/mathmacros-utf.vim b/ftplugin/latex-suite/mathmacros-utf.vim new file mode 100644 index 00000000..ac9cf7e5 --- /dev/null +++ b/ftplugin/latex-suite/mathmacros-utf.vim @@ -0,0 +1,729 @@ +"============================================================================= +" File: mathmacros.vim +" Author: Mikolaj Machowski +" Created: Tue Apr 23 06:00 PM 2002 PST +" +" Description: macros for everything mathematical in latex. +"============================================================================= + +if !(has('gui_running') && g:Tex_MathMenus && g:Tex_Menus) + finish +endif + +let s:MathMenuName = g:Tex_MenuPrefix.'Ma&th.' + +function! Tex_MathMenuRemove() + exe 'silent! aunmenu '.s:MathMenuName +endfunction + +let s:pA = 'amenu <silent> 85 '.s:MathMenuName + +" brackets and dollars {{{ +exe s:pA.'\\&[\ \\] <plug><C-r>=IMAP_PutTextWithMovement("\\[<++>\\]<++>")<cr>' +exe s:pA.'\\&(\ \\) <plug><C-r>=IMAP_PutTextWithMovement("\\(<++>\\)<++>")<cr>' +exe s:pA.'&$\ $ <plug>$$' +exe s:pA.'-sepmath1- :' +" }}} +" MATH arrows {{{ +let s:pA1 = s:pA."&Arrows." +exe s:pA1.'Leftarrow<Tab>⇠<plug>\Leftarrow ' +exe s:pA1.'leftarrow<Tab>↠<plug>\leftarrow' +exe s:pA1.'longleftarrow<Tab>↠<plug>\longleftarrow ' +exe s:pA1.'Longleftarrow<Tab>⇠<plug>\Longleftarrow ' +exe s:pA1.'rightarrow<Tab>→ <plug>\rightarrow ' +exe s:pA1.'longrightarrow<Tab>→ <plug>\longrightarrow ' +exe s:pA1.'Rightarrow<Tab>⇒ <plug>\Rightarrow ' +exe s:pA1.'Longrightarrow<Tab>⇒ <plug>\Longrightarrow ' +exe s:pA1.'leftrightarrow<Tab>⇆ <plug>\leftrightarrow ' +exe s:pA1.'longleftrightarrow<Tab>↔ <plug>\longleftrightarrow ' +exe s:pA1.'Leftrightarrow<Tab>⇔ <plug>\Leftrightarrow ' +exe s:pA1.'Longleftrightarrow<Tab>⇔ <plug>\Longleftrightarrow ' +exe s:pA1.'uparrow<Tab>↑ <plug>\uparrow ' +exe s:pA1.'Uparrow<Tab>⇑ <plug>\Uparrow ' +exe s:pA1.'downarrow<Tab>↓ <plug>\downarrow ' +exe s:pA1.'Downarrow<Tab>⇓ <plug>\Downarrow ' +exe s:pA1.'updownarrow<Tab>↕ <plug>\updownarrow ' +exe s:pA1.'Updownarrow<Tab>⇕ <plug>\Updownarrow ' +exe s:pA1.'nearrow<Tab>↗ <plug>\nearrow ' +exe s:pA1.'searrow<Tab>↘ <plug>\searrow ' +exe s:pA1.'swarrow<Tab>↙ <plug>\swarrow ' +exe s:pA1.'nwarrow<Tab>↖ <plug>\nwarrow ' +exe s:pA1.'mapsto<Tab>↦ <plug>\mapsto ' +exe s:pA1.'leadsto<Tab>↠<plug>\leadsto ' +exe s:pA1.'longmapsto<Tab>⇖ <plug>\longmapsto ' +exe s:pA1.'hookleftarrow<Tab>↩ <plug>\hookleftarrow ' +exe s:pA1.'hookrightarrow<Tab>↪ <plug>\hookrightarrow ' +exe s:pA1.'leftharpoonup<Tab>↼ <plug>\leftharpoonup ' +exe s:pA1.'leftharpoondown<Tab>↽ <plug>\leftharpoondown ' +exe s:pA1.'rightharpoonup<Tab>⇀ <plug>\rightharpoonup ' +exe s:pA1.'rightharpoondown<Tab>⇠<plug>\rightharpoondown ' +exe s:pA1.'rightleftharpoons<Tab>⇌ <plug>\rightleftharpoons ' +exe s:pA1.'overleftarrow<Tab> <plug>\overleftarrow ' +exe s:pA1.'overrightarrow<Tab> <plug>\overrightarrow ' +exe s:pA1.'overleftrightarrow<Tab> <plug>\overleftrightarrow ' +exe s:pA1.'underleftarrow<Tab> <plug>\underleftarrow ' +exe s:pA1.'underrightarrow<Tab> <plug>\underrightarrow ' +exe s:pA1.'underleftrightarrow<Tab> <plug>\underleftrightarrow ' +exe s:pA1.'xleftarrow<Tab> <plug>\xleftarrow ' +exe s:pA1.'xrightarrow<Tab> <plug>\xrightarrow ' +" }}} +" MATH Arrows2 {{{ +let s:pA1a = s:pA."Arrows2." +exe s:pA1a.'dashleftarrow<Tab>⇠<plug>\dashleftarrow ' +exe s:pA1a.'leftleftarrows<Tab>⇇ <plug>\leftleftarrows ' +exe s:pA1a.'leftrightarrows<Tab>⇆ <plug>\leftrightarrows ' +exe s:pA1a.'Lleftarrow<Tab>⇚ <plug>\Lleftarrow ' +exe s:pA1a.'twoheadleftarrow<Tab>↞ <plug>\twoheadleftarrow ' +exe s:pA1a.'leftarrowtail<Tab>↢ <plug>\leftarrowtail ' +exe s:pA1a.'leftrightharpoons<Tab>⇋ <plug>\leftrightharpoons ' +exe s:pA1a.'Lsh<Tab>↰ <plug>\Lsh ' +exe s:pA1a.'looparrowleft<Tab>↫ <plug>\looparrowleft ' +exe s:pA1a.'curvearrowleft<Tab>↶ <plug>\curvearrowleft ' +exe s:pA1a.'circlearrowleft<Tab>↺ <plug>\circlearrowleft ' +exe s:pA1a.'dashrightarrow<Tab>⇢ <plug>\dashrightarrow ' +exe s:pA1a.'rightrightarrows<Tab>⇉ <plug>\rightrightarrows ' +exe s:pA1a.'rightleftarrows<Tab>⇄ <plug>\rightleftarrows ' +exe s:pA1a.'Rrightarrow<Tab>⇛ <plug>\Rrightarrow ' +exe s:pA1a.'twoheadrightarrow<Tab>↠<plug>\twoheadrightarrow ' +exe s:pA1a.'rightarrowtail<Tab>↣ <plug>\rightarrowtail ' +exe s:pA1a.'rightleftharpoons<Tab>⇌ <plug>\rightleftharpoons ' +exe s:pA1a.'Rsh<Tab>↱ <plug>\Rsh ' +exe s:pA1a.'looparrowright<Tab>↬ <plug>\looparrowright ' +exe s:pA1a.'curvearrowright<Tab>↷ <plug>\curvearrowright ' +exe s:pA1a.'circlearrowright<Tab>↻ <plug>\circlearrowright ' +exe s:pA1a.'multimap<Tab>⊸ <plug>\multimap ' +exe s:pA1a.'upuparrows<Tab>⇈ <plug>\upuparrows ' +exe s:pA1a.'downdownarrows<Tab>⇊ <plug>\downdownarrows ' +exe s:pA1a.'upharpoonleft<Tab>↿ <plug>\upharpoonleft ' +exe s:pA1a.'upharpoonright<Tab>↾ <plug>\upharpoonright ' +exe s:pA1a.'downharpoonleft<Tab>⇃ <plug>\downharpoonleft ' +exe s:pA1a.'downharpoonright<Tab>⇂ <plug>\downharpoonright ' +exe s:pA1a.'rightsquigarrow<Tab>⇠<plug>\rightsquigarrow ' +exe s:pA1a.'leftrightsquigarrow<Tab>↠<plug>\leftrightsquigarrow ' +" }}} +" MATH nArrows {{{ +let s:pA1b = s:pA."&nArrows." +exe s:pA1b.'nleftarrow<Tab>↚ <plug>\nleftarrow ' +exe s:pA1b.'nLeftarrow<Tab>⇠<plug>\nLeftarrow ' +exe s:pA1b.'nleftrightarrow<Tab>↮ <plug>\nleftrightarrow ' +exe s:pA1b.'nLeftrightarrow<Tab>⇎ <plug>\nleftrightarrow ' +exe s:pA1b.'nrightarrow<Tab>↛ <plug>\nrightarrow ' +exe s:pA1b.'nRightarrow<Tab>⇠<plug>\nRightarrow ' +" }}} +" MATH Fonts {{{ +let s:pA2a = s:pA."&MathFonts." +exe s:pA2a.'mathbf{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathbf{<++>}<++>")<cr>' +exe s:pA2a.'mathrm{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathrm{<++>}<++>")<cr>' +exe s:pA2a.'mathsf{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathsf{<++>}<++>")<cr>' +exe s:pA2a.'mathtt{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathtt{<++>}<++>")<cr>' +exe s:pA2a.'mathit{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathit{<++>}<++>")<cr>' +exe s:pA2a.'mathfrak{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathfrak{<++>}<++>")<cr>' +exe s:pA2a.'mathcal{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathcal{<++>}<++>")<cr>' +exe s:pA2a.'mathscr{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathscr{<++>}<++>")<cr>' +exe s:pA2a.'mathbb{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathbb{<++>}<++>")<cr>' +" }}} +" Greek Letters small {{{ +let s:pA2 = s:pA."&Greek.&Small." +exe s:pA2.'alpha<Tab>`a\ \ α <plug>\alpha ' +exe s:pA2.'beta<Tab>`b\ \ β <plug>\beta ' +exe s:pA2.'gamma<Tab>`g\ \ γ <plug>\gamma ' +exe s:pA2.'delta<Tab>`d\ \ δ <plug>\delta ' +exe s:pA2.'epsilon<Tab>∊ <plug>\epsilon ' +exe s:pA2.'varepsilon<Tab>`e\ \ ε <plug>\varepsilon ' +exe s:pA2.'zeta<Tab>`z\ \ ζ <plug>\zeta ' +exe s:pA2.'eta<Tab>`h\ \ η <plug>\eta ' +exe s:pA2.'theta<Tab>`q\ \ θ <plug>\theta ' +exe s:pA2.'vartheta<Tab>Ï‘ <plug>\vartheta ' +exe s:pA2.'iota<Tab>`i\ \ ι <plug>\iota ' +exe s:pA2.'kappa<Tab>`k\ \ κ <plug>\kappa ' +exe s:pA2.'lambda<Tab>`l\ \ λ <plug>\lambda ' +exe s:pA2.'mu<Tab>`m\ \ μ <plug>\mu ' +exe s:pA2.'nu<Tab>`n\ \ ν <plug>\nu ' +exe s:pA2.'xi<Tab>`x\ \ ξ <plug>\xi ' +exe s:pA2.'pi<Tab>`p\ \ Ï€ <plug>\pi ' +exe s:pA2.'varpi<Tab>Ï– <plug>\varpi ' +exe s:pA2.'rho<Tab>`r\ \ Ï <plug>\rho ' +exe s:pA2.'varrho<Tab>ϱ <plug>\varrho ' +exe s:pA2.'sigma<Tab>`s\ \ σ <plug>\sigma ' +exe s:pA2.'varsigma<Tab>`v\ \ Ï‚ <plug>\varsigma ' +exe s:pA2.'tau<Tab>`t\ \ Ï„ <plug>\tau ' +exe s:pA2.'upsilon<Tab>`u\ \ Ï… <plug>\upsilon ' +exe s:pA2.'phi<Tab>φ <plug>\phi ' +exe s:pA2.'varphi<Tab>`f\ \ Ï• <plug>\varphi ' +exe s:pA2.'chi<Tab>`c\ \ χ <plug>\chi ' +exe s:pA2.'psi<Tab>`y\ \ ψ <plug>\psi ' +exe s:pA2.'omega<Tab>`w\ \ ω <plug>\omega ' +" }}} +" Greek Letters big {{{ +let s:pA3 = s:pA.'&Greek.&Big.' +exe s:pA3.'Alpha<Tab>`A\ \ A <plug>\Alpha ' +exe s:pA3.'Beta<Tab>`B\ \ B <plug>\Beta ' +exe s:pA3.'Gamma<Tab>`G\ \ Γ <plug>\Gamma ' +exe s:pA3.'Delta<Tab>`D\ \ Δ <plug>\Delta ' +exe s:pA3.'Epsilon<Tab>`E\ \ E <plug>\Epsilon ' +exe s:pA3.'Zeta<Tab>`Z\ \ Z <plug>\mathrm{Z} ' +exe s:pA3.'Eta<Tab>`H\ \ H <plug>\Eta ' +exe s:pA3.'Theta<Tab>Θ <plug>\Theta ' +exe s:pA3.'Iota<Tab>I <plug>\mathrm{I} ' +exe s:pA3.'Kappa<Tab>`K\ \ K <plug>\Kappa ' +exe s:pA3.'Lambda<Tab>`L\ \ Λ <plug>\Lambda ' +exe s:pA3.'Mu<Tab>`M\ \ M <plug>\Mu ' +exe s:pA3.'Nu<Tab>`N\ \ N <plug>\Nu ' +exe s:pA3.'Xi<Tab>`X\ \ Ξ <plug>\Xi ' +exe s:pA3.'Pi<Tab>`P\ \ Î <plug>\Pi ' +exe s:pA3.'Rho<Tab>`R\ \ P <plug>\Rho ' +exe s:pA3.'Sigma<Tab>`S\ \ Σ <plug>\Sigma ' +exe s:pA3.'Tau<Tab>`T\ \ T <plug>\Tau ' +exe s:pA3.'Upsilon<Tab>`U\ \ Y <plug>\Upsilon ' +exe s:pA3.'Phi<Tab>Φ <plug>\Phi ' +exe s:pA3.'Chi<Tab>`C\ \ X <plug>\Chi ' +exe s:pA3.'Psi<Tab>`Y\ \ Ψ <plug>\Psi ' +exe s:pA3.'Omega<Tab>`W\ \ Ω <plug>\Omega ' +" }}} +" BinaryRel1 {{{ +let s:pA4 = s:pA."&BinaryRel1." +exe s:pA4.'ll<Tab>≪ <plug>\ll ' +exe s:pA4.'lll<Tab>⋘ <plug>\lll ' +exe s:pA4.'leqslant<Tab>≤ <plug>\leqslant ' +exe s:pA4.'leq<Tab>≤ <plug>\leq ' +exe s:pA4.'leqq<Tab>≦ <plug>\leqq ' +exe s:pA4.'eqslantless<Tab>⋜ <plug>\eqslantless ' +exe s:pA4.'lessdot<Tab>â‹– <plug>\lessdot ' +exe s:pA4.'prec<Tab>≺ <plug>\prec ' +exe s:pA4.'preceq<Tab>≼ <plug>\preceq ' +exe s:pA4.'preccurlyeq<Tab>≼ <plug>\preccurlyeq ' +exe s:pA4.'curlyeqprec<Tab>⋞ <plug>\curlyeqprec ' +exe s:pA4.'lesssim<Tab>≲ <plug>\lesssim ' +exe s:pA4.'lessapprox<Tab> <plug>\lessapprox ' +exe s:pA4.'precsim<Tab>≾ <plug>\precsim ' +exe s:pA4.'precapprox<Tab> <plug>\precapprox ' +exe s:pA4.'in<Tab>∈ <plug>\in ' +exe s:pA4.'subset<Tab>`(\ \ ⊂ <plug>\subset ' +exe s:pA4.'Subset<Tab>`)\ \ â‹ <plug>\Subset ' +exe s:pA4.'subseteq<Tab>⊆ <plug>\subseteq ' +exe s:pA4.'subseteqq<Tab> <plug>\subseteqq ' +exe s:pA4.'sqsubset<Tab>⊠<plug>\sqsubset ' +exe s:pA4.'sqsubseteq<Tab>⊑ <plug>\sqsubseteq ' +exe s:pA4.'smile<Tab>⌣ <plug>\smile ' +exe s:pA4.'smallsmile<Tab>⌣ <plug>\smallsmile ' +exe s:pA4.'parallel<Tab>∥ <plug>\parallel ' +exe s:pA4.'shortparallel<Tab>∥ <plug>\shortparallel ' +exe s:pA4.'dashv<Tab>⊣ <plug>\dashv ' +exe s:pA4.'vdash<Tab>⊢ <plug>\vdash ' +exe s:pA4.'vDash<Tab>⊨ <plug>\vDash ' +exe s:pA4.'models<Tab>⊨ <plug>\models ' +exe s:pA4.'therefore<Tab>∴ <plug>\therefore ' +exe s:pA4.'backepsilon<Tab>∠<plug>\backepsilon ' +" }}} +" nBinaryRel1 {{{ +let s:pA4a = s:pA."&nBinaryRel1." +exe s:pA4a.'nless<Tab>≮ <plug>\nless ' +exe s:pA4a.'nleqslant<Tab>≰ <plug>\nleqslant ' +exe s:pA4a.'nleq<Tab> <plug>\nleq ' +exe s:pA4a.'lneq<Tab> <plug>\lneq ' +exe s:pA4a.'nleqq<Tab> <plug>\nleqq ' +exe s:pA4a.'lneqq<Tab>≨ <plug>\lneqq ' +exe s:pA4a.'lvertneqq<Tab> <plug>\lvertneqq ' +exe s:pA4a.'nprec<Tab>⊀ <plug>\nprec ' +exe s:pA4a.'npreceq<Tab>â‹ <plug>\npreceq ' +exe s:pA4a.'precneqq<Tab> <plug>\precneqq ' +exe s:pA4a.'lnsim<Tab>⋦ <plug>\lnsim ' +exe s:pA4a.'lnapprox<Tab> <plug>\lnapprox ' +exe s:pA4a.'precnsim<Tab>⋨ <plug>\precnsim ' +exe s:pA4a.'precnapprox<Tab> <plug>\precnapprox ' +exe s:pA4a.'notin<Tab>∉ <plug>\notin ' +exe s:pA4a.'nsubseteq<Tab>⊈ <plug>\nsubseteq ' +exe s:pA4a.'varsubsetneq<Tab> <plug>\varsubsetneq ' +exe s:pA4a.'subsetneq<Tab>⊊ <plug>\subsetneq ' +exe s:pA4a.'nsubseteqq<Tab> <plug>\nsubseteqq ' +exe s:pA4a.'varsubsetneqq<Tab> <plug>\varsubsetneqq ' +exe s:pA4a.'subsetneqq<Tab>⊈ <plug>\subsetneqq ' +exe s:pA4a.'nparallel<Tab>∦ <plug>\nparallel ' +exe s:pA4a.'nshortparallel<Tab> <plug>\nshortparallel ' +exe s:pA4a.'nvdash<Tab>⊬ <plug>\nvdash ' +exe s:pA4a.'nvDash<Tab>⊠<plug>\nvDash ' +" }}} +" BinaryRel2 {{{ +let s:pA5 = s:pA."&BinaryRel2." +exe s:pA5.'gg<Tab>≫ <plug>\gg ' +exe s:pA5.'ggg<Tab>â‹™ <plug>\ggg ' +exe s:pA5.'gggtr<Tab>â‹™ <plug>\gggtr ' +exe s:pA5.'geqslant<Tab> <plug>\geqslant ' +exe s:pA5.'geq<Tab>≥ <plug>\geq ' +exe s:pA5.'geqq<Tab>≧ <plug>\geqq ' +exe s:pA5.'eqslantgtr<Tab> <plug>\eqslantgtr ' +exe s:pA5.'gtrdot<Tab>â‹— <plug>\gtrdot ' +exe s:pA5.'succ<Tab>≻ <plug>\succ ' +exe s:pA5.'succeq<Tab>≽ <plug>\succeq ' +exe s:pA5.'succcurlyeq<Tab>≽ <plug>\succcurlyeq ' +exe s:pA5.'curlyeqsucc<Tab>⋟ <plug>\curlyeqsucc ' +exe s:pA5.'gtrsim<Tab>≳ <plug>\gtrsim ' +exe s:pA5.'gtrapprox<Tab> <plug>\gtrapprox ' +exe s:pA5.'succsim<Tab>≿ <plug>\succsim ' +exe s:pA5.'succapprox<Tab> <plug>\succapprox ' +exe s:pA5.'ni<Tab>∋ <plug>\ni ' +exe s:pA5.'owns<Tab> <plug>\owns ' +exe s:pA5.'supset<Tab>⊃ <plug>\supset ' +exe s:pA5.'Supset<Tab>â‹‘ <plug>\Supset ' +exe s:pA5.'supseteq<Tab>⊇ <plug>\supseteq ' +exe s:pA5.'supseteqq<Tab> <plug>\supseteqq ' +exe s:pA5.'sqsupset<Tab>⊠<plug>\sqsupset ' +exe s:pA5.'sqsupseteq<Tab>⊒ <plug>\sqsupseteq ' +exe s:pA5.'frown<Tab>⌢ <plug>\frown ' +exe s:pA5.'smallfrown<Tab>⌢ <plug>\smallfrown ' +exe s:pA5.'mid<Tab>∣ <plug>\mid ' +exe s:pA5.'shortmid<Tab> <plug>\shortmid ' +exe s:pA5.'between<Tab>≬ <plug>\between ' +exe s:pA5.'Vdash<Tab>⊩ <plug>\Vdash ' +exe s:pA5.'bowtie<Tab>⋈ <plug>\bowtie ' +exe s:pA5.'Join<Tab>⋈ <plug>\Join ' +exe s:pA5.'pitchfork<Tab>â‹” <plug>\pitchfork ' +" }}} +" {{{ nBinaryRel2 +let s:pA5a = s:pA."n&BinaryRel2." "TODO: dorobiæ logarytmy +exe s:pA5a.'ngtr<Tab>≯ <plug>\ngtr ' +exe s:pA5a.'ngeqslant<Tab>≱ <plug>\ngeqslant ' +exe s:pA5a.'ngeq<Tab> <plug>\ngeq ' +exe s:pA5a.'gneq<Tab> <plug>\gneq ' +exe s:pA5a.'ngeqq<Tab> <plug>\ngeqq ' +exe s:pA5a.'gneqq<Tab>≩ <plug>\gneqq ' +exe s:pA5a.'nsucc<Tab>⊠<plug>\nsucc ' +exe s:pA5a.'nsucceq<Tab>â‹¡ <plug>\nsucceq ' +exe s:pA5a.'succneqq<Tab> <plug>\succneqq ' +exe s:pA5a.'gnsim<Tab>â‹§ <plug>\gnsim ' +exe s:pA5a.'gnapprox<Tab> <plug>\gnapprox ' +exe s:pA5a.'succnsim<Tab>â‹© <plug>\succnsim ' +exe s:pA5a.'succnapprox<Tab> <plug>\succnapprox ' +exe s:pA5a.'nsupseteq<Tab>⊉ <plug>\nsupseteq ' +exe s:pA5a.'varsupsetneq<Tab> <plug>\varsupsetneq ' +exe s:pA5a.'supsetneq<Tab>⊋ <plug>\supsetneq ' +exe s:pA5a.'nsupseteqq<Tab> <plug>\nsupseteqq ' +exe s:pA5a.'varsupsetneqq<Tab> <plug>\varsupsetneqq ' +exe s:pA5a.'supsetneqq<Tab> <plug>\supsetneqq ' +exe s:pA5a.'nmid<Tab>∤ <plug>\nmid ' +exe s:pA5a.'nshortmid<Tab> <plug>\nshortmid ' +exe s:pA5a.'nVdash<Tab>⊮ <plug>\nVdash ' +" }}} +" {{{ BinaryRel3 +let s:pA6 = s:pA."&BinaryRel3." +exe s:pA6.'doteq<Tab>≠<plug>\doteq ' +exe s:pA6.'circeq<Tab>≗ <plug>\circeq ' +exe s:pA6.'eqcirc<Tab>≖ <plug>\eqcirc ' +exe s:pA6.'risingdotseq<Tab>≓ <plug>\risingdotseq ' +exe s:pA6.'doteqdot<Tab>≑ <plug>\doteqdot ' +exe s:pA6.'Doteq<Tab>≑ <plug>\Doteq ' +exe s:pA6.'fallingdotseq<Tab>≒ <plug>\fallingdotseq ' +exe s:pA6.'triangleq<Tab>≜ <plug>\triangleq ' +exe s:pA6.'bumpeq<Tab>≠<plug>\bumpeq ' +exe s:pA6.'Bumpeq<Tab>≎ <plug>\Bumpeq ' +exe s:pA6.'equiv<Tab>`=\ \ ≡ <plug>\equiv ' +exe s:pA6.'sim<Tab>∼ <plug>\sim ' +exe s:pA6.'thicksim<Tab>∼ <plug>\thicksim ' +exe s:pA6.'backsim<Tab>∽ <plug>\backsim ' +exe s:pA6.'simeq<Tab>≃ <plug>\simeq ' +exe s:pA6.'backsimeq<Tab>â‹ <plug>\backsimeq ' +exe s:pA6.'cong<Tab>≅ <plug>\cong ' +exe s:pA6.'approx<tab>=~\ \ ≈ <plug>\approx ' +exe s:pA6.'thickapprox<Tab>≈ <plug>\thickapprox ' +exe s:pA6.'approxeq<Tab>≊ <plug>\approxeq ' +exe s:pA6.'blacktriangleleft<Tab>â—€ <plug>\blacktriangleleft ' +exe s:pA6.'vartriangleleft<Tab>⊲ <plug>\vartriangleleft ' +exe s:pA6.'trianglelefteq<Tab>⊴ <plug>\trianglelefteq ' +exe s:pA6.'blacktriangleright<Tab>â–¶ <plug>\blacktriangleright ' +exe s:pA6.'vartriangleright<Tab>⊳ <plug>\vartriangleright ' +exe s:pA6.'trianglerighteq<Tab>⊵ <plug>\trianglerighteq ' +exe s:pA6.'perp<Tab>⊥ <plug>\perp ' +exe s:pA6.'asymp<Tab>≠<plug>\asymp ' +exe s:pA6.'Vvdash<Tab>⊪ <plug>\Vvdash ' +exe s:pA6.'propto<Tab>∠<plug>\propto ' +exe s:pA6.'varpropto<Tab>∠<plug>\varpropto ' +exe s:pA6.'because<Tab>∵ <plug>\because ' +" }}} +" {{{ nBinaryRel3 +let s:pA6a = s:pA."&nBinaryRel3." +exe s:pA6a.'neq<Tab>≠<plug>\neq ' +exe s:pA6a.'nsim<Tab>≠<plug>\nsim ' +exe s:pA6a.'ncong<Tab>≆ <plug>\ncong ' +exe s:pA6a.'ntriangleleft<Tab>⋪ <plug>\ntriangleleft ' +exe s:pA6a.'ntrianglelefteq<Tab>⋬ <plug>\ntrianglelefteq ' +exe s:pA6a.'ntriangleright<Tab>â‹« <plug>\ntriangleright ' +exe s:pA6a.'ntrianglerighteq<Tab>â‹ <plug>\ntrianglerighteq ' +" }}} +" {{{ BinaryRel4 +let s:pA7 = s:pA."&BinaryRel4." +exe s:pA7.'lessgtr<Tab>≶ <plug>\lessgtr ' +exe s:pA7.'gtrless<Tab>≷ <plug>\gtrless ' +exe s:pA7.'lesseqgtr<Tab>⋚ <plug>\lesseqgtr ' +exe s:pA7.'gtreqless<Tab>â‹› <plug>\gtreqless ' +exe s:pA7.'lesseqqgtr<Tab> <plug>\lesseqqgtr ' +exe s:pA7.'gtreqqless<Tab> <plug>\gtreqqless ' +" }}} +" {{{ BigOp +let s:pA8a = s:pA."&BigOp." +exe s:pA8a.'limits<Tab> <plug>\limits' +exe s:pA8a.'nolimits<Tab> <plug>\nolimits' +exe s:pA8a.'displaylimits<Tab> <plug>\displaylimits' +exe s:pA8a.'-seplimits- :' +exe s:pA8a.'bigcap<Tab>`-\ \ â‹‚ <plug>\bigcap' +exe s:pA8a.'bigcup<Tab>`+\ \ ⋃ <plug>\bigcup' +exe s:pA8a.'bigodot<Tab>⊙ <plug>\bigodot' +exe s:pA8a.'bigoplus<Tab>⊕ <plug>\bigoplus' +exe s:pA8a.'bigotimes<Tab>⊗ <plug>\bigotimes' +exe s:pA8a.'bigsqcup<Tab>⊔ <plug>\bigsqcup' +exe s:pA8a.'biguplus<Tab>⊎ <plug>\biguplus' +exe s:pA8a.'bigvee<Tab>â‹ <plug>\bigvee' +exe s:pA8a.'bigwedge<Tab>â‹€ <plug>\bigwedge' +exe s:pA8a.'coprod<Tab>∠<plug>\coprod' +exe s:pA8a.'int<Tab>∫ <plug>\int' +exe s:pA8a.'iint<Tab>∬ <plug>\int' +exe s:pA8a.'iiint<Tab>∠<plug>\int' +exe s:pA8a.'oint<Tab>∮ <plug>\oint' +exe s:pA8a.'prod<Tab>∠<plug>\prod' +exe s:pA8a.'sum<Tab>∑ <plug>\sum' +" }}} +" {{{ BinaryOp +let s:pA8 = s:pA."&BinaryOp." +exe s:pA8.'pm<Tab>± <plug>\pm ' +exe s:pA8.'mp<Tab>∓ <plug>\mp ' +exe s:pA8.'dotplus<Tab>∔ <plug>\dotplus ' +exe s:pA8.'cdot<Tab>`.\ \ â‹… <plug>\cdot ' +exe s:pA8.'centerdot<Tab>â‹… <plug>\centerdot ' +exe s:pA8.'times<Tab>`*\ \ × <plug>\times ' +exe s:pA8.'ltimes<Tab>⋉ <plug>\ltimes ' +exe s:pA8.'rtimes<Tab>⋊ <plug>\rtimes ' +exe s:pA8.'leftthreetimes<Tab>â‹‹ <plug>\leftthreetimes ' +exe s:pA8.'rightthreetimes<Tab>⋌ <plug>\rightthreetimes ' +exe s:pA8.'div<Tab>÷ <plug>\div ' +exe s:pA8.'divideontimes<Tab>⋇ <plug>\divideontimes ' +exe s:pA8.'bmod<Tab> <plug>\bmod ' +exe s:pA8.'ast<Tab>∗ <plug>\ast ' +exe s:pA8.'star<Tab>⋆ <plug>\star ' +exe s:pA8.'setminus<Tab>`\\\ \ ∖ <plug>\setminus ' +exe s:pA8.'smallsetminus<Tab>∖ <plug>\smallsetminus ' +exe s:pA8.'diamond<Tab>â‹„ <plug>\diamond ' +exe s:pA8.'wr<Tab>≀ <plug>\wr ' +exe s:pA8.'intercal<Tab>⊺ <plug>\intercal ' +exe s:pA8.'circ<Tab>`@\ \ ∘ <plug>\circ ' +exe s:pA8.'bigcirc<Tab>â—‹ <plug>\bigcirc ' +exe s:pA8.'bullet<Tab>∙ <plug>\bullet ' +exe s:pA8.'cap<Tab>∩ <plug>\cap ' +exe s:pA8.'Cap<Tab>â‹’ <plug>\Cap ' +exe s:pA8.'cup<Tab>∪ <plug>\cup ' +exe s:pA8.'Cup<Tab>â‹“ <plug>\Cup ' +exe s:pA8.'sqcap<Tab>⊓ <plug>\sqcap ' +exe s:pA8.'sqcup<Tab>⊔ <plug>\sqcup' +exe s:pA8.'amalg<Tab> <plug>\amalg ' +exe s:pA8.'uplus<Tab>⊎ <plug>\uplus ' +exe s:pA8.'triangleleft<Tab>â— <plug>\triangleleft ' +exe s:pA8.'triangleright<Tab>â–· <plug>\triangleright ' +exe s:pA8.'bigtriangleup<Tab>â–³ <plug>\bigtriangleup ' +exe s:pA8.'bigtriangledown<Tab>â–½ <plug>\bigtriangledown ' +exe s:pA8.'vee<Tab>∨ <plug>\vee ' +exe s:pA8.'veebar<Tab>⊻ <plug>\veebar ' +exe s:pA8.'curlyvee<Tab>⋎ <plug>\curlyvee ' +exe s:pA8.'wedge<Tab>`&\ \ ∧ <plug>\wedge ' +exe s:pA8.'barwedge<Tab>⊼ <plug>\barwedge ' +exe s:pA8.'doublebarwedge<Tab>⌆ <plug>\doublebarwedge ' +exe s:pA8.'curlywedge<Tab>â‹ <plug>\curlywedge ' +exe s:pA8.'oplus<Tab>⊕ <plug>\oplus ' +exe s:pA8.'ominus<Tab>⊖ <plug>\ominus ' +exe s:pA8.'otimes<Tab>⊗ <plug>\otimes ' +exe s:pA8.'oslash<Tab>⊘ <plug>\oslash ' +exe s:pA8.'boxplus<Tab>⊞ <plug>\boxplus ' +exe s:pA8.'boxminus<Tab>⊟ <plug>\boxminus ' +exe s:pA8.'boxtimes<Tab>⊠<plug>\boxtimes ' +exe s:pA8.'boxdot<Tab>⊡ <plug>\boxdot ' +exe s:pA8.'odot<Tab>⊙ <plug>\odot ' +exe s:pA8.'circledast<Tab>⊛ <plug>\circledast ' +exe s:pA8.'circleddash<Tab>⊠<plug>\circleddash ' +exe s:pA8.'circledcirc<Tab>⊚ <plug>\circledcirc ' +exe s:pA8.'dagger<Tab>†<plug>\dagger ' +exe s:pA8.'ddagger<Tab>‡ <plug>\ddagger ' +exe s:pA8.'lhd<Tab>⊲ <plug>\lhd ' +exe s:pA8.'unlhd<Tab>⊴ <plug>\unlhd ' +exe s:pA8.'rhd<Tab>⊳ <plug>\rhd ' +exe s:pA8.'unrhd<Tab>⊵ <plug>\unrhd ' +" }}} +" {{{ Other1 +let s:pA9 = s:pA."&Other1." +exe s:pA9.'hat<Tab>â <plug>\hat ' +exe s:pA9.'check<Tab>ÇŽ <plug>\check ' +exe s:pA9.'grave<Tab>à <plug>\grave ' +exe s:pA9.'acute<Tab>á <plug>\acute ' +exe s:pA9.'dot<Tab>ȧ <plug>\dot ' +exe s:pA9.'ddot<Tab>ä <plug>\ddot ' +exe s:pA9.'tilde<Tab>`,\ \ ã <plug>\tilde ' +exe s:pA9.'breve<Tab>ă <plug>\breve ' +exe s:pA9.'bar<Tab>Ä <plug>\bar ' +exe s:pA9.'vec<Tab>a⃗ <plug>\vec ' +exe s:pA9.'aleph<Tab>× <plug>\aleph ' +exe s:pA9.'hbar<Tab>â„ <plug>\hbar ' +exe s:pA9.'imath<Tab> <plug>\imath ' +exe s:pA9.'jmath<Tab> <plug>\jmath ' +exe s:pA9.'ell<Tab>â„“ <plug>\ell ' +exe s:pA9.'wp<Tab>℘ <plug>\wp ' +exe s:pA9.'Re<Tab>ℜ <plug>\Re ' +exe s:pA9.'Im<Tab>â„‘ <plug>\Im ' +exe s:pA9.'partial<Tab>∂ <plug>\partial ' +exe s:pA9.'infty<Tab>`8\ \ ∞ <plug>\infty ' +exe s:pA9.'prime<Tab>′ <plug>\prime ' +exe s:pA9.'emptyset<Tab>∅ <plug>\emptyset ' +exe s:pA9.'nabla<Tab>∇ <plug>\nabla ' +exe s:pA9.'surd<Tab>√ <plug>\surd ' +exe s:pA9.'top<Tab>⊤ <plug>\top ' +exe s:pA9.'bot<Tab>⊥ <plug>\bot ' +exe s:pA9.'angle<Tab>∠<plug>\angle ' +exe s:pA9.'triangle<Tab>â–³ <plug>\triangle ' +exe s:pA9.'backslash<Tab>\\ <plug>\backslash ' +exe s:pA9.'forall<Tab>∀ <plug>\forall ' +exe s:pA9.'exists<Tab>∃ <plug>\exists ' +exe s:pA9.'neg<Tab>¬ <plug>\neg ' +exe s:pA9.'flat<Tab>â™ <plug>\flat ' +exe s:pA9.'natural<Tab>â™® <plug>\natural ' +exe s:pA9.'sharp<Tab>♯ <plug>\sharp ' +exe s:pA9.'clubsuit<Tab>♣ <plug>\clubsuit ' +exe s:pA9.'diamondsuit<Tab>♢ <plug>\diamondsuit ' +exe s:pA9.'heartsuit<Tab>♡ <plug>\heartsuit ' +exe s:pA9.'spadesuit<Tab>â™ <plug>\spadesuit ' +exe s:pA9.'S<Tab>§ <plug>\S ' +exe s:pA9.'P<Tab>¶ <plug>\P' +" }}} +" {{{ MathCreating +let s:pA10 = s:pA."&MathCreating." +exe s:pA10.'not<Tab> <plug>\not' +exe s:pA10.'mkern<Tab> <plug>\mkern' +exe s:pA10.'mathbin<Tab> <plug>\mathbin' +exe s:pA10.'mathrel<Tab> <plug>\mathrel' +exe s:pA10.'stackrel<Tab> <plug>\stackrel' +exe s:pA10.'mathord<Tab> <plug>\mathord' +" }}} +" {{{ Styles +let s:pA11 = s:pA."&Styles." +exe s:pA11.'displaystyle<Tab> <plug>\displaystyle' +exe s:pA11.'textstyle<Tab> <plug>\textstyle' +exe s:pA11.'scritpstyle<Tab> <plug>\scritpstyle' +exe s:pA11.'scriptscriptstyle<Tab> <plug>\scriptscriptstyle' +" }}} +" {{{ MathDiacritics +let s:pA12 = s:pA."&MathDiacritics." +exe s:pA12.'acute{}<Tab>á <plug><C-r>=IMAP_PutTextWithMovement("\\acute{<++>}<++>")<cr>' +exe s:pA12.'bar{}<Tab>`_\ \ Ä <plug><C-r>=IMAP_PutTextWithMovement("\\bar{<++>}<++>")<cr>' +exe s:pA12.'breve{}<Tab>ă <plug><C-r>=IMAP_PutTextWithMovement("\\breve{<++>}<++>")<cr>' +exe s:pA12.'check{}<Tab>ÇŽ <plug><C-r>=IMAP_PutTextWithMovement("\\check{<++>}<++>")<cr>' +exe s:pA12.'ddot{}<Tab>`:\ \ ä <plug><C-r>=IMAP_PutTextWithMovement("\\ddot{<++>}<++>")<cr>' +exe s:pA12.'dot{}<Tab>`;\ \ ȧ <plug><C-r>=IMAP_PutTextWithMovement("\\dot{<++>}<++>")<cr>' +exe s:pA12.'grave{}<Tab>à <plug><C-r>=IMAP_PutTextWithMovement("\\grave{<++>}<++>")<cr>' +exe s:pA12.'hat{}<Tab>`^\ \ â <plug><C-r>=IMAP_PutTextWithMovement("\\hat{<++>}<++>")<cr>' +exe s:pA12.'tilde{}<tab>`~\ \ ã <plug><C-r>=IMAP_PutTextWithMovement("\\tilde{<++>}<++>")<cr>' +exe s:pA12.'vec{}<Tab>a⃗ <plug><C-r>=IMAP_PutTextWithMovement("\\vec{<++>}<++>")<cr>' +exe s:pA12.'widehat{}<Tab> <plug><C-r>=IMAP_PutTextWithMovement("\\widehat{<++>}<++>")<cr>' +exe s:pA12.'widetilde{}<Tab> <plug><C-r>=IMAP_PutTextWithMovement("\\widetilde{<++>}<++>")<cr>' +exe s:pA12.'imath<Tab> <plug><C-r>=IMAP_PutTextWithMovement("\\imath")<cr>' +exe s:pA12.'jmath<Tab> <plug><C-r>=IMAP_PutTextWithMovement("\\jmath")<cr>' +" }}} +" {{{ OverlineAndCo +let s:pA13 = s:pA."&OverlineAndCo." +exe s:pA13.'overline{} <plug><C-r>=IMAP_PutTextWithMovement("\\overline{}")<cr>' +exe s:pA13.'underline{} <plug><C-r>=IMAP_PutTextWithMovement("\\underline{}")<cr>' +exe s:pA13.'overrightarrow{} <plug><C-r>=IMAP_PutTextWithMovement("\\overrightarrow{}")<cr>' +exe s:pA13.'overleftarrow{} <plug><C-r>=IMAP_PutTextWithMovement("\\overleftarrow{}")<cr>' +exe s:pA13.'overbrace{} <plug><C-r>=IMAP_PutTextWithMovement("\\overbrace{}")<cr>' +exe s:pA13.'underbrace{} <plug><C-r>=IMAP_PutTextWithMovement("\\underbrace{}")<cr>' +" }}} +" {{{ Symbols1 +let s:pA14a = s:pA."&Symbols1." +exe s:pA14a.'forall<Tab>∀ <plug>\forall ' +exe s:pA14a.'exists<Tab>∃ <plug>\exists ' +exe s:pA14a.'nexists<Tab>∄ <plug>\nexists ' +exe s:pA14a.'neg<Tab>¬ <plug>\neg ' +exe s:pA14a.'top<Tab>⊤ <plug>\top ' +exe s:pA14a.'bot<Tab>⊥ <plug>\bot ' +exe s:pA14a.'emptyset<Tab>∅ <plug>\emptyset ' +exe s:pA14a.'varnothing<Tab>⌀ <plug>\varnothing ' +exe s:pA14a.'infty<Tab>∞ <plug>\infty ' +exe s:pA14a.'aleph<Tab>× <plug>\aleph ' +exe s:pA14a.'beth<Tab>ב <plug>\beth ' +exe s:pA14a.'gimel<Tab>×’ <plug>\gimel ' +exe s:pA14a.'daleth<Tab>ד <plug>\daleth ' +exe s:pA14a.'hbar<Tab> <plug>\hbar ' +exe s:pA14a.'hslash<Tab>â„ <plug>\hslash ' +exe s:pA14a.'diagup<Tab>â„ <plug>\diagup ' +exe s:pA14a.'vert<Tab>\| <plug>\vert ' +exe s:pA14a.'Vert<Tab>∥ <plug>\Vert ' +exe s:pA14a.'backslash<Tab>\\ <plug>\backslash ' +exe s:pA14a.'diagdown<Tab> <plug>\diagdown ' +exe s:pA14a.'Bbbk<Tab>ᵕ <plug>\Bbbk ' +exe s:pA14a.'P<Tab>¶ <plug>\P ' +exe s:pA14a.'S<Tab>§ <plug>\S ' +" }}} +" {{{ Symbols2 +let s:pA14b = s:pA."&Symbols2." +exe s:pA14b.'# <plug>\# ' +exe s:pA14b.'% <plug>\% ' +exe s:pA14b.'_<Tab> <plug>\_ ' +exe s:pA14b.'$ <plug>\$ ' +exe s:pA14b.'& <plug>\& ' +exe s:pA14b.'imath<Tab> <plug>\imath ' +exe s:pA14b.'jmath<Tab> <plug>\jmath ' +exe s:pA14b.'ell<Tab>â„“ <plug>\ell ' +exe s:pA14b.'wp<Tab>℘ <plug>\wp ' +exe s:pA14b.'Re<Tab>ℜ <plug>\Re ' +exe s:pA14b.'Im<Tab>â„‘ <plug>\Im ' +exe s:pA14b.'prime<Tab>′ <plug>\prime ' +exe s:pA14b.'backprime<Tab>‵ <plug>\backprime ' +exe s:pA14b.'nabla<Tab>∇ <plug>\nabla ' +exe s:pA14b.'surd<Tab>√ <plug>\surd ' +exe s:pA14b.'flat<Tab>â™ <plug>\flat ' +exe s:pA14b.'sharp<Tab>♯ <plug>\sharp ' +exe s:pA14b.'natural<Tab>â™® <plug>\natural ' +exe s:pA14b.'eth<Tab>ð <plug>\eth ' +exe s:pA14b.'bigstar<Tab>★ <plug>\bigstar ' +exe s:pA14b.'circledS<Tab>Ⓢ <plug>\circledS ' +exe s:pA14b.'Finv<Tab>Ⅎ <plug>\Finv ' +exe s:pA14b.'dag<Tab>†<plug>\dag ' +exe s:pA14b.'ddag<Tab>‡ <plug>\ddag ' +" }}} +" {{{ Symbols3 +let s:pA14c = s:pA."&Symbols3." +exe s:pA14c.'angle<Tab>∠<plug>\angle ' +exe s:pA14c.'measuredangle<Tab>∡ <plug>\measuredangle ' +exe s:pA14c.'sphericalangle<Tab>∢ <plug>\sphericalangle ' +exe s:pA14c.'spadesuit<Tab>â™ <plug>\spadesuit ' +exe s:pA14c.'heartsuit<Tab>♡ <plug>\heartsuit ' +exe s:pA14c.'diamondsuit<Tab>♢ <plug>\diamondsuit ' +exe s:pA14c.'clubsuit<Tab>♣ <plug>\clubsuit ' +exe s:pA14c.'lozenge<Tab>â—Š <plug>\lozenge ' +exe s:pA14c.'blacklozenge<Tab>â—† <plug>\blacklozenge ' +exe s:pA14c.'Diamond<Tab>â—‡ <plug>\Diamond ' +exe s:pA14c.'triangle<Tab>â–³ <plug>\triangle ' +exe s:pA14c.'vartriangle<Tab>â–³ <plug>\vartriangle ' +exe s:pA14c.'blacktriangle<Tab>â–² <plug>\blacktriangle ' +exe s:pA14c.'triangledown<Tab>â–½ <plug>\triangledown ' +exe s:pA14c.'blacktriangledown<Tab>â–¼ <plug>\blacktriangledown ' +exe s:pA14c.'Box<Tab>â–¡ <plug>\Box ' +exe s:pA14c.'square<Tab>â–¡ <plug>\square ' +exe s:pA14c.'blacksquare<Tab>â– <plug>\blacksquare ' +exe s:pA14c.'complement<Tab>∠<plug>\complement ' +exe s:pA14c.'mho<Tab>â„§ <plug>\mho ' +exe s:pA14c.'Game<Tab>â… <plug>\Game ' +exe s:pA14c.'partial<Tab>`6\ \ ∂ <plug>\partial ' +exe s:pA14c.'smallint<Tab>∫ <plug>\smallint ' +" }}} +" {{{ Logic +let s:pA15 = s:pA."&Logic." +exe s:pA15.'lnot<Tab>¬ <plug>\lnot ' +exe s:pA15.'lor<Tab>∨ <plug>\lor ' +exe s:pA15.'land<Tab>∧ <plug>\land ' +" }}} +" {{{ Limits1 +let s:pA16 = s:pA."&Limits1." +exe s:pA16.'left<Tab>( <plug>\left' +exe s:pA16.'right<Tab>) <plug>\right' +exe s:pA16.'-sepbigl- :' +exe s:pA16.'bigl<Tab> <plug>\bigl' +exe s:pA16.'Bigl<Tab> <plug>\Bigl' +exe s:pA16.'biggl<Tab> <plug>\biggl' +exe s:pA16.'Biggl<Tab> <plug>\Biggl' +exe s:pA16.'-sepbigr- :' +exe s:pA16.'bigr<Tab> <plug>\bigr' +exe s:pA16.'Bigr<Tab> <plug>\Bigr' +exe s:pA16.'biggr<Tab> <plug>\biggr' +exe s:pA16.'Biggr<Tab> <plug>\Biggr' +exe s:pA16.'-sepbig- :' +exe s:pA16.'big<Tab> <plug>\big' +exe s:pA16.'bigm<Tab> <plug>\bigm' +exe s:pA16.'-sepfloor- :' +exe s:pA16.'lfloor<Tab>⌊ <plug>\lfloor ' +exe s:pA16.'lceil<Tab>⌈ <plug>\lceil ' +exe s:pA16.'rfloor<Tab>⌋ <plug>\rfloor ' +exe s:pA16.'rceil<Tab>⌉ <plug>\rceil ' +exe s:pA16.'-sepangle- :' +exe s:pA16.'langle<Tab>〈 <plug>\langle ' +exe s:pA16.'rangle<Tab>〉 <plug>\rangle ' +" }}} +" {{{ Limits2 +let s:pA16a = s:pA."&Limits2." +exe s:pA16a.'ulcorner<Tab>⌜ <plug>\ulcorner ' +exe s:pA16a.'urcorner<Tab>⌠<plug>\urcorner ' +exe s:pA16a.'llcorner<Tab>⌞ <plug>\llcorner ' +exe s:pA16a.'rlcorner<Tab>⌟ <plug>\rlcorner ' +exe s:pA16a.'-sepcorner- :' +exe s:pA16a.'vert<Tab>\| <plug>\vert ' +exe s:pA16a.'Vert<Tab>∥ <plug>\Vert ' +exe s:pA16a.'lvert<Tab> <plug>\lvert ' +exe s:pA16a.'lVert<Tab> <plug>\lVert ' +exe s:pA16a.'rvert<Tab> <plug>\rvert ' +exe s:pA16a.'rVert<Tab> <plug>\rVert ' +exe s:pA16a.'uparrow<Tab>↑ <plug>\uparrow ' +exe s:pA16a.'Uparrow<Tab>⇑ <plug>\Uparrow ' +exe s:pA16a.'downarrow<Tab>↓ <plug>\downarrow ' +exe s:pA16a.'Downarrow<Tab>⇓ <plug>\Downarrow ' +exe s:pA16a.'updownarrow<Tab>↕ <plug>\updownarrow ' +exe s:pA16a.'Updownarrow<Tab>⇕ <plug>\Updownarrow ' +exe s:pA16a.'lgroup<Tab> <plug>\lgroup ' +exe s:pA16a.'rgroup<Tab> <plug>\rgroup ' +exe s:pA16a.'lmoustache<Tab>∫ <plug>\lmoustache ' +exe s:pA16a.'rmoustache<Tab> <plug>\rmoustache ' +exe s:pA16a.'arrowvert<Tab> <plug>\arrowvert ' +exe s:pA16a.'Arrowvert<Tab> <plug>\Arrowvert ' +exe s:pA16a.'bracevert<Tab> <plug>\bracevert ' +" }}} +" {{{ Log-likes +let s:pA17 = s:pA."Lo&g-likes." +exe s:pA17.'arccos<Tab> <plug>\arccos ' +exe s:pA17.'arcsin<Tab> <plug>\arcsin ' +exe s:pA17.'arctan<Tab> <plug>\arctan ' +exe s:pA17.'arg<Tab> <plug>\arg ' +exe s:pA17.'cos<Tab> <plug>\cos ' +exe s:pA17.'cosh<Tab> <plug>\cosh ' +exe s:pA17.'cot<Tab> <plug>\cot ' +exe s:pA17.'coth<Tab> <plug>\coth ' +exe s:pA17.'csc<Tab> <plug>\csc ' +exe s:pA17.'deg<Tab> <plug>\deg ' +exe s:pA17.'det<Tab> <plug>\det ' +exe s:pA17.'dim<Tab> <plug>\dim ' +exe s:pA17.'exp<Tab> <plug>\exp ' +exe s:pA17.'gcd<Tab> <plug>\gcd ' +exe s:pA17.'hom<Tab> <plug>\hom ' +exe s:pA17.'inf<Tab> <plug>\inf ' +exe s:pA17.'injlim<Tab> <plug>\injlim ' +exe s:pA17.'ker<Tab> <plug>\ker ' +exe s:pA17.'lg<Tab> <plug>\lg ' +exe s:pA17.'lim<Tab> <plug>\lim ' +exe s:pA17.'liminf<Tab> <plug>\liminf ' +exe s:pA17.'limsup<Tab> <plug>\limsup ' +exe s:pA17.'ln<Tab> <plug>\ln ' +exe s:pA17.'log<Tab> <plug>\log ' +exe s:pA17.'max<Tab> <plug>\max ' +exe s:pA17.'min<Tab> <plug>\min ' +exe s:pA17.'Pr<Tab> <plug>\Pr ' +exe s:pA17.'projlim<Tab> <plug>\projlim ' +exe s:pA17.'sec<Tab> <plug>\sec ' +exe s:pA17.'sin<Tab> <plug>\sin ' +exe s:pA17.'sinh<Tab> <plug>\sinh ' +exe s:pA17.'sup<Tab> <plug>\sup ' +exe s:pA17.'tan<Tab> <plug>\tan ' +exe s:pA17.'tanh<Tab> <plug>\tanh ' +exe s:pA17.'varlimsup<Tab> <plug>\varlimsup ' +exe s:pA17.'varliminf<Tab> <plug>\varliminf ' +exe s:pA17.'varinjlim<Tab> <plug>\varinjlim ' +exe s:pA17.'varprojlim<Tab> <plug>\varprojlim ' +" }}} +" {{{ MathSpacing +let s:pA18 = s:pA."MathSpacing." +exe s:pA18.', <plug>\, ' +exe s:pA18.': <plug>\: ' +exe s:pA18.'; <plug>\; ' +exe s:pA18.'[space] <plug>\ ' +exe s:pA18.'quad<Tab> <plug>\quad ' +exe s:pA18.'qquad<Tab> <plug>\qquad ' +exe s:pA18.'! <plug>\! ' +exe s:pA18.'thinspace<Tab> <plug>\thinspace ' +exe s:pA18.'medspace<Tab> <plug>\medspace ' +exe s:pA18.'thickspace<Tab> <plug>\thickspace ' +exe s:pA18.'negthinspace<Tab> <plug>\negthinspace ' +exe s:pA18.'negmedspace<Tab> <plug>\negmedspace ' +exe s:pA18.'negthickspace<Tab> <plug>\negthickspace ' +" 1}}} + +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4:fenc=utf-8 diff --git a/ftplugin/latex-suite/mathmacros.vim b/ftplugin/latex-suite/mathmacros.vim new file mode 100644 index 00000000..553965c6 --- /dev/null +++ b/ftplugin/latex-suite/mathmacros.vim @@ -0,0 +1,730 @@ +"============================================================================= +" File: mathmacros.vim +" Author: Mikolaj Machowski +" Created: Tue Apr 23 06:00 PM 2002 PST +" +" Description: macros for everything mathematical in latex. +"============================================================================= + +if !(has('gui_running') && g:Tex_MathMenus && g:Tex_Menus) + finish +endif + +let s:MathMenuName = g:Tex_MenuPrefix.'&Math.' + +function! Tex_MathMenuRemove() + exe 'silent! aunmenu '.s:MathMenuName +endfunction + +let s:pA = 'amenu <silent> '.g:Tex_NextMenuLocation.' '.s:MathMenuName +let g:Tex_NextMenuLocation = g:Tex_NextMenuLocation + 1 + +" brackets and dollars {{{ +exe s:pA.'\\&[\ \\] <plug><C-r>=IMAP_PutTextWithMovement("\\[<++>\\]<++>")<cr>' +exe s:pA.'\\&(\ \\) <plug><C-r>=IMAP_PutTextWithMovement("\\(<++>\\)<++>")<cr>' +exe s:pA.'&$\ $ <plug>$$' +exe s:pA.'-sepmath1- :' +" }}} +" MATH arrows {{{ +let s:pA1 = s:pA."&Arrows." +exe s:pA1.'Leftarrow <plug>\leftarrow ' +exe s:pA1.'leftarrow <plug>\leftarrow' +exe s:pA1.'longleftarrow <plug>\longleftarrow ' +exe s:pA1.'Leftarrow <plug>\Leftarrow ' +exe s:pA1.'Longleftarrow <plug>\Longleftarrow ' +exe s:pA1.'rightarrow <plug>\rightarrow ' +exe s:pA1.'longrightarrow <plug>\longrightarrow ' +exe s:pA1.'Rightarrow <plug>\Rightarrow ' +exe s:pA1.'Longrightarrow <plug>\Longrightarrow ' +exe s:pA1.'leftrightarrow <plug>\leftrightarrow ' +exe s:pA1.'longleftrightarrow <plug>\longleftrightarrow ' +exe s:pA1.'Leftrightarrow <plug>\Leftrightarrow ' +exe s:pA1.'Longleftrightarrow <plug>\Longleftrightarrow ' +exe s:pA1.'uparrow <plug>\uparrow ' +exe s:pA1.'Uparrow <plug>\Uparrow ' +exe s:pA1.'downarrow <plug>\downarrow ' +exe s:pA1.'Downarrow <plug>\Downarrow ' +exe s:pA1.'updownarrow <plug>\updownarrow ' +exe s:pA1.'Updownarrow <plug>\Updownarrow ' +exe s:pA1.'nearrow <plug>\nearrow ' +exe s:pA1.'searrow <plug>\searrow ' +exe s:pA1.'swarrow <plug>\swarrow ' +exe s:pA1.'nwarrow <plug>\nwarrow ' +exe s:pA1.'mapsto <plug>\mapsto ' +exe s:pA1.'leadsto <plug>\leadsto ' +exe s:pA1.'longmapsto <plug>\longmapsto ' +exe s:pA1.'hookleftarrow <plug>\hookleftarrow ' +exe s:pA1.'hookrightarrow <plug>\hookrightarrow ' +exe s:pA1.'leftharpoonup <plug>\leftharpoonup ' +exe s:pA1.'leftharpoondown <plug>\leftharpoondown ' +exe s:pA1.'rightharpoonup <plug>\rightharpoonup ' +exe s:pA1.'rightharpoondown <plug>\rightharpoondown ' +exe s:pA1.'rightleftharpoons <plug>\rightleftharpoons ' +exe s:pA1.'overleftarrow <plug>\overleftarrow ' +exe s:pA1.'overrightarrow <plug>\overrightarrow ' +exe s:pA1.'overleftrightarrow <plug>\overleftrightarrow ' +exe s:pA1.'underleftarrow <plug>\underleftarrow ' +exe s:pA1.'underrightarrow <plug>\underrightarrow ' +exe s:pA1.'underleftrightarrow <plug>\underleftrightarrow ' +exe s:pA1.'xleftarrow <plug>\xleftarrow ' +exe s:pA1.'xrightarrow <plug>\xrightarrow ' +" }}} + + +" MATH nArrows {{{ +let s:pA1a = s:pA."&nArrows." +exe s:pA1a.'nleftarrow <plug>\nleftarrow ' +exe s:pA1a.'nLeftarrow <plug>\nLeftarrow ' +exe s:pA1a.'nleftrightarrow <plug>\nleftrightarrow ' +exe s:pA1a.'nrightarrow <plug>\nrightarrow ' +exe s:pA1a.'nRightarrow <plug>\nRightarrow ' +" }}} +" MATH Arrows2 {{{ +let s:pA1a = s:pA."Arrows2." +exe s:pA1a.'dashleftarrow <plug>\dashleftarrow ' +exe s:pA1a.'leftleftarrows <plug>\leftleftarrows ' +exe s:pA1a.'leftrightarrows <plug>\leftrightarrows ' +exe s:pA1a.'Lleftarrow <plug>\Lleftarrow ' +exe s:pA1a.'twoheadleftarrow <plug>\twoheadleftarrow ' +exe s:pA1a.'leftarrowtail <plug>\leftarrowtail ' +exe s:pA1a.'leftrightharpoons <plug>\leftrightharpoons ' +exe s:pA1a.'Lsh <plug>\Lsh ' +exe s:pA1a.'looparrowleft <plug>\looparrowleft ' +exe s:pA1a.'curvearrowleft <plug>\curvearrowleft ' +exe s:pA1a.'circlearrowleft <plug>\circlearrowleft ' +exe s:pA1a.'dashrightarrow <plug>\dashrightarrow ' +exe s:pA1a.'rightrightarrows <plug>\rightrightarrows ' +exe s:pA1a.'rightleftarrows <plug>\rightleftarrows ' +exe s:pA1a.'Rrightarrow <plug>\Rrightarrow ' +exe s:pA1a.'twoheadrightarrow <plug>\twoheadrightarrow ' +exe s:pA1a.'rightarrowtail <plug>\rightarrowtail ' +exe s:pA1a.'rightleftharpoons <plug>\rightleftharpoons ' +exe s:pA1a.'Rsh <plug>\Rsh ' +exe s:pA1a.'looparrowright <plug>\looparrowright ' +exe s:pA1a.'curvearrowright <plug>\curvearrowright ' +exe s:pA1a.'circlearrowright <plug>\circlearrowright ' +exe s:pA1a.'multimap <plug>\multimap ' +exe s:pA1a.'upuparrows <plug>\upuparrows ' +exe s:pA1a.'downdownarrows <plug>\downdownarrows ' +exe s:pA1a.'upharpoonleft <plug>\upharpoonleft ' +exe s:pA1a.'upharpoonright <plug>\upharpoonright ' +exe s:pA1a.'downharpoonleft <plug>\downharpoonleft ' +exe s:pA1a.'downharpoonright <plug>\downharpoonright ' +exe s:pA1a.'rightsquigarrow <plug>\rightsquigarrow ' +exe s:pA1a.'leftrightsquigarrow <plug>\leftrightsquigarrow ' +" }}} +" MATH Fonts {{{ +let s:pA2a = s:pA."&MathFonts." +exe s:pA2a.'mathbf{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathbf{<++>}<++>")<cr>' +exe s:pA2a.'mathrm{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathrm{<++>}<++>")<cr>' +exe s:pA2a.'mathsf{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathsf{<++>}<++>")<cr>' +exe s:pA2a.'mathtt{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathtt{<++>}<++>")<cr>' +exe s:pA2a.'mathit{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathit{<++>}<++>")<cr>' +exe s:pA2a.'mathfrak{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathfrak{<++>}<++>")<cr>' +exe s:pA2a.'mathcal{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathcal{<++>}<++>")<cr>' +exe s:pA2a.'mathscr{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathscr{<++>}<++>")<cr>' +exe s:pA2a.'mathbb{} <plug><C-r>=IMAP_PutTextWithMovement("\\mathbb{<++>}<++>")<cr>' +" }}} +" Greek Letters small {{{ +let s:pA2 = s:pA."&Greek.&Small." +exe s:pA2.'alpha<Tab>`a <plug>\alpha ' +exe s:pA2.'beta<Tab>`b <plug>\beta ' +exe s:pA2.'gamma<Tab>`g <plug>\gamma ' +exe s:pA2.'delta<Tab>`d <plug>\delta ' +exe s:pA2.'epsilon <plug>\epsilon ' +exe s:pA2.'varepsilon<Tab>`e <plug>\varepsilon ' +exe s:pA2.'zeta<Tab>`z <plug>\zeta ' +exe s:pA2.'eta<Tab>`h <plug>\eta ' +exe s:pA2.'theta<Tab>`q <plug>\theta ' +exe s:pA2.'vartheta <plug>\vartheta ' +exe s:pA2.'iota<Tab>`i <plug>\iota ' +exe s:pA2.'kappa<Tab>`k <plug>\kappa ' +exe s:pA2.'lambda<Tab>`l <plug>\lambda ' +exe s:pA2.'mu<Tab>`m <plug>\mu ' +exe s:pA2.'nu<Tab>`n <plug>\nu ' +exe s:pA2.'xi<Tab>`x <plug>\xi ' +exe s:pA2.'pi<Tab>`p <plug>\pi ' +exe s:pA2.'varpi <plug>\varpi ' +exe s:pA2.'rho<Tab>`r <plug>\rho ' +exe s:pA2.'varrho <plug>\varrho ' +exe s:pA2.'sigma<Tab>`s <plug>\sigma ' +exe s:pA2.'varsigma<Tab>`v <plug>\varsigma ' +exe s:pA2.'tau<Tab>`t <plug>\tau ' +exe s:pA2.'upsilon<Tab>`u <plug>\upsilon ' +exe s:pA2.'phi <plug>\phi ' +exe s:pA2.'varphi<Tab>`f <plug>\varphi ' +exe s:pA2.'chi<Tab>`c <plug>\chi ' +exe s:pA2.'psi<Tab>`y <plug>\psi ' +exe s:pA2.'omega<Tab>`w <plug>\omega ' +" }}} +" Greek Letters big {{{ +let s:pA3 = s:pA.'&Greek.&Big.' +exe s:pA3.'Alpha<Tab>`A <plug>\Alpha ' +exe s:pA3.'Beta<Tab>`B <plug>\Beta ' +exe s:pA3.'Gamma<Tab>`G <plug>\Gamma ' +exe s:pA3.'Delta<Tab>`D <plug>\Delta ' +exe s:pA3.'Epsilon<Tab>`E <plug>\Epsilon ' +exe s:pA3.'Zeta<Tab>`Z <plug>\mathrm{Z} ' +exe s:pA3.'Eta<Tab>`H <plug>\Eta ' +exe s:pA3.'Theta <plug>\Theta ' +exe s:pA3.'Iota <plug>\mathrm{I} ' +exe s:pA3.'Kappa<Tab>`K <plug>\Kappa ' +exe s:pA3.'Lambda<Tab>`L <plug>\Lambda ' +exe s:pA3.'Mu<Tab>`M <plug>\Mu ' +exe s:pA3.'Nu<Tab>`N <plug>\Nu ' +exe s:pA3.'Xi<Tab>`X <plug>\Xi ' +exe s:pA3.'Pi<Tab>`P <plug>\Pi ' +exe s:pA3.'Rho<Tab>`R <plug>\Rho ' +exe s:pA3.'Sigma<Tab>`S <plug>\Sigma ' +exe s:pA3.'Tau<Tab>`T <plug>\Tau ' +exe s:pA3.'Upsilon<Tab>`U <plug>\Upsilon ' +exe s:pA3.'Phi <plug>\Phi ' +exe s:pA3.'Chi<Tab>`C <plug>\Chi ' +exe s:pA3.'Psi<Tab>`Y <plug>\Psi ' +exe s:pA3.'Omega<Tab>`W <plug>\Omega ' +" }}} +" BinaryRel1 {{{ +let s:pA4 = s:pA."&BinaryRel1." +exe s:pA4.'ll <plug>\ll ' +exe s:pA4.'lll <plug>\lll ' +exe s:pA4.'leqslant <plug>\leqslant ' +exe s:pA4.'leq <plug>\leq ' +exe s:pA4.'leqq <plug>\leqq ' +exe s:pA4.'eqslantless <plug>\eqslantless ' +exe s:pA4.'lessdot <plug>\lessdot ' +exe s:pA4.'prec <plug>\prec ' +exe s:pA4.'preceq <plug>\preceq ' +exe s:pA4.'preccurlyeq <plug>\preccurlyeq ' +exe s:pA4.'curlyeqprec <plug>\curlyeqprec ' +exe s:pA4.'lesssim <plug>\lesssim ' +exe s:pA4.'lessapprox <plug>\lessapprox ' +exe s:pA4.'precsim <plug>\precsim ' +exe s:pA4.'precapprox <plug>\precapprox ' +exe s:pA4.'in <plug>\in ' +exe s:pA4.'subset<Tab>`( <plug>\subset ' +exe s:pA4.'Subset<Tab>`) <plug>\Subset ' +exe s:pA4.'subseteq <plug>\subseteq ' +exe s:pA4.'subseteqq <plug>\subseteqq ' +exe s:pA4.'sqsubset <plug>\sqsubset ' +exe s:pA4.'sqsubseteq <plug>\sqsubseteq ' +exe s:pA4.'smile <plug>\smile ' +exe s:pA4.'smallsmile <plug>\smallsmile ' +exe s:pA4.'parallel <plug>\parallel ' +exe s:pA4.'shortparallel <plug>\shortparallel ' +exe s:pA4.'dashv <plug>\dashv ' +exe s:pA4.'vdash <plug>\vdash ' +exe s:pA4.'vDash <plug>\vDash ' +exe s:pA4.'models <plug>\models ' +exe s:pA4.'therefore <plug>\therefore ' +exe s:pA4.'backepsilon <plug>\backepsilon ' +" }}} +" nBinaryRel1 {{{ +let s:pA4a = s:pA."&nBinaryRel1." +exe s:pA4a.'nless <plug>\nless ' +exe s:pA4a.'nleqslant <plug>\nleqslant ' +exe s:pA4a.'nleq <plug>\nleq ' +exe s:pA4a.'lneq <plug>\lneq ' +exe s:pA4a.'nleqq <plug>\nleqq ' +exe s:pA4a.'lneqq <plug>\lneqq ' +exe s:pA4a.'lvertneqq <plug>\lvertneqq ' +exe s:pA4a.'nprec <plug>\nprec ' +exe s:pA4a.'npreceq <plug>\npreceq ' +exe s:pA4a.'precneqq <plug>\precneqq ' +exe s:pA4a.'lnsim <plug>\lnsim ' +exe s:pA4a.'lnapprox <plug>\lnapprox ' +exe s:pA4a.'precnsim <plug>\precnsim ' +exe s:pA4a.'precnapprox <plug>\precnapprox ' +exe s:pA4a.'notin <plug>\notin ' +exe s:pA4a.'nsubseteq <plug>\nsubseteq ' +exe s:pA4a.'varsubsetneq <plug>\varsubsetneq ' +exe s:pA4a.'subsetneq <plug>\subsetneq ' +exe s:pA4a.'nsubseteqq <plug>\nsubseteqq ' +exe s:pA4a.'varsubsetneqq <plug>\varsubsetneqq ' +exe s:pA4a.'subsetneqq <plug>\subsetneqq ' +exe s:pA4a.'nparallel <plug>\nparallel ' +exe s:pA4a.'nshortparallel <plug>\nshortparallel ' +exe s:pA4a.'nvdash <plug>\nvdash ' +exe s:pA4a.'nvDash <plug>\nvDash ' +" }}} +" BinaryRel2 {{{ +let s:pA5 = s:pA."&BinaryRel2." +exe s:pA5.'gg <plug>\gg ' +exe s:pA5.'ggg <plug>\ggg ' +exe s:pA5.'gggtr <plug>\gggtr ' +exe s:pA5.'geqslant <plug>\geqslant ' +exe s:pA5.'geq <plug>\geq ' +exe s:pA5.'geqq <plug>\geqq ' +exe s:pA5.'eqslantgtr <plug>\eqslantgtr ' +exe s:pA5.'gtrdot <plug>\gtrdot ' +exe s:pA5.'succ <plug>\succ ' +exe s:pA5.'succeq <plug>\succeq ' +exe s:pA5.'succcurlyeq <plug>\succcurlyeq ' +exe s:pA5.'curlyeqsucc <plug>\curlyeqsucc ' +exe s:pA5.'gtrsim <plug>\gtrsim ' +exe s:pA5.'gtrapprox <plug>\gtrapprox ' +exe s:pA5.'succsim <plug>\succsim ' +exe s:pA5.'succapprox <plug>\succapprox ' +exe s:pA5.'ni <plug>\ni ' +exe s:pA5.'owns <plug>\owns ' +exe s:pA5.'supset <plug>\supset ' +exe s:pA5.'Supset <plug>\Supset ' +exe s:pA5.'supseteq <plug>\supseteq ' +exe s:pA5.'supseteqq <plug>\supseteqq ' +exe s:pA5.'sqsupset <plug>\sqsupset ' +exe s:pA5.'sqsupseteq <plug>\sqsupseteq ' +exe s:pA5.'frown <plug>\frown ' +exe s:pA5.'smallfrown <plug>\smallfrown ' +exe s:pA5.'mid <plug>\mid ' +exe s:pA5.'shortmid <plug>\shortmid ' +exe s:pA5.'between <plug>\between ' +exe s:pA5.'Vdash <plug>\Vdash ' +exe s:pA5.'bowtie <plug>\bowtie ' +exe s:pA5.'Join <plug>\Join ' +exe s:pA5.'pitchfork <plug>\pitchfork ' +" }}} +" {{{ nBinaryRel2 +let s:pA5a = s:pA."n&BinaryRel2." "TODO: dorobiæ logarytmy +exe s:pA5a.'ngtr <plug>\ngtr ' +exe s:pA5a.'ngeqslant <plug>\ngeqslant ' +exe s:pA5a.'ngeq <plug>\ngeq ' +exe s:pA5a.'gneq <plug>\gneq ' +exe s:pA5a.'ngeqq <plug>\ngeqq ' +exe s:pA5a.'gneqq <plug>\gneqq ' +exe s:pA5a.'nsucc <plug>\nsucc ' +exe s:pA5a.'nsucceq <plug>\nsucceq ' +exe s:pA5a.'succneqq <plug>\succneqq ' +exe s:pA5a.'gnsim <plug>\gnsim ' +exe s:pA5a.'gnapprox <plug>\gnapprox ' +exe s:pA5a.'succnsim <plug>\succnsim ' +exe s:pA5a.'succnapprox <plug>\succnapprox ' +exe s:pA5a.'nsupseteq <plug>\nsupseteq ' +exe s:pA5a.'varsupsetneq <plug>\varsupsetneq ' +exe s:pA5a.'supsetneq <plug>\supsetneq ' +exe s:pA5a.'nsupseteqq <plug>\nsupseteqq ' +exe s:pA5a.'varsupsetneqq <plug>\varsupsetneqq ' +exe s:pA5a.'supsetneqq <plug>\supsetneqq ' +exe s:pA5a.'nmid <plug>\nmid ' +exe s:pA5a.'nshortmid <plug>\nshortmid ' +exe s:pA5a.'nVdash <plug>\nVdash ' +" }}} +" {{{ BinaryRel3 +let s:pA6 = s:pA."&BinaryRel3." +exe s:pA6.'doteq <plug>\doteq ' +exe s:pA6.'circeq <plug>\circeq ' +exe s:pA6.'eqcirc <plug>\eqcirc ' +exe s:pA6.'risingdotseq <plug>\risingdotseq ' +exe s:pA6.'doteqdot <plug>\doteqdot ' +exe s:pA6.'Doteq <plug>\Doteq ' +exe s:pA6.'fallingdotseq <plug>\fallingdotseq ' +exe s:pA6.'triangleq <plug>\triangleq ' +exe s:pA6.'bumpeq <plug>\bumpeq ' +exe s:pA6.'Bumpeq <plug>\Bumpeq ' +exe s:pA6.'equiv<Tab>`= <plug>\equiv ' +exe s:pA6.'sim <plug>\sim ' +exe s:pA6.'thicksim <plug>\thicksim ' +exe s:pA6.'backsim <plug>\backsim ' +exe s:pA6.'simeq <plug>\simeq ' +exe s:pA6.'backsimeq <plug>\backsimeq ' +exe s:pA6.'cong <plug>\cong ' +exe s:pA6.'approx<tab>=~ <plug>\approx ' +exe s:pA6.'thickapprox <plug>\thickapprox ' +exe s:pA6.'approxeq <plug>\approxeq ' +exe s:pA6.'blacktriangleleft <plug>\blacktriangleleft ' +exe s:pA6.'vartriangleleft <plug>\vartriangleleft ' +exe s:pA6.'trianglelefteq <plug>\trianglelefteq ' +exe s:pA6.'blacktriangleright <plug>\blacktriangleright ' +exe s:pA6.'vartriangleright <plug>\vartriangleright ' +exe s:pA6.'trianglerighteq <plug>\trianglerighteq ' +exe s:pA6.'perp <plug>\perp ' +exe s:pA6.'asymp <plug>\asymp ' +exe s:pA6.'Vvdash <plug>\Vvdash ' +exe s:pA6.'propto <plug>\propto ' +exe s:pA6.'varpropto <plug>\varpropto ' +exe s:pA6.'because <plug>\because ' +" }}} +" {{{ nBinaryRel3 +let s:pA6a = s:pA."&nBinaryRel3." +exe s:pA6a.'neq <plug>\neq ' +exe s:pA6a.'nsim <plug>\nsim ' +exe s:pA6a.'ncong <plug>\ncong ' +exe s:pA6a.'ntriangleleft <plug>\ntriangleleft ' +exe s:pA6a.'ntrianglelefteq <plug>\ntrianglelefteq ' +exe s:pA6a.'ntriangleright <plug>\ntriangleright ' +exe s:pA6a.'ntrianglerighteq <plug>\ntrianglerighteq ' +" }}} +" {{{ BinaryRel4 +let s:pA7 = s:pA."&BinaryRel4." +exe s:pA7.'lessgtr <plug>\lessgtr ' +exe s:pA7.'gtrless <plug>\gtrless ' +exe s:pA7.'lesseqgtr <plug>\lesseqgtr ' +exe s:pA7.'gtreqless <plug>\gtreqless ' +exe s:pA7.'lesseqqgtr <plug>\lesseqqgtr ' +exe s:pA7.'gtreqqless <plug>\gtreqqless ' +" }}} +" {{{ BigOp +let s:pA8a = s:pA."&BigOp." +exe s:pA8a.'limits <plug>\limits' +exe s:pA8a.'nolimits <plug>\nolimits' +exe s:pA8a.'displaylimits <plug>\displaylimits' +exe s:pA8a.'-seplimits- :' +exe s:pA8a.'bigcap<Tab>`- <plug>\bigcap' +exe s:pA8a.'bigcup<Tab>`+ <plug>\bigcup' +exe s:pA8a.'bigodot <plug>\bigodot' +exe s:pA8a.'bigoplus <plug>\bigoplus' +exe s:pA8a.'bigotimes <plug>\bigotimes' +exe s:pA8a.'bigsqcup <plug>\bigsqcup' +exe s:pA8a.'biguplus <plug>\biguplus' +exe s:pA8a.'bigvee <plug>\bigvee' +exe s:pA8a.'bigwedge <plug>\bigwedge' +exe s:pA8a.'coprod <plug>\coprod' +exe s:pA8a.'int <plug>\int' +exe s:pA8a.'oint <plug>\oint' +exe s:pA8a.'prod <plug>\prod' +exe s:pA8a.'sum <plug>\sum' +" }}} +" {{{ BinaryOp +let s:pA8 = s:pA."&BinaryOp." +exe s:pA8.'pm <plug>\pm ' +exe s:pA8.'mp <plug>\mp ' +exe s:pA8.'dotplus <plug>\dotplus ' +exe s:pA8.'cdot<Tab>`. <plug>\cdot ' +exe s:pA8.'centerdot <plug>\centerdot ' +exe s:pA8.'times<Tab>`* <plug>\times ' +exe s:pA8.'ltimes <plug>\ltimes ' +exe s:pA8.'rtimes <plug>\rtimes ' +exe s:pA8.'leftthreetimes <plug>\leftthreetimes ' +exe s:pA8.'rightthreetimes <plug>\rightthreetimes ' +exe s:pA8.'div <plug>\div ' +exe s:pA8.'divideontimes <plug>\divideontimes ' +exe s:pA8.'bmod <plug>\bmod ' +exe s:pA8.'ast <plug>\ast ' +exe s:pA8.'star <plug>\star ' +exe s:pA8.'setminus<Tab>`\\ <plug>\setminus ' +exe s:pA8.'smallsetminus <plug>\smallsetminus ' +exe s:pA8.'diamond <plug>\diamond ' +exe s:pA8.'wr <plug>\wr ' +exe s:pA8.'intercal <plug>\intercal ' +exe s:pA8.'circ<Tab>`@ <plug>\circ ' +exe s:pA8.'bigcirc <plug>\bigcirc ' +exe s:pA8.'bullet <plug>\bullet ' +exe s:pA8.'cap <plug>\cap ' +exe s:pA8.'Cap <plug>\Cap ' +exe s:pA8.'cup <plug>\cup ' +exe s:pA8.'Cup <plug>\Cup ' +exe s:pA8.'sqcap <plug>\sqcap ' +exe s:pA8.'sqcup <plug>\sqcup' +exe s:pA8.'amalg <plug>\amalg ' +exe s:pA8.'uplus <plug>\uplus ' +exe s:pA8.'triangleleft <plug>\triangleleft ' +exe s:pA8.'triangleright <plug>\triangleright ' +exe s:pA8.'bigtriangleup <plug>\bigtriangleup ' +exe s:pA8.'bigtriangledown <plug>\bigtriangledown ' +exe s:pA8.'vee <plug>\vee ' +exe s:pA8.'veebar <plug>\veebar ' +exe s:pA8.'curlyvee <plug>\curlyvee ' +exe s:pA8.'wedge<Tab>`& <plug>\wedge ' +exe s:pA8.'barwedge <plug>\barwedge ' +exe s:pA8.'doublebarwedge <plug>\doublebarwedge ' +exe s:pA8.'curlywedge <plug>\curlywedge ' +exe s:pA8.'oplus <plug>\oplus ' +exe s:pA8.'ominus <plug>\ominus ' +exe s:pA8.'otimes <plug>\otimes ' +exe s:pA8.'oslash <plug>\oslash ' +exe s:pA8.'boxplus <plug>\boxplus ' +exe s:pA8.'boxminus <plug>\boxminus ' +exe s:pA8.'boxtimes <plug>\boxtimes ' +exe s:pA8.'boxdot <plug>\boxdot ' +exe s:pA8.'odot <plug>\odot ' +exe s:pA8.'circledast <plug>\circledast ' +exe s:pA8.'circleddash <plug>\circleddash ' +exe s:pA8.'circledcirc <plug>\circledcirc ' +exe s:pA8.'dagger <plug>\dagger ' +exe s:pA8.'ddagger <plug>\ddagger ' +exe s:pA8.'lhd <plug>\lhd ' +exe s:pA8.'unlhd <plug>\unlhd ' +exe s:pA8.'rhd <plug>\rhd ' +exe s:pA8.'unrhd <plug>\unrhd ' +" }}} +" {{{ Other1 +let s:pA9 = s:pA."&Other1." +exe s:pA9.'hat <plug>\hat ' +exe s:pA9.'check <plug>\check ' +exe s:pA9.'grave <plug>\grave ' +exe s:pA9.'acute <plug>\acute ' +exe s:pA9.'dot <plug>\dot ' +exe s:pA9.'ddot <plug>\ddot ' +exe s:pA9.'tilde<Tab>`, <plug>\tilde ' +exe s:pA9.'breve <plug>\breve ' +exe s:pA9.'bar <plug>\bar ' +exe s:pA9.'vec <plug>\vec ' +exe s:pA9.'aleph <plug>\aleph ' +exe s:pA9.'hbar <plug>\hbar ' +exe s:pA9.'imath <plug>\imath ' +exe s:pA9.'jmath <plug>\jmath ' +exe s:pA9.'ell <plug>\ell ' +exe s:pA9.'wp <plug>\wp ' +exe s:pA9.'Re <plug>\Re ' +exe s:pA9.'Im <plug>\Im ' +exe s:pA9.'partial <plug>\partial ' +exe s:pA9.'infty<Tab>`8 <plug>\infty ' +exe s:pA9.'prime <plug>\prime ' +exe s:pA9.'emptyset <plug>\emptyset ' +exe s:pA9.'nabla <plug>\nabla ' +exe s:pA9.'surd <plug>\surd ' +exe s:pA9.'top <plug>\top ' +exe s:pA9.'bot <plug>\bot ' +exe s:pA9.'angle <plug>\angle ' +exe s:pA9.'triangle <plug>\triangle ' +exe s:pA9.'backslash <plug>\backslash ' +exe s:pA9.'forall <plug>\forall ' +exe s:pA9.'exists <plug>\exists ' +exe s:pA9.'neg <plug>\neg ' +exe s:pA9.'flat <plug>\flat ' +exe s:pA9.'natural <plug>\natural ' +exe s:pA9.'sharp <plug>\sharp ' +exe s:pA9.'clubsuit <plug>\clubsuit ' +exe s:pA9.'diamondsuit <plug>\diamondsuit ' +exe s:pA9.'heartsuit <plug>\heartsuit ' +exe s:pA9.'spadesuit <plug>\spadesuit ' +exe s:pA9.'S <plug>\S ' +exe s:pA9.'P <plug>\P' +" }}} +" {{{ MathCreating +let s:pA10 = s:pA."&MathCreating." +exe s:pA10.'not <plug>\not' +exe s:pA10.'mkern <plug>\mkern' +exe s:pA10.'mathbin <plug>\mathbin' +exe s:pA10.'mathrel <plug>\mathrel' +exe s:pA10.'stackrel <plug>\stackrel' +exe s:pA10.'mathord <plug>\mathord' +" }}} +" {{{ Styles +let s:pA11 = s:pA."&Styles." +exe s:pA11.'displaystyle <plug>\displaystyle' +exe s:pA11.'textstyle <plug>\textstyle' +exe s:pA11.'scritpstyle <plug>\scritpstyle' +exe s:pA11.'scriptscriptstyle <plug>\scriptscriptstyle' +" }}} +" {{{ MathDiacritics +let s:pA12 = s:pA."&MathDiacritics." +exe s:pA12.'acute{} <plug><C-r>=IMAP_PutTextWithMovement("\\acute{<++>}<++>")<cr>' +exe s:pA12.'bar{}<Tab>`_ <plug><C-r>=IMAP_PutTextWithMovement("\\bar{<++>}<++>")<cr>' +exe s:pA12.'breve{} <plug><C-r>=IMAP_PutTextWithMovement("\\breve{<++>}<++>")<cr>' +exe s:pA12.'check{} <plug><C-r>=IMAP_PutTextWithMovement("\\check{<++>}<++>")<cr>' +exe s:pA12.'ddot{}<Tab>`: <plug><C-r>=IMAP_PutTextWithMovement("\\ddot{<++>}<++>")<cr>' +exe s:pA12.'dot{}<Tab>`; <plug><C-r>=IMAP_PutTextWithMovement("\\dot{<++>}<++>")<cr>' +exe s:pA12.'grave{} <plug><C-r>=IMAP_PutTextWithMovement("\\grave{<++>}<++>")<cr>' +exe s:pA12.'hat{}<Tab>`^ <plug><C-r>=IMAP_PutTextWithMovement("\\hat{<++>}<++>")<cr>' +exe s:pA12.'tilde{}<tab>`~ <plug><C-r>=IMAP_PutTextWithMovement("\\tilde{<++>}<++>")<cr>' +exe s:pA12.'vec{} <plug><C-r>=IMAP_PutTextWithMovement("\\vec{<++>}<++>")<cr>' +exe s:pA12.'widehat{} <plug><C-r>=IMAP_PutTextWithMovement("\\widehat{<++>}<++>")<cr>' +exe s:pA12.'widetilde{} <plug><C-r>=IMAP_PutTextWithMovement("\\widetilde{<++>}<++>")<cr>' +exe s:pA12.'imath <plug><C-r>=IMAP_PutTextWithMovement("\\imath")<cr>' +exe s:pA12.'jmath <plug><C-r>=IMAP_PutTextWithMovement("\\jmath")<cr>' +" }}} +" {{{ OverlineAndCo +let s:pA13 = s:pA."&OverlineAndCo." +exe s:pA13.'overline{} <plug><C-r>=IMAP_PutTextWithMovement("\\overline{}")<cr>' +exe s:pA13.'underline{} <plug><C-r>=IMAP_PutTextWithMovement("\\underline{}")<cr>' +exe s:pA13.'overrightarrow{} <plug><C-r>=IMAP_PutTextWithMovement("\\overrightarrow{}")<cr>' +exe s:pA13.'overleftarrow{} <plug><C-r>=IMAP_PutTextWithMovement("\\overleftarrow{}")<cr>' +exe s:pA13.'overbrace{} <plug><C-r>=IMAP_PutTextWithMovement("\\overbrace{}")<cr>' +exe s:pA13.'underbrace{} <plug><C-r>=IMAP_PutTextWithMovement("\\underbrace{}")<cr>' +" }}} +" {{{ Symbols1 +let s:pA14a = s:pA."&Symbols1." +exe s:pA14a.'forall <plug>\forall ' +exe s:pA14a.'exists <plug>\exists ' +exe s:pA14a.'nexists <plug>\nexists ' +exe s:pA14a.'neg <plug>\neg ' +exe s:pA14a.'top <plug>\top ' +exe s:pA14a.'bot <plug>\bot ' +exe s:pA14a.'emptyset <plug>\emptyset ' +exe s:pA14a.'varnothing <plug>\varnothing ' +exe s:pA14a.'infty <plug>\infty ' +exe s:pA14a.'aleph <plug>\aleph ' +exe s:pA14a.'beth <plug>\beth ' +exe s:pA14a.'gimel <plug>\gimel ' +exe s:pA14a.'daleth <plug>\daleth ' +exe s:pA14a.'hbar <plug>\hbar ' +exe s:pA14a.'hslash <plug>\hslash ' +exe s:pA14a.'diagup <plug>\diagup ' +exe s:pA14a.'vert <plug>\vert ' +exe s:pA14a.'Vert <plug>\Vert ' +exe s:pA14a.'backslash <plug>\backslash ' +exe s:pA14a.'diagdown <plug>\diagdown ' +exe s:pA14a.'Bbbk <plug>\Bbbk ' +exe s:pA14a.'P <plug>\P ' +exe s:pA14a.'S <plug>\S ' +" }}} +" {{{ Symbols2 +let s:pA14b = s:pA."&Symbols2." +exe s:pA14b.'# <plug>\# ' +exe s:pA14b.'% <plug>\% ' +exe s:pA14b.'_ <plug>\_ ' +exe s:pA14b.'$ <plug>\$ ' +exe s:pA14b.'& <plug>\& ' +exe s:pA14b.'imath <plug>\imath ' +exe s:pA14b.'jmath <plug>\jmath ' +exe s:pA14b.'ell <plug>\ell ' +exe s:pA14b.'wp <plug>\wp ' +exe s:pA14b.'Re <plug>\Re ' +exe s:pA14b.'Im <plug>\Im ' +exe s:pA14b.'prime <plug>\prime ' +exe s:pA14b.'backprime <plug>\backprime ' +exe s:pA14b.'nabla <plug>\nabla ' +exe s:pA14b.'surd <plug>\surd ' +exe s:pA14b.'flat <plug>\flat ' +exe s:pA14b.'sharp <plug>\sharp ' +exe s:pA14b.'natural <plug>\natural ' +exe s:pA14b.'eth <plug>\eth ' +exe s:pA14b.'bigstar <plug>\bigstar ' +exe s:pA14b.'circledS <plug>\circledS ' +exe s:pA14b.'Finv <plug>\Finv ' +exe s:pA14b.'dag <plug>\dag ' +exe s:pA14b.'ddag <plug>\ddag ' +" }}} +" {{{ Symbols3 +let s:pA14c = s:pA."&Symbols3." +exe s:pA14c.'angle <plug>\angle ' +exe s:pA14c.'measuredangle <plug>\measuredangle ' +exe s:pA14c.'sphericalangle <plug>\sphericalangle ' +exe s:pA14c.'spadesuit <plug>\spadesuit ' +exe s:pA14c.'heartsuit <plug>\heartsuit ' +exe s:pA14c.'diamondsuit <plug>\diamondsuit ' +exe s:pA14c.'clubsuit <plug>\clubsuit ' +exe s:pA14c.'lozenge <plug>\lozenge ' +exe s:pA14c.'blacklozenge <plug>\blacklozenge ' +exe s:pA14c.'Diamond <plug>\Diamond ' +exe s:pA14c.'triangle <plug>\triangle ' +exe s:pA14c.'vartriangle <plug>\vartriangle ' +exe s:pA14c.'blacktriangle <plug>\blacktriangle ' +exe s:pA14c.'triangledown <plug>\triangledown ' +exe s:pA14c.'blacktriangledown <plug>\blacktriangledown ' +exe s:pA14c.'Box <plug>\Box ' +exe s:pA14c.'square <plug>\square ' +exe s:pA14c.'blacksquare <plug>\blacksquare ' +exe s:pA14c.'complement <plug>\complement ' +exe s:pA14c.'mho <plug>\mho ' +exe s:pA14c.'Game <plug>\Game ' +exe s:pA14c.'partial<Tab>`6 <plug>\partial ' +exe s:pA14c.'smallint <plug>\smallint ' +" }}} +" {{{ Logic +let s:pA15 = s:pA."&Logic." +exe s:pA15.'lnot <plug>\lnot ' +exe s:pA15.'lor <plug>\lor ' +exe s:pA15.'land <plug>\land ' +" }}} +" {{{ Limits1 +let s:pA16 = s:pA."&Limits1." +exe s:pA16.'left <plug>\left' +exe s:pA16.'right <plug>\right' +exe s:pA16.'-sepbigl- :' +exe s:pA16.'bigl <plug>\bigl' +exe s:pA16.'Bigl <plug>\Bigl' +exe s:pA16.'biggl <plug>\biggl' +exe s:pA16.'Biggl <plug>\Biggl' +exe s:pA16.'-sepbigr- :' +exe s:pA16.'bigr <plug>\bigr' +exe s:pA16.'Bigr <plug>\Bigr' +exe s:pA16.'biggr <plug>\biggr' +exe s:pA16.'Biggr <plug>\Biggr' +exe s:pA16.'-sepbig- :' +exe s:pA16.'big <plug>\big' +exe s:pA16.'bigm <plug>\bigm' +exe s:pA16.'-sepfloor- :' +exe s:pA16.'lfloor <plug>\lfloor ' +exe s:pA16.'lceil <plug>\lceil ' +exe s:pA16.'rfloor <plug>\rfloor ' +exe s:pA16.'rceil <plug>\rceil ' +exe s:pA16.'-sepangle- :' +exe s:pA16.'langle <plug>\langle ' +exe s:pA16.'rangle <plug>\rangle ' +" }}} +" {{{ Limits2 +let s:pA16a = s:pA."&Limits2." +exe s:pA16a.'ulcorner <plug>\ulcorner ' +exe s:pA16a.'urcorner <plug>\urcorner ' +exe s:pA16a.'llcorner <plug>\llcorner ' +exe s:pA16a.'rlcorner <plug>\rlcorner ' +exe s:pA16a.'-sepcorner- :' +exe s:pA16a.'vert <plug>\vert ' +exe s:pA16a.'Vert <plug>\Vert ' +exe s:pA16a.'lvert <plug>\lvert ' +exe s:pA16a.'lVert <plug>\lVert ' +exe s:pA16a.'rvert <plug>\rvert ' +exe s:pA16a.'rVert <plug>\rVert ' +exe s:pA16a.'uparrow <plug>\uparrow ' +exe s:pA16a.'Uparrow <plug>\Uparrow ' +exe s:pA16a.'downarrow <plug>\downarrow ' +exe s:pA16a.'Downarrow <plug>\Downarrow ' +exe s:pA16a.'updownarrow <plug>\updownarrow ' +exe s:pA16a.'Updownarrow <plug>\Updownarrow ' +exe s:pA16a.'lgroup <plug>\lgroup ' +exe s:pA16a.'rgroup <plug>\rgroup ' +exe s:pA16a.'lmoustache <plug>\lmoustache ' +exe s:pA16a.'rmoustache <plug>\rmoustache ' +exe s:pA16a.'arrowvert <plug>\arrowvert ' +exe s:pA16a.'Arrowvert <plug>\Arrowvert ' +exe s:pA16a.'bracevert <plug>\bracevert ' +" }}} +" {{{ Log-likes +let s:pA17 = s:pA."Lo&g-likes." +exe s:pA17.'arccos <plug>\arccos ' +exe s:pA17.'arcsin <plug>\arcsin ' +exe s:pA17.'arctan <plug>\arctan ' +exe s:pA17.'arg <plug>\arg ' +exe s:pA17.'cos <plug>\cos ' +exe s:pA17.'cosh <plug>\cosh ' +exe s:pA17.'cot <plug>\cot ' +exe s:pA17.'coth <plug>\coth ' +exe s:pA17.'csc <plug>\csc ' +exe s:pA17.'deg <plug>\deg ' +exe s:pA17.'det <plug>\det ' +exe s:pA17.'dim <plug>\dim ' +exe s:pA17.'exp <plug>\exp ' +exe s:pA17.'gcd <plug>\gcd ' +exe s:pA17.'hom <plug>\hom ' +exe s:pA17.'inf <plug>\inf ' +exe s:pA17.'injlim <plug>\injlim ' +exe s:pA17.'ker <plug>\ker ' +exe s:pA17.'lg <plug>\lg ' +exe s:pA17.'lim <plug>\lim ' +exe s:pA17.'liminf <plug>\liminf ' +exe s:pA17.'limsup <plug>\limsup ' +exe s:pA17.'ln <plug>\ln ' +exe s:pA17.'log <plug>\log ' +exe s:pA17.'max <plug>\max ' +exe s:pA17.'min <plug>\min ' +exe s:pA17.'Pr <plug>\Pr ' +exe s:pA17.'projlim <plug>\projlim ' +exe s:pA17.'sec <plug>\sec ' +exe s:pA17.'sin <plug>\sin ' +exe s:pA17.'sinh <plug>\sinh ' +exe s:pA17.'sup <plug>\sup ' +exe s:pA17.'tan <plug>\tan ' +exe s:pA17.'tanh <plug>\tanh ' +exe s:pA17.'varlimsup <plug>\varlimsup ' +exe s:pA17.'varliminf <plug>\varliminf ' +exe s:pA17.'varinjlim <plug>\varinjlim ' +exe s:pA17.'varprojlim <plug>\varprojlim ' +" }}} +" {{{ MathSpacing +let s:pA18 = s:pA."MathSpacing." +exe s:pA18.', <plug>\, ' +exe s:pA18.': <plug>\: ' +exe s:pA18.'; <plug>\; ' +exe s:pA18.'[space] <plug>\ ' +exe s:pA18.'quad <plug>\quad ' +exe s:pA18.'qquad <plug>\qquad ' +exe s:pA18.'! <plug>\! ' +exe s:pA18.'thinspace <plug>\thinspace ' +exe s:pA18.'medspace <plug>\medspace ' +exe s:pA18.'thickspace <plug>\thickspace ' +exe s:pA18.'negthinspace <plug>\negthinspace ' +exe s:pA18.'negmedspace <plug>\negmedspace ' +exe s:pA18.'negthickspace <plug>\negthickspace ' +" 1}}} + +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4 diff --git a/ftplugin/latex-suite/multicompile.vim b/ftplugin/latex-suite/multicompile.vim new file mode 100644 index 00000000..2e747623 --- /dev/null +++ b/ftplugin/latex-suite/multicompile.vim @@ -0,0 +1,16 @@ +" ============================================================================ +" File: multicompile.vim +" Author: Srinath Avadhanula +" Created: Sat Jul 05 03:00 PM 2003 +" Description: compile a .tex file multiple times to get cross references +" right. +" License: Vim Charityware License +" Part of vim-latexSuite: http://vim-latex.sourceforge.net +" ============================================================================ + +" The contents of this file have been moved to compiler.vim, the file which +" contains all functions relevant to compiling and viewing. +" This file is kept empty on purpose so that it will over-write previous +" versions of multicompile.vim, therby preventing conflicts. + +" vim:fdm=marker:nowrap:noet:ff=unix:ts=4:sw=4 diff --git a/ftplugin/latex-suite/packages.vim b/ftplugin/latex-suite/packages.vim new file mode 100644 index 00000000..49b4e489 --- /dev/null +++ b/ftplugin/latex-suite/packages.vim @@ -0,0 +1,676 @@ +"============================================================================= +" File: packages.vim +" Author: Mikolaj Machowski +" Created: Tue Apr 23 06:00 PM 2002 PST +" +" Description: handling packages from within vim +"============================================================================= + +" avoid reinclusion. +if !g:Tex_PackagesMenu || exists('s:doneOnce') + finish +endif +let s:doneOnce = 1 + +let s:path = fnameescape(expand("<sfile>:p:h")) + +let s:menu_div = 20 + +com! -nargs=0 TPackageUpdate :silent! call Tex_pack_updateall(1) +com! -nargs=0 TPackageUpdateAll :silent! call Tex_pack_updateall(1) + +" Custom command-line completion of Tcommands is very useful but this feature +" is available only in Vim 6.2 and above. Check number of version and choose +" proper command and function. +if v:version >= 602 + com! -complete=custom,Tex_CompletePackageName -nargs=* TPackage let s:retVal = Tex_pack_one(<f-args>) <bar> normal! i<C-r>=s:retVal<CR> + + " Tex_CompletePackageName: for completing names in TPackage command {{{ + " Description: get list of package names with globpath(), remove full path + " and return list of names separated with newlines. + " + function! Tex_CompletePackageName(A,P,L) + " Get name of packages from all runtimepath directories + let packnames = Tex_FindInRtp('', 'packages') + let packnames = substitute(packnames, '^,', '', 'e') + " Separate names with \n not , + let packnames = substitute(packnames,',','\n','g') + return packnames + endfunction + " }}} + +else + com! -nargs=* TPackage let s:retVal = Tex_pack_one(<f-args>) <bar> normal! i<C-r>=s:retVal<CR> + +endif + +imap <silent> <plug> <Nop> +nmap <silent> <plug> i + +let g:Tex_package_supported = '' +let g:Tex_package_detected = '' +" Remember the defaults because we want g:Tex_PromptedEnvironments to contain +" in addition to the default, \newenvironments, and the \newenvironments might +" change... +let g:Tex_PromptedEnvironmentsDefault = g:Tex_PromptedEnvironments +let g:Tex_PromptedCommandsDefault = g:Tex_PromptedCommands + + +" Tex_pack_check: creates the package menu and adds to 'dict' setting. {{{ +" +function! Tex_pack_check(package) + " Use Tex_FindInRtp() function to get first name from packages list in all + " rtp directories conforming with latex-suite directories hierarchy + " Store names in variables to process functions only once. + let packname = Tex_FindInRtp(a:package, 'packages') + if packname != '' + exe 'runtime! ftplugin/latex-suite/packages/' . a:package + if has("gui_running") + call Tex_pack(a:package) + endif + if g:Tex_package_supported !~ a:package + let g:Tex_package_supported = g:Tex_package_supported.','.a:package + endif + endif + " Return full list of dictionaries (separated with ,) for package in &rtp + call Tex_Debug("Tex_pack_check: searching for ".a:package." in dictionaries/ in &rtp", "pack") + let dictname = Tex_FindInRtp(a:package, 'dictionaries', ':p') + if dictname != '' + exe 'setlocal dict^=' . dictname + call Tex_Debug('Tex_pack_check: setlocal dict^=' . dictname, 'pack') + if g:Tex_package_supported !~ a:package + let g:Tex_package_supported = g:Tex_package_supported.','.a:package + endif + endif + if g:Tex_package_detected !~ '\<'.a:package.'\>' + let g:Tex_package_detected = g:Tex_package_detected.','.a:package + endif + let g:Tex_package_detected = substitute(g:Tex_package_detected, '^,', '', '') + let g:Tex_package_supported = substitute(g:Tex_package_supported, '^,', '', '') +endfunction + +" }}} +" Tex_pack_uncheck: removes package from menu and 'dict' settings. {{{ +function! Tex_pack_uncheck(package) + if has("gui_running") && Tex_FindInRtp(a:package, 'packages') != '' + exe 'silent! aunmenu '.g:Tex_PackagesMenuLocation.'-sep'.a:package.'-' + exe 'silent! aunmenu '.g:Tex_PackagesMenuLocation.a:package.'\ Options' + exe 'silent! aunmenu '.g:Tex_PackagesMenuLocation.a:package.'\ Commands' + endif + if Tex_FindInRtp(a:package, 'dictionaries') != '' + exe 'setlocal dict-='.Tex_FindInRtp(a:package, 'dictionaries') + endif +endfunction + +" }}} +" Tex_pack_updateall: updates the TeX-Packages menu {{{ +" Description: +" This function first calls Tex_pack_all to scan for \usepackage's etc if +" necessary. After that, it 'supports' and 'unsupports' packages as needed +" in such a way as to not repeat work. +function! Tex_pack_updateall(force) + call Tex_Debug('+Tex_pack_updateall', 'pack') + + " Find out which file we need to scan. + let fname = Tex_GetMainFileName(':p') + + " If this is the same as last time, don't repeat. + if !a:force && exists('s:lastScannedFile') && + \ s:lastScannedFile == fname + return + endif + " Remember which file we scanned for next time. + let s:lastScannedFile = fname + + " Remember which packages we detected last time. + if exists('g:Tex_package_detected') + let oldpackages = g:Tex_package_detected + else + let oldpackages = '' + endif + + " This sets up a global variable of all detected packages. + let g:Tex_package_detected = '' + " reset the environments and commands. + let g:Tex_PromptedEnvironments = g:Tex_PromptedEnvironmentsDefault + let g:Tex_PromptedCommands = g:Tex_PromptedCommandsDefault + + if expand('%:p') != fname + call Tex_Debug(':Tex_pack_updateall: sview '.Tex_EscapeSpaces(fname), 'pack') + exe 'sview '.Tex_EscapeSpaces(fname) + else + call Tex_Debug(':Tex_pack_updateall: split', 'pack') + split + endif + + call Tex_ScanForPackages() + q + + call Tex_Debug(':Tex_pack_updateall: detected ['.g:Tex_package_detected.'] in first run', 'pack') + + " Now for each package find out if this is a custom package and if so, + " scan that as well. We will use the ':find' command in vim to let vim + " search through the file paths for us. + " + " NOTE: This while loop will also take into account packages included + " within packages to any level of recursion as long as + " g:Tex_package_detected is always padded with new package names + " from the end. + " + " First set the &path setting to the user's TEXINPUTS setting. + let _path = &path + let _suffixesadd = &suffixesadd + + let &path = '.,'.g:Tex_TEXINPUTS + let &suffixesadd = '.sty,.tex' + + let scannedPackages = '' + + let i = 1 + let packname = Tex_Strntok(g:Tex_package_detected, ',', i) + while packname != '' + + call Tex_Debug(':Tex_pack_updateall: scanning package '.packname, 'pack') + + " Scan this package only if we have not scanned it before in this + " run. + if scannedPackages =~ '\<'.packname.'\>' + let i = i + 1 + + call Tex_Debug(':Tex_pack_updateall: '.packname.' already scanned', 'pack') + let packname = Tex_Strntok(g:Tex_package_detected, ',', i) + continue + endif + + " Split this window in two. The packages/files being found will open + " in this new window and we also need not bother with files being + " modified etc. + split + + call Tex_Debug(':Tex_pack_updateall: silent! find '.Tex_EscapeSpaces(packname).'.sty', 'pack') + let thisbufnum = bufnr('%') + exec 'silent! find '.Tex_EscapeSpaces(packname).'.sty' + call Tex_Debug(':Tex_pack_updateall: present file = '.bufname('%'), 'pack') + + " If this file was not found, assume that it means its not a + " custom package and mark it "scanned". + " A package is not found if we stay in the same buffer as before and + " its not the one where we want to go. + if bufnr('%') == thisbufnum && bufnr('%') != bufnr(packname.'.sty') + let scannedPackages = scannedPackages.','.packname + q + + call Tex_Debug(':Tex_pack_updateall: '.packname.' not found anywhere', 'pack') + let i = i + 1 + let packname = Tex_Strntok(g:Tex_package_detected, ',', i) + continue + endif + + " otherwise we are presently editing a custom package, scan it for + " more \usepackage lines from the first line to the last. + let packpath = expand('%:p') + let &complete = &complete.'s'.packpath + + call Tex_Debug(':Tex_pack_updateall: found custom package '.packpath, 'pack') + call Tex_ScanForPackages(line('$'), line('$')) + call Tex_Debug(':Tex_pack_updateall: After scanning, g:Tex_package_detected = '.g:Tex_package_detected, 'pack') + + let scannedPackages = scannedPackages.','.packname + " Do not use bwipe, but that leads to excessive buffer number + " consumption. Besides, its intuitive for a custom package to remain + " on the buffer list. + q + + let i = i + 1 + let packname = Tex_Strntok(g:Tex_package_detected, ',', i) + endwhile + + let &path = _path + let &suffixesadd = _suffixesadd + + " Now only support packages we didn't last time. + " First remove packages which were used last time but are no longer used. + let i = 1 + let oldPackName = Tex_Strntok(oldpackages, ',', i) + while oldPackName != '' + if g:Tex_package_detected !~ oldPackName + call Tex_pack_uncheck(oldPackName) + endif + let i = i + 1 + let oldPackName = Tex_Strntok(oldpackages, ',', i) + endwhile + + " Then support packages which are used this time but weren't used last + " time. + let i = 1 + let newPackName = Tex_Strntok(g:Tex_package_detected, ',', i) + while newPackName != '' + if oldpackages !~ newPackName + call Tex_pack_one(newPackName) + endif + let i = i + 1 + let newPackName = Tex_Strntok(g:Tex_package_detected, ',', i) + endwhile + + " Throw an event that we are done scanning packages. Some packages might + " use this to change behavior based on which options have been used etc. + call Tex_Debug(":Tex_pack_updateall: throwing LatexSuiteScannedPackages event", "pack") + silent! do LatexSuite User LatexSuiteScannedPackages + + call Tex_Debug("-Tex_pack_updateall", "pack") +endfunction + +" }}} +" Tex_pack_one: supports each package in the argument list.{{{ +" Description: +" If no arguments are supplied, then the user is asked to choose from the +" packages found in the packages/ directory +function! Tex_pack_one(...) + if a:0 == 0 || (a:0 > 0 && a:1 == '') + let packlist = Tex_FindInRtp('', 'packages') + let packname = Tex_ChooseFromPrompt( + \ "Choose a package: \n" . + \ Tex_CreatePrompt(packlist, '3', ',') . + \ "\nEnter number or filename :", + \ packlist, ',') + if packname != '' + return Tex_pack_one(packname) + else + return '' + endif + else + " Support the packages supplied. This function can be called with + " multiple arguments in which case, support each of them in turn. + let retVal = '' + let omega = 1 + while omega <= a:0 + let packname = a:{omega} + if Tex_FindInRtp(packname, 'packages') != '' + call Tex_pack_check(packname) + if exists('g:TeX_package_option_'.packname) + \ && g:TeX_package_option_{packname} != '' + let retVal = retVal.'\usepackage[<++>]{'.packname.'}<++>' + else + let retVal = retVal.'\usepackage{'.packname.'}'."\<CR>" + endif + else + let retVal = retVal.'\usepackage{'.packname.'}'."\<CR>" + endif + let omega = omega + 1 + endwhile + return IMAP_PutTextWithMovement(substitute(retVal, "\<CR>$", '', ''), '<+', '+>') + endif +endfunction +" }}} +" Tex_ScanForPackages: scans the current file for \usepackage{} lines {{{ +" and if supported, loads the options and commands found in the +" corresponding package file. Also scans for \newenvironment and +" \newcommand lines and adds names to g:Tex_Prompted variables, they can be +" easy available through <F5> and <F7> shortcuts +function! Tex_ScanForPackages(...) + call Tex_Debug("+Tex_ScanForPackages", "pack") + + let pos = Tex_GetPos() + + " For package files without \begin and \end{document}, we might be told to + " search from beginning to end. + if a:0 < 2 + 0 + let beginline = search('\\begin{document}', 'W') + let endline = search('\\end{document}', 'W') + 0 + else + let beginline = a:1 + let endline = a:2 + endif + + call Tex_Debug(":Tex_ScanForPackages: Begining scans in [".bufname('%')."], beginline = ".beginline, "pack") + + + " Scan the file. First open up all the folds, because the command + " /somepattern + " issued in a closed fold _always_ goes to the first match. + let erm = v:errmsg + silent! normal! ggVGzO + let v:errmsg = erm + + call Tex_Debug(":Tex_ScanForPackages: beginning scan for \\usepackage lines", "pack") + " The wrap trick enables us to match \usepackage on the first line as + " well. + let wrap = 'w' + while search('^\s*\\usepackage\_.\{-}{\_.\+}', wrap) + let wrap = 'W' + + if line('.') > beginline + break + endif + + let saveUnnamed = @" + let saveA = @a + + " If there are options, then find those. + if getline('.') =~ '\\usepackage\[.\{-}\]' + let options = matchstr(getline('.'), '\\usepackage\[\zs.\{-}\ze\]') + elseif getline('.') =~ '\\usepackage\[' + " Entering here means that the user has split the \usepackage + " across newlines. Therefore, use yank. + exec "normal! /{\<CR>\"ayi}" + let options = @a + else + let options = '' + endif + + " The following statement puts the stuff between the { }'s of a + " \usepackage{stuff,foo} into @a. Do not use matchstr() and the like + " because we can have things split across lines and such. + exec "normal! /{\<CR>\"ay/}\<CR>" + + " now remove all whitespace from @a. We need to remove \n and \r + " because we can encounter stuff like + " \usepackage{pack1, + " newpackonanotherline} + let @a = substitute(@a, "[ \t\n\r]", '', 'g') + + " Now we have something like pack1,pack2,pack3 with possibly commas + " and stuff before the first package and after the last package name. + " Remove those. + let @a = substitute(@a, '\(^\W*\|\W*$\)', '', 'g') + + " This gets us a string like 'pack1,pack2,pack3' + " TODO: This will contain duplicates if the user has duplicates. + " Should we bother taking care of this? + let g:Tex_package_detected = g:Tex_package_detected.','.@a + + " For each package found, form a global variable of the form + " g:Tex_{packagename}_options + " which contains a list of the options. + let j = 1 + while Tex_Strntok(@a, ',', j) != '' + let g:Tex_{Tex_Strntok(@a, ',', j)}_options = options + let j = j + 1 + endwhile + + " Finally convert @a into something like '"pack1","pack2"' + let @a = substitute(@a, '^\|$', '"', 'g') + let @a = substitute(@a, ',', '","', 'g') + + call Tex_Debug(":Tex_ScanForPackages: found package(s) [".@a."] on line ".line('.'), "pack") + + " restore @a + let @a = saveA + let @" = saveUnnamed + endwhile + call Tex_Debug(":Tex_ScanForPackages: End scan \\usepackage, detected packages = ".g:Tex_package_detected, "pack") + + " TODO: This needs to be changed. In the future, we might have + " functionality to remember the fold-state before opening up all the folds + " and then re-creating them. Use mkview.vim. + let erm = v:errmsg + silent! normal! ggVGzC + let v:errmsg = erm + + " Because creating list of detected packages gives string + " ',pack1,pack2,pack3' remove leading , + let g:Tex_package_detected = substitute(g:Tex_package_detected, '^,', '', '') + + call Tex_Debug(":Tex_ScanForPackages: Beginning scan for \\newcommand's", "pack") + " Scans whole file (up to \end{document}) for \newcommand and adds this + " commands to g:Tex_PromptedCommands variable, it is easily available + " through <F7> + 0 + while search('^\s*\\newcommand\*\?{.\{-}}', 'W') + + if line('.') > endline + break + endif + + let newcommand = matchstr(getline('.'), '\\newcommand\*\?{\\\zs.\{-}\ze}') + let g:Tex_PromptedCommands = g:Tex_PromptedCommands . ',' . newcommand + + endwhile + + " Scans whole file (up to \end{document}) for \newenvironment and adds this + " environments to g:Tex_PromptedEnvironments variable, it is easily available + " through <F5> + 0 + call Tex_Debug(":Tex_ScanForPackages: Beginning scan for \\newenvironment's", 'pack') + + while search('^\s*\\newenvironment\*\?{.\{-}}', 'W') + call Tex_Debug('found newenvironment on '.line('.'), 'pack') + + if line('.') > endline + break + endif + + let newenvironment = matchstr(getline('.'), '\\newenvironment\*\?{\zs.\{-}\ze}') + let g:Tex_PromptedEnvironments = g:Tex_PromptedEnvironments . ',' . newenvironment + + endwhile + + call Tex_SetPos(pos) + " first make a random search so that we push at least one item onto the + " search history. Since vim puts only one item in the history per function + " call, this way we make sure that one and only item is put into the + " search history. + normal! /^<CR> + " now delete it... + call histdel('/', -1) + + call Tex_Debug("-Tex_ScanForPackages", "pack") +endfunction + +" }}} +" Tex_pack_supp_menu: sets up a menu for package files {{{ +" found in the packages directory groups the packages thus found into groups +" of 20... +function! Tex_pack_supp_menu() + let suplist = Tex_FindInRtp('', 'packages') + + call Tex_MakeSubmenu(suplist, g:Tex_PackagesMenuLocation.'Supported.', + \ '<plug><C-r>=Tex_pack_one("', '")<CR>') +endfunction + +" }}} +" Tex_pack: loads the options (and commands) for the given package {{{ +function! Tex_pack(pack) + if exists('g:TeX_package_'.a:pack) + + let optionList = g:TeX_package_option_{a:pack}.',' + let commandList = g:TeX_package_{a:pack}.',' + + " Don't create separator if in package file are only Vim commands. + " Rare but possible. + if !(commandList == ',' && optionList == ',') + exec 'amenu '.g:Tex_PackagesMenuLocation.'-sep'.a:pack.'- <Nop>' + endif + + if optionList != '' + + let mainMenuName = g:Tex_PackagesMenuLocation.a:pack.'\ Options.' + call s:GroupPackageMenuItems(optionList, mainMenuName, + \ '<plug><C-r>=IMAP_PutTextWithMovement("', ',")<CR>') + + endif + + if commandList != '' + + let mainMenuName = g:Tex_PackagesMenuLocation.a:pack.'\ Commands.' + call s:GroupPackageMenuItems(commandList, mainMenuName, + \ '<plug><C-r>=Tex_ProcessPackageCommand("', '")<CR>', + \ '<SID>FilterPackageMenuLHS') + endif + endif +endfunction + +" }}} + +" ============================================================================== +" Menu Functions +" Creating menu items for the all the package files found in the packages/ +" directory as well as creating menus for each supported package found in the +" preamble. +" ============================================================================== +" Tex_MakeSubmenu: makes a submenu given a list of items {{{ +" Description: +" This function takes a comma seperated list of menu items and creates a +" 'grouped' menu. i.e, it groups the items into s:menu_div items each and +" puts them in submenus of the given mainMenu. +" Each menu item is linked to the HandlerFunc. +" If an additional argument is supplied, then it is used to filter each of +" the menu items to generate better names for the menu display. +" +function! Tex_MakeSubmenu(menuList, mainMenuName, + \ handlerFuncLHS, handlerFuncRHS, ...) + + let extractFunction = (a:0 > 0 ? a:1 : '' ) + let menuList = substitute(a:menuList, '[^,]$', ',', '') + + let doneMenuSubmenu = 0 + + while menuList != '' + + " Extract upto s:menu_div menus at once. + let menuBunch = matchstr(menuList, '\v(.{-},){,'.s:menu_div.'}') + + " The remaining menus go into the list. + let menuList = strpart(menuList, strlen(menuBunch)) + + let submenu = '' + " If there is something remaining, then we got s:menu_div items. + " therefore put these menu items into a submenu. + if strlen(menuList) || doneMenuSubmenu + exec 'let firstMenu = '.extractFunction."(matchstr(menuBunch, '\\v^.{-}\\ze,'))" + exec 'let lastMenu = '.extractFunction."(matchstr(menuBunch, '\\v[^,]{-}\\ze,$'))" + + let submenu = firstMenu.'\ \-\ '.lastMenu.'.' + + let doneMenuSubmenu = 1 + endif + + " Now for each menu create a menu under the submenu + let i = 1 + let menuName = Tex_Strntok(menuBunch, ',', i) + while menuName != '' + exec 'let menuItem = '.extractFunction.'(menuName)' + execute 'amenu '.a:mainMenuName.submenu.menuItem + \ ' '.a:handlerFuncLHS.menuName.a:handlerFuncRHS + + let i = i + 1 + let menuName = Tex_Strntok(menuBunch, ',', i) + endwhile + endwhile +endfunction + +" }}} +" GroupPackageMenuItems: uses the sbr: to split menus into groups {{{ +" Description: +" This function first splits up the menuList into groups based on the +" special sbr: tag and then calls Tex_MakeSubmenu +" +function! <SID>GroupPackageMenuItems(menuList, menuName, + \ handlerFuncLHS, handlerFuncRHS,...) + + if a:0 > 0 + let extractFunction = a:1 + else + let extractFunction = '' + endif + let menuList = a:menuList + + while matchstr(menuList, 'sbr:') != '' + let groupName = matchstr(menuList, '\v^sbr:\zs.{-}\ze,') + let menuList = strpart(menuList, strlen('sbr:'.groupName.',')) + if matchstr(menuList, 'sbr:') != '' + let menuGroup = matchstr(menuList, '\v^.{-},\zesbr:') + else + let menuGroup = menuList + endif + + call Tex_MakeSubmenu(menuGroup, a:menuName.groupName.'.', + \ a:handlerFuncLHS, a:handlerFuncRHS, extractFunction) + + let menuList = strpart(menuList, strlen(menuGroup)) + endwhile + + call Tex_MakeSubmenu(menuList, a:menuName, + \ a:handlerFuncLHS, a:handlerFuncRHS, extractFunction) + +endfunction " }}} +" Definition of what to do for various package commands {{{ +let s:CommandSpec_brs = '\<+replace+><++>' +let s:CommandSpec_bra = '\<+replace+>{<++>}<++>' +let s:CommandSpec_brd = '\<+replace+>{<++>}{<++>}<++>' + +let s:CommandSpec_nor = '\<+replace+>' +let s:CommandSpec_noo = '\<+replace+>[<++>]' +let s:CommandSpec_nob = '\<+replace+>[<++>]{<++>}{<++>}<++>' + +let s:CommandSpec_env = '\begin{<+replace+>}'."\<CR><++>\<CR>".'\end{<+replace+>}<++>' +let s:CommandSpec_ens = '\begin{<+replace+>}<+extra+>'."\<CR><++>\<CR>".'\end{<+replace+>}<++>' +let s:CommandSpec_eno = '\begin[<++>]{<+replace+>}'."\<CR><++>\<CR>".'\end{<+replace+>}' + +let s:CommandSpec_spe = '<+replace+>' +let s:CommandSpec_ = '\<+replace+>' + +let s:MenuLHS_bra = '\\&<+replace+>{}' +let s:MenuLHS_brs = '\\&<+replace+>{}' +let s:MenuLHS_brd = '\\&<+replace+>{}{}' +let s:MenuLHS_env = '&<+replace+>\ (E)' +let s:MenuLHS_ens = '&<+replace+>\ (E)' +let s:MenuLHS_eno = '&<+replace+>\ (E)' +let s:MenuLHS_nor = '\\&<+replace+>' +let s:MenuLHS_noo = '\\&<+replace+>[]' +let s:MenuLHS_nob = '\\&<+replace+>[]{}{}' +let s:MenuLHS_spe = '&<+replace+>' +let s:MenuLHS_sep = '-sep<+replace+>-' +let s:MenuLHS_ = '\\&<+replace+>' +" }}} +" Tex_ProcessPackageCommand: processes a command from the package menu {{{ +" Description: +function! Tex_ProcessPackageCommand(command) + if a:command =~ ':' + let commandType = matchstr(a:command, '^\w\+\ze:') + let commandName = matchstr(a:command, '^\w\+:\zs[^:]\+\ze:\?') + let extrapart = strpart(a:command, strlen(commandType.':'.commandName.':')) + else + let commandType = '' + let commandName = a:command + let extrapart = '' + endif + + let command = s:CommandSpec_{commandType} + let command = substitute(command, '<+replace+>', commandName, 'g') + let command = substitute(command, '<+extra+>', extrapart, 'g') + return IMAP_PutTextWithMovement(command) +endfunction +" }}} +" FilterPackageMenuLHS: filters the command description to provide a better menu item {{{ +" Description: +function! <SID>FilterPackageMenuLHS(command) + let commandType = matchstr(a:command, '^\w\+\ze:') + if commandType != '' + let commandName = strpart(a:command, strlen(commandType.':')) + else + let commandName = a:command + endif + + return substitute(s:MenuLHS_{commandType}, '<+replace+>', commandName, 'g') +endfunction " }}} + +if g:Tex_Menus + exe 'amenu '.g:Tex_PackagesMenuLocation.'&UpdatePackage :call Tex_pack(expand("<cword>"))<cr>' + exe 'amenu '.g:Tex_PackagesMenuLocation.'&UpdateAll :call Tex_pack_updateall(1)<cr>' + + call Tex_pack_supp_menu() +endif + +augroup LatexSuite + au LatexSuite User LatexSuiteFileType + \ call Tex_Debug('packages.vim: Catching LatexSuiteFileType event', 'pack') | + \ let s:save_clipboard = &clipboard | + \ set clipboard= | + \ call Tex_pack_updateall(0) | + \ let &clipboard=s:save_clipboard +augroup END + +" vim:fdm=marker:ts=4:sw=4:noet:ff=unix diff --git a/ftplugin/latex-suite/projecttemplate.vim b/ftplugin/latex-suite/projecttemplate.vim new file mode 100644 index 00000000..1ab4be02 --- /dev/null +++ b/ftplugin/latex-suite/projecttemplate.vim @@ -0,0 +1,11 @@ +" Project name +" let g:projName = '' +" +" Project files +" let g:projFiles = '' + + +" Vim settings/maps/abbrs specific for this project + +" Modeline for this file +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4:ft=vim diff --git a/ftplugin/latex-suite/smartspace.vim b/ftplugin/latex-suite/smartspace.vim new file mode 100644 index 00000000..07526d8d --- /dev/null +++ b/ftplugin/latex-suite/smartspace.vim @@ -0,0 +1,102 @@ +"============================================================================= +" File: smartspace.vim +" Author: Carl Muller +" Created: Fri Dec 06 12:00 AM 2002 PST +" +" Description: +" Maps the <space> key in insert mode so that mathematical formulaes are +" always kept on the same line. i.e, $$'s dont get broken across multiple +" lines. +"============================================================================= + +" Avoid reinclusion or if the user doesn't want us. +if exists('b:done_smartspace') + \ || (exists('g:Tex_SmartKeySpace') && !g:Tex_SmartKeySpace) + finish +endif +let b:done_smartspace = 1 + +" Smart space relies on taking over vim's insertion of carriage returns in +" order to keep $$'s on the same line. The only way to get vim not to break +" lines is to set tw=0. +" +" NOTE: setting tw != 0 will break smartspace +" the user's 'tw' setting is still respected in the insert mode. +" However, normal mode actions which rely on 'tw' such as gqap will be +" broken because of the faulty 'tw' setting. +let b:tw = &l:tw +setlocal tw=0 + +inoremap <buffer> <silent> <Space> <Space><Esc>:call <SID>TexFill(b:tw)<CR>a + +" Do not redefine the function. +if exists('*s:TexFill') + finish +endif + +" TexFormatLine: format line retaining $$'s on the same line. {{{ +function! s:TexFill(width) + if a:width != 0 && col(".") > a:width + " For future use, record the current line and the number of the current column + let current_line = getline(".") + let current_column = col(".") + exe "normal! a##\<Esc>" + call <SID>TexFormatLine(a:width,current_line,current_column) + exe "normal! ?##\<CR>2s\<Esc>" + " Remove ## from the search history. + call histdel("/", -1)|let @/=histget("/", -1) + endif +endfunction + +" }}} +function! s:TexFormatLine(width, current_line, current_column) " {{{ + " get the first non-blank character. + let first = matchstr(getline('.'), '\S') + normal! $ + let length = col('.') + let go = 1 + while length > a:width+2 && go + let between = 0 + let string = strpart(getline('.'), 0, a:width) + " Count the dollar signs + let number_of_dollars = 0 + let evendollars = 1 + let counter = 0 + while counter <= a:width-1 + " Pay attention to '$$'. + if string[counter] == '$' && string[counter-1] != '$' + let evendollars = 1 - evendollars + let number_of_dollars = number_of_dollars + 1 + endif + let counter = counter + 1 + endwhile + " Get ready to split the line. + exe 'normal! ' . (a:width + 1) . '|' + if evendollars + " Then you are not between dollars. + exe "normal! ?\\$\\+\\| \<CR>W" + else + " Then you are between dollars. + normal! F$ + if col(".") == 1 || getline('.')[col(".")-1] != "$" + let go = 0 + endif + endif + if first == '$' && number_of_dollars == 1 + let go = 0 + else + exe "normal! i\<CR>\<Esc>$" + " get the first non-blank character. + let first = matchstr(getline('.'), '\S') + endif + let length = col(".") + endwhile + if go == 0 && strpart(a:current_line, 0, a:current_column) =~ '.*\$.*\$.*' + exe "normal! ^f$a\<CR>\<Esc>" + call <SID>TexFormatLine(a:width, a:current_line, a:current_column) + endif +endfunction + +" }}} + +" vim:fdm=marker:ts=4:sw=4:noet diff --git a/ftplugin/latex-suite/templates.vim b/ftplugin/latex-suite/templates.vim new file mode 100644 index 00000000..ad1bbecd --- /dev/null +++ b/ftplugin/latex-suite/templates.vim @@ -0,0 +1,148 @@ +"============================================================================= +" File: templates.vim +" Author: Gergely Kontra +" (minor modifications by Srinath Avadhanula) +" (plus other modifications by Mikolaj Machowski) +" Version: 1.0 +" Created: Tue Apr 23 05:00 PM 2002 PST +" +" Description: functions for handling templates in latex-suite/templates +" directory. +"============================================================================= + +let s:path = fnameescape(expand("<sfile>:p:h")) + +" SetTemplateMenu: sets up the menu for templates {{{ +function! <SID>SetTemplateMenu() + let flist = Tex_FindInRtp('', 'templates') + let i = 1 + while 1 + let fname = Tex_Strntok(flist, ',', i) + if fname == '' + break + endif + exe "amenu ".g:Tex_TemplatesMenuLocation."&".i.":<Tab>".fname." ". + \":call <SID>ReadTemplate('".fname."')<CR>" + let i = i + 1 + endwhile +endfunction + +if g:Tex_Menus + call <SID>SetTemplateMenu() +endif + +" }}} +" ReadTemplate: reads in the template file from the template directory. {{{ +function! <SID>ReadTemplate(...) + if a:0 > 0 + let filename = a:1 + else + let filelist = Tex_FindInRtp('', 'templates') + let filename = + \ Tex_ChooseFromPrompt("Choose a template file:\n" . + \ Tex_CreatePrompt(filelist, 2, ',') . + \ "\nEnter number or name of file :", + \ filelist, ',') + endif + + let fname = Tex_FindInRtp(filename.'.tex', 'templates', ':p') + call Tex_Debug("0read ".fname, 'templates') + + silent! exe "0read ".fname + + " The first line of the file contains the specifications of what the + " placeholder characters and the other special characters are. + let pattern = '\v(\S+)\t(\S+)\t(\S+)\t(\S+)' + + let s:phsTemp = substitute(getline(1), pattern, '\1', '') + let s:pheTemp = substitute(getline(1), pattern, '\2', '') + let s:exeTemp = substitute(getline(1), pattern, '\3', '') + let s:comTemp = substitute(getline(1), pattern, '\4', '') + + 0 d_ + + call s:ProcessTemplate() + call Tex_pack_updateall(1) + + " Do not handle the placeholders here. Let IMAP_PutTextWithMovement do it + " because it handles UTF-8 character substitutions etc. Therefore delete + " the text into @a and paste it using IMAP_PutTextWithMovement(). + let _a = @a + normal! ggVG"ax + + let _fo = &fo + " Since IMAP_PutTextWithMovement simulates the key-presses, leading + " indendatation can get duplicated in strange ways if ``fo`` is non-empty. + " NOTE: the indentexpr thingie is still respected with an empty fo so that + " environments etc are properly indented. + set fo= + + call Tex_Debug("normal! i\<C-r>=IMAP_PutTextWithMovement(@a, '".s:phsTemp."', '".s:pheTemp."')\<CR>", 'templates') + exec "normal! i\<C-r>=IMAP_PutTextWithMovement(@a, '".s:phsTemp."', '".s:pheTemp."')\<CR>" + + let &fo = _fo + let @a = _a + + call Tex_Debug('phs = '.s:phsTemp.', phe = '.s:pheTemp.', exe = '.s:exeTemp.', com = '.s:comTemp, 'templates') + +endfunction + +" }}} +" ProcessTemplate: processes the special characters in template file. {{{ +" This implementation follows from Gergely Kontra's +" mu-template.vim +" http://vim.sourceforge.net/scripts/script.php?script_id=222 +function! <SID>ProcessTemplate() + if exists('s:phsTemp') && s:phsTemp != '' + + exec 'silent! %s/^'.s:comTemp.'\(\_.\{-}\)'.s:comTemp.'$/\=<SID>Compute(submatch(1))/ge' + exec 'silent! %s/'.s:exeTemp.'\(.\{-}\)'.s:exeTemp.'/\=<SID>Exec(submatch(1))/ge' + exec 'silent! g/'.s:comTemp.s:comTemp.'/d' + + " A function only puts one item into the search history... + call Tex_CleanSearchHistory() + endif +endfunction + +function! <SID>Exec(what) + exec 'return '.a:what +endfunction + +" Back-Door to trojans !!! +function! <SID>Compute(what) + exe a:what + if exists('s:comTemp') + return s:comTemp.s:comTemp + else + return '' + endif +endfunction + +" }}} +" Command definitions {{{ +if v:version >= 602 + com! -complete=custom,Tex_CompleteTemplateName -nargs=? TTemplate :call <SID>ReadTemplate(<f-args>) + \| :startinsert + + " Tex_CompleteTemplateName: for completing names in TTemplate command {{{ + " Description: get list of template names with Tex_FindInRtp(), remove full path + " and return list of names separated with newlines. + " + function! Tex_CompleteTemplateName(A,P,L) + " Get name of macros from all runtimepath directories + let tmplnames = Tex_FindInRtp('', 'templates') + " Separate names with \n not , + let tmplnames = substitute(tmplnames,',','\n','g') + return tmplnames + endfunction + " }}} + +else + com! -nargs=? TTemplate :call <SID>ReadTemplate(<f-args>) + \| :startinsert + +endif + +" }}} + +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4 diff --git a/ftplugin/latex-suite/texmenuconf.vim b/ftplugin/latex-suite/texmenuconf.vim new file mode 100644 index 00000000..d2c42f3c --- /dev/null +++ b/ftplugin/latex-suite/texmenuconf.vim @@ -0,0 +1,130 @@ +"============================================================================= +" File: texmenuconf.vim +" Author: Srinath Avadhanula +" Copyright: Vim charityware license. :help license +" Description: +" +"============================================================================= + +" Paths, crucial for functions +let s:path = fnameescape(expand("<sfile>:p:h")) +let s:up_path = fnameescape(expand("<sfile>:p:h:h")) +let s:mainmenuname = g:Tex_MenuPrefix.'S&uite.' +let s:mapleader = exists('mapleader') ? mapleader : "\\" + +" This glboal variable is incremented each time a top-level latex-suite menu +" is created. We should always use this variable for setting the locations of +" newly created top-level menus. +let g:Tex_NextMenuLocation = g:Tex_MainMenuLocation + +" The templates and macros menus are always nested within the main latex-suit +" menu. +let g:Tex_TemplatesMenuLocation = g:Tex_MainMenuLocation.'.20 '.s:mainmenuname.'&Templates.' +let g:Tex_MacrosMenuLocation = g:Tex_MainMenuLocation.'.20 '.s:mainmenuname.'&Macros.' + +" The packages menu can either be a child of the main menu or be a top-level +" menu by itself. +if g:Tex_NestPackagesMenu + let g:Tex_PackagesMenuLocation = (g:Tex_MainMenuLocation).'.10 '.s:mainmenuname.'&Packages.' +else + let g:Tex_PackagesMenuLocation = (g:Tex_NextMenuLocation).'.10 '.g:Tex_MenuPrefix.'Packages.' + let g:Tex_NextMenuLocation = g:Tex_NextMenuLocation + 1 +endif + +" Environments are always a top-level menu. +let g:Tex_EnvMenuLocation = (g:Tex_NextMenuLocation).'.20 '.g:Tex_MenuPrefix.'E&nvironments.' +let g:Tex_NextMenuLocation = g:Tex_NextMenuLocation + 1 + +" Elements are always a top-level menu. +" If we choose to nest elements, then the top-level &TeX-Elements menu +" contains <Fonts / Counters / Dimensions> +" otherwise, the Fonts, Counters and Dimensions menus become top-level menus. +if g:Tex_NestElementMenus + let g:Tex_ElementsMenuLocation = (g:Tex_NextMenuLocation).'.20 '.g:Tex_MenuPrefix.'E&lements.' +else + let g:Tex_ElementsMenuLocation = (g:Tex_NextMenuLocation).'.20 '.g:Tex_MenuPrefix +endif +let g:Tex_NextMenuLocation = g:Tex_NextMenuLocation + 1 + + +" Set up the compiler/viewer menus. {{{ +" +if has('gui_running') && g:Tex_Menus + exec 'anoremenu '.g:Tex_MainMenuLocation.'.25 '. s:mainmenuname.'-sepsuite0- :' + + " menus for compiling / viewing etc. + exec 'anoremenu '.g:Tex_MainMenuLocation.'.30 '.s:mainmenuname.'&Compile<tab>'.s:mapleader.'ll'. + \' :silent! call Tex_RunLaTeX()<CR>' + exec 'anoremenu '.g:Tex_MainMenuLocation.'.40 '.s:mainmenuname.'&View<tab>'.s:mapleader.'lv'. + \' :silent! call Tex_ViewLaTeX()<CR>' + exec 'anoremenu '.g:Tex_MainMenuLocation.'.50 '.s:mainmenuname.'&Search<tab>'.s:mapleader.'ls'. + \' :silent! call ForwardSearchLaTeX()<CR>' + exec 'anoremenu '.g:Tex_MainMenuLocation.'.60 '.s:mainmenuname.'&Target\ Format<tab>:TTarget'. + \' :call SetTeXTarget()<CR>' + exec 'anoremenu '.g:Tex_MainMenuLocation.'.70 '.s:mainmenuname.'&Compiler\ Target<tab>:TCTarget'. + \' :call Tex_SetTeXCompilerTarget("Compile", "")<CR>' + exec 'anoremenu '.g:Tex_MainMenuLocation.'.80 '.s:mainmenuname.'&Viewer\ Target<tab>:TVTarget'. + \' :call Tex_SetTeXCompilerTarget("View", "")<CR>' + exec 'anoremenu '.g:Tex_MainMenuLocation.'.90 '.s:mainmenuname.'Set\ &Ignore\ Level<tab>:TCLevel'. + \' :TCLevel<CR>' + exec 'imenu '.g:Tex_MainMenuLocation.'.100 '.s:mainmenuname.'C&omplete\ Ref/Cite'. + \' <Plug>Tex_Completion' + exec 'anoremenu '.g:Tex_MainMenuLocation.'.110 '.s:mainmenuname.'-sepsuite1- :' + " refreshing folds + if g:Tex_Folding + exec 'anoremenu '.g:Tex_MainMenuLocation.'.120 '.s:mainmenuname.'&Refresh\ Folds<tab>'.s:mapleader.'rf'. + \' :call MakeTexFolds(1)<CR>' + exec 'anoremenu '.g:Tex_MainMenuLocation.'.130 '.s:mainmenuname.'-sepsuite2- :' + endif +endif + +" }}} + +" ============================================================================== +" MenuConf: configure the menus as compact/extended, with/without math +" ============================================================================== +function! Tex_MenuConfigure(type, action) " {{{ + let menuloc = s:mainmenuname.'Configure\ Menu.' + if a:type == 'math' + if a:action == 1 + let g:Tex_MathMenus = 1 + exe 'source '.s:path.'/mathmacros.vim' + exe 'amenu disable '.menuloc.'Add\ Math\ Menu' + exe 'amenu enable '.menuloc.'Remove\ Math\ Menu' + elseif a:action == 0 + call Tex_MathMenuRemove() + exe 'amenu enable '.menuloc.'Add\ Math\ Menu' + exe 'amenu disable '.menuloc.'Remove\ Math\ Menu' + endif + elseif a:type == 'elements' + if a:action == 'expand' + let g:Tex_ElementsMenuLocation = '80.20 '.g:Tex_MenuPrefix + exe 'amenu disable '.menuloc.'Expand\ Elements' + exe 'amenu enable '.menuloc.'Compress\ Elements' + elseif a:action == 'nest' + let g:Tex_ElementsMenuLocation = '80.20 '.g:Tex_MenuPrefix.'Elements.' + exe 'amenu enable '.menuloc.'Expand\ Elements' + exe 'amenu disable '.menuloc.'Compress\ Elements' + endif + exe 'source '.fnameescape(s:path.'/elementmacros.vim') + elseif a:type == 'packages' + if a:action == 1 + let g:Tex_PackagesMenu = 1 + exe 'source '.s:path.'/packages.vim' + exe 'amenu disable '.menuloc.'Load\ Packages\ Menu' + endif + endif +endfunction + +" }}} + +" configuration menu. +if g:Tex_Menus + exe 'amenu '.g:Tex_MainMenuLocation.'.900 '.s:mainmenuname.'Configure\ Menu.Add\ Math\ Menu :call Tex_MenuConfigure("math", 1)<cr>' + exe 'amenu '.g:Tex_MainMenuLocation.'.900 '.s:mainmenuname.'Configure\ Menu.Remove\ Math\ Menu :call Tex_MenuConfigure("math", 0)<cr>' + exe 'amenu '.g:Tex_MainMenuLocation.'.900 '.s:mainmenuname.'Configure\ Menu.Expand\ Elements :call Tex_MenuConfigure("elements", "expand")<cr>' + exe 'amenu '.g:Tex_MainMenuLocation.'.900 '.s:mainmenuname.'Configure\ Menu.Compress\ Elements :call Tex_MenuConfigure("elements", "nest")<cr>' + exe 'amenu '.g:Tex_MainMenuLocation.'.900 '.s:mainmenuname.'Configure\ Menu.Load\ Packages\ Menu :call Tex_MenuConfigure("packages", 1)<cr>' +endif + +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4 diff --git a/ftplugin/latex-suite/texproject.vim b/ftplugin/latex-suite/texproject.vim new file mode 100644 index 00000000..fd1734bc --- /dev/null +++ b/ftplugin/latex-suite/texproject.vim @@ -0,0 +1,54 @@ +"============================================================================= +" File: texproject.vim +" Author: Mikolaj Machowski +" Version: 1.0 +" Created: Wen Apr 16 05:00 PM 2003 +" +" Description: Handling tex projects. +"============================================================================= + +let s:path = fnameescape(expand("<sfile>:p:h")) + +command! -nargs=0 TProjectEdit :call <SID>Tex_ProjectEdit() + +" Tex_ProjectEdit: Edit project file " {{{ +" Description: If project file exists (*.latexmain) open it in window created +" with ':split', if no create ':new' window and read there +" project template +" +function! s:Tex_ProjectEdit() + + let file = expand("%:p") + let mainfname = Tex_GetMainFileName() + if glob(mainfname.'.latexmain') != '' + exec 'split '.fnameescape(mainfname.'.latexmain') + else + echohl WarningMsg + echomsg "Master file not found." + echomsg " :help latex-master-file" + echomsg "for more information" + echohl None + endif + +endfunction " }}} +" Tex_ProjectLoad: loads the .latexmain file {{{ +" Description: If a *.latexmain file exists, then sources it +function! Tex_ProjectLoad() + let s:origdir = fnameescape(getcwd()) + exe 'cd '.fnameescape(expand('%:p:h')) + + if glob(Tex_GetMainFileName(':p').'.latexmain') != '' + call Tex_Debug("Tex_ProjectLoad: sourcing [".Tex_GetMainFileName().".latexmain]", "proj") + exec 'source '.fnameescape(Tex_GetMainFileName().'.latexmain') + endif + + exe 'cd '.s:origdir +endfunction " }}} + +augroup LatexSuite + au LatexSuite User LatexSuiteFileType + \ call Tex_Debug("texproject.vim: catching LatexSuiteFileType event", "proj") | + \ call Tex_ProjectLoad() +augroup END + +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4 diff --git a/ftplugin/latex-suite/texviewer.vim b/ftplugin/latex-suite/texviewer.vim new file mode 100644 index 00000000..0b511dd1 --- /dev/null +++ b/ftplugin/latex-suite/texviewer.vim @@ -0,0 +1,1070 @@ +" ============================================================================ +" File: texviewer.vim +" Author: Mikolaj Machowski +" Created: Sun Jan 26 06:00 PM 2003 +" Description: make a viewer for various purposes: \cite{, \ref{ +" License: Vim Charityware License +" Part of vim-latexSuite: http://vim-latex.sourceforge.net +" ============================================================================ +" Tex_SetTexViewerMaps: sets maps for this ftplugin {{{ +function! Tex_SetTexViewerMaps() + inoremap <silent> <Plug>Tex_Completion <Esc>:call Tex_Complete("default","text")<CR> + if !hasmapto('<Plug>Tex_Completion', 'i') + if has('gui_running') + imap <buffer> <silent> <F9> <Plug>Tex_Completion + else + imap <buffer> <F9> <Plug>Tex_Completion + endif + endif +endfunction + +augroup LatexSuite + au LatexSuite User LatexSuiteFileType + \ call Tex_Debug('texviewer.vim: Catching LatexSuiteFileType event', 'view') | + \ call Tex_SetTexViewerMaps() +augroup END + +command -nargs=1 TLook call Tex_Complete(<q-args>, 'tex') +command -nargs=1 TLookAll call Tex_Complete(<q-args>, 'all') +command -nargs=1 TLookBib call Tex_Complete(<q-args>, 'bib') + +" }}} + +" ============================================================================== +" Main completion function +" ============================================================================== +" Tex_Complete: main function {{{ +" Description: +function! Tex_Complete(what, where) + + " Get info about current window and position of cursor in file + let s:winnum = winnr() + let s:pos = Tex_GetPos() + + " Change to the directory of the file being edited before running all the + " :grep commands. We will change back to the original directory after we + " finish with the grep. + let s:origdir = fnameescape(getcwd()) + exe 'cd '.fnameescape(expand('%:p:h')) + + unlet! s:type + unlet! s:typeoption + + if Tex_GetVarValue('Tex_WriteBeforeCompletion') == 1 + wall + endif + + if a:where == "text" + " What to do after <F9> depending on context + let s:curline = strpart(getline('.'), 0, col('.')) + let s:prefix = matchstr(s:curline, '.*{\zs.\{-}\(}\|$\)') + " a command is of the type + " \psfig[option=value]{figure=} + " Thus + " s:curline = '\psfig[option=value]{figure=' + " (with possibly some junk before \psfig) + " from which we need to extract + " s:type = 'psfig' + " s:typeoption = '[option=value]' + let pattern = '.*\\\(\w\{-}\)\(\[.\{-}\]\)*{\([^ [\]\t]\+\)\?$' + if s:curline =~ pattern + let s:type = substitute(s:curline, pattern, '\1', 'e') + let s:typeoption = substitute(s:curline, pattern, '\2', 'e') + call Tex_Debug('Tex_Complete: s:type = '.s:type.', typeoption = '.s:typeoption, 'view') + endif + + if exists("s:type") && s:type =~ 'ref' + if Tex_GetVarValue('Tex_UseOutlineCompletion') == 1 + call Tex_Debug("Tex_Complete: using outline search method", "view") + call Tex_StartOutlineCompletion() + + elseif Tex_GetVarValue('Tex_UseSimpleLabelSearch') == 1 + call Tex_Debug("Tex_Complete: searching for \\labels in all .tex files in the present directory", "view") + call Tex_Debug("Tex_Complete: silent! grep! ".Tex_EscapeForGrep('\\label{'.s:prefix)." *.tex", 'view') + call Tex_Grep('\\label{'.s:prefix, '*.tex') + call <SID>Tex_SetupCWindow() + + elseif Tex_GetVarValue('Tex_ProjectSourceFiles') != '' + call Tex_Debug('Tex_Complete: searching for \\labels in all Tex_ProjectSourceFiles', 'view') + exec 'cd '.fnameescape(Tex_GetMainFileName(':p:h')) + call Tex_Grep('\\label{'.s:prefix, Tex_GetVarValue('Tex_ProjectSourceFiles')) + call <SID>Tex_SetupCWindow() + + else + call Tex_Debug("Tex_Complete: calling Tex_GrepHelper", "view") + silent! grep! ____HIGHLY_IMPROBABLE___ % + call Tex_GrepHelper(s:prefix, 'label') + call <SID>Tex_SetupCWindow() + endif + + redraw! + + elseif exists("s:type") && s:type =~ 'cite' + + let s:prefix = matchstr(s:prefix, '\([^,]\+,\)*\zs\([^,]\+\)\ze$') + call Tex_Debug(":Tex_Complete: using s:prefix = ".s:prefix, "view") + + if has('python') && Tex_GetVarValue('Tex_UsePython') + \ && Tex_GetVarValue('Tex_UseCiteCompletionVer2') == 1 + + exe 'cd '.s:origdir + silent! call Tex_StartCiteCompletion() + + elseif Tex_GetVarValue('Tex_UseJabref') == 1 + + exe 'cd '.s:origdir + let g:Remote_WaitingForCite = 1 + let citation = input('Enter citation from jabref (<enter> to leave blank): ') + let g:Remote_WaitingForCite = 0 + call Tex_CompleteWord(citation, strlen(s:prefix)) + + else + " grep! nothing % + " does _not_ clear the search history contrary to what the + " help-docs say. This was expected. So use something improbable. + " TODO: Is there a way to clear the search-history w/o making a + " useless, inefficient search? + silent! grep! ____HIGHLY_IMPROBABLE___ % + if g:Tex_RememberCiteSearch && exists('s:citeSearchHistory') + call <SID>Tex_SetupCWindow(s:citeSearchHistory) + else + call Tex_GrepHelper(s:prefix, 'bib') + redraw! + call <SID>Tex_SetupCWindow() + endif + if g:Tex_RememberCiteSearch && &ft == 'qf' + let _a = @a + silent! normal! ggVG"ay + let s:citeSearchHistory = @a + let @a = _a + endif + endif + + elseif exists("s:type") && (s:type =~ 'includegraphics' || s:type == 'psfig') + call Tex_SetupFileCompletion( + \ '', + \ '^\.\\|\.tex$\\|\.bib$\\|\.bbl$\\|\.zip$\\|\.gz$', + \ 'noext', + \ Tex_GetVarValue('Tex_ImageDir', '.'), + \ Tex_GetVarValue('Tex_ImageDir', '')) + + elseif exists("s:type") && s:type == 'bibliography' + call Tex_SetupFileCompletion( + \ '\.b..$', + \ '', + \ 'noext', + \ '.', + \ '') + + elseif exists("s:type") && s:type =~ 'include\(only\)\=' + call Tex_SetupFileCompletion( + \ '\.t..$', + \ '', + \ 'noext', + \ '.', + \ '') + + elseif exists("s:type") && s:type == 'input' + call Tex_SetupFileCompletion( + \ '', + \ '', + \ 'ext', + \ '.', + \ '') + + elseif exists('s:type') && exists("g:Tex_completion_".s:type) + call <SID>Tex_CompleteRefCiteCustom('plugin_'.s:type) + + else + let s:word = expand('<cword>') + if s:word == '' + call Tex_SwitchToInsertMode() + return + endif + call Tex_Debug("silent! grep! ".Tex_EscapeForGrep('\<'.s:word.'\>')." *.tex", 'view') + call Tex_Grep('\<'.s:word.'\>', '*.tex') + + call <SID>Tex_SetupCWindow() + endif + + elseif a:where == 'tex' + " Process :TLook command + call Tex_Grep(a:what, "*.tex") + call <SID>Tex_SetupCWindow() + + elseif a:where == 'bib' + " Process :TLookBib command + call Tex_Grep(a:what, "*.bib") + call Tex_Grepadd(a:what, "*.bbl") + call <SID>Tex_SetupCWindow() + + elseif a:where == 'all' + " Process :TLookAll command + call Tex_Grep(a:what, "*") + call <SID>Tex_SetupCWindow() + endif + +endfunction +" }}} +" Tex_CompleteWord: inserts a word at the chosen location {{{ +" Description: This function is meant to be called when the user press +" ``<enter>`` in one of the [Error List] windows which shows the list of +" matches. completeword is the rest of the word which needs to be inserted. +" prefixlength characters are deleted before completeword is inserted +function! Tex_CompleteWord(completeword, prefixlength) + " Set cursor to window and position recorded when completion was invoked. + exe s:winnum.' wincmd w' + call Tex_SetPos(s:pos) + + " Complete word, check if add closing } + if a:prefixlength > 0 + if a:prefixlength > 1 + exe 'normal! '.(a:prefixlength-1).'h' + endif + exe 'normal! '.a:prefixlength.'s'.a:completeword."\<Esc>" + else + exe 'normal! a'.a:completeword."\<Esc>" + endif + + if getline('.')[col('.')-1] !~ '{' && getline('.')[col('.')] !~ '}' + exe "normal! a}\<Esc>" + endif + + " Return to Insert mode + call Tex_SwitchToInsertMode() +endfunction " }}} + +" ============================================================================== +" File name completion helper functons +" ============================================================================== +" Tex_SetupFileCompletion: {{{ +" Description: +function! Tex_SetupFileCompletion(accept, reject, ext, dir, root) + call FB_SetVar('FB_AllowRegexp', a:accept) + call FB_SetVar('FB_RejectRegexp', a:reject) + call FB_SetVar('FB_CallBackFunction', 'Tex_CompleteFileName') + call FB_SetVar('FB_CallBackFunctionArgs', '"'.a:ext.'", "'.a:root.'"') + + call FB_OpenFileBrowser(a:dir) +endfunction " }}} +" Tex_CompleteFileName: {{{ +" Description: +function! Tex_CompleteFileName(filename, ext, root) + let root = (a:root == '' ? Tex_GetMainFileName(':p:h') : a:root) + + call Tex_Debug('+Tex_CompleteFileName: getting filename '.a:filename, 'view') + + if a:ext == 'noext' + let completeword = fnamemodify(a:filename, ':r') + else + let completeword = a:filename + endif + let completeword = Tex_RelPath(completeword, root) + + call Tex_Debug(":Tex_CompleteFileName: completing with ".completeword, "view") + call Tex_CompleteWord(completeword, strlen(s:prefix)) +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_NormalizePath: {{{ +" Description: +function! Tex_NormalizePath(path) + let retpath = a:path + if has("win32") || has("win16") || has("dos32") || has("dos16") + let retpath = substitute(retpath, '\\', '/', 'ge') + endif + if isdirectory(retpath) && retpath !~ '/$' + let retpath = retpath.'/' + endif + return retpath +endfunction " }}} +" Tex_RelPath: ultimate file name {{{ +function! Tex_RelPath(explfilename,texfilename) + let path1 = Tex_NormalizePath(a:explfilename) + let path2 = Tex_NormalizePath(a:texfilename) + + 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 escape(Tex_NormalizePath(relpath), ' ') +endfunction " }}} + +" ============================================================================== +" Helper functions for dealing with the 'quickfix' and 'preview' windows. +" ============================================================================== +" Tex_SetupCWindow: set maps and local settings for cwindow {{{ +" Description: Set local maps jkJKq<cr> for cwindow. Also size and basic +" settings +" +function! s:Tex_SetupCWindow(...) + call Tex_Debug('+Tex_SetupCWindow', 'view') + cclose + exe 'copen '. g:Tex_ViewerCwindowHeight + " If called with an argument, it means we want to re-use some search + " history from last time. Therefore, just paste it here and proceed. + if a:0 == 1 + set modifiable + % d _ + silent! 0put!=a:1 + $ d _ + endif + setlocal nonumber + setlocal nowrap + + let s:scrollOffVal = &scrolloff + call <SID>Tex_SyncPreviewWindow() + + " If everything went well, then we should be situated in the quickfix + " window. If there were problems, (no matches etc), then we will not be. + " Therefore return. + if &ft != 'qf' + call Tex_Debug('not in quickfix window, quitting', 'view') + return + endif + + nnoremap <buffer> <silent> j j:call <SID>Tex_SyncPreviewWindow()<CR> + nnoremap <buffer> <silent> k k:call <SID>Tex_SyncPreviewWindow()<CR> + nnoremap <buffer> <silent> <up> <up>:call <SID>Tex_SyncPreviewWindow()<CR> + nnoremap <buffer> <silent> <down> <down>:call <SID>Tex_SyncPreviewWindow()<CR> + + " Change behaviour of <cr> only for 'ref' and 'cite' context. + if exists("s:type") && s:type =~ 'ref\|cite' + exec 'nnoremap <buffer> <silent> <cr> ' + \ .':set scrolloff='.s:scrollOffVal.'<CR>' + \ .':cd '.s:origdir.'<CR>' + \ .':silent! call <SID>Tex_CompleteRefCiteCustom("'.s:type.'")<CR>' + + else + " In other contexts jump to place described in cwindow and close small + " windows + exec 'nnoremap <buffer> <silent> <cr> ' + \ .':set scrolloff='.s:scrollOffVal.'<CR>' + \ .':cd '.s:origdir.'<CR>' + \ .':call <SID>Tex_GoToLocation()<cr>' + + endif + + " Scroll the preview window while in the quickfix window + nnoremap <buffer> <silent> J :wincmd j<cr><c-e>:wincmd k<cr> + nnoremap <buffer> <silent> K :wincmd j<cr><c-y>:wincmd k<cr> + + " Exit the quickfix window without doing anything. + exe 'nnoremap <buffer> <silent> q ' + \ .':set scrolloff='.s:scrollOffVal.'<CR>' + \ .':cd '.s:origdir.'<CR>' + \ .':call Tex_CloseSmallWindows()<CR>' + +endfunction " }}} +" Tex_CompleteRefCiteCustom: complete/insert name for current item {{{ +" Description: handle completion of items depending on current context +" +function! s:Tex_CompleteRefCiteCustom(type) + + let prefixlength=strlen(s:prefix) + if a:type =~ 'cite' + if getline('.') =~ '\\bibitem\s*{' + let bibkey = matchstr(getline('.'), '\\bibitem\s*{\zs.\{-}\ze}') + else + let bibkey = matchstr(getline('.'), '\\bibitem\s*\[.\{-}\]\s*{\zs.\{-}\ze}') + endif + let completeword = bibkey + + elseif a:type =~ 'ref' + let label = matchstr(getline('.'), '\\label{\zs.\{-}\ze}') + let completeword = label + + elseif a:type =~ '^plugin_' + let type = substitute(a:type, '^plugin_', '', '') + let completeword = <SID>Tex_DoCompletion(type) + " use old behaviour for plugins because of backward compatibility + let prefixlength=0 + + endif + + call Tex_CloseSmallWindows() + call Tex_Debug(":Tex_CompleteRefCiteCustom: completing with ".completeword, "view") + call Tex_CompleteWord(completeword, prefixlength) +endfunction " }}} +" Tex_SyncPreviewWindow: synchronize quickfix and preview window {{{ +" Description: Usually quickfix engine takes care about most of these things +" but we discard it for better control of events. +" +function! s:Tex_SyncPreviewWindow() + call Tex_Debug('+Tex_SyncPreviewWindow', 'view') + + let viewfile = matchstr(getline('.'), '^\f*\ze|\d') + let viewline = matchstr(getline('.'), '|\zs\d\+\ze') + + " Hilight current line in cwindow + " Normally hightlighting is done with quickfix engine but we use something + " different and have to do it separately + syntax clear + runtime syntax/qf.vim + exe 'syn match vTodo /\%'. line('.') .'l.*/' + hi link vTodo Todo + + " Close preview window and open it again in new place + pclose + exe 'silent! bot pedit +'.viewline.' '.viewfile + + " Vanilla 6.1 has bug. This additional setting of cwindow height prevents + " resizing of this window + exe g:Tex_ViewerCwindowHeight.' wincmd _' + + " Handle situation if there is no item beginning with s:prefix. + " Unfortunately, because we know it late we have to close everything and + " return as in complete process + if v:errmsg =~ 'E32\>' + exe s:winnum.' wincmd w' + call Tex_SetPos(s:pos) + pclose! + cclose + if exists("s:prefix") + echomsg 'No bibkey, label or word beginning with "'.s:prefix.'"' + endif + call Tex_SwitchToInsertMode() + let v:errmsg = '' + call Tex_Debug('Tex_SyncPreviewWindow: got error E32, no matches found, quitting', 'view') + return 0 + endif + + " Move to preview window. Really is it under cwindow? + wincmd j + + " Settings of preview window + exe g:Tex_ViewerPreviewHeight.' wincmd _' + setlocal nofoldenable + + if exists('s:type') && s:type =~ 'cite' + " In cite context place bibkey at the top of preview window. + setlocal scrolloff=0 + normal! zt + else + " In other contexts in the middle. Highlight this line? + setlocal scrolloff=100 + normal! z. + endif + + " Return to cwindow + wincmd p + +endfunction " }}} +" Tex_CloseSmallWindows: {{{ +" Description: +" +function! Tex_CloseSmallWindows() + pclose! + cclose + exe s:winnum.' wincmd w' + call Tex_SetPos(s:pos) +endfunction " }}} +" Tex_GoToLocation: Go to chosen location {{{ +" Description: Get number of current line and go to this number +" +function! s:Tex_GoToLocation() + pclose! + let errmsg = v:errmsg + let v:errmsg = '' + exe 'silent! cc ' . line('.') + " If the current buffer is modified, then split + if v:errmsg =~ '^E37:' + split + exe 'silent! cc ' . line('.') + endif + cclose + let v:errmsg = errmsg +endfunction " }}} + +" ============================================================================== +" Functions for finding \\label's or \\bibitem's in the main file. +" ============================================================================== +" Tex_GrepHelper: grep main filename for \\bibitem's or \\label's {{{ +" Description: +function! Tex_GrepHelper(prefix, what) + let _path = &path + let _suffixesadd = &suffixesadd + let _hidden = &hidden + + let mainfname = Tex_GetMainFileName(':p') + " If we are already editing the file, then use :split without any + " arguments so it works even if the file is modified. + " FIXME: If mainfname is being presently edited in another window and + " is 'modified', then the second split statement will not work. + " We will need to travel to that window and back. + if mainfname == expand('%:p') + split + else + exec 'split '.fnameescape(mainfname) + endif + + let pos = Tex_GetPos() + if a:what =~ 'bib' + call Tex_ScanFileForCite(a:prefix) + else + call Tex_ScanFileForLabels(a:prefix) + endif + call Tex_SetPos(pos) + + q + let &path = _path + let &suffixesadd = _suffixesadd + +endfunction " }}} +" Tex_ScanFileForCite: search for \bibitem's in .bib or .bbl or tex files {{{ +" Description: +" Search for bibliographic entries in the presently edited file in the +" following manner: +" 1. First see if the file has a \bibliography command. +" If YES: +" 1. If a .bib file corresponding to the \bibliography command can be +" found, then search for '@.*'.a:prefix inside it. +" 2. Otherwise, if a .bbl file corresponding to the \bibliography command +" can be found, then search for '\bibitem'.a:prefix inside it. +" 2. Next see if the file has a \thebibliography environment +" If YES: +" 1. Search for '\bibitem'.a:prefix in this file. +" +" If neither a \bibliography or \begin{thebibliography} are found, then repeat +" steps 1 and 2 for every file \input'ed into this file. Abort any searching +" as soon as the first \bibliography or \begin{thebibliography} is found. +function! Tex_ScanFileForCite(prefix) + call Tex_Debug('+Tex_ScanFileForCite: searching for bibkeys in '.bufname('%').' (buffer #'.bufnr('%').')', 'view') + let presBufNum = bufnr('%') + + let foundCiteFile = 0 + " First find out if this file has a \bibliography command in it. If so, + " assume that this is the only file in the project which defines a + " bibliography. + if search('\\\(no\)\?bibliography{', 'w') + call Tex_Debug('Tex_ScanFileForCite: found bibliography command in '.bufname('%'), 'view') + " convey that we have found a bibliography command. we do not need to + " proceed any further. + let foundCiteFile = 1 + + " extract the bibliography filenames from the command. + let bibnames = matchstr(getline('.'), '\\\(no\)\?bibliography{\zs.\{-}\ze}') + let bibnames = substitute(bibnames, '\s', '', 'g') + + call Tex_Debug('trying to search through ['.bibnames.']', 'view') + + let &path = '.,'.g:Tex_BIBINPUTS + + let i = 1 + while 1 + let bibname = Tex_Strntok(bibnames, ',', i) + if bibname == '' + break + endif + + " first try to find if a .bib file exists. If so do not search in + " the corresponding .bbl file. (because the .bbl file will most + " probly be generated automatically from the .bib file with + " bibtex). + + let fname = Tex_FindFile(bibname, '.,'.g:Tex_BIBINPUTS, '.bib') + if fname != '' + call Tex_Debug('finding .bib file ['.bufname('%').']', 'view') + exec 'split '.Tex_EscapeSpaces(fname) + call Tex_Grepadd('@.*{'.a:prefix, "%") + q + else + let fname = Tex_FindFile(bibname, '.,'.g:Tex_BIBINPUTS, '.bbl') + if fname != '' + exec 'split '.Tex_EscapeSpaces(fname) + call Tex_Debug('finding .bbl file ['.bufname('.').']', 'view') + call Tex_Grepadd('\\bibitem{'.a:prefix, "%") + q + endif + endif + + let i = i + 1 + endwhile + + if foundCiteFile + return 1 + endif + endif + + " If we have a thebibliography environment, then again assume that this is + " the only file which defines the bib-keys. Aand convey this information + " upwards by returning 1. + if search('^\s*\\begin{thebibliography}', 'w') + call Tex_Debug('got a thebibliography environment in '.bufname('%'), 'view') + + let foundCiteFile = 1 + + split + exec 'lcd'.fnameescape(expand('%:p:h')) + call Tex_Debug("silent! grepadd! ".Tex_EscapeForGrep('\\bibitem{'.a:prefix)." %", 'view') + call Tex_Grepadd('\\bibitem\s*[\[|{]'.a:prefix, "%") + q + + return 1 + endif + + " If we have not found any \bibliography or \thebibliography environment + " in this file, search for these environments in all the files which this + " file includes. + + exec 0 + let wrap = 'w' + while search('^\s*\\\(input\|include\)', wrap) + let wrap = 'W' + + let filename = matchstr(getline('.'), '\\\(input\|include\){\zs.\{-}\ze}') + + let foundfile = Tex_FindFile(filename, '.,'.g:Tex_TEXINPUTS, '.tex') + if foundfile != '' + exec 'split '.Tex_EscapeSpaces(foundfile) + call Tex_Debug('scanning recursively in ['.foundfile.']', 'view') + let foundCiteFile = Tex_ScanFileForCite(a:prefix) + q + endif + + if foundCiteFile + return 1 + endif + endwhile + + + return 0 +endfunction " }}} +" Tex_ScanFileForLabels: greps present file and included files for \\label's {{{ +" Description: +" Grep the presently edited file for \\label's. If the present file \include's +" or \input's other files, then recursively scan those as well, i.e we support +" arbitrary levels of \input'ed-ness. +function! Tex_ScanFileForLabels(prefix) + call Tex_Debug("+Tex_ScanFileForLabels: grepping in file [".bufname('%')."]", "view") + + exec 'lcd'.fnameescape(expand('%:p:h')) + call Tex_Grepadd('\\label{'.a:prefix, "%") + + " Then recursively grep for all \include'd or \input'ed files. + exec 0 + let wrap = 'w' + while search('^\s*\\\(input\|include\)', wrap) + let wrap = 'W' + + let filename = matchstr(getline('.'), '\\\(input\|include\){\zs.\{-}\ze}') + let foundfile = Tex_FindFile(filename, '.,'.Tex_TEXINPUTS, '.tex') + if foundfile != '' + exec 'split '.Tex_EscapeSpaces(foundfile) + call Tex_Debug('Tex_ScanFileForLabels: scanning recursively in ['.foundfile.']', 'view') + call Tex_ScanFileForLabels(a:prefix) + q + endif + endwhile + +endfunction " }}} + +" ============================================================================== +" Functions for custom command completion +" ============================================================================== +" Tex_completion_{var}: 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_PromptForCompletion: prompts for a completion {{{ +" Description: +function! s:Tex_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! s:Tex_DoCompletion(texcommand) + let completion = <SID>Tex_PromptForCompletion(a:texcommand, 'Choose a completion to insert: ') + if completion != '' + return completion + else + return '' + endif +endfunction " }}} + +" ============================================================================== +" Functions for presenting an outlined version for completion +" ============================================================================== +" Tex_StartOutlineCompletion: sets up an outline window {{{ + +" get the place where this plugin resides for setting cpt and dict options. +" these lines need to be outside the function. +let s:path = expand('<sfile>:p:h') +if has('python') && Tex_GetVarValue('Tex_UsePython') + python import sys, re + exec "python sys.path += [r'". s:path . "']" + python import outline +endif + +function! Tex_StartOutlineCompletion() + let mainfname = Tex_GetMainFileName(':p') + + " open the buffer + let _report = &report + let _cmdheight=&cmdheight + let _lazyredraw = &lazyredraw + set report=1000 + set cmdheight=1 + set lazyredraw + + if has('python') && Tex_GetVarValue('Tex_UsePython') + python retval = outline.main(vim.eval("Tex_GetMainFileName(':p')"), vim.eval("s:prefix")) + + " transfer variable from python to a local variable. + python vim.command("""let retval = "%s" """ % re.sub(r'"|\\', r'\\\g<0>', retval)) + else + let retval = system(shellescape(s:path.'/outline.py').' '.shellescape(mainfname).' '.shellescape(s:prefix)) + endif + + bot split __OUTLINE__ + exec Tex_GetVarValue('Tex_OutlineWindowHeight', 15).' wincmd _' + + setlocal modifiable + setlocal noswapfile + setlocal buftype=nowrite + setlocal bufhidden=delete + setlocal nowrap + setlocal foldmethod=marker + setlocal foldmarker=<<<,>>> + + " delete everything in it to the blackhole + % d _ + 0put!=retval + + 0 + + call Tex_SetupOutlineSyntax() + + exec 'nnoremap <buffer> <cr> ' + \ .':cd '.s:origdir.'<CR>' + \ .':call Tex_FinishOutlineCompletion()<CR>' + exec 'nnoremap <buffer> q ' + \ .':cd '.s:origdir.'<CR>' + \ .':close<CR>' + \ .':call Tex_SwitchToInsertMode()<CR>' + + " once the buffer is initialized, go back to the original settings. + setlocal nomodifiable + setlocal nomodified + let &report = _report + let &cmdheight = _cmdheight + let &lazyredraw = _lazyredraw + +endfunction " }}} +" Tex_SetupOutlineSyntax: sets up the syntax items for the outline {{{ +" Description: +function! Tex_SetupOutlineSyntax() + syn match outlineFileName "<\f\+>$" contained + syn match foldMarkers "<<<\d$" contained + syn match firstSemiColon '^:' contained + syn match firstAngle '^>' contained + + syn match sectionNames '\(\d\.\)\+ .*' contains=foldMarkers + syn match previousLine '^:.*' contains=firstSemiColon + syn match labelLine '^>.*' contains=firstAngle,outlineFileName + + hi def link outlineFileName Ignore + hi def link foldMarkers Ignore + hi def link firstSemiColon Ignore + hi def link firstAngle Ignore + + hi def link sectionNames Type + hi def link previousLine Special + hi def link labelLine Comment +endfunction " }}} +" Tex_FinishOutlineCompletion: inserts the reference back in the text {{{ +function! Tex_FinishOutlineCompletion() + if getline('.') !~ '^[>:]' + return + endif + + if getline('.') =~ '^>' + let ref_complete = matchstr(getline('.'), '^>\s\+\zs\S\+\ze') + elseif getline('.') =~ '^:' + let ref_complete = matchstr(getline(line('.')-1), '^>\s\+\zs\S\+\ze') + endif + + close + call Tex_CompleteWord(ref_complete, strlen(s:prefix)) +endfunction " }}} + +" ============================================================================== +" Functions for presenting a nicer list of bibtex entries +" ============================================================================== +" Tex_FindBibFiles: finds all .bib files used by the main file {{{ +" Description: +function! Tex_FindBibFiles() + call Tex_Debug(":Tex_FindBibFiles: ", "view") + + let mainfname = Tex_GetMainFileName(':p') + new + exec 'e ' . fnameescape(mainfname) + + if search('\\\(no\)\?bibliography{', 'w') + + call Tex_Debug('Tex_FindBibFiles: found bibliography command in '.bufname('%'), 'view') + + " extract the bibliography filenames from the command. + let bibnames = matchstr(getline('.'), '\\\(no\)\?bibliography{\zs.\{-}\ze}') + let bibnames = substitute(bibnames, '\s', '', 'g') + + call Tex_Debug(':Tex_FindBibFiles: trying to search through ['.bibnames.']', 'view') + + let bibfiles = '' + let i = 1 + while 1 + let bibname = Tex_Strntok(bibnames, ',', i) + if bibname == '' + break + endif + let fname = Tex_FindFile(bibname, '.,'.g:Tex_BIBINPUTS, '.bib') + if fname != '' + let bibfiles = bibfiles.fname."\n" + endif + let i = i + 1 + endwhile + + call Tex_Debug(":Tex_FindBibFiles: returning [".bibfiles."]", "view") + q + return bibfiles + + else + q + return '' + endif + +endfunction " }}} +" Tex_StartBibtexOutline: sets up an outline window {{{ + +" get the place where this plugin resides for setting cpt and dict options. +" these lines need to be outside the function. +if has('python') && Tex_GetVarValue('Tex_UsePython') + python import sys, re + exec "python sys.path += [r'". s:path . "']" + python import bibtools +endif + +function! Tex_StartCiteCompletion() + let bibfiles = Tex_FindBibFiles() + if bibfiles !~ '\S' + call Tex_SwitchToInsertMode() + echohl WarningMsg + echomsg 'No bibfiles found! Sorry' + echohl None + return + endif + + bot split __OUTLINE__ + exec Tex_GetVarValue('Tex_OutlineWindowHeight', 15).' wincmd _' + + exec 'python Tex_BibFile = bibtools.BibFile("""'.bibfiles.'""")' + exec 'python Tex_BibFile.addfilter("key ^'.s:prefix.'")' + call Tex_DisplayBibList() + + nnoremap <buffer> <Plug>Tex_JumpToNextBibEntry :call search('^\S.*\]$', 'W')<CR>:call Tex_EchoBibShortcuts()<CR>z. + nnoremap <buffer> <Plug>Tex_JumpToPrevBibEntry :call search('^\S.*\]$', 'bW')<CR>:call Tex_EchoBibShortcuts()<CR>z. + nnoremap <buffer> <Plug>Tex_FilterBibEntries :call Tex_HandleBibShortcuts('filter')<CR> + nnoremap <buffer> <Plug>Tex_RemoveBibFilters :call Tex_HandleBibShortcuts('remove_filters')<CR> + nnoremap <buffer> <Plug>Tex_SortBibEntries :call Tex_HandleBibShortcuts('sort')<CR> + nnoremap <buffer> <Plug>Tex_CompleteCiteEntry :call Tex_CompleteCiteEntry()<CR> + + nmap <buffer> <silent> n <Plug>Tex_JumpToNextBibEntry + nmap <buffer> <silent> p <Plug>Tex_JumpToPrevBibEntry + nmap <buffer> <silent> f <Plug>Tex_FilterBibEntries + nmap <buffer> <silent> s <Plug>Tex_SortBibEntries + nmap <buffer> <silent> a <Plug>Tex_RemoveBibFilters + nmap <buffer> <silent> q :close<CR>:call Tex_SwitchToInsertMode()<CR> + nmap <buffer> <silent> <CR> <Plug>Tex_CompleteCiteEntry + +endfunction " }}} +" Tex_DisplayBibList: displays the list of bibtex entries {{{ +" Description: +function! Tex_DisplayBibList() + " open the buffer + let _report = &report + let _cmdheight=&cmdheight + let _lazyredraw = &lazyredraw + set report=1000 + set cmdheight=1 + set lazyredraw + + setlocal modifiable + setlocal noswapfile + setlocal buftype=nowrite + setlocal bufhidden=delete + setlocal nowrap + setlocal foldmethod=marker + setlocal foldmarker=<<<,>>> + + + " delete everything in it to the blackhole + % d _ + + exec 'python Tex_CurBuf = vim.current.buffer' + exec 'python Tex_CurBuf[:] = str(Tex_BibFile).splitlines()' + + call Tex_SetupBibSyntax() + + 0 + call Tex_EchoBibShortcuts() + + " once the buffer is initialized, go back to the original settings. + setlocal nomodifiable + setlocal nomodified + let &report = _report + let &cmdheight = _cmdheight + let &lazyredraw = _lazyredraw + +endfunction " }}} +" Tex_EchoBibShortcuts: echos all the shortcuts in the status line {{{ +" Description: +function! Tex_EchoBibShortcuts() + echomsg '(a) all (f) filter (s) sort (n) next (p) previous (q) quit (<CR>) choose' +endfunction " }}} +" Tex_SetupBibSyntax: sets up the syntax items for the outline {{{ +" Description: +function! Tex_SetupBibSyntax() + syn match BibTitleHeader "^TI" contained + syn match BibAuthorHeader "^AU" contained + syn match BibLocationHeader "^IN" contained + syn match BibMiscHeader "^MI" contained + + syn match BibKeyLine '^\S.*\]$' contains=BibKey + syn match BibTitle "^TI .*" contains=BibTitleHeader + syn match BibAuthor "^AU .*" contains=BibAuthorHeader + syn match BibLocation "^IN .*" contains=BibLocationHeader + syn match BibMisc "^MI .*" contains=BibMiscHeader + + hi def link BibTitleHeader Ignore + hi def link BibAuthorHeader Ignore + hi def link BibLocationHeader Ignore + hi def link BibMiscHeader Ignore + + hi def link BibKeyLine Visual + hi def link BibTitle Type + hi def link BibAuthor Special + hi def link BibLocation Comment + hi def link BibMisc Comment +endfunction " }}} +" Tex_HandleBibShortcuts: handles user keypresses {{{ +" Description: +function! Tex_HandleBibShortcuts(command) + + if a:command == 'filter' || a:command == 'sort' + + let fieldprompt = + \ "Field acronyms: (`:let g:Tex_EchoBibFields = 0` to avoid this message)\n" . + \ " [t] title [a] author [b] booktitle \n" . + \ " [j] journal [y] year [p] bibtype \n" . + \ " (you can also enter the complete field name) \n" + + let fieldprompt = Tex_GetVarValue('Tex_BibFieldPrompt', fieldprompt) + + if Tex_GetVarValue('Tex_EchoBibFields', 1) == 1 + echo fieldprompt + endif + + let inp = input('Enter '.a:command.' criterion [field<space>value]: ') + if inp !~ '\v^\S+\s+\S.*' + echohl WarningMsg + echomsg 'Invalid filter specification. Use "field<space>value"' + echohl None + return + endif + + if inp != '' + " If the field is specified as a single character, then replace + " it with the corresponding 'full form'. + if inp =~ '^[a-z]\>' + if Tex_GetVarValue('Tex_BibAcronym_'.inp[0]) != '' + let inp = substitute(inp, '.', Tex_GetVarValue('Tex_BibAcronym_'.inp[0]), '') + elseif fieldprompt =~ '\['.inp[0].'\]' + let full = matchstr(fieldprompt, '\['.inp[0].'\] \zs\w\+\ze') + let inp = substitute(inp, '.', full, '') + endif + endif + call Tex_Debug(":Tex_HandleBibShortcuts: using inp = [".inp."]", "view") + if a:command == 'filter' + exec 'python Tex_BibFile.addfilter("'.inp.'")' + elseif a:command == 'sort' + exec "python Tex_BibFile.addsortfield(\"".inp."\")" + exec 'python Tex_BibFile.sort()' + endif + silent! call Tex_DisplayBibList() + endif + + elseif a:command == 'remove_filters' + + exec 'python Tex_BibFile.rmfilters()' + exec 'python Tex_BibFile.addfilter("key ^'.s:prefix.'")' + call Tex_DisplayBibList() + + endif + +endfunction " }}} +" Tex_CompleteCiteEntry: completes cite entry {{{ +" Description: +function! Tex_CompleteCiteEntry() + normal! 0 + call search('\[\S\+\]$', 'W') + if getline('.') !~ '\[\S\+\]$' + call search('\[\S\+\]$', 'bW') + endif + + if getline('.') !~ '\[\S\+\]$' + return + endif + + let ref = matchstr(getline('.'), '\[\zs\S\+\ze\]$') + close + call Tex_Debug(":Tex_CompleteCiteEntry: completing with ".ref, "view") + call Tex_CompleteWord(ref, strlen(s:prefix)) +endfunction " }}} + +" Tex_SwitchToInsertMode: Switch to insert mode {{{ +" Description: This is usually called when completion is finished +function! Tex_SwitchToInsertMode() + call Tex_Debug(":Tex_SwitchToInsertMode: ", "view") + if col('.') == strlen(getline('.')) + startinsert! + else + normal! l + startinsert + endif +endfunction " }}} + +com! -nargs=0 TClearCiteHist unlet! s:citeSearchHistory + +" vim:fdm=marker:nowrap:noet:ff=unix:ts=4:sw=4 diff --git a/ftplugin/latex-suite/version.vim b/ftplugin/latex-suite/version.vim new file mode 100644 index 00000000..3da5ef42 --- /dev/null +++ b/ftplugin/latex-suite/version.vim @@ -0,0 +1,30 @@ +" Tex_Version: returns a string which gives the current version number of latex-suite +" Description: +" Each time a bug fix/addition is done in any source file in latex-suite, +" not just this file, the number below has to be incremented by the author. +" This will ensure that there is a single 'global' version number for all of +" latex-suite. +" +" If a change is done in the doc/ directory, i.e an addition/change in the +" documentation, then this number should NOT be incremented. +" +" Latex-suite will follow a 3-tier system of versioning just as Vim. A +" version number will be of the form: +" +" X.Y.ZZ +" +" 'X' will only be incremented for a major over-haul or feature addition. +" 'Y' will be incremented for significant changes which do not qualify +" as major. +" 'ZZ' will be incremented for bug-fixes and very trivial additions such +" as adding an option etc. Once ZZ reaches 50, then Y will be +" incremented and ZZ will be reset to 01. Each time we have a +" version number of the form X.Y.01, then we'll make a release on +" vim.sf.net and also create a cvs tag at that point. We'll try to +" "stabilize" that version by releasing a few pre-releases and then +" keep that as a stable point. +function! Tex_Version() + return "Latex-Suite: version 1.8.23" +endfunction + +com! -nargs=0 TVersion echo Tex_Version() diff --git a/ftplugin/latex-suite/wizardfuncs.vim b/ftplugin/latex-suite/wizardfuncs.vim new file mode 100644 index 00000000..4a290698 --- /dev/null +++ b/ftplugin/latex-suite/wizardfuncs.vim @@ -0,0 +1,376 @@ +" File: wizardfuncs.vim +" Author: Mikolaj Machowski <mikmach@wp.pl> +" Description: +" +" Installation: +" History: pluginized by Srinath Avadhanula +"============================================================================= + +if exists('s:doneOnce') + finish +endif +let s:doneOnce = 1 + +let s:mapleader = exists('mapleader') ? mapleader : "\\" +" ============================================================================== +" Specialized functions for handling sections from command line +" ============================================================================== + +com! -nargs=? TSection call Tex_section(<f-args>) +com! -nargs=? TSectionAdvanced call Tex_section_adv(<f-args>) + +" Tex_VisSecAdv: handles visual selection for sections {{{ +function! Tex_VisSecAdv(section) + let shorttitle = input("Short title? ") + let toc = input("Include in table of contents [y]/n ? ") + let sstructure = "\\".a:section + if ( toc == "" || toc == "y" ) + let toc = "" + else + let toc = "*" + endif + if shorttitle != "" + let shorttitle = '['.shorttitle.']' + endif + exe "normal `>a}\<cr>\<esc>`<i".sstructure.toc.shorttitle."{" +endfunction + +" }}} +" Tex_InsSecAdv: section wizard in insert mode {{{ +function! Tex_InsSecAdv(structure) + let ttitle = input("Title? ") + let shorttitle = input("Short title? ") + let toc = input("Include in table of contents [y]/n ? ") + "Structure + let sstructure = "\\".a:structure + "TOC + if ( toc == "" || toc == "y" ) + let toc = "" + else + let toc = "*" + endif + "Shorttitle + if shorttitle != "" + let shorttitle = '['.shorttitle.']' + endif + "Title + let ttitle = '{'.ttitle.'}' + "Happy end? + return sstructure.toc.shorttitle.ttitle +endfunction + +" }}} +function! Tex_section(...) "{{{ + silent let pos = Tex_GetPos() + silent let last_section_value = s:Tex_section_detection() + if a:0 == 0 + silent let last_section_name = s:Tex_section_name(last_section_value) + silent call s:Tex_section_call(last_section_name) + elseif a:1 =~ "[+=\-]" + silent let sec_arg = a:1 + silent let curr_section_value = s:Tex_section_curr_rel_value(sec_arg, last_section_value) + silent let curr_section_name = s:Tex_section_name(curr_section_value) + silent call s:Tex_section_call(curr_section_name) + elseif a:1 == "?" + echo s:last_section_line + else + silent let curr_section_value = s:Tex_section_curr_value(a:1) + silent let curr_section_name = s:Tex_section_name(curr_section_value) + silent call s:Tex_section_call(curr_section_name) + endif + silent call Tex_SetPos(pos) +endfunction "}}} +function! Tex_section_adv(...) "{{{ + let pos = Tex_GetPos() + silent let last_section_value = s:Tex_section_detection() + if a:0 == 0 + silent let last_section_name = s:Tex_section_name(last_section_value) + let section = Tex_InsSecAdv(last_section_name) + elseif a:1 =~ "[+=\-]" + silent let sec_arg = a:1 + silent let curr_section_value = s:Tex_section_curr_rel_value(sec_arg, last_section_value) + silent let curr_section_name = s:Tex_section_name(curr_section_value) + let section = Tex_InsSecAdv(curr_section_name) + else + silent let curr_section_value = s:Tex_section_curr_value(a:1) + silent let curr_section_name = s:Tex_section_name(curr_section_value) + silent call s:Tex_section_call(curr_section_name) + let section = Tex_InsSecAdv(curr_section_name) + endif + exe "normal i".section + call Tex_SetPos(pos) +endfunction "}}} +function! s:Tex_section_detection() "{{{ + let pos = Tex_GetPos() + let last_section1 = search("\\\\\subparagraph\\|\\\\paragraph\\|\\\\subsubsection\\|\\\\subsection\\|\\\\section\\|\\\\chapter\\|\\\part\)", "b") + call Tex_SetPos(pos) + let last_section2 = search("\\\\\part\\|\\\\chapter\\|\\\\section\\|\\\\subsection\\|\\\\subsubsection\\|\\\\paragraph\\|\\\subparagraph\)", "b") + if last_section1 > last_section2 + let last_section = last_section1 + else + let last_section = last_section2 + endif + if last_section != 0 + exe last_section + if getline(".") =~ "\\\\part" + let last_section_value = 0 + elseif getline(".") =~ "\\\\chapter" + let last_section_value = 1 + elseif getline(".") =~ "\\\\section" + let last_section_value = 2 + elseif getline(".") =~ "\\\\subsection" + let last_section_value = 3 + elseif getline(".") =~ "\\\\subsubsection" + let last_section_value = 4 + elseif getline(".") =~ "\\\\paragraph" + let last_section_value = 5 + elseif getline(".") =~ "\\\\subparagraph" + let last_section_value = 6 + endif + let s:last_section_line = getline(".") + else + let last_section_value = 0 + endif + call Tex_SetPos(pos) + return last_section_value +endfunction "}}} +function! s:Tex_section_curr_value(sec_arg) "{{{ + if a:sec_arg == "pa" || a:sec_arg == "0" || a:sec_arg == "part" + let curr_section_value = 0 + elseif a:sec_arg == "ch" || a:sec_arg == "1" || a:sec_arg == "chapter" + let curr_section_value = 1 + elseif a:sec_arg == "se" || a:sec_arg == "2" || a:sec_arg == "section" + let curr_section_value = 2 + elseif a:sec_arg == "ss" || a:sec_arg == "3" || a:sec_arg == "subsection" + let curr_section_value = 3 + elseif a:sec_arg == "s2" || a:sec_arg == "4" || a:sec_arg == "subsubsection" + let curr_section_value = 4 + elseif a:sec_arg == "pr" || a:sec_arg == "5" || a:sec_arg == "paragraph" + let curr_section_value = 5 + elseif a:sec_arg == "sp" || a:sec_arg == "6" || a:sec_arg == "subparagraph" + let curr_section_value = 6 + endif + return curr_section_value +endfunction "}}} +function! s:Tex_section_curr_rel_value(sec_arg, last_section_value) "{{{ + let last_section_value = a:last_section_value + if a:sec_arg == "+" || a:sec_arg == "+1" + let curr_section_value = last_section_value + 1 + elseif a:sec_arg == "++" || a:sec_arg == "+2" + let curr_section_value = last_section_value + 2 + elseif a:sec_arg == "-" || a:sec_arg == "-1" + let curr_section_value = last_section_value - 1 + elseif a:sec_arg == "--" || a:sec_arg == "-2" + let curr_section_value = last_section_value - 2 + elseif a:sec_arg == "=" + let curr_section_value = last_section_value + else + exe "let curr_section_value = last_section_value".a:sec_arg + endif + if curr_section_value < 0 + let curr_section_value = 0 + elseif curr_section_value > 6 + let curr_section_value = 6 + endif + return curr_section_value +endfunction "}}} +function! s:Tex_section_name(section_value) "{{{ + if a:section_value == 0 + let section_name = "part" + elseif a:section_value == 1 + let section_name = "chapter" + elseif a:section_value == 2 + let section_name = "section" + elseif a:section_value == 3 + let section_name = "subsection" + elseif a:section_value == 4 + let section_name = "subsubsection" + elseif a:section_value == 5 + let section_name = "paragraph" + elseif a:section_value == 6 + let section_name = "subparagraph" + endif + return section_name +endfunction "}}} +function! s:Tex_section_call(section_name) "{{{ + exe "normal! i\\".a:section_name."{<++>}<++>\<Esc>0\<C-j>" +" let ret_section = "\\".a:section_name."{<++>}<++>" +" exe "normal! i\<C-r>=IMAP_PutTextWithMovement(ret_section)\<CR>" +" normal f}i +endfunction "}}} + +" ============================================================================== +" Add looking help into latexhelp.txt +" ============================================================================== + +inoremap <silent> <Plug>Tex_Help <C-o>:call <SID>TexHelp()<CR> +nnoremap <silent> <Plug>Tex_Help :call <SID>TexHelp()<CR> +command! -nargs=0 THelp call <SID>TexHelp() +call Tex_MakeMap('<F1>', '<Plug>Tex_Help', 'i', '') +call Tex_MakeMap('<F1>', '<Plug>Tex_Help', 'n', '') + +" TexHelp: Cursor being on LaTeX item check if exists help tag about it " {{{ +function! s:TexHelp() + let syntax_item = synIDattr(synID(line('.'),col('.')-1,0),"name") + if syntax_item =~ '^tex' + setlocal isk+=\ + let curword = expand('<cword>') + setlocal isk-=\ + let v:errmsg = '' + if curword =~ "^\\" || syntax_item == 'texSectionName' + exe 'silent! help '.curword + if v:errmsg =~ '^E149:' + echohl ErrorMsg + exe "echomsg 'Sorry, no help for LaTeX: ".curword."'" + echohl None + let v:errmsg = '' + endif + else + help + endif + else + help + endif +endfunction " }}} + +" ============================================================================== +" Tables of shortcuts +" ============================================================================== +" +command! -nargs=? Tshortcuts call Tex_shortcuts(<f-args>)<CR> + +" Tex_shortcuts: Show shortcuts in terminal after : command {{{ +function! Tex_shortcuts(...) + if a:0 == 0 + let shorts = input(" Allowed arguments are:" + \."\n g General" + \."\n e Environments" + \."\n f Fonts" + \."\n s Sections" + \."\n m Math" + \."\n a All" + \."\n Enter your choice (<Enter> quits) : ") + call Tex_shortcuts(shorts) + elseif a:1 == 'g' + echo g:generalshortcuts + elseif a:1 == 'e' + echo g:environmentshortcuts + elseif a:1 == 'f' + echo g:fontshortcuts + elseif a:1 == 's' + echo g:sectionshortcuts + elseif a:1 == 'm' + echo g:mathshortcuts + elseif a:1 == 'a' + echo g:generalshortcuts + echo g:environmentshortcuts + echo g:fontshortcuts + echo g:sectionshortcuts + echo g:mathshortcuts + endif + +endfunction +" }}} + +" General shortcuts {{{ +let g:generalshortcuts = '' +\."\n General shortcuts" +\."\n <mapleader> is a value of <Leader>" +\."\n ".s:mapleader.'ll compile whole document' +\."\n ".s:mapleader.'lv view compiled document' +\."\n ".s:mapleader.'ls forward searching (if possible)' +\."\n ".s:mapleader.'rf refresh folds' +" }}} +" Environment shortcuts {{{ +let g:environmentshortcuts = '' +\."\n Environment shortcuts" +\."\n <mapleader> is a value of g:Tex_Leader2" +\."\n I v&V I v&V" +\."\n ELI ".g:Tex_Leader2."li list EQN ".g:Tex_Leader2."qn quotation" +\."\n EDE ".g:Tex_Leader2."de description ESP ".g:Tex_Leader2."sb sloppypar" +\."\n EEN ".g:Tex_Leader2."en enumerate ETI ".g:Tex_Leader2."ti theindex" +\."\n EIT ".g:Tex_Leader2."it itemize ETP ".g:Tex_Leader2."tp titlepage" +\."\n ETI ".g:Tex_Leader2."ti theindex EVM ".g:Tex_Leader2."vm verbatim" +\."\n ETL ".g:Tex_Leader2."tl trivlist EVE ".g:Tex_Leader2."ve verse" +\."\n ETE ".g:Tex_Leader2."te table ETB ".g:Tex_Leader2."tb thebibliography" +\."\n ETG ".g:Tex_Leader2."tg tabbing ENO ".g:Tex_Leader2."no note" +\."\n ETR ".g:Tex_Leader2."tr tabular EOV ".g:Tex_Leader2."ov overlay" +\."\n EAR ".g:Tex_Leader2."ar array ESL ".g:Tex_Leader2."sl slide" +\."\n EDM ".g:Tex_Leader2."dm displaymath EAB ".g:Tex_Leader2."ab abstract" +\."\n EEA ".g:Tex_Leader2."ea eqnarray EAP ".g:Tex_Leader2."ap appendix" +\."\n EEQ ".g:Tex_Leader2."eq equation ECE ".g:Tex_Leader2."ce center" +\."\n EDO ".g:Tex_Leader2."do document EFI ".g:Tex_Leader2."fi figure" +\."\n EFC ".g:Tex_Leader2."fc filecontents ELR ".g:Tex_Leader2."lr lrbox" +\."\n EFL ".g:Tex_Leader2."fl flushleft EMP ".g:Tex_Leader2."mp minipage" +\."\n EFR ".g:Tex_Leader2."fr flushright EPI ".g:Tex_Leader2."pi picture" +\."\n EMA ".g:Tex_Leader2."ma math EQE ".g:Tex_Leader2."qe quote" +" }}} +" Font shortcuts {{{ +let g:fontshortcuts = '' +\."\n Font shortcuts" +\."\n <mapleader> is a value of g:Tex_Leader" +\."\n Shortcuts Effects" +\."\n I v&V I&v V" +\."\n FBF ".g:Tex_Leader."bf \\textbf{} {\\bfseries }" +\."\n FMD ".g:Tex_Leader."md \\textmd{} {\\mdseries }" +\."\n" +\."\n FTT ".g:Tex_Leader."tt \\texttt{} {\\ttfamily }" +\."\n FSF ".g:Tex_Leader."sf \\textsf{} {\\sffamily }" +\."\n FRM ".g:Tex_Leader."rm \\textrm{} {\\rmfamily }" +\."\n" +\."\n FUP ".g:Tex_Leader."up \\textup{} {\\upshape }" +\."\n FSL ".g:Tex_Leader."sl \\textsl{} {\\slshape }" +\."\n FSC ".g:Tex_Leader."sc \\textsc{} {\\scshape }" +\."\n FIT ".g:Tex_Leader."it \\textit{} {\\itshape }" +" }}} +" Section shortcuts {{{ +let g:sectionshortcuts = '' +\."\n Section shortcuts" +\."\n <mapleader> is a value of g:Tex_Leader2" +\."\n I v&V" +\."\n SPA ".g:Tex_Leader2."pa part" +\."\n SCH ".g:Tex_Leader2."ch chapter" +\."\n SSE ".g:Tex_Leader2."se section" +\."\n SSS ".g:Tex_Leader2."ss subsection" +\."\n SS2 ".g:Tex_Leader2."s2 subsubsection" +\."\n SPG ".g:Tex_Leader2."pg paragraph" +\."\n SSP ".g:Tex_Leader2."sp subparagraph" +" }}} +" Math shortcuts {{{ +let g:mathshortcuts = '' +\."\n Math shortcuts - Insert mode" +\."\n `a \\alpha `b \\beta" +\."\n `g \\gamma `d \\delta" +\."\n `e \\varepsilon `z \\zeta" +\."\n `h \\eta `q \\theta" +\."\n `i \\iota `k \\kappa" +\."\n `l \\lambda `m \\mu" +\."\n `n \\nu `x \\xi" +\."\n `p \\pi `r \\rho" +\."\n `s \\sigma `v \\varsigma" +\."\n `t \\tau `u \\upsilon" +\."\n `f \\varphi `c \\chi" +\."\n `y \\psi `w \\omega" +\."\n `A \\Alpha `B \\Beta" +\."\n `G \\Gamma `D \\Delta" +\."\n `E \\Epsilon `Z \\mathrm{Z}" +\."\n `H \\Eta `K \\Kappa" +\."\n `L \\Lambda `M \\Mu" +\."\n `N \\Nu `X \\Xi" +\."\n `P \\Pi `R \\Rho" +\."\n `S \\Sigma `T \\Tau" +\."\n `U \\Upsilon `C \\Chi" +\."\n `Y \\Psi `W \\Omega" +\."\n `( \\subset `) \\Subset" +\."\n `= \\equiv =~ \\approx" +\."\n `- \\bigcap `+ \\bigcup" +\."\n `. \\cdot `* \\times" +\."\n `\\ \\setminus `@ \\circ" +\."\n `& \\wedge `, \\nonumber" +\."\n `8 \\infty `_ \\bar{}" +\."\n `: \\ddot{} `; \\dot{}" +\."\n `^ \\hat{} `~ \\tilde{}" +\."\n `6 \\partial" +" }}} + +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4 diff --git a/ftplugin/tex_latexSuite.vim b/ftplugin/tex_latexSuite.vim new file mode 100644 index 00000000..7ad5acc2 --- /dev/null +++ b/ftplugin/tex_latexSuite.vim @@ -0,0 +1,13 @@ +" LaTeX filetype +" Language: LaTeX (ft=tex) +" Maintainer: Srinath Avadhanula +" Email: srinath@fastmail.fm + +if !exists('s:initLatexSuite') + let s:initLatexSuite = 1 + exec 'so '.fnameescape(expand('<sfile>:p:h').'/latex-suite/main.vim') + + silent! do LatexSuite User LatexSuiteInitPost +endif + +silent! do LatexSuite User LatexSuiteFileType |