From 1c019761dfaf6be82de9284fa5e2b9dbfbdec27d Mon Sep 17 00:00:00 2001 From: Ryan Kavanagh Date: Sun, 14 Aug 2011 17:16:55 -0400 Subject: Initial import --- .vim/ftplugin/bib_latexSuite.vim | 16 + .vim/ftplugin/c.vim | 294 +++++ .vim/ftplugin/cpp.vim | 164 +++ .vim/ftplugin/gpg.vim | 33 + .vim/ftplugin/haskell.vim | 13 + .vim/ftplugin/haskell_doc.vim | 817 ++++++++++++++ .vim/ftplugin/haskell_hpaste.vim | 79 ++ .vim/ftplugin/latex-suite/bibtex.vim | 266 +++++ .vim/ftplugin/latex-suite/bibtools.py | 221 ++++ .vim/ftplugin/latex-suite/bibtools.pyc | Bin 0 -> 7004 bytes .vim/ftplugin/latex-suite/brackets.vim | 145 +++ .vim/ftplugin/latex-suite/compiler.vim | 820 ++++++++++++++ .vim/ftplugin/latex-suite/custommacros.vim | 257 +++++ .vim/ftplugin/latex-suite/diacritics.vim | 124 +++ .vim/ftplugin/latex-suite/dictionaries/SIunits | 289 +++++ .vim/ftplugin/latex-suite/dictionaries/dictionary | 677 ++++++++++++ .vim/ftplugin/latex-suite/elementmacros.vim | 338 ++++++ .vim/ftplugin/latex-suite/envmacros.vim | 1167 ++++++++++++++++++++ .vim/ftplugin/latex-suite/folding.vim | 393 +++++++ .vim/ftplugin/latex-suite/macros/example | 11 + .vim/ftplugin/latex-suite/main.vim | 1024 +++++++++++++++++ .vim/ftplugin/latex-suite/mathmacros-utf.vim | 729 ++++++++++++ .vim/ftplugin/latex-suite/mathmacros.vim | 730 ++++++++++++ .vim/ftplugin/latex-suite/multicompile.vim | 17 + .vim/ftplugin/latex-suite/outline.py | 186 ++++ .vim/ftplugin/latex-suite/outline.pyc | Bin 0 -> 4324 bytes .vim/ftplugin/latex-suite/packages.vim | 669 +++++++++++ .vim/ftplugin/latex-suite/packages/SIunits | 315 ++++++ .vim/ftplugin/latex-suite/packages/accents | 28 + .vim/ftplugin/latex-suite/packages/acromake | 10 + .vim/ftplugin/latex-suite/packages/afterpage | 10 + .vim/ftplugin/latex-suite/packages/alltt | 12 + .vim/ftplugin/latex-suite/packages/amsmath | 106 ++ .vim/ftplugin/latex-suite/packages/amsthm | 21 + .vim/ftplugin/latex-suite/packages/amsxtra | 12 + .vim/ftplugin/latex-suite/packages/arabic | 10 + .vim/ftplugin/latex-suite/packages/array | 17 + .vim/ftplugin/latex-suite/packages/babel | 98 ++ .vim/ftplugin/latex-suite/packages/bar | 27 + .vim/ftplugin/latex-suite/packages/bm | 10 + .vim/ftplugin/latex-suite/packages/bophook | 12 + .vim/ftplugin/latex-suite/packages/boxedminipage | 10 + .vim/ftplugin/latex-suite/packages/caption2 | 43 + .vim/ftplugin/latex-suite/packages/cases | 12 + .vim/ftplugin/latex-suite/packages/ccaption | 20 + .vim/ftplugin/latex-suite/packages/changebar | 35 + .vim/ftplugin/latex-suite/packages/chapterbib | 24 + .vim/ftplugin/latex-suite/packages/cite | 32 + .vim/ftplugin/latex-suite/packages/color | 43 + .vim/ftplugin/latex-suite/packages/comma | 12 + .vim/ftplugin/latex-suite/packages/deleq | 36 + .vim/ftplugin/latex-suite/packages/drftcite | 29 + .vim/ftplugin/latex-suite/packages/dropping | 12 + .vim/ftplugin/latex-suite/packages/enumerate | 10 + .vim/ftplugin/latex-suite/packages/eqlist | 19 + .vim/ftplugin/latex-suite/packages/eqparbox | 12 + .vim/ftplugin/latex-suite/packages/everyshi | 10 + .vim/ftplugin/latex-suite/packages/exmpl | 55 + .vim/ftplugin/latex-suite/packages/flafter | 10 + .vim/ftplugin/latex-suite/packages/float | 16 + .vim/ftplugin/latex-suite/packages/floatflt | 12 + .vim/ftplugin/latex-suite/packages/fn2end | 10 + .vim/ftplugin/latex-suite/packages/footmisc | 21 + .vim/ftplugin/latex-suite/packages/geometry | 93 ++ .vim/ftplugin/latex-suite/packages/german | 12 + .vim/ftplugin/latex-suite/packages/graphicx | 69 ++ .vim/ftplugin/latex-suite/packages/graphpap | 10 + .vim/ftplugin/latex-suite/packages/harpoon | 18 + .vim/ftplugin/latex-suite/packages/hhline | 21 + .vim/ftplugin/latex-suite/packages/histogram | 13 + .vim/ftplugin/latex-suite/packages/hyperref | 167 +++ .vim/ftplugin/latex-suite/packages/ifthen | 21 + .vim/ftplugin/latex-suite/packages/inputenc | 29 + .vim/ftplugin/latex-suite/packages/letterspace | 10 + .vim/ftplugin/latex-suite/packages/lineno | 60 + .vim/ftplugin/latex-suite/packages/longtable | 35 + .vim/ftplugin/latex-suite/packages/lscape | 10 + .vim/ftplugin/latex-suite/packages/manyfoot | 15 + .vim/ftplugin/latex-suite/packages/moreverb | 28 + .vim/ftplugin/latex-suite/packages/multibox | 10 + .vim/ftplugin/latex-suite/packages/multicol | 21 + .vim/ftplugin/latex-suite/packages/newalg | 26 + .vim/ftplugin/latex-suite/packages/ngerman | 10 + .vim/ftplugin/latex-suite/packages/numprint | 18 + .vim/ftplugin/latex-suite/packages/oldstyle | 12 + .vim/ftplugin/latex-suite/packages/outliner | 19 + .vim/ftplugin/latex-suite/packages/overcite | 34 + .vim/ftplugin/latex-suite/packages/parallel | 15 + .vim/ftplugin/latex-suite/packages/plain | 10 + .vim/ftplugin/latex-suite/packages/plates | 16 + .vim/ftplugin/latex-suite/packages/polski | 165 +++ .vim/ftplugin/latex-suite/packages/psgo | 27 + .vim/ftplugin/latex-suite/packages/schedule | 20 + .vim/ftplugin/latex-suite/packages/textfit | 12 + .vim/ftplugin/latex-suite/packages/times | 10 + .vim/ftplugin/latex-suite/packages/tipa | 364 ++++++ .vim/ftplugin/latex-suite/packages/ulem | 21 + .vim/ftplugin/latex-suite/packages/url | 24 + .vim/ftplugin/latex-suite/packages/verbatim | 18 + .vim/ftplugin/latex-suite/packages/version | 12 + .vim/ftplugin/latex-suite/projecttemplate.vim | 11 + .vim/ftplugin/latex-suite/pytools.py | 52 + .vim/ftplugin/latex-suite/smartspace.vim | 102 ++ .vim/ftplugin/latex-suite/templates.vim | 149 +++ .vim/ftplugin/latex-suite/templates/IEEEtran.tex | 142 +++ .vim/ftplugin/latex-suite/templates/article.tex | 9 + .vim/ftplugin/latex-suite/templates/report.tex | 9 + .../latex-suite/templates/report_two_column.tex | 9 + .vim/ftplugin/latex-suite/texmenuconf.vim | 131 +++ .vim/ftplugin/latex-suite/texproject.vim | 54 + .vim/ftplugin/latex-suite/texrc | 738 +++++++++++++ .vim/ftplugin/latex-suite/texviewer.vim | 1052 ++++++++++++++++++ .vim/ftplugin/latex-suite/version.vim | 30 + .vim/ftplugin/latex-suite/wizardfuncs.vim | 377 +++++++ .vim/ftplugin/pythoncomplete.vim | 625 +++++++++++ .vim/ftplugin/tex.vim | 10 + .vim/ftplugin/tex_latexSuite.vim | 13 + 117 files changed, 15638 insertions(+) create mode 100644 .vim/ftplugin/bib_latexSuite.vim create mode 100644 .vim/ftplugin/c.vim create mode 100644 .vim/ftplugin/cpp.vim create mode 100644 .vim/ftplugin/gpg.vim create mode 100644 .vim/ftplugin/haskell.vim create mode 100644 .vim/ftplugin/haskell_doc.vim create mode 100644 .vim/ftplugin/haskell_hpaste.vim create mode 100644 .vim/ftplugin/latex-suite/bibtex.vim create mode 100644 .vim/ftplugin/latex-suite/bibtools.py create mode 100644 .vim/ftplugin/latex-suite/bibtools.pyc create mode 100644 .vim/ftplugin/latex-suite/brackets.vim create mode 100644 .vim/ftplugin/latex-suite/compiler.vim create mode 100644 .vim/ftplugin/latex-suite/custommacros.vim create mode 100644 .vim/ftplugin/latex-suite/diacritics.vim create mode 100644 .vim/ftplugin/latex-suite/dictionaries/SIunits create mode 100644 .vim/ftplugin/latex-suite/dictionaries/dictionary create mode 100644 .vim/ftplugin/latex-suite/elementmacros.vim create mode 100644 .vim/ftplugin/latex-suite/envmacros.vim create mode 100644 .vim/ftplugin/latex-suite/folding.vim create mode 100644 .vim/ftplugin/latex-suite/macros/example create mode 100644 .vim/ftplugin/latex-suite/main.vim create mode 100644 .vim/ftplugin/latex-suite/mathmacros-utf.vim create mode 100644 .vim/ftplugin/latex-suite/mathmacros.vim create mode 100644 .vim/ftplugin/latex-suite/multicompile.vim create mode 100644 .vim/ftplugin/latex-suite/outline.py create mode 100644 .vim/ftplugin/latex-suite/outline.pyc create mode 100644 .vim/ftplugin/latex-suite/packages.vim create mode 100644 .vim/ftplugin/latex-suite/packages/SIunits create mode 100644 .vim/ftplugin/latex-suite/packages/accents create mode 100644 .vim/ftplugin/latex-suite/packages/acromake create mode 100644 .vim/ftplugin/latex-suite/packages/afterpage create mode 100644 .vim/ftplugin/latex-suite/packages/alltt create mode 100644 .vim/ftplugin/latex-suite/packages/amsmath create mode 100644 .vim/ftplugin/latex-suite/packages/amsthm create mode 100644 .vim/ftplugin/latex-suite/packages/amsxtra create mode 100644 .vim/ftplugin/latex-suite/packages/arabic create mode 100644 .vim/ftplugin/latex-suite/packages/array create mode 100644 .vim/ftplugin/latex-suite/packages/babel create mode 100644 .vim/ftplugin/latex-suite/packages/bar create mode 100644 .vim/ftplugin/latex-suite/packages/bm create mode 100644 .vim/ftplugin/latex-suite/packages/bophook create mode 100644 .vim/ftplugin/latex-suite/packages/boxedminipage create mode 100644 .vim/ftplugin/latex-suite/packages/caption2 create mode 100644 .vim/ftplugin/latex-suite/packages/cases create mode 100644 .vim/ftplugin/latex-suite/packages/ccaption create mode 100644 .vim/ftplugin/latex-suite/packages/changebar create mode 100644 .vim/ftplugin/latex-suite/packages/chapterbib create mode 100644 .vim/ftplugin/latex-suite/packages/cite create mode 100644 .vim/ftplugin/latex-suite/packages/color create mode 100644 .vim/ftplugin/latex-suite/packages/comma create mode 100644 .vim/ftplugin/latex-suite/packages/deleq create mode 100644 .vim/ftplugin/latex-suite/packages/drftcite create mode 100644 .vim/ftplugin/latex-suite/packages/dropping create mode 100644 .vim/ftplugin/latex-suite/packages/enumerate create mode 100644 .vim/ftplugin/latex-suite/packages/eqlist create mode 100644 .vim/ftplugin/latex-suite/packages/eqparbox create mode 100644 .vim/ftplugin/latex-suite/packages/everyshi create mode 100644 .vim/ftplugin/latex-suite/packages/exmpl create mode 100644 .vim/ftplugin/latex-suite/packages/flafter create mode 100644 .vim/ftplugin/latex-suite/packages/float create mode 100644 .vim/ftplugin/latex-suite/packages/floatflt create mode 100644 .vim/ftplugin/latex-suite/packages/fn2end create mode 100644 .vim/ftplugin/latex-suite/packages/footmisc create mode 100644 .vim/ftplugin/latex-suite/packages/geometry create mode 100644 .vim/ftplugin/latex-suite/packages/german create mode 100644 .vim/ftplugin/latex-suite/packages/graphicx create mode 100644 .vim/ftplugin/latex-suite/packages/graphpap create mode 100644 .vim/ftplugin/latex-suite/packages/harpoon create mode 100644 .vim/ftplugin/latex-suite/packages/hhline create mode 100644 .vim/ftplugin/latex-suite/packages/histogram create mode 100644 .vim/ftplugin/latex-suite/packages/hyperref create mode 100644 .vim/ftplugin/latex-suite/packages/ifthen create mode 100644 .vim/ftplugin/latex-suite/packages/inputenc create mode 100644 .vim/ftplugin/latex-suite/packages/letterspace create mode 100644 .vim/ftplugin/latex-suite/packages/lineno create mode 100644 .vim/ftplugin/latex-suite/packages/longtable create mode 100644 .vim/ftplugin/latex-suite/packages/lscape create mode 100644 .vim/ftplugin/latex-suite/packages/manyfoot create mode 100644 .vim/ftplugin/latex-suite/packages/moreverb create mode 100644 .vim/ftplugin/latex-suite/packages/multibox create mode 100644 .vim/ftplugin/latex-suite/packages/multicol create mode 100644 .vim/ftplugin/latex-suite/packages/newalg create mode 100644 .vim/ftplugin/latex-suite/packages/ngerman create mode 100644 .vim/ftplugin/latex-suite/packages/numprint create mode 100644 .vim/ftplugin/latex-suite/packages/oldstyle create mode 100644 .vim/ftplugin/latex-suite/packages/outliner create mode 100644 .vim/ftplugin/latex-suite/packages/overcite create mode 100644 .vim/ftplugin/latex-suite/packages/parallel create mode 100644 .vim/ftplugin/latex-suite/packages/plain create mode 100644 .vim/ftplugin/latex-suite/packages/plates create mode 100644 .vim/ftplugin/latex-suite/packages/polski create mode 100644 .vim/ftplugin/latex-suite/packages/psgo create mode 100644 .vim/ftplugin/latex-suite/packages/schedule create mode 100644 .vim/ftplugin/latex-suite/packages/textfit create mode 100644 .vim/ftplugin/latex-suite/packages/times create mode 100644 .vim/ftplugin/latex-suite/packages/tipa create mode 100644 .vim/ftplugin/latex-suite/packages/ulem create mode 100644 .vim/ftplugin/latex-suite/packages/url create mode 100644 .vim/ftplugin/latex-suite/packages/verbatim create mode 100644 .vim/ftplugin/latex-suite/packages/version create mode 100644 .vim/ftplugin/latex-suite/projecttemplate.vim create mode 100644 .vim/ftplugin/latex-suite/pytools.py create mode 100644 .vim/ftplugin/latex-suite/smartspace.vim create mode 100644 .vim/ftplugin/latex-suite/templates.vim create mode 100644 .vim/ftplugin/latex-suite/templates/IEEEtran.tex create mode 100644 .vim/ftplugin/latex-suite/templates/article.tex create mode 100644 .vim/ftplugin/latex-suite/templates/report.tex create mode 100644 .vim/ftplugin/latex-suite/templates/report_two_column.tex create mode 100644 .vim/ftplugin/latex-suite/texmenuconf.vim create mode 100644 .vim/ftplugin/latex-suite/texproject.vim create mode 100644 .vim/ftplugin/latex-suite/texrc create mode 100644 .vim/ftplugin/latex-suite/texviewer.vim create mode 100644 .vim/ftplugin/latex-suite/version.vim create mode 100644 .vim/ftplugin/latex-suite/wizardfuncs.vim create mode 100644 .vim/ftplugin/pythoncomplete.vim create mode 100644 .vim/ftplugin/tex.vim create mode 100644 .vim/ftplugin/tex_latexSuite.vim (limited to '.vim/ftplugin') diff --git a/.vim/ftplugin/bib_latexSuite.vim b/.vim/ftplugin/bib_latexSuite.vim new file mode 100644 index 0000000..6b803af --- /dev/null +++ b/.vim/ftplugin/bib_latexSuite.vim @@ -0,0 +1,16 @@ +" 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. +" +" CVS: $Id: bib_latexSuite.vim 997 2006-03-20 09:45:45Z srinathava $ + +" 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/.vim/ftplugin/c.vim b/.vim/ftplugin/c.vim new file mode 100644 index 0000000..ff5a637 --- /dev/null +++ b/.vim/ftplugin/c.vim @@ -0,0 +1,294 @@ +" Vim filetype plugin file +" +" Language : C / C++ +" Plugin : c.vim (version 5.0) +" Maintainer : Fritz Mehner +" Revision : $Id: c.vim,v 1.18 2007/11/20 18:12:02 mehner Exp $ +" +" This will enable keyword completion for C and C++ +" using Vim's dictionary feature |i_CTRL-X_CTRL-K|. +" ----------------------------------------------------------------- +" +" Only do this when not done yet for this buffer +" +if exists("b:did_C_ftplugin") + finish +endif +let b:did_C_ftplugin = 1 +" +" ---------- C/C++ dictionary ----------------------------------- +" +if exists("g:C_Dictionary_File") + silent! exec 'setlocal dictionary+='.g:C_Dictionary_File +endif +" +" ---------- F-key mappings ------------------------------------ +" +" Alt-F9 write buffer and compile +" F9 compile and link +" Ctrl-F9 run executable +" Shift-F9 command line arguments +" + map :call C_Compile():redraw:call C_HlMessage() +imap :call C_Compile():redraw:call C_HlMessage() +" + map :call C_Link():redraw:call C_HlMessage() +imap :call C_Link():redraw:call C_HlMessage() +" +" seems to be essential here: + map :call C_Run() +imap :call C_Run() +" + map :call C_Arguments() +imap :call C_Arguments() +" +" alternate file plugin +" +"if exists("loaded_alternateFile") +" map :A +"imap :A +"endif +" +" +" ---------- KEY MAPPINGS : MENU ENTRIES ------------------------------------- +" +" ---------- comments menu ------------------------------------------------ +" + + noremap cl :call C_LineEndComment() +inoremap cl :call C_LineEndComment()a +vnoremap cl :call C_MultiLineEndComments() + noremap cj :call C_AdjustLineEndComm("a") +vnoremap cj :call C_AdjustLineEndComm("v") +inoremap cj :call C_AdjustLineEndComm("a")a + noremap cs :call C_GetLineEndCommCol() + noremap c* :call C_CodeComment("a","yes"):nohlsearchj +vnoremap c* :call C_CodeComment("v","yes"):nohlsearchj + noremap c/ :call C_CodeComment("a","no"):nohlsearchj +vnoremap c/ :call C_CodeComment("v","no"):nohlsearchj + noremap co :call C_CommentCode("a"):nohlsearch +vnoremap co :call C_CommentCode("v"):nohlsearch + + noremap cfr :call C_InsertTemplate("comment.frame") + noremap cfu :call C_InsertTemplate("comment.function") + noremap cme :call C_InsertTemplate("comment.method") + noremap ccl :call C_InsertTemplate("comment.class") + +inoremap cfr :call C_InsertTemplate("comment.frame") +inoremap cfu :call C_InsertTemplate("comment.function") +inoremap cme :call C_InsertTemplate("comment.method") +inoremap ccl :call C_InsertTemplate("comment.class") + + noremap cd a=C_InsertDateAndTime('d') +inoremap cd =C_InsertDateAndTime('d') + noremap ct a=C_InsertDateAndTime('dt') +inoremap ct =C_InsertDateAndTime('dt') +" +" ---------- statements menu ------------------------------------------------ +" + noremap sd :call C_InsertTemplate("statements.do-while") +vnoremap sd :call C_InsertTemplate("statements.do-while", "v") +inoremap sd :call C_InsertTemplate("statements.do-while") + + noremap sf :call C_InsertTemplate("statements.for") +inoremap sf :call C_InsertTemplate("statements.for") + + noremap sfo :call C_InsertTemplate("statements.for-block") +vnoremap sfo :call C_InsertTemplate("statements.for-block", "v") +inoremap sfo :call C_InsertTemplate("statements.for-block") + + noremap si :call C_InsertTemplate("statements.if") +inoremap si :call C_InsertTemplate("statements.if") + + noremap sif :call C_InsertTemplate("statements.if-block") +vnoremap sif :call C_InsertTemplate("statements.if-block", "v") +inoremap sif :call C_InsertTemplate("statements.if-block") + + noremap sie :call C_InsertTemplate("statements.if-else") +vnoremap sie :call C_InsertTemplate("statements.if-else", "v") +inoremap sie :call C_InsertTemplate("statements.if-else") + + noremap sife :call C_InsertTemplate("statements.if-block-else") +vnoremap sife :call C_InsertTemplate("statements.if-block-else", "v") +inoremap sife :call C_InsertTemplate("statements.if-block-else") + + noremap sw :call C_InsertTemplate("statements.while") +inoremap sw :call C_InsertTemplate("statements.while") + + noremap swh :call C_InsertTemplate("statements.while-block") +vnoremap swh :call C_InsertTemplate("statements.while-block", "v") +inoremap swh :call C_InsertTemplate("statements.while-block") + + noremap ss :call C_InsertTemplate("statements.switch") +vnoremap ss :call C_InsertTemplate("statements.switch", "v") +inoremap ss :call C_InsertTemplate("statements.switch") + + noremap sc :call C_InsertTemplate("statements.case") +inoremap sc :call C_InsertTemplate("statements.case") + + noremap s{ :call C_InsertTemplate("statements.block") +vnoremap s{ :call C_InsertTemplate("statements.block", "v") +inoremap s{ :call C_InsertTemplate("statements.block") +" +" ---------- preprocessor menu ---------------------------------------------- +" +inoremap p< o#include<> +inoremap p" o#include"" +inoremap pd :call C_InsertTemplate("preprocessor.define") +inoremap pu :call C_InsertTemplate("preprocessor.undefine") +" + noremap p< o#include<> + noremap p" o#include"" + noremap pd :call C_InsertTemplate("preprocessor.define") + noremap pu :call C_InsertTemplate("preprocessor.undefine") + + noremap pie :call C_InsertTemplate("preprocessor.if-else-endif") + noremap pid :call C_InsertTemplate("preprocessor.ifdef-else-endif") + noremap pin :call C_InsertTemplate("preprocessor.ifndef-else-endif") + noremap pind :call C_InsertTemplate("preprocessor.ifndef-def-endif") + noremap pi0 :call C_PPIf0("a")2ji + +vnoremap pie :call C_InsertTemplate("preprocessor.if-else-endif", "v") +vnoremap pid :call C_InsertTemplate("preprocessor.ifdef-else-endif", "v") +vnoremap pin :call C_InsertTemplate("preprocessor.ifndef-else-endif", "v") +vnoremap pind :call C_InsertTemplate("preprocessor.ifndef-def-endif", "v") +vnoremap pi0 :call C_PPIf0("v") + +inoremap pie :call C_InsertTemplate("preprocessor.if-else-endif") +inoremap pid :call C_InsertTemplate("preprocessor.ifdef-else-endif") +inoremap pin :call C_InsertTemplate("preprocessor.ifndef-else-endif") +inoremap pind :call C_InsertTemplate("preprocessor.ifndef-def-endif") +inoremap pi0 :call C_PPIf0("a")2ji + + noremap pr0 :call C_PPIf0Remove() +" +" ---------- idioms menu ---------------------------------------------------- +" + noremap if :call C_InsertTemplate("idioms.function") +vnoremap if :call C_InsertTemplate("idioms.function", "v") +inoremap if :call C_InsertTemplate("idioms.function") + noremap isf :call C_InsertTemplate("idioms.function-static") +vnoremap isf :call C_InsertTemplate("idioms.function-static", "v") +inoremap isf :call C_InsertTemplate("idioms.function-static") + noremap im :call C_InsertTemplate("idioms.main") +vnoremap im :call C_InsertTemplate("idioms.main", "v") +inoremap im :call C_InsertTemplate("idioms.main") +" + noremap i0 :call C_CodeFor("up" , "a")a +vnoremap i0 :call C_CodeFor("up" , "v") +inoremap i0 :call C_CodeFor("up" , "a")a + noremap in :call C_CodeFor("down", "a")a +vnoremap in :call C_CodeFor("down", "v") +inoremap in :call C_CodeFor("down", "a")a +" + noremap ie :call C_InsertTemplate("idioms.enum") +vnoremap ie :call C_InsertTemplate("idioms.enum" , "v") +inoremap ie :call C_InsertTemplate("idioms.enum") + noremap is :call C_InsertTemplate("idioms.struct") +vnoremap is :call C_InsertTemplate("idioms.struct", "v") +inoremap is :call C_InsertTemplate("idioms.struct") + noremap iu :call C_InsertTemplate("idioms.union") +vnoremap iu :call C_InsertTemplate("idioms.union" , "v") +inoremap iu :call C_InsertTemplate("idioms.union") +" + noremap ip oprintf("\n");2F"a +inoremap ip printf("\n");2F"a + noremap isc oscanf("", & );F"i +inoremap isc scanf("", & );F"i +" + noremap ica :call C_InsertTemplate("idioms.calloc") +inoremap ica :call C_InsertTemplate("idioms.calloc") + noremap ima :call C_InsertTemplate("idioms.malloc") +inoremap ima :call C_InsertTemplate("idioms.malloc") +" + noremap isi isizeof() +vnoremap isi ssizeof()P +inoremap isi sizeof() + noremap ias oassert(); +vnoremap ias sassert();F(p +inoremap ias assert(); +" + noremap ii :call C_InsertTemplate("idioms.open-input-file") +inoremap ii :call C_InsertTemplate("idioms.open-input-file") + noremap io :call C_InsertTemplate("idioms.open-output-file") +inoremap io :call C_InsertTemplate("idioms.open-output-file") +" +" ---------- snippet menu ---------------------------------------------------- +" + noremap nr :call C_CodeSnippet("r") + noremap nw :call C_CodeSnippet("w") +vnoremap nw :call C_CodeSnippet("wv") + noremap ne :call C_CodeSnippet("e") +" + noremap np :call C_ProtoPick("n") +vnoremap np :call C_ProtoPick("v") + noremap ni :call C_ProtoInsert() + noremap nc :call C_ProtoClear() + noremap ns :call C_ProtoShow() +" +" ---------- C++ menu ---------------------------------------------------- +" + noremap +m :call C_InsertTemplate("cpp.method-implementation") +inoremap +m :call C_InsertTemplate("cpp.method-implementation") + noremap +c :call C_InsertTemplate("cpp.class") +inoremap +c :call C_InsertTemplate("cpp.class") + noremap +cn :call C_InsertTemplate("cpp.class-using-new") +inoremap +cn :call C_InsertTemplate("cpp.class-using-new") + + noremap +tm :call C_InsertTemplate("cpp.template-method-implementation") +inoremap +tm :call C_InsertTemplate("cpp.template-method-implementation") + noremap +tc :call C_InsertTemplate("cpp.template-class") +inoremap +tc :call C_InsertTemplate("cpp.template-class") + noremap +tcn :call C_InsertTemplate("cpp.template-class-using-new") +inoremap +tcn :call C_InsertTemplate("cpp.template-class-using-new") + + noremap +tf :call C_InsertTemplate("cpp.template-function") +inoremap +tf :call C_InsertTemplate("cpp.template-function") + + noremap +ec :call C_InsertTemplate("cpp.error-class") +inoremap +ec :call C_InsertTemplate("cpp.error-class") + + noremap +tr :call C_InsertTemplate("cpp.try-catch") +vnoremap +tr :call C_InsertTemplate("cpp.try-catch", "v") +inoremap +tr :call C_InsertTemplate("cpp.try-catch") + + noremap +ca :call C_InsertTemplate("cpp.catch") +vnoremap +ca :call C_InsertTemplate("cpp.catch", "v") +inoremap +ca :call C_InsertTemplate("cpp.catch") + + noremap +c. :call C_InsertTemplate("cpp.catch-points") +vnoremap +c. :call C_InsertTemplate("cpp.catch-points", "v") +inoremap +c. :call C_InsertTemplate("cpp.catch-points") +" +" +" ---------- run menu -------------------------------------------------------- +" + map rc :call C_Compile():redraw:call C_HlMessage() + map rl :call C_Link():redraw:call C_HlMessage() + map rr :call C_Run() + map ra :call C_Arguments() + map rm :call C_Make() + map rg :call C_MakeArguments() + map rp :call C_SplintCheck():redraw:call C_HlMessage() + map ri :call C_SplintArguments() + map rd :call C_Indent("a"):redraw:call C_HlMessage() +vmap rd :call C_Indent("v"):redraw:call C_HlMessage() + map rh :call C_Hardcopy("n") +vmap rh :call C_Hardcopy("v") + map rs :call C_Settings() + map rt :call C_RebuildTemplates() + if has("unix") + map rx :call C_XtermSize() + endif + map ro :call C_Toggle_Gvim_Xterm() +" +" Abraxas CodeCheck (R) +" +if executable("check") + map rk :call C_CodeCheck():redraw:call C_HlMessage() + map re :call C_CodeCheckArguments() +endif +" ---------- plugin help ----------------------------------------------------- +" + map h :call C_HelpCsupport() +" diff --git a/.vim/ftplugin/cpp.vim b/.vim/ftplugin/cpp.vim new file mode 100644 index 0000000..79b3445 --- /dev/null +++ b/.vim/ftplugin/cpp.vim @@ -0,0 +1,164 @@ +" Line numbering +set number +" Set syntax highlighting +syntax on +" Tabbing +set et +set shiftwidth=4 +set smarttab +set autoindent +" Complete Brackets { +" +" }" +" Complete quotes" +inoremap " "" +" We want a mouse in consoles, so:" +set mouse=a +" +"=============================================================================== +"========== load example vimrc from the distribution ========================= +"=============================================================================== +" +runtime vimrc_example.vim +" +filetype plugin on +" +"=============================================================================== +"========== CUSTOMIZATION (vimrc) ============================================ +"=============================================================================== +" +" Platform specific items: +" - central backup directory (has to be created) +" - default dictionary +" Uncomment your choice. +if has("win16") || has("win32") || has("win64") || + \ has("win95") || has("win32unix") + " +" runtime mswin.vim +" set backupdir =$VIM\vimfiles\backupdir +" set dictionary=$VIM\vimfiles\wordlists/german.list +else +" set backupdir =$HOME/.vim.backupdir +" set dictionary=$HOME/.vim/wordlists/german.list +endif +" +" Using a backupdir under UNIX/Linux: you may want to include a line similar to +" find $HOME/.vim.backupdir -name "*" -type f -mtime +60 -exec rm -f {} \; +" in one of your shell startup files (e.g. $HOME/.profile) +" +"------------------------------------------------------------------------------- +" Use of dictionaries +"------------------------------------------------------------------------------- +" +set complete+=k " scan the files given with the 'dictionary' option +" +"------------------------------------------------------------------------------- +" Various settings +"------------------------------------------------------------------------------- +" +set autoread " read open files again when changed outside Vim +set autowrite " write a modified buffer on each :next , ... +set browsedir =current " which directory to use for the file browser +set incsearch " use incremental search +"set nowrap " do not wrap lines +set shiftwidth =4 " number of spaces to use for each step of indent +set tabstop =4 " number of spaces that a in the file counts for +set visualbell " visual bell instead of beeping +" +" +"------------------------------------------------------------------------------- +" some additional hot keys +"------------------------------------------------------------------------------- +" F2 - write file without confirmation +" F3 - call file explorer Ex +" F4 - show tag under curser in the preview window (tagfile must exist!) +" F5 - open quickfix error window +" F6 - close quickfix error window +" F7 - display previous error +" F8 - display next error +" S-Tab - Fast switching between buffers (see below) +" C-q - Leave the editor with Ctrl-q (see below) +"------------------------------------------------------------------------------- +" +map :write +map :Explore +nmap :exe ":ptag ".expand("") +map :copen +map :cclose +map :cp +map :cn +" +imap :write +imap :Explore +imap :exe ":ptag ".expand("") +imap :copen +imap :cclose +imap :cp +imap :cn +" +"------------------------------------------------------------------------------- +" Fast switching between buffers +" The current buffer will be saved before switching to the next one. +" Choose :bprevious or :bnext +"------------------------------------------------------------------------------- +" + map :if &modifiable && !&readonly && + \ &modified :write :endif:bprevious +imap :if &modifiable && !&readonly && + \ &modified :write :endif:bprevious +" +"------------------------------------------------------------------------------- +" Leave the editor with Ctrl-q : Write all changed buffers and exit Vim +"------------------------------------------------------------------------------- +nmap :wqa +" +"------------------------------------------------------------------------------- +" autocomplete parenthesis, brackets and braces +"------------------------------------------------------------------------------- +inoremap ( () +inoremap [ [] +inoremap { {}ko +" +vnoremap ( s()P% +vnoremap [ s[]P% +vnoremap { s{}P% +" +"------------------------------------------------------------------------------- +" Change the working directory to the directory containing the current file +"------------------------------------------------------------------------------- +if has("autocmd") + autocmd BufEnter * :lchdir %:p:h +endif " has("autocmd") +" +"------------------------------------------------------------------------------- +" Filename completion +" +" wildmenu : command-line completion operates in an enhanced mode +" wildignore : A file that matches with one of these +" patterns is ignored when completing file or directory names. +"------------------------------------------------------------------------------- +" +set wildmenu +set wildignore=*.bak,*.o,*.e,*~ +" +"------------------------------------------------------------------------------- +" print options (pc = percentage of the media size) +"------------------------------------------------------------------------------- +set printoptions=left:8pc,right:3pc +" +"------------------------------------------------------------------------------- +" taglist.vim : toggle the taglist window +" taglist.vim : define the title texts for make +" taglist.vim : define the title texts for qmake +"------------------------------------------------------------------------------- + noremap :Tlist +inoremap :Tlist + +let tlist_make_settings = 'make;m:makros;t:targets' + +let tlist_qmake_settings = 'qmake;t:SystemVariables' + +if has("autocmd") + " ---------- qmake : set filetype for *.pro ---------- + autocmd BufNewFile,BufRead *.pro set filetype=qmake +endif " has("autocmd") diff --git a/.vim/ftplugin/gpg.vim b/.vim/ftplugin/gpg.vim new file mode 100644 index 0000000..20f641f --- /dev/null +++ b/.vim/ftplugin/gpg.vim @@ -0,0 +1,33 @@ +" Transparent editing of gpg encrypted files. +" By Wouter Hanegraaff +augroup encrypted +au! +" First make sure nothing is written to ~/.viminfo while editing +" an encrypted file. +autocmd BufReadPre,FileReadPre *.gpg set viminfo= +" We don't want a swap file, as it writes unencrypted data to disk +autocmd BufReadPre,FileReadPre *.gpg set noswapfile +" Switch to binary mode to read the encrypted file +autocmd BufReadPre,FileReadPre *.gpg set bin +autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2 +autocmd BufReadPre,FileReadPre *.gpg let shsave=&sh +autocmd BufReadPre,FileReadPre *.gpg let &sh='sh' +autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2 +autocmd BufReadPost,FileReadPost *.gpg '[,']!gpg --decrypt --default-recipient-self 2> /dev/null +autocmd BufReadPost,FileReadPost *.gpg let &sh=shsave +" Switch to normal mode for editing +autocmd BufReadPost,FileReadPost *.gpg set nobin +autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save +autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r") +" Convert all text to encrypted text before writing +autocmd BufWritePre,FileWritePre *.gpg set bin +autocmd BufWritePre,FileWritePre *.gpg let shsave=&sh +autocmd BufWritePre,FileWritePre *.gpg let &sh='sh' +autocmd BufWritePre,FileWritePre *.gpg '[,']!gpg --encrypt --default-recipient-self 2>/dev/null +autocmd BufWritePre,FileWritePre *.gpg let &sh=shsave +" Undo the encryption so we are back in the normal text, directly +" after the file has been written. +autocmd BufWritePost,FileWritePost *.gpg silent u +autocmd BufWritePost,FileWritePost *.gpg set nobin +augroup END + diff --git a/.vim/ftplugin/haskell.vim b/.vim/ftplugin/haskell.vim new file mode 100644 index 0000000..ffe83fe --- /dev/null +++ b/.vim/ftplugin/haskell.vim @@ -0,0 +1,13 @@ +" +" general Haskell source settings +" (shared functions are in autoload/haskellmode.vim) +" +" (Claus Reinke, last modified: 21/04/2009) +" +" part of haskell plugins: http://projects.haskell.org/haskellmode-vim +" please send patches to + +" try gf on import line, or ctrl-x ctrl-i, or [I, [i, .. +set include=^import\\s*\\(qualified\\)\\?\\s* +set includeexpr=substitute(v:fname,'\\.','/','g').'.hs' + diff --git a/.vim/ftplugin/haskell_doc.vim b/.vim/ftplugin/haskell_doc.vim new file mode 100644 index 0000000..f850667 --- /dev/null +++ b/.vim/ftplugin/haskell_doc.vim @@ -0,0 +1,817 @@ +" +" use haddock docs and index files +" show documentation, complete & qualify identifiers +" +" (Claus Reinke; last modified: 24/04/2009) +" +" part of haskell plugins: http://projects.haskell.org/haskellmode-vim +" please send patches to + +" :Doc and :IDoc open haddocks for in opera +" +" :Doc needs qualified name (default Prelude) and package (default base) +" :IDoc needs unqualified name, looks up possible links in g:haddock_index +" +" :DocIndex populates g:haddock_index from haddock's index files +" :ExportDocIndex saves g:haddock_index to cache file +" :ImportDocIndex reloads g:haddock_index from cache file +" +" all the following use the haddock index (g:haddock_index) +" +" _? opens haddocks for unqualified name under cursor, +" suggesting alternative full qualifications in popup menu +" +" _. fully qualifies unqualified name under cursor, +" suggesting alternative full qualifications in popup menu +" +" _i add import () statement for unqualified under cursor, +" _im add import statement for unqualified under cursor, +" suggesting alternative full qualifications in popup menu +" (this currently adds one statement per call, instead of +" merging into existing import statements, but it's a start;-) +" +" CTRL-X CTRL-U (user-defined insert mode completion) +" suggests completions of unqualified names in popup menu + +let s:scriptname = "haskell_doc.vim" + +" script parameters +" g:haddock_browser *mandatory* which browser to call +" g:haddock_browser_callformat [optional] how to call browser +" g:haddock_indexfiledir [optional] where to put 'haddock_index.vim' +" g:haddock_docdir [optional] where to find html docs +" g:ghc [optional] which ghc to call +" g:ghc_pkg [optional] which ghc_pkg to call + +" been here before? +if exists("g:haddock_index") + finish +endif + +" initialise nested dictionary, to be populated +" - from haddock index files via :DocIndex +" - from previous cached version via :ImportDocIndex +let g:haddock_index = {} + +" initialise dictionary, mapping modules with haddocks to their packages, +" populated via MkHaddockModuleIndex() or HaveModuleIndex() +let g:haddock_moduleindex = {} + +" program to open urls, please set this in your vimrc + "examples (for windows): + "let g:haddock_browser = "C:/Program Files/Opera/Opera.exe" + "let g:haddock_browser = "C:/Program Files/Mozilla Firefox/firefox.exe" + "let g:haddock_browser = "C:/Program Files/Internet Explorer/IEXPLORE.exe" +if !exists("g:haddock_browser") + echoerr s:scriptname." WARNING: please set g:haddock_browser!" +endif + +if (!exists("g:ghc") || !executable(g:ghc)) + if !executable('ghc') + echoerr s:scriptname." can't find ghc. please set g:ghc, or extend $PATH" + finish + else + let g:ghc = 'ghc' + endif +endif + +if (!exists("g:ghc_pkg") || !executable(g:ghc_pkg)) + let g:ghc_pkg = substitute(g:ghc,'\(.*\)ghc','\1ghc-pkg','') +endif + +if exists("g:haddock_docdir") && isdirectory(g:haddock_docdir) + let s:docdir = g:haddock_docdir +elseif executable(g:ghc_pkg) +" try to figure out location of html docs +" first choice: where the base docs are (from the first base listed) + let [field;x] = split(system(g:ghc_pkg . ' field base haddock-html'),'\n') + let field = substitute(field,'haddock-html: \(.*\)libraries.base','\1','') + let field = substitute(field,'\\','/','g') + let alternate = substitute(field,'html','doc/html','') + if isdirectory(field) + let s:docdir = field + elseif isdirectory(alternate) + let s:docdir = alternate + endif +else + echoerr s:scriptname." can't find ghc-pkg (set g:ghc_pkg ?)." +endif + +" second choice: try some known suspects for windows/unix +if !exists('s:docdir') || !isdirectory(s:docdir) + let s:ghc_libdir = substitute(system(g:ghc . ' --print-libdir'),'\n','','') + let location1a = s:ghc_libdir . '/doc/html/' + let location1b = s:ghc_libdir . '/doc/' + let s:ghc_version = substitute(system(g:ghc . ' --numeric-version'),'\n','','') + let location2 = '/usr/share/doc/ghc-' . s:ghc_version . '/html/' + if isdirectory(location1a) + let s:docdir = location1a + elseif isdirectory(location1b) + let s:docdir = location1b + elseif isdirectory(location2) + let s:docdir = location2 + else " give up + echoerr s:scriptname." can't find locaton of html documentation (set g:haddock_docdir)." + finish + endif +endif + +" todo: can we turn s:docdir into a list of paths, and +" include docs for third-party libs as well? + +let s:libraries = s:docdir . 'libraries/' +let s:guide = s:docdir . 'users_guide/' +let s:index = 'index.html' +if exists("g:haddock_indexfiledir") && filewritable(g:haddock_indexfiledir) + let s:haddock_indexfiledir = g:haddock_indexfiledir +elseif filewritable(s:libraries) + let s:haddock_indexfiledir = s:libraries +elseif filewritable($HOME) + let s:haddock_indexfiledir = $HOME.'/' +else "give up + echoerr s:scriptname." can't locate index file. please set g:haddock_indexfiledir" + finish +endif +let s:haddock_indexfile = s:haddock_indexfiledir . 'haddock_index.vim' + +" different browser setups require different call formats; +" you might want to call the browser synchronously or +" asynchronously, and the latter is os-dependent; +" +" by default, the browser is started in the background when on +" windows or if running in a gui, and in the foreground otherwise +" (eg, console-mode for remote sessions, with text-mode browsers). +" +" you can override these defaults in your vimrc, via a format +" string including 2 %s parameters (the first being the browser +" to call, the second being the url). +if !exists("g:haddock_browser_callformat") + if has("win32") || has("win64") + let g:haddock_browser_callformat = 'start %s "%s"' + else + if has("gui_running") + let g:haddock_browser_callformat = '%s %s '.printf(&shellredir,'/dev/null').' &' + else + let g:haddock_browser_callformat = '%s %s' + endif + endif +endif + +" allow map leader override +if !exists("maplocalleader") + let maplocalleader='_' +endif + +command! DocSettings call DocSettings() +function! DocSettings() + for v in ["g:haddock_browser","g:haddock_browser_callformat","g:haddock_docdir","g:haddock_indexfiledir","s:ghc_libdir","s:ghc_version","s:docdir","s:libraries","s:guide","s:haddock_indexfile"] + if exists(v) + echo v '=' eval(v) + else + echo v '=' + endif + endfor +endfunction + +function! DocBrowser(url) + "echomsg "DocBrowser(".url.")" + if (!exists("g:haddock_browser") || !executable(g:haddock_browser)) + echoerr s:scriptname." can't find documentation browser. please set g:haddock_browser" + return + endif + " start browser to open url, according to specified format + let url = a:url=~'^\(file://\|http://\)' ? a:url : 'file://'.a:url + silent exe '!'.printf(g:haddock_browser_callformat,g:haddock_browser,escape(url,'#%')) +endfunction + +"usage examples: +" :Doc length +" :Doc Control.Monad.when +" :Doc Data.List. +" :Doc Control.Monad.State.runState mtl +" :Doc -top +" :Doc -libs +" :Doc -guide +command! -nargs=+ Doc call Doc('v',) +command! -nargs=+ Doct call Doc('t',) + +function! Doc(kind,qualname,...) + let suffix = '.html' + let relative = '#'.a:kind.'%3A' + + if a:qualname=="-top" + call DocBrowser(s:docdir . s:index) + return + elseif a:qualname=="-libs" + call DocBrowser(s:libraries . s:index) + return + elseif a:qualname=="-guide" + call DocBrowser(s:guide . s:index) + return + endif + + if a:0==0 " no package specified + let package = 'base/' + else + let package = a:1 . '/' + endif + + if match(a:qualname,'\.')==-1 " unqualified name + let [qual,name] = [['Prelude'],a:qualname] + let file = join(qual,'-') . suffix . relative . name + elseif a:qualname[-1:]=='.' " module qualifier only + let parts = split(a:qualname,'\.') + let quallen = len(parts)-1 + let [qual,name] = [parts[0:quallen],parts[-1]] + let file = join(qual,'-') . suffix + else " qualified name + let parts = split(a:qualname,'\.') + let quallen = len(parts)-2 + let [qual,name] = [parts[0:quallen],parts[-1]] + let file = join(qual,'-') . suffix . relative . name + endif + +" let path = s:libraries . package . file + let path = file + call DocBrowser(path) +endfunction + +" TODO: add commandline completion for :IDoc +" indexed variant of Doc, looking up links in g:haddock_index +" usage: +" 1. :IDoc length +" 2. click on one of the choices, or select by number (starting from 0) +command! -nargs=+ IDoc call IDoc() +function! IDoc(name,...) + let choices = HaddockIndexLookup(a:name) + if choices=={} | return | endif + if a:0==0 + let keylist = map(deepcopy(keys(choices)),'substitute(v:val,"\\[.\\]","","")') + let choice = inputlist(keylist) + else + let choice = a:1 + endif + let path = values(choices)[choice] " assumes same order for keys/values.. + call DocBrowser(path) +endfunction + +let s:flagref = s:guide . 'flag-reference.html' +if filereadable(s:flagref) + " extract the generated fragment ids for the + " flag reference sections + let s:headerPat = '.\{-}

<\/a>\([^<]*\)<\/h3>\(.*\)' + let s:flagheaders = [] + let s:flagheaderids = {} + let s:contents = join(readfile(s:flagref)) + let s:ml = matchlist(s:contents,s:headerPat) + while s:ml!=[] + let [_,s:id,s:title,s:r;s:x] = s:ml + let s:flagheaders = add(s:flagheaders, s:title) + let s:flagheaderids[s:title] = s:id + let s:ml = matchlist(s:r,s:headerPat) + endwhile + command! -nargs=1 -complete=customlist,CompleteFlagHeaders FlagReference call FlagReference() + function! FlagReference(section) + let relativeUrl = a:section==""||!exists("s:flagheaderids['".a:section."']") ? + \ "" : "#".s:flagheaderids[a:section] + call DocBrowser(s:flagref.relativeUrl) + endfunction + function! CompleteFlagHeaders(al,cl,cp) + let s:choices = s:flagheaders + return CompleteAux(a:al,a:cl,a:cp) + endfunction +endif + +command! -nargs=1 -complete=customlist,CompleteHaddockModules MDoc call MDoc() +function! MDoc(module) + let suffix = '.html' + call HaveModuleIndex() + if !has_key(g:haddock_moduleindex,a:module) + echoerr a:module 'not found in haddock module index' + return + endif + let package = g:haddock_moduleindex[a:module]['package'] + let file = substitute(a:module,'\.','-','g') . suffix +" let path = s:libraries . package . '/' . file + let path = g:haddock_moduleindex[a:module]['html'] + call DocBrowser(path) +endfunction + +function! CompleteHaddockModules(al,cl,cp) + call HaveModuleIndex() + let s:choices = keys(g:haddock_moduleindex) + return CompleteAux(a:al,a:cl,a:cp) +endfunction + +" create a dictionary g:haddock_index, containing the haddoc index +command! DocIndex call DocIndex() +function! DocIndex() + let files = split(globpath(s:libraries,'doc-index*.html'),'\n') + let g:haddock_index = {} + call ProcessHaddockIndexes2(s:libraries,files) + if GHC_VersionGE([6,8,2]) + if &shell =~ 'sh' " unix-type shell + let s:addon_libraries = split(system(g:ghc_pkg . ' field \* haddock-html'),'\n') + else " windows cmd.exe and the like + let s:addon_libraries = split(system(g:ghc_pkg . ' field * haddock-html'),'\n') + endif + for addon in s:addon_libraries + let ml = matchlist(addon,'haddock-html: \("\)\?\(file:///\)\?\([^"]*\)\("\)\?') + if ml!=[] + let [_,quote,file,addon_path;x] = ml + let addon_path = substitute(addon_path,'\(\\\\\|\\\)','/','g') + let addon_files = split(globpath(addon_path,'doc-index*.html'),'\n') + call ProcessHaddockIndexes2(addon_path,addon_files) + endif + endfor + endif + return 1 +endfunction + +function! ProcessHaddockIndexes(location,files) + let entryPat= '.\{-}"indexentry"[^>]*>\([^<]*\)<\(\%([^=]\{-}TD CLASS="\%(indexentry\)\@!.\{-}', '&': '\\&' } + for enc in keys(decode) + exe 'let res = substitute(res,"'.enc.'","'.decode[enc].'","g")' + endfor + return res +endfunction + +" find haddocks for word under cursor +" also lists possible definition sites +" - needs to work for both qualified and unqualified items +" - for 'import qualified M as A', consider M.item as source of A.item +" - offer sources from both type [t] and value [v] namespaces +" - for unqualified items, list all possible sites +" - for qualified items, list imported sites only +" keep track of keys with and without namespace tags: +" the former are needed for lookup, the latter for matching against source +map ? :call Haddock() +function! Haddock() + amenu ]Popup.- :echo '-' + aunmenu ]Popup + let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),0) + if namsym==[] + redraw + echo 'no name/symbol under cursor!' + return 0 + endif + let [start,symb,qual,unqual] = namsym + let imports = haskellmode#GatherImports() + let asm = has_key(imports[1],qual) ? imports[1][qual]['modules'] : [] + let name = unqual + let dict = HaddockIndexLookup(name) + if dict=={} | return | endif + " for qualified items, narrow results to possible imports that provide qualifier + let filteredKeys = filter(copy(keys(dict)) + \ ,'match(asm,substitute(v:val,''\[.\]'','''',''''))!=-1') + let keys = (qual!='') ? filteredKeys : keys(dict) + if (keys==[]) && (qual!='') + echoerr qual.'.'.unqual.' not found in imports' + return 0 + endif + if len(keys)==1 && exists("g:haskell_avoid_singleton_menus") + call DocBrowser(dict[keys[0]]) + elseif has("gui_running") + for key in keys + exe 'amenu ]Popup.'.escape(key,'\.').' :call DocBrowser('''.dict[key].''')' + endfor + popup ]Popup + else + let s:choices = keys + let key = input('browse docs for '.name.' in: ','','customlist,CompleteAux') + if key!='' + call DocBrowser(dict[key]) + endif + endif +endfunction + +if !exists("g:haskell_search_engines") + let g:haskell_search_engines = + \ {'hoogle':'http://www.haskell.org/hoogle/?hoogle=%s' + \ ,'hayoo!':'http://holumbus.fh-wedel.de/hayoo/hayoo.html?query=%s' + \ } +endif + +map ?? :let es=g:haskell_search_engines + \ \|echo "g:haskell_search_engines" + \ \|for e in keys(es) + \ \|echo e.' : '.es[e] + \ \|endfor +map ?1 :call HaskellSearchEngine('hoogle') +map ?2 :call HaskellSearchEngine('hayoo!') + +" query one of the Haskell search engines for the thing under cursor +" - unqualified symbols need to be url-escaped +" - qualified ids need to be fed as separate qualifier and id for +" both hoogle (doesn't handle qualified symbols) and hayoo! (no qualified +" ids at all) +" - qualified ids referring to import-qualified-as qualifiers need to be +" translated to the multi-module searches over the list of original modules +function! HaskellSearchEngine(engine) + amenu ]Popup.- :echo '-' + aunmenu ]Popup + let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),0) + if namsym==[] + redraw + echo 'no name/symbol under cursor!' + return 0 + endif + let [start,symb,qual,unqual] = namsym + let imports = haskellmode#GatherImports() + let asm = has_key(imports[1],qual) ? imports[1][qual]['modules'] : [] + let unqual = haskellmode#UrlEncode(unqual) + if a:engine=='hoogle' + let name = asm!=[] ? unqual.'+'.join(map(copy(asm),'"%2B".v:val'),'+') + \ : qual!='' ? unqual.'+'.haskellmode#UrlEncode('+').qual + \ : unqual + elseif a:engine=='hayoo!' + let name = asm!=[] ? unqual.'+module:('.join(copy(asm),' OR ').')' + \ : qual!='' ? unqual.'+module:'.qual + \ : unqual + else + let name = qual=="" ? unqual : qual.".".unqual + endif + if has_key(g:haskell_search_engines,a:engine) + call DocBrowser(printf(g:haskell_search_engines[a:engine],name)) + else + echoerr "unknown search engine: ".a:engine + endif +endfunction + +" used to pass on choices to CompleteAux +let s:choices=[] + +" if there's no gui, use commandline completion instead of :popup +" completion function CompleteAux suggests completions for a:al, wrt to s:choices +function! CompleteAux(al,cl,cp) + "echomsg '|'.a:al.'|'.a:cl.'|'.a:cp.'|' + let res = [] + let l = len(a:al)-1 + for r in s:choices + if l==-1 || r[0 : l]==a:al + let res += [r] + endif + endfor + return res +endfunction + +" CamelCase shorthand matching: +" favour upper-case letters and module qualifier separators (.) for disambiguation +function! CamelCase(shorthand,string) + let s1 = a:shorthand + let s2 = a:string + let notFirst = 0 " don't elide before first pattern letter + while ((s1!="")&&(s2!="")) + let head1 = s1[0] + let head2 = s2[0] + let elide = notFirst && ( ((head1=~'[A-Z]') && (head2!~'[A-Z.]')) + \ ||((head1=='.') && (head2!='.')) ) + if elide + let s2=s2[1:] + elseif (head1==head2) + let s1=s1[1:] + let s2=s2[1:] + else + return 0 + endif + let notFirst = (head1!='.')||(head2!='.') " treat separators as new beginnings + endwhile + return (s1=="") +endfunction + +" use haddock name index for insert mode completion (CTRL-X CTRL-U) +function! CompleteHaddock(findstart, base) + if a:findstart + let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),-1) " insert-mode: we're 1 beyond the text + if namsym==[] + redraw + echo 'no name/symbol under cursor!' + return -1 + endif + let [start,symb,qual,unqual] = namsym + return (start-1) + else " find keys matching with "a:base" + let res = [] + let l = len(a:base)-1 + let qual = a:base =~ '^[A-Z][a-zA-Z0-9_'']*\(\.[A-Z][a-zA-Z0-9_'']*\)*\(\.[a-zA-Z0-9_'']*\)\?$' + call HaveIndex() + for key in keys(g:haddock_index) + let keylist = map(deepcopy(keys(g:haddock_index[key])),'substitute(v:val,"\\[.\\]","","")') + if (key[0 : l]==a:base) + for m in keylist + let res += [{"word":key,"menu":m,"dup":1}] + endfor + elseif qual " this tends to be slower + for m in keylist + let word = m . '.' . key + if word[0 : l]==a:base + let res += [{"word":word,"menu":m,"dup":1}] + endif + endfor + endif + endfor + if res==[] " no prefix matches, try CamelCase shortcuts + for key in keys(g:haddock_index) + let keylist = map(deepcopy(keys(g:haddock_index[key])),'substitute(v:val,"\\[.\\]","","")') + if CamelCase(a:base,key) + for m in keylist + let res += [{"word":key,"menu":m,"dup":1}] + endfor + elseif qual " this tends to be slower + for m in keylist + let word = m . '.' . key + if CamelCase(a:base,word) + let res += [{"word":word,"menu":m,"dup":1}] + endif + endfor + endif + endfor + endif + return res + endif +endfunction +set completefunc=CompleteHaddock +set completeopt=menu,menuone,longest + +" fully qualify an unqualified name +" TODO: - standardise commandline versions of menus +map . :call Qualify() +function! Qualify() + amenu ]Popup.- :echo '-' + aunmenu ]Popup + let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),0) + if namsym==[] + redraw + echo 'no name/symbol under cursor!' + return 0 + endif + let [start,symb,qual,unqual] = namsym + if qual!='' " TODO: should we support re-qualification? + redraw + echo 'already qualified' + return 0 + endif + let name = unqual + let line = line('.') + let prefix = (start<=1 ? '' : getline(line)[0:start-2] ) + let dict = HaddockIndexLookup(name) + if dict=={} | return | endif + let keylist = map(deepcopy(keys(dict)),'substitute(v:val,"\\[.\\]","","")') + let imports = haskellmode#GatherImports() + let qualifiedImports = [] + for qualifiedImport in keys(imports[1]) + let c=0 + for module in imports[1][qualifiedImport]['modules'] + if haskellmode#ListElem(keylist,module) | let c+=1 | endif + endfor + if c>0 | let qualifiedImports=[qualifiedImport]+qualifiedImports | endif + endfor + "let asm = has_key(imports[1],qual) ? imports[1][qual]['modules'] : [] + let keylist = filter(copy(keylist),'index(qualifiedImports,v:val)==-1') + if has("gui_running") + " amenu ]Popup.-imported- : + for key in qualifiedImports + let lhs=escape(prefix.name,'/.|\') + let rhs=escape(prefix.key.'.'.name,'/&|\') + exe 'amenu ]Popup.'.escape(key,'\.').' :'.line.'s/'.lhs.'/'.rhs.'/:noh' + endfor + amenu ]Popup.-not\ imported- : + for key in keylist + let lhs=escape(prefix.name,'/.|\') + let rhs=escape(prefix.key.'.'.name,'/&|\') + exe 'amenu ]Popup.'.escape(key,'\.').' :'.line.'s/'.lhs.'/'.rhs.'/:noh' + endfor + popup ]Popup + else + let s:choices = qualifiedImports+keylist + let key = input('qualify '.name.' with: ','','customlist,CompleteAux') + if key!='' + let lhs=escape(prefix.name,'/.\') + let rhs=escape(prefix.key.'.'.name,'/&\') + exe line.'s/'.lhs.'/'.rhs.'/' + noh + endif + endif +endfunction + +" create (qualified) import for a (qualified) name +" TODO: refine search patterns, to avoid misinterpretation of +" oddities like import'Neither or not'module +map i :call Import(0,0) +map im :call Import(1,0) +map iq :call Import(0,1) +map iqm :call Import(1,1) +function! Import(module,qualified) + amenu ]Popup.- :echo '-' + aunmenu ]Popup + let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),0) + if namsym==[] + redraw + echo 'no name/symbol under cursor!' + return 0 + endif + let [start,symb,qual,unqual] = namsym + let name = unqual + let pname = ( symb ? '('.name.')' : name ) + let importlist = a:module ? '' : '('.pname.')' + let qualified = a:qualified ? 'qualified ' : '' + + if qual!='' + exe 'call append(search(''\%1c\(\\|\\|{-# OPTIONS\|{-# LANGUAGE\)'',''nb''),''import '.qualified.qual.importlist.''')' + return + endif + + let line = line('.') + let prefix = getline(line)[0:start-1] + let dict = HaddockIndexLookup(name) + if dict=={} | return | endif + let keylist = map(deepcopy(keys(dict)),'substitute(v:val,"\\[.\\]","","")') + if has("gui_running") + for key in keylist + " exe 'amenu ]Popup.'.escape(key,'\.').' :call append(search("\\%1c\\(import\\\\|module\\\\|{-# OPTIONS\\)","nb"),"import '.key.importlist.'")' + exe 'amenu ]Popup.'.escape(key,'\.').' :call append(search(''\%1c\(\\\|\\\|{-# OPTIONS\\|{-# LANGUAGE\)'',''nb''),''import '.qualified.key.escape(importlist,'|').''')' + endfor + popup ]Popup + else + let s:choices = keylist + let key = input('import '.name.' from: ','','customlist,CompleteAux') + if key!='' + exe 'call append(search(''\%1c\(\\|\\|{-# OPTIONS\|{-# LANGUAGE\)'',''nb''),''import '.qualified.key.importlist.''')' + endif + endif +endfunction + +function! HaddockIndexLookup(name) + call HaveIndex() + if !has_key(g:haddock_index,a:name) + echoerr a:name 'not found in haddock index' + return {} + endif + return g:haddock_index[a:name] +endfunction + +" copied from ghc.vim :-( should we move everything to using autoload instead? +" we query the ghc version here, as we don't otherwise need it.. +function! GHC_VersionGE(target) + let s:ghc_version = substitute(system(g:ghc . ' --numeric-version'),'\n','','') + let current = split(g:ghc_version, '\.' ) + let target = a:target + for i in current + if ((target==[]) || (i>target[0])) + return 1 + elseif (i==target[0]) + let target = target[1:] + else + return 0 + endif + endfor + return 1 +endfunction diff --git a/.vim/ftplugin/haskell_hpaste.vim b/.vim/ftplugin/haskell_hpaste.vim new file mode 100644 index 0000000..33ea0bd --- /dev/null +++ b/.vim/ftplugin/haskell_hpaste.vim @@ -0,0 +1,79 @@ +" rudimentary hpaste support for vim +" (using netrw for reading, wget for posting/annotating) +" +" claus reinke, last modified: 07/04/2009 +" +" part of haskell plugins: http://projects.haskell.org/haskellmode-vim + +" unless wget is in your PATH, you need to set g:wget +" before loading this script. windows users are out of +" luck, unless they have wget installed (such as the +" cygwin one looked for here), or adapt this script to +" whatever alternative they have at hand (perhaps using +" vim's perl/python bindings?) +if !exists("g:wget") + if executable("wget") + let g:wget = "!wget -q" + else + let g:wget = "!c:\\cygwin\\bin\\wget -q" + endif +endif + +" read (recent) hpaste files +" show index in new buffer, where ,r will open current entry +" and ,p will annotate current entry with current buffer +command! HpasteIndex call HpasteIndex() +function! HpasteIndex() + new + read http://hpaste.org + %s/\_$\_.//g + %s/]*>//g + %s/<\/tr>/ /g + g/<\/table>/d + g/DOCTYPE/d + %s/\([^<]*\)<\/td>\([^<]*\)<\/a><\/td>\([^<]*\)<\/td>\([^<]*\)<\/td>\([^<]*\)<\/td>/\2 [\1] "\3" \4 \5 \6/ + map ,r 0yE:noh:call HpasteEditEntry('"') +endfunction + +" load an existing entry for editing +command! -nargs=1 HpasteEditEntry call HpasteEditEntry() +function! HpasteEditEntry(entry) + new + exe 'Nread http://hpaste.org/fastcgi/hpaste.fcgi/raw?id='.a:entry + "exe 'map ,p :call HpasteAnnotate('''.a:entry.''')' +endfunction + +" " posting temporarily disabled -- needs someone to look into new +" " hpaste.org structure + +" " annotate existing entry (only to be called via ,p in HpasteIndex) +" function! HpasteAnnotate(entry) +" let nick = input("nick? ") +" let title = input("title? ") +" if nick=='' || title=='' +" echo "nick or title missing. aborting annotation" +" return +" endif +" call HpastePost('annotate/'.a:entry,nick,title) +" endfunction +" +" " post new hpaste entry +" " using 'wget --post-data' and url-encoded content +" command! HpastePostNew call HpastePost('new',) +" function! HpastePost(mode,nick,title,...) +" let lines = getbufline("%",1,"$") +" let pat = '\([^[:alnum:]]\)' +" let code = '\=printf("%%%02X",char2nr(submatch(1)))' +" let lines = map(lines,'substitute(v:val."\r\n",'''.pat.''','''.code.''',''g'')') +" +" let url = 'http://hpaste.org/' . a:mode +" let nick = substitute(a:nick,pat,code,'g') +" let title = substitute(a:title,pat,code,'g') +" if a:0==0 +" let announce = 'false' +" else +" let announce = a:1 +" endif +" let cmd = g:wget.' --post-data="content='.join(lines,'').'&nick='.nick.'&title='.title.'&announce='.announce.'" '.url +" exe escape(cmd,'%') +" endfunction diff --git a/.vim/ftplugin/latex-suite/bibtex.vim b/.vim/ftplugin/latex-suite/bibtex.vim new file mode 100644 index 0000000..8037914 --- /dev/null +++ b/.vim/ftplugin/latex-suite/bibtex.vim @@ -0,0 +1,266 @@ +"============================================================================= +" File: bibtex.vim +" Function: BibT +" Author: Alan G Isaac +" modified by Srinath Avadhanula for latex-suite. +" License: Vim Charityware license. +" CVS: $Id: bibtex.vim 997 2006-03-20 09:45:45Z srinathava $ +"============================================================================= + +" 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/.vim/ftplugin/latex-suite/bibtools.py b/.vim/ftplugin/latex-suite/bibtools.py new file mode 100644 index 0000000..0a5366c --- /dev/null +++ b/.vim/ftplugin/latex-suite/bibtools.py @@ -0,0 +1,221 @@ +# Author: Srinath Avadhanula +# This file is distributed as part of the vim-latex project +# http://vim-latex.sf.net + +import re + +class Bibliography(dict): + def __init__(self, txt, macros={}): + """ + txt: + a string which represents the entire bibtex entry. A typical + entry is of the form: + @ARTICLE{ellington:84:part3, + author = {Ellington, C P}, + title = {The Aerodynamics of Hovering Insect Flight. III. Kinematics}, + journal = {Philosophical Transactions of the Royal Society of London. Series B, Biological Sciences}, + year = {1984}, + volume = {305}, + pages = {41-78}, + number = {1122}, + owner = {Srinath}, + pdf = {C:\srinath\research\papers\Ellington-3-Kinematics.pdf}, + timestamp = {2006.01.02}, + } + """ + + if macros: + for k, v in macros.iteritems(): + txt = txt.replace(k, '{'+v+'}') + + m = re.match(r'\s*@(\w+){((\S+),)?(.*)}\s*', txt, re.MULTILINE | re.DOTALL) + if not m: + return None + + self['bibtype'] = m.group(1).capitalize() + self['key'] = m.group(3) + self['body'] = m.group(4) + + body = self['body'] + self['bodytext'] = '' + while 1: + m = re.search(r'(\S+?)\s*=\s*(.)', body) + if not m: + break + + field = m.group(1) + + body = body[(m.start(2)+1):] + if m.group(2) == '{': + # search for the next closing brace. This is not simply a + # matter of searching for the next closing brace since + # braces can be nested. The following code basically goes + # to the next } which has not already been closed by a + # following {. + mniter = re.finditer(r'{|}', body) + + count = 1 + while 1: + try: + mn = mniter.next() + except StopIteration: + return None + + if mn.group(0) == '{': + count += 1 + else: + count -= 1 + + if count == 0: + value = body[:(mn.start(0))] + break + + elif m.group(2) == '"': + # search for the next unquoted double-quote. To be more + # precise, a double quote which is preceded by an even + # number of double quotes. + mn = re.search(r'(?!\\)(\\\\)*"', body) + if not mn: + return None + + value = body[:(mn.start(0))] + + else: + # $ always matches. So we do not need to do any + # error-checking. + mn = re.search(r',|$', body) + value = m.group(2) + body[:(mn.start(0))].rstrip() + + self[field] = re.sub(r'\s+', ' ', value) + body = body[(mn.start(0)+1):] + + self['bodytext'] += (' %s: %s\n' % (field, value)) + if self['bibtype'].lower() == 'string': + self['macro'] = {field: value} + + self['bodytext'] = self['bodytext'].rstrip() + + + def __getitem__(self, key): + try: + return dict.__getitem__(self, key) + except KeyError: + return '' + + def __str__(self): + if self['bibtype'].lower() == 'string': + return 'String: %(macro)s' % self + + elif self['bibtype'].lower() == 'article': + return ('Article [%(key)s]\n' + + 'TI "%(title)s"\n' + + 'AU %(author)s\n' + + 'IN In %(journal)s, %(year)s') % self + + elif self['bibtype'].lower() == 'conference': + return ('Conference [%(key)s]\n' + + 'TI "%(title)s"\n' + + 'AU %(author)s\n' + + 'IN In %(booktitle)s, %(year)s') % self + + elif self['bibtype'].lower() == 'mastersthesis': + return ('Masters [%(key)s]\n' + + 'TI "%(title)s"\n' + + 'AU %(author)s\n' + + 'IN In %(school)s, %(year)s') % self + + elif self['bibtype'].lower() == 'phdthesis': + return ('PhD [%(key)s]\n' + + 'TI "%(title)s"\n' + + 'AU %(author)s\n' + + 'IN In %(school)s, %(year)s') % self + + elif self['bibtype'].lower() == 'book': + return ('Book [%(key)s]\n' + + 'TI "%(title)s"\n' + + 'AU %(author)s\n' + + 'IN %(publisher)s, %(year)s') % self + + else: + s = '%(bibtype)s [%(key)s]\n' % self + if self['title']: + s += 'TI "%(title)s"\n' % self + if self['author']: + s += 'AU %(author)s\n' % self + for k, v in self.iteritems(): + if k not in ['title', 'author', 'bibtype', 'key', 'id', 'file', 'body', 'bodytext']: + s += 'MI %s: %s\n' % (k, v) + + return s.rstrip() + + def satisfies(self, filters): + for field, regexp in filters: + if not re.search(regexp, self[field], re.I): + return False + + return True + +class BibFile: + + def __init__(self, filelist=''): + self.bibentries = [] + self.filters = [] + self.macros = {} + self.sortfields = [] + if filelist: + for f in filelist.splitlines(): + self.addfile(f) + + def addfile(self, file): + fields = open(file).read().split('@') + for f in fields: + if not (f and re.match('string', f, re.I)): + continue + + b = Bibliography('@' + f) + self.macros.update(b['macro']) + + for f in fields: + if not f or re.match('string', f, re.I): + continue + + b = Bibliography('@' + f, self.macros) + if b: + b['file'] = file + b['id'] = len(self.bibentries) + self.bibentries += [b] + + + def addfilter(self, filterspec): + self.filters += [filterspec.split()] + + def rmfilters(self): + self.filters = [] + + def __str__(self): + s = '' + for b in self.bibentries: + if b['key'] and b.satisfies(self.filters): + s += '%s\n\n' % b + return s + + def addsortfield(self, field): + self.sortfields += [field] + + def rmsortfields(self): + self.sortfields = [] + + def sort(self): + def cmpfun(b1, b2): + for f in self.sortfields: + c = cmp(b1[f], b2[f]) + if c: + return c + return 0 + self.bibentries.sort(cmp=cmpfun) + +if __name__ == "__main__": + import sys + + bf = BibFile(sys.argv[1]) + print bf diff --git a/.vim/ftplugin/latex-suite/bibtools.pyc b/.vim/ftplugin/latex-suite/bibtools.pyc new file mode 100644 index 0000000..c79961f Binary files /dev/null and b/.vim/ftplugin/latex-suite/bibtools.pyc differ diff --git a/.vim/ftplugin/latex-suite/brackets.vim b/.vim/ftplugin/latex-suite/brackets.vim new file mode 100644 index 0000000..0669ce4 --- /dev/null +++ b/.vim/ftplugin/latex-suite/brackets.vim @@ -0,0 +1,145 @@ +" ============================================================================== +" 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. +" CVS: $Id: brackets.vim 997 2006-03-20 09:45:45Z srinathava $ +" 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/.vim/ftplugin/latex-suite/compiler.vim b/.vim/ftplugin/latex-suite/compiler.vim new file mode 100644 index 0000000..245f6cd --- /dev/null +++ b/.vim/ftplugin/latex-suite/compiler.vim @@ -0,0 +1,820 @@ +"============================================================================= +" File: compiler.vim +" Author: Srinath Avadhanula +" Created: Tue Apr 23 05:00 PM 2002 PST +" +" Description: functions for compiling/viewing/searching latex documents +" CVS: $Id: compiler.vim 997 2006-03-20 09:45:45Z srinathava $ +"============================================================================= + +" 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 + + else + let curd = getcwd() + exe 'cd '.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 '.curd + 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 curd = 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! + + call Tex_CD(curd) +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 curd = 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() + + call Tex_CD(curd) + 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 curd = 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') + if strlen(s:viewer) + let s:viewer = '-a '.s:viewer + endif + let execString = 'open '.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 == "xdvi" || 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 = 'kdvi --unique $*.dvi &' + + else + + let execString = s:viewer.' $*.dvi &' + + endif + + else + + let execString = s:viewer.' $*.'.s:target.' &' + + 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 + + call Tex_CD(curd) +endfunction + +" }}} +" Tex_ForwardSearchLaTeX: searches for current location in dvi file. {{{ +" Description: if the DVI viewr 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_ViewLaTeX from a non-tex file" + return + end + + " only know how to do forward search for yap on windows and xdvik (and + " some newer versions of xdvi) on unices. Therefore forward searching will + " automatically open the DVI viewer irrespective of what the user chose as + " the default view format. + if Tex_GetVarValue('Tex_ViewRule_dvi') == '' + return + endif + let viewer = Tex_GetVarValue('Tex_ViewRule_dvi') + + let curd = getcwd() + + let mainfname = Tex_GetMainFileName(':t') + let mainfnameRoot = fnamemodify(Tex_GetMainFileName(), ':t: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') + + let execString = 'silent! !start '. viewer.' -s '.line('.').expand('%').' '.mainfnameRoot + + else + if Tex_GetVarValue('Tex_UseEditorSettingInDVIViewer') == 1 && + \ exists('v:servername') && + \ (viewer == "xdvi" || viewer == "xdvik") + + let execString = 'silent! !'.viewer.' -name xdvi -sourceposition '.line('.').expand("%"). + \ ' -editor "gvim --servername '.v:servername.' --remote-silent +\%l \%f" '. + \ mainfnameRoot.'.dvi &' + + elseif Tex_GetVarValue('Tex_UseEditorSettingInDVIViewer') == 1 && viewer == "kdvi" + + let execString = 'silent! !kdvi --unique file:'.mainfnameRoot.'.dvi\#src:'.line('.').expand("%").' &' + + else + + let execString = 'silent! !'.viewer.' -name xdvi -sourceposition '.line('.').expand("%").' '.mainfnameRoot.'.dvi &' + + endif + end + + call Tex_Debug("Tex_ForwardSearchLaTeX: execString = ".execString, "comp") + execute execString + if !has('gui_running') + redraw! + endif + + call Tex_CD(curd) +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') + " Save position + let pos = line('.').' | normal! '.virtcol('.').'|' + + " 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 curd = 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 + + 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' + + call Tex_CD(curd) +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 = exists('g:mapleader') ? g:mapleader : "\\" + + 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/.vim/ftplugin/latex-suite/custommacros.vim b/.vim/ftplugin/latex-suite/custommacros.vim new file mode 100644 index 0000000..1b1c6bd --- /dev/null +++ b/.vim/ftplugin/latex-suite/custommacros.vim @@ -0,0 +1,257 @@ +"============================================================================= +" File: custommacros.vim +" Author: Mikolaj Machowski +" Version: 1.0 +" Created: Tue Apr 23 05:00 PM 2002 PST +" CVS: $Id: custommacros.vim 997 2006-03-20 09:45:45Z srinathava $ +" +" 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 + let position = line('.').' | normal! '.virtcol('.').'|' + 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/.vim/ftplugin/latex-suite/diacritics.vim b/.vim/ftplugin/latex-suite/diacritics.vim new file mode 100644 index 0000000..616d30a --- /dev/null +++ b/.vim/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/.vim/ftplugin/latex-suite/dictionaries/SIunits b/.vim/ftplugin/latex-suite/dictionaries/SIunits new file mode 100644 index 0000000..d4ac081 --- /dev/null +++ b/.vim/ftplugin/latex-suite/dictionaries/SIunits @@ -0,0 +1,289 @@ +addprefix +addunit +ampere +amperemetresecond +amperepermetre +amperepermetrenp +amperepersquaremetre +amperepersquaremetrenp +angstrom +arad +arcminute +arcsecond +are +atomicmass +atto +attod +barn +bbar +becquerel +becquerelbase +bel +candela +candelapersquaremetre +candelapersquaremetrenp +celsius +Celsius +celsiusbase +centi +centid +coulomb +coulombbase +coulombpercubicmetre +coulombpercubicmetrenp +coulombperkilogram +coulombperkilogramnp +coulombpermol +coulombpermolnp +coulombpersquaremetre +coulombpersquaremetrenp +cubed +cubic +cubicmetre +cubicmetreperkilogram +cubicmetrepersecond +curie +dday +deca +decad +deci +decid +degree +degreecelsius +deka +dekad +derbecquerel +dercelsius +dercoulomb +derfarad +dergray +derhenry +derhertz +derjoule +derkatal +derlumen +derlux +dernewton +derohm +derpascal +derradian +dersiemens +dersievert +dersteradian +dertesla +dervolt +derwatt +derweber +electronvolt +exa +exad +farad +faradbase +faradpermetre +faradpermetrenp +femto +femtod +fourth +gal +giga +gigad +gram +graybase +graypersecond +graypersecondnp +hectare +hecto +hectod +henry +henrybase +henrypermetre +henrypermetrenp +hertz +hertzbase +hour +joule +joulebase +joulepercubicmetre +joulepercubicmetrenp +jouleperkelvin +jouleperkelvinnp +jouleperkilogram +jouleperkilogramkelvin +jouleperkilogramkelvinnp +jouleperkilogramnp +joulepermole +joulepermolekelvin +joulepermolekelvinnp +joulepermolenp +joulepersquaremetre +joulepersquaremetrenp +joulepertesla +jouleperteslanp +katal +katalbase +katalpercubicmetre +katalpercubicmetrenp +kelvin +kilo +kilod +kilogram +kilogrammetrepersecond +kilogrammetrepersecondnp +kilogrammetrepersquaresecond +kilogrammetrepersquaresecondnp +kilogrampercubicmetre +kilogrampercubicmetrecoulomb +kilogrampercubicmetrecoulombnp +kilogrampercubicmetrenp +kilogramperkilomole +kilogramperkilomolenp +kilogrampermetre +kilogrampermetrenp +kilogrampersecond +kilogrampersecondcubicmetre +kilogrampersecondcubicmetrenp +kilogrampersecondnp +kilogrampersquaremetre +kilogrampersquaremetrenp +kilogrampersquaremetresecond +kilogrampersquaremetresecondnp +kilogramsquaremetre +kilogramsquaremetrenp +kilogramsquaremetrepersecond +kilogramsquaremetrepersecondnp +kilowatthour +liter +litre +lumen +lumenbase +lux +luxbase +mega +megad +meter +metre +metrepersecond +metrepersecondnp +metrepersquaresecond +metrepersquaresecondnp +micro +microd +milli +millid +minute +mole +molepercubicmetre +molepercubicmetrenp +nano +nanod +neper +newton +newtonbase +newtonmetre +newtonpercubicmetre +newtonpercubicmetrenp +newtonperkilogram +newtonperkilogramnp +newtonpermetre +newtonpermetrenp +newtonpersquaremetre +newtonpersquaremetrenp +NoAMS +no@qsk +ohm +ohmbase +ohmmetre +one +paminute +pascal +pascalbase +pascalsecond +pasecond +per +period@active +persquaremetresecond +persquaremetresecondnp +peta +petad +pico +picod +power +@qsk +quantityskip +rad +radian +radianbase +radianpersecond +radianpersecondnp +radianpersquaresecond +radianpersquaresecondnp +reciprocal +rem +roentgen +rp +rpcubed +rpcubic +rpcubicmetreperkilogram +rpcubicmetrepersecond +rperminute +rpersecond +rpfourth +rpsquare +rpsquared +rpsquaremetreperkilogram +second +siemens +siemensbase +sievert +sievertbase +square +squared +squaremetre +squaremetrepercubicmetre +squaremetrepercubicmetrenp +squaremetrepercubicsecond +squaremetrepercubicsecondnp +squaremetreperkilogram +squaremetrepernewtonsecond +squaremetrepernewtonsecondnp +squaremetrepersecond +squaremetrepersecondnp +squaremetrepersquaresecond +squaremetrepersquaresecondnp +steradian +steradianbase +tera +terad +tesla +teslabase +ton +tonne +unit +unitskip +usk +volt +voltbase +voltpermetre +voltpermetrenp +watt +wattbase +wattpercubicmetre +wattpercubicmetrenp +wattperkilogram +wattperkilogramnp +wattpermetrekelvin +wattpermetrekelvinnp +wattpersquaremetre +wattpersquaremetrenp +wattpersquaremetresteradian +wattpersquaremetresteradiannp +weber +weberbase +yocto +yoctod +yotta +yottad +zepto +zeptod +zetta +zettad diff --git a/.vim/ftplugin/latex-suite/dictionaries/dictionary b/.vim/ftplugin/latex-suite/dictionaries/dictionary new file mode 100644 index 0000000..458dc0b --- /dev/null +++ b/.vim/ftplugin/latex-suite/dictionaries/dictionary @@ -0,0 +1,677 @@ +abbrv +abovedisplayshortskip +abovedisplayskip +abstract +abstract +abstractname +acute +addcontentsline +address +addtime +addtocontents +addtocounter +addtolength +addvspace +align +alph +Alph +alpha +amsmath +amsthm +and +appendix +appendixname +arabic +array +arraycolsep +arrayrulewidth +arraystretch +article +author +a4paper +a5paper +backmatter +bar +bar +baselineskip +baselinestretch +batchmode +begin +belowdisplayshortskip +belowdisplayskip +bezier +bf +bfseries +bibindent +bibitem +bibliography +bibliographystyle +bibname +big +Big +Bigg +bigg +Biggl +biggl +Biggm +biggm +Biggr +biggr +Bigl +bigl +bigm +Bigm +bigr +Bigr +bigskip +bigskipamount +binom +blg +boldmath +boldsymbol +book +botfigrule +bottmofraction +bottomnumber +boxedminipage +bp +breve +b5paper +calc +calc +caption +caption2 +capt-of +cases +cc +ccaption +ccname +cdotscenter +centering +cercle +cfrac +changebar +chapter +chapterbib +chaptername +check +cite +cleardoublepage +clearpage +cline +clock +closing +cm +COLON +columnsep +columnseprule +columnwidth +contentsline +contentsname +copyright +dag +dashbox +date +dbinom +dblfigure +dblfloatpage +dblfloatsep +dbltextfloatsep +dbltopfraction +dbltopnumber +dcolumn +dd +ddag +ddot +ddots +DeclareMathOperator +depth +description +dfrac +displaylimits +displaymath +displaystyle +document +documentclass +dot +dotfill +doublerulesep +downbracefill +draft +dropping +dywiz +em +emph +empty +encl +enclname +end +endfloat +enlargethispage +enskip +enspace +ensuremath +enumerate +enumi +enumii +enumiii +enumiv +eqnarray +equation +errorstopmode +eucal +eufrak +evensidemargin +everyship +ex +executivepaper +expdlist +extracolsep +extramark +fancybox +fancyhdr +fbox +fboxrule +fboxsep +figure +figurename +file +filecontents +final +flafter +fleqn +floatflt +floatpagefraction +floatsep +flushbottom +flushleft +flushright +fnpara +fnsymbol +fn2end +fontenc +footheight +footmisc +footnote +footnotemark +footnoterule +footnotesep +footnotesize +footnotetext +footnpag +footskip +frac +frame +framebox +frenchspacing +frontmatter +ftnright +fussy +gather +genfrac +geometry +glossary +glossaryentry +graphicx +graphpaper +grave +hat +hbox +headheihgt +headings +headsep +height +helvet +hfill +hhline +hline +hrulefill +hspace +huge +Huge +HUGE +hyperref +hyphenation +ifthen +in +include +includeonly +indent +indentfirst +index +indexentry +indexname +indexspace +input +inputenc +intertext +intextsep +invisible +it +item +itemindent +itemize +itemsep +itshape +jot +kill +label +labelenumi +labelenumii +labelenumiii +labelenumiv +labelitemi +labelitemii +labelitemiii +labelitemiv +labelsep +labelwidth +landscape +large +LARGE +Large +LaTeX +LaTeXe +latexsym +ldots +left +leftarrowfill +lefteqn +leftmargin +leftmargini +leftmarginii +leftmarginiii +leftmarginiv +leftmarginv +leftmarginvi +leftmark +legalpaper +leq +leqno +letter +letterpaper +letterspace +lhead +limits +line +linebreak +linethickness +linewidth +list +listfigurename +listfiles +listoffigures +listoftables +listparindent +location +longtable +lq +lrbox +lscape +mainmatter +makeatletter +makeatother +makebox +makeglossary +makeidx +makeindex +makelabel +maketitle +manyfoot +marginpar +marginparpush +marginparsep +marginparwidth +markboth +markleft +markright +math +mathbb +mathbf +mathbin +mathcal +mathclose +mathfrak +mathindent +mathit +mathnormal +mathop +mathopen +mathord +mathpunct +mathrel +mathrm +mathscr +mathsf +mathstrut +mathtt +mathversion +mbox +mdseries +medmuskip +medskip +medskipamount +minipage +minitoc +minus +mkern +mm +moreverbatim +mpfootnote +mu +multicol +multicolumn +multilanguage +multiput +multirow +myheadings +nabla +name +NeedsTeXFormat +newcommand +newcounter +newenvironment +newfont +newlength +newline +newpage +newsavebox +newtheorem +nocite +nofiles +noindent +nolimits +nolinebreak +nomathsymbols +nonfrenchspacing +nonumber +nopagebreak +normalfont +normalsize +not +notag +note +notitlepage +nu +numberline +numline +numprint +oddsidemargin +oldstyle +onecolumn +oneside +onlynotes +onlyslides +openany +openbib +opening +openright +operatorname +oval +overbrace +overlay +overleftarrow +overline +overrightarrow +page +pagebreak +pagenumbering +pageref +pagestyle +paperheight +paperwidth +par +paragraph +parbox +parbox +parindent +parsep +parskip +part +partial +partname +partopsep +pauza +pc +phi +pi +picture +plain +PLdateending +plmath +PLSlash +plus +pmb +pmod +polski +polski +poptabs +pounds +ppauza +prefixing +printindex +protect +providecommand +ps +pt +pushtabs +put +qbezier +qbeziermax +qquad +quad +quotation +quote +raggedbottom +raggedleft +raggedright +ragged2e +raisebox +ratio +real +ref +refname +refstepcounter +relsize +renewcommand +renewenvironment +report +reversemarginpar +rhead +right +rightarrowfill +rightmargin +rightmark +rm +rmfamily +roman +Roman +rotate +rotating +rq +rule +samepage +savebox +sb +sbox +sc +scriptscriptstyle +scriptsize +scriptstyle +scrollmode +scshape +secnumdepth +section +sectionmark +see +seename +selectfont +selectlanguage +setcounter +setlength +settime +settodepth +settoheight +settowidth +sf +sffamily +shadethm +shadow +shapepar +shortstack +showlabels +sidecap +signature +sin +sl +slide +slides +sloppy +sloppybar +slshape +small +smallskip +smallskipamount +soul +sp +space +sqrt +ss +SS +stackrel +startbreaks +stepcounter +stop +stopbreaks +stretch +strut +subfigure +subfigure +subitem +subparagraph +subsection +subsubitem +subsubsection +sum +supressfloats +symbol +symbol +tabbing +tabcolsep +table +tablename +tableofcontents +tabular +tabularx +tag +tan +tbinom +telephone +TeX +textbf +textbullet +textcircled +textcompwordmark +textemdash +textendash +textexclamdown +textfloatsep +textfraction +textheight +textit +textmd +textnormal +textperiodcenter +textquestiondown +textquotedblleft +textquotedblright +textquoteleft +textquoteright +textrm +textsc +textsf +textsl +textstyle +textsuperscript +texttt +textup +textvisiblespace +textwidth +tfrac +thanks +the +thebibliography +theindex +theorem +thepage +thesection +theta +thicklines +thickmuskip +thinlines +thispagestyle +tilde +time +times +tiny +title +titlepage +tocdepth +today +topfigrule +topfraction +topmargin +topmargin +topmargin +topsep +topskip +topskip +totalheight +totalnumber +trivlist +tt +ttfamily +twocolumn +twocolumn +twoside +typein +typein +typeout +typeout +ulem +ulem +unboldmath +underbrace +underline +unsort +unsrt +upbracefill +upshape +upshape +usebox +usebox +usecounter +usefont +usepackage +value +vbox +vdots +vec +vector +verb +verb +verbatim +verse +vfill +visible +vline +vmargin +voffset +vspace +widehat +widetilde +width +wrapfig +xleftarrow +xrightarrow +threeparttable diff --git a/.vim/ftplugin/latex-suite/elementmacros.vim b/.vim/ftplugin/latex-suite/elementmacros.vim new file mode 100644 index 0000000..8960a0f --- /dev/null +++ b/.vim/ftplugin/latex-suite/elementmacros.vim @@ -0,0 +1,338 @@ +"============================================================================= +" 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