diff --git a/build b/build index 86a1ff6..e3fdfca 100755 --- a/build +++ b/build @@ -81,6 +81,7 @@ PACKS=" tpope/vim-git skwp/vim-rspec vim-scripts/vbnet.vim + jcf/vim-latex " download "$PACKS" diff --git a/compiler/tex.vim b/compiler/tex.vim new file mode 100644 index 0000000..d9543ad --- /dev/null +++ b/compiler/tex.vim @@ -0,0 +1,298 @@ +" File: tex.vim +" Type: compiler plugin for LaTeX +" Original Author: Artem Chuprina +" Customization: Srinath Avadhanula +" Description: {{{ +" This file sets the 'makeprg' and 'errorformat' options for the LaTeX +" compiler. It is customizable to optionally ignore certain warnings and +" provides the ability to set a dynamic 'ignore-warning' level. +" +" By default it is set up in a 'non-verbose', 'ignore-common-warnings' mode, +" which means that irrelevant lines from the compilers output will be +" ignored and also some very common warnings are ignored. +" +" Depending on the 'ignore-level', the following kinds of messages are +" ignored. An ignore level of 3 for instance means that messages 1-3 will be +" ignored. By default, the ignore level is set to 4. +" +" 1. LaTeX Warning: Specifier 'h' changed to 't'. +" This errors occurs when TeX is not able to correctly place a floating +" object at a specified location, because of which it defaulted to the +" top of the page. +" 2. LaTeX Warning: Underfull box ... +" 3. LaTeX Warning: Overfull box ... +" both these warnings (very common) are due to \hbox settings not being +" satisfied nicely. +" 4. LaTeX Warning: You have requested ..., +" This warning occurs in slitex when using the xypic package. +" 5. Missing number error: +" Usually, when the name of an included eps file is spelled incorrectly, +" then the \bb-error message is accompanied by a bunch of "missing +" number, treated as zero" error messages. This level ignores these +" warnings. +" NOTE: number 5 is actually a latex error, not a warning! +" +" Use +" TCLevel +" where level is a number to set the ignore level dynamically. +" +" When TCLevel is called with the unquoted string strict +" TClevel strict +" then the 'efm' switches to a 'verbose', 'no-lines-ignored' mode which is +" useful when you want to make final checks of your document and want to be +" careful not to let things slip by. +" +" TIP: MikTeX has a bug where it sometimes erroneously splits a line number +" into multiple lines. i.e, if the warning is on line 1234. the compiler +" output is: +" LaTeX Warning: ... on input line 123 +" 4. +" In this case, vim will wrongly interpret the line-number as 123 instead +" of 1234. If you have cygwin, a simple remedy around this is to first +" copy the file vimlatex (provided) into your $PATH, make sure its +" executable and then set the variable g:tex_flavor to vimlatex in your +" ~/.vimrc (i.e putting let "g:tex_flavor = 'vimlatex'" in your .vimrc). +" This problem occurs rarely enough that its not a botheration for most +" people. +" +" TODO: +" 1. menu items for dynamically selecting a ignore warning level. +" }}} + +" avoid reinclusion for the same buffer. keep it buffer local so it can be +" externally reset in case of emergency re-sourcing. +if exists('b:doneTexCompiler') && !exists('b:forceRedoTexCompiler') + finish +endif +let b:doneTexCompiler = 1 + +" ============================================================================== +" Customization of 'efm': {{{ +" This section contains the customization variables which the user can set. +" g:Tex_IgnoredWarnings: This variable contains a ยก seperated list of +" patterns which will be ignored in the TeX compiler's output. Use this +" carefully, otherwise you might end up losing valuable information. +if !exists('g:Tex_IgnoredWarnings') + let g:Tex_IgnoredWarnings = + \'Underfull'."\n". + \'Overfull'."\n". + \'specifier changed to'."\n". + \'You have requested'."\n". + \'Missing number, treated as zero.'."\n". + \'There were undefined references'."\n". + \'Citation %.%# undefined' +endif +" This is the number of warnings in the g:Tex_IgnoredWarnings string which +" will be ignored. +if !exists('g:Tex_IgnoreLevel') + let g:Tex_IgnoreLevel = 7 +endif +" There will be lots of stuff in a typical compiler output which will +" completely fall through the 'efm' parsing. This options sets whether or not +" you will be shown those lines. +if !exists('g:Tex_IgnoreUnmatched') + let g:Tex_IgnoreUnmatched = 1 +endif +" With all this customization, there is a slight risk that you might be +" ignoring valid warnings or errors. Therefore before getting the final copy +" of your work, you might want to reset the 'efm' with this variable set to 1. +" With that value, all the lines from the compiler are shown irrespective of +" whether they match the error or warning patterns. +" NOTE: An easier way of resetting the 'efm' to show everything is to do +" TCLevel strict +if !exists('g:Tex_ShowallLines') + let g:Tex_ShowallLines = 0 +endif + +" }}} +" ============================================================================== +" Customization of 'makeprg': {{{ + +" There are several alternate ways in which 'makeprg' is set up. +" +" Case 1 +" ------ +" The first is when this file is a part of latex-suite. In this case, a +" variable called g:Tex_DefaultTargetFormat exists, which gives the default +" format .tex files should be compiled into. In this case, we use the TTarget +" command provided by latex-suite. +" +" Case 2 +" ------ +" The user is using this file without latex-suite AND he wants to directly +" specify the complete 'makeprg'. Then he should set the g:Tex_CompileRule_dvi +" variable. This is a string which should be directly be able to be cast into +" &makeprg. An example of one such string is: +" +" g:Tex_CompileRule_dvi = 'pdflatex \\nonstopmode \\input\{$*\}' +" +" NOTE: You will need to escape back-slashes, {'s etc yourself if you are +" using this file independently of latex-suite. +" TODO: Should we also have a check for backslash escaping here based on +" platform? +" +" Case 3 +" ------ +" The use is using this file without latex-suite and he doesnt want any +" customization. In this case, this file makes some intelligent guesses based +" on the platform. If he doesn't want to specify the complete 'makeprg' but +" only the name of the compiler program (for example 'pdflatex' or 'latex'), +" then he sets b:tex_flavor or g:tex_flavor. + +if exists('g:Tex_DefaultTargetFormat') + exec 'TTarget '.g:Tex_DefaultTargetFormat +elseif exists('g:Tex_CompileRule_dvi') + let &l:makeprg = g:Tex_CompileRule_dvi +else + " If buffer-local variable 'tex_flavor' exists, it defines TeX flavor, + " otherwize the same for global variable with same name, else it will be LaTeX + if exists("b:tex_flavor") + let current_compiler = b:tex_flavor + elseif exists("g:tex_flavor") + let current_compiler = g:tex_flavor + else + let current_compiler = "latex" + end + if has('win32') + let escChars = '' + else + let escChars = '{}\' + endif + " Furthermore, if 'win32' is detected, then we want to set the arguments up so + " that miktex can handle it. + if has('win32') + let options = '--src-specials' + else + let options = '' + endif + let &l:makeprg = current_compiler . ' ' . options . + \ escape(' \nonstopmode \input{$*}', escChars) +endif + +" }}} +" ============================================================================== +" Functions for setting up a customized 'efm' {{{ + +" IgnoreWarnings: parses g:Tex_IgnoredWarnings for message customization {{{ +" Description: +function! IgnoreWarnings() + let i = 1 + while s:Strntok(g:Tex_IgnoredWarnings, "\n", i) != '' && + \ i <= g:Tex_IgnoreLevel + let warningPat = s:Strntok(g:Tex_IgnoredWarnings, "\n", i) + let warningPat = escape(substitute(warningPat, '[\,]', '%\\\\&', 'g'), ' ') + exe 'setlocal efm+=%-G%.%#'.warningPat.'%.%#' + let i = i + 1 + endwhile +endfunction + +" }}} +" SetLatexEfm: sets the 'efm' for the latex compiler {{{ +" Description: +function! SetLatexEfm() + + let pm = ( g:Tex_ShowallLines == 1 ? '+' : '-' ) + + setlocal efm= + " remove default error formats that cause issues with revtex, where they + " match version messages + " Reference: http://bugs.debian.org/582100 + setlocal efm-=%f:%l:%m + setlocal efm-=%f:%l:%c:%m + + if !g:Tex_ShowallLines + call s:IgnoreWarnings() + endif + + setlocal efm+=%E!\ LaTeX\ %trror:\ %m + setlocal efm+=%E!\ %m + setlocal efm+=%E%f:%l:\ %m + + setlocal efm+=%+WLaTeX\ %.%#Warning:\ %.%#line\ %l%.%# + setlocal efm+=%+W%.%#\ at\ lines\ %l--%*\\d + setlocal efm+=%+WLaTeX\ %.%#Warning:\ %m + + exec 'setlocal efm+=%'.pm.'Cl.%l\ %m' + exec 'setlocal efm+=%'.pm.'Cl.%l\ ' + exec 'setlocal efm+=%'.pm.'C\ \ %m' + exec 'setlocal efm+=%'.pm.'C%.%#-%.%#' + exec 'setlocal efm+=%'.pm.'C%.%#[]%.%#' + exec 'setlocal efm+=%'.pm.'C[]%.%#' + exec 'setlocal efm+=%'.pm.'C%.%#%[{}\\]%.%#' + exec 'setlocal efm+=%'.pm.'C<%.%#>%m' + exec 'setlocal efm+=%'.pm.'C\ \ %m' + exec 'setlocal efm+=%'.pm.'GSee\ the\ LaTeX%m' + exec 'setlocal efm+=%'.pm.'GType\ \ H\ %m' + exec 'setlocal efm+=%'.pm.'G\ ...%.%#' + exec 'setlocal efm+=%'.pm.'G%.%#\ (C)\ %.%#' + exec 'setlocal efm+=%'.pm.'G(see\ the\ transcript%.%#)' + exec 'setlocal efm+=%'.pm.'G\\s%#' + exec 'setlocal efm+=%'.pm.'O(%*[^()])%r' + exec 'setlocal efm+=%'.pm.'P(%f%r' + exec 'setlocal efm+=%'.pm.'P\ %\\=(%f%r' + exec 'setlocal efm+=%'.pm.'P%*[^()](%f%r' + exec 'setlocal efm+=%'.pm.'P(%f%*[^()]' + exec 'setlocal efm+=%'.pm.'P[%\\d%[^()]%#(%f%r' + if g:Tex_IgnoreUnmatched && !g:Tex_ShowallLines + setlocal efm+=%-P%*[^()] + endif + exec 'setlocal efm+=%'.pm.'Q)%r' + exec 'setlocal efm+=%'.pm.'Q%*[^()])%r' + exec 'setlocal efm+=%'.pm.'Q[%\\d%*[^()])%r' + if g:Tex_IgnoreUnmatched && !g:Tex_ShowallLines + setlocal efm+=%-Q%*[^()] + endif + if g:Tex_IgnoreUnmatched && !g:Tex_ShowallLines + setlocal efm+=%-G%.%# + endif + +endfunction + +" }}} +" Strntok: extract the n^th token from a list {{{ +" example: Strntok('1,23,3', ',', 2) = 23 +fun! Strntok(s, tok, n) + return matchstr( a:s.a:tok[0], '\v(\zs([^'.a:tok.']*)\ze['.a:tok.']){'.a:n.'}') +endfun + +" }}} +" SetTexCompilerLevel: sets the "level" for the latex compiler {{{ +function! SetTexCompilerLevel(...) + if a:0 > 0 + let level = a:1 + else + call Tex_ResetIncrementNumber(0) + echo substitute(g:Tex_IgnoredWarnings, + \ '^\|\n\zs\S', '\=Tex_IncrementNumber(1)." ".submatch(0)', 'g') + let level = input("\nChoose an ignore level: ") + if level == '' + return + endif + endif + if level == 'strict' + let g:Tex_ShowallLines = 1 + elseif level =~ '^\d\+$' + let g:Tex_ShowallLines = 0 + let g:Tex_IgnoreLevel = level + else + echoerr "SetTexCompilerLevel: Unkwown option [".level."]" + end + call s:SetLatexEfm() +endfunction + +com! -nargs=? TCLevel :call SetTexCompilerLevel() +" }}} + +" }}} +" ============================================================================== + +call s:SetLatexEfm() + +if !exists('*Tex_Debug') + function! Tex_Debug(...) + endfunction +endif + +call Tex_Debug("compiler/tex.vim: sourcing this file", "comp") + +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4 diff --git a/ftplugin/bib_latexSuite.vim b/ftplugin/bib_latexSuite.vim new file mode 100644 index 0000000..7a8d47d --- /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 0000000..2cc8199 --- /dev/null +++ b/ftplugin/latex-suite/bibtex.vim @@ -0,0 +1,265 @@ +"============================================================================= +" File: bibtex.vim +" Function: BibT +" Author: Alan G Isaac +" 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', "\=BibT('', '', 0)\", 'bib') +call IMAP ('BBL', "\=BibT('', 'o', 0)\", 'bib') +call IMAP ('BBH', "\=BibT('', 'O', 0)\", 'bib') +call IMAP ('BBX', "\=BibT('', 'Ox', 0)\", '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 0000000..e1d69ae --- /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: +" . encloses the previous character in \mathbf{} +" . 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{} +" . is also polymorphic as follows: +" If the character before typing is one of '([{| \left(\right +" similarly for [, | +" { \left\{\right\} +" 2. < \langle\rangle +" 3. q \lefteqn{} +" otherwise insert \label{} +" . 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 "\\\mathbf{\}" +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 "\".'\mathcal{'.toupper(char).'}' + else + return IMAP_PutTextWithMovement('\cite{<++>}<++>') + endif +endfunction +" }}} +" Tex_LeftRight: maps in insert mode. {{{ +" Description: +" This is a polymorphic function, which maps the behaviour of in the +" following way: +" If the character before typing is one of '([{| \left(<++>\right<++> +" similarly for [, | +" { \left\{<++>\right\}<++> +" 2. < \langle<++>\rangle<++> +" 3. q \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 "\".IMAP_PutTextWithMovement('\left'.add.char.'<++>\right'.add.rhs.'<++>') + elseif char == '<' + return "\".IMAP_PutTextWithMovement('\langle <++>\rangle<++>') + elseif char == 'q' + return "\".IMAP_PutTextWithMovement('\lefteqn{<++>}<++>') + else + return IMAP_PutTextWithMovement('\label{<++>}<++>') + endif +endfunction " }}} +" Tex_PutLeftRight: maps 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\\\l%iright\\\l%" + elseif char == '}' + exe "normal iright\\\l%ileft\\\l%" + endif + elseif char =~ '\[\|(' + exe "normal i\\left\l%i\\right\l%" + elseif char =~ '\]\|)' + exe "normal i\\right\l%i\\left\l%" + endif +endfunction " }}} + +" Provide 'd mapping for easy user customization. {{{ +inoremap Tex_MathBF =Tex_MathBF() +inoremap Tex_MathCal =Tex_MathCal() +inoremap Tex_LeftRight =Tex_LeftRight() +vnoremap Tex_MathBF `>a}` +vnoremap Tex_MathCal `>a}` +nnoremap Tex_LeftRight :call Tex_PutLeftRight() + +" }}} +" Tex_SetBracketingMaps: create mappings for the current buffer {{{ +function! Tex_SetBracketingMaps() + + call Tex_MakeMap('', 'Tex_MathBF', 'i', ' ') + call Tex_MakeMap('', 'Tex_MathCal', 'i', ' ') + call Tex_MakeMap('', 'Tex_LeftRight', 'i', ' ') + call Tex_MakeMap('', 'Tex_MathBF', 'v', ' ') + call Tex_MakeMap('', 'Tex_MathCal', 'v', ' ') + call Tex_MakeMap('', 'Tex_LeftRight', 'n', ' ') + +endfunction +" }}} + +augroup LatexSuite + au LatexSuite User LatexSuiteFileType + \ call Tex_Debug('brackets.vim: Catching LatexSuiteFileType event', 'brak') | + \ call 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 0000000..28213fa --- /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', ) +com! -nargs=1 TVTarget :call Tex_SetTeXCompilerTarget('View', ) +com! -nargs=? TTarget :call SetTeXTarget() + +" }}} +" 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 j j:call Tex_UpdatePreviewWindow("'.mfnlog.'")' + exe 'nnoremap k k:call Tex_UpdatePreviewWindow("'.mfnlog.'")' + exe 'nnoremap :call Tex_UpdatePreviewWindow("'.mfnlog.'")' + exe 'nnoremap :call Tex_UpdatePreviewWindow("'.mfnlog.'")' + endif + exe 'nnoremap :call Tex_GotoErrorLocation("'.mfnlog.'")' + + 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! \" + " 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\" + 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."\" + + 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! Tex_SetCompilerMaps() + if exists('b:Tex_doneCompilerMaps') + return + endif + let s:ml = '' + + nnoremap Tex_Compile :call Tex_RunLaTeX() + vnoremap Tex_Compile :call Tex_PartCompile() + nnoremap Tex_View :call Tex_ViewLaTeX() + nnoremap Tex_ForwardSearch :call Tex_ForwardSearchLaTeX() + + call Tex_MakeMap(s:ml."ll", "Tex_Compile", 'n', '') + call Tex_MakeMap(s:ml."ll", "Tex_Compile", 'v', '') + call Tex_MakeMap(s:ml."lv", "Tex_View", 'n', '') + call Tex_MakeMap(s:ml."ls", "Tex_ForwardSearch", 'n', '') +endfunction +" }}} + +augroup LatexSuite + au LatexSuite User LatexSuiteFileType + \ call Tex_Debug('compiler.vim: Catching LatexSuiteFileType event', 'comp') | + \ call Tex_SetCompilerMaps() +augroup END + +command! -nargs=0 -range=% TPartCompile :, 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 0000000..a8482ab --- /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(':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! SetCustomMacrosMenu() + let flist = Tex_FindInRtp('', 'macros') + exe 'amenu '.g:Tex_MacrosMenuLocation.'&New :call NewMacro("FFFromMMMenu")' + exe 'amenu '.g:Tex_MacrosMenuLocation.'&Redraw :call RedrawMacro()' + + let i = 1 + while 1 + let fname = Tex_Strntok(flist, ',', i) + if fname == '' + break + endif + exe "amenu ".g:Tex_MacrosMenuLocation."&Delete.&".i.":".fname." :call DeleteMacro('".fname."')" + exe "amenu ".g:Tex_MacrosMenuLocation."&Edit.&".i.":".fname." :call EditMacro('".fname."')" + exe "imenu ".g:Tex_MacrosMenuLocation."&".i.":".fname." =ReadMacro('".fname."')" + exe "nmenu ".g:Tex_MacrosMenuLocation."&".i.":".fname." i=ReadMacro('".fname."')" + let i = i + 1 + endwhile +endfunction + +if g:Tex_Menus + call SetCustomMacrosMenu() +endif + +" }}} +" NewMacro: opens new file in macros directory {{{ +function! 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 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! 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! 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! 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\\"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 NewMacro() + +" This macros had to have 2 versions: +if v:version >= 602 + com! -complete=custom,Tex_CompleteMacroName -nargs=? TMacro + \ :let s:retVal = ReadMacro() normal! i=s:retVal + com! -complete=custom,Tex_CompleteMacroName -nargs=? TMacroEdit + \ :call EditMacro() + com! -complete=custom,Tex_CompleteMacroName -nargs=? TMacroDelete + \ :call DeleteMacro() + + " 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 = ReadMacro() normal! i=s:retVal + com! -nargs=? TMacroEdit :call EditMacro() + com! -nargs=? TMacroDelete :call DeleteMacro() + +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 0000000..616d30a --- /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 0000000..132291a --- /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