From: Penny Leach Date: Fri, 4 Jul 2025 07:52:10 +0000 (+1200) Subject: 2025-07 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=dotfiles%2Fvim.git 2025-07 --- diff --git a/.vim/compiler/tex.vim b/.vim/compiler/tex.vim deleted file mode 120000 index 96de836..0000000 --- a/.vim/compiler/tex.vim +++ /dev/null @@ -1 +0,0 @@ -/usr/share/vim/addons/compiler/tex.vim \ No newline at end of file diff --git a/.vim/compiler/tex.vim b/.vim/compiler/tex.vim new file mode 100644 index 0000000..f87bd5f --- /dev/null +++ b/.vim/compiler/tex.vim @@ -0,0 +1,409 @@ +" File: tex.vim +" Type: compiler plugin for LaTeX +" Original Author: Artem Chuprina +" Customization: Srinath Avadhanula +" Description: {{{ +" This file sets the 'makeprg' and 'errorformat' options for the LaTeX +" compiler. It is customizable to optionally ignore certain warnings and +" provides the ability to set a dynamic 'ignore-warning' level. +" +" By default it is set up in a 'non-verbose', 'ignore-common-warnings' mode, +" which means that irrelevant lines from the compilers output will be +" ignored and also some very common warnings are ignored. +" +" Depending on the 'ignore-level', the following kinds of messages are +" ignored. An ignore level of 3 for instance means that messages 1-3 will be +" ignored. By default, the ignore level is set to 4. +" +" 1. LaTeX Warning: Specifier 'h' changed to 't'. +" This errors occurs when TeX is not able to correctly place a floating +" object at a specified location, because of which it defaulted to the +" top of the page. +" 2. LaTeX Warning: Underfull box ... +" 3. LaTeX Warning: Overfull box ... +" both these warnings (very common) are due to \hbox settings not being +" satisfied nicely. +" 4. LaTeX Warning: You have requested ..., +" This warning occurs in slitex when using the xypic package. +" 5. Missing number error: +" Usually, when the name of an included eps file is spelled incorrectly, +" then the \bb-error message is accompanied by a bunch of "missing +" number, treated as zero" error messages. This level ignores these +" warnings. +" NOTE: number 5 is actually a latex error, not a warning! +" +" Use +" TCLevel +" where level is a number to set the ignore level dynamically. +" +" When TCLevel is called with the unquoted string strict +" TClevel strict +" then the 'efm' switches to a 'verbose', 'no-lines-ignored' mode which is +" useful when you want to make final checks of your document and want to be +" careful not to let things slip by. +" +" TIP: MikTeX has a bug where it sometimes erroneously splits a line number +" into multiple lines. i.e, if the warning is on line 1234. the compiler +" output is: +" LaTeX Warning: ... on input line 123 +" 4. +" In this case, vim will wrongly interpret the line-number as 123 instead +" of 1234. If you have cygwin, a simple remedy around this is to first +" copy the file vimlatex (provided) into your $PATH, make sure its +" executable and then set the variable g:tex_flavor to vimlatex in your +" ~/.vimrc (i.e putting let "g:tex_flavor = 'vimlatex'" in your .vimrc). +" This problem occurs rarely enough that its not a botheration for most +" people. +" +" TODO: +" 1. menu items for dynamically selecting a ignore warning level. +" }}} + +if exists('b:suppress_latex_suite') && b:suppress_latex_suite == 1 + finish +endif + +" avoid reinclusion for the same buffer. keep it buffer local so it can be +" externally reset in case of emergency re-sourcing. +if exists('b:doneTexCompiler') && !exists('b:forceRedoTexCompiler') + finish +endif +let b:doneTexCompiler = 1 + +" ============================================================================== +" Customization of 'efm': {{{ +" This section contains the customization variables which the user can set. +" g:Tex_IgnoredWarnings: This variable contains a ¡ seperated list of +" patterns which will be ignored in the TeX compiler's output. Use this +" carefully, otherwise you might end up losing valuable information. +if !exists('g:Tex_IgnoredWarnings') + let g:Tex_IgnoredWarnings = + \'Underfull'."\n". + \'Overfull'."\n". + \'specifier changed to'."\n". + \'You have requested'."\n". + \'Missing number, treated as zero.'."\n". + \'There were undefined references'."\n". + \'Citation %.%# undefined' +endif +" This is the number of warnings in the g:Tex_IgnoredWarnings string which +" will be ignored. +if !exists('g:Tex_IgnoreLevel') + let g:Tex_IgnoreLevel = 7 +endif +" There will be lots of stuff in a typical compiler output which will +" completely fall through the 'efm' parsing. This options sets whether or not +" you will be shown those lines. +if !exists('g:Tex_IgnoreUnmatched') + let g:Tex_IgnoreUnmatched = 1 +endif +" With all this customization, there is a slight risk that you might be +" ignoring valid warnings or errors. Therefore before getting the final copy +" of your work, you might want to reset the 'efm' with this variable set to 1. +" With that value, all the lines from the compiler are shown irrespective of +" whether they match the error or warning patterns. +" NOTE: An easier way of resetting the 'efm' to show everything is to do +" TCLevel strict +if !exists('g:Tex_ShowallLines') + let g:Tex_ShowallLines = 0 +endif + +" }}} +" ============================================================================== +" Customization of 'makeprg': {{{ + +" There are several alternate ways in which 'makeprg' is set up. +" +" Case 1 +" ------ +" The first is when this file is a part of latex-suite. In this case, a +" variable called g:Tex_DefaultTargetFormat exists, which gives the default +" format .tex files should be compiled into. In this case, we use the TTarget +" command provided by latex-suite. +" +" Case 2 +" ------ +" The user is using this file without latex-suite AND he wants to directly +" specify the complete 'makeprg'. Then he should set the g:Tex_CompileRule_dvi +" variable. This is a string which should be directly be able to be cast into +" &makeprg. An example of one such string is: +" +" g:Tex_CompileRule_dvi = 'pdflatex \\nonstopmode \\input\{$*\}' +" +" NOTE: You will need to escape back-slashes, {'s etc yourself if you are +" using this file independently of latex-suite. +" TODO: Should we also have a check for backslash escaping here based on +" platform? +" +" Case 3 +" ------ +" The use is using this file without latex-suite and he doesnt want any +" customization. In this case, this file makes some intelligent guesses based +" on the platform. If he doesn't want to specify the complete 'makeprg' but +" only the name of the compiler program (for example 'pdflatex' or 'latex'), +" then he sets b:tex_flavor or g:tex_flavor. + +if exists('g:Tex_DefaultTargetFormat') + exec 'TTarget '.g:Tex_DefaultTargetFormat +elseif exists('g:Tex_CompileRule_dvi') + let &l:makeprg = g:Tex_CompileRule_dvi +else + " If buffer-local variable 'tex_flavor' exists, it defines TeX flavor, + " otherwize the same for global variable with same name, else it will be LaTeX + if exists("b:tex_flavor") + let current_compiler = b:tex_flavor + elseif exists("g:tex_flavor") + let current_compiler = g:tex_flavor + else + let current_compiler = "latex" + end + if has('win32') + let escChars = '' + else + let escChars = '{}\' + endif + " Furthermore, if 'win32' is detected, then we want to set the arguments up so + " that miktex can handle it. + if has('win32') + let options = '--src-specials' + else + let options = '' + endif + let &l:makeprg = current_compiler . ' ' . options . + \ escape(' \nonstopmode \input{$*}', escChars) +endif + +" }}} +" ============================================================================== +" Functions for setting up a customized 'efm' {{{ + +" IgnoreWarnings: parses g:Tex_IgnoredWarnings for message customization {{{ +" Description: +function! IgnoreWarnings() + let s:Ignored_Overfull = 0 + + let i = 1 + while s:Strntok(g:Tex_IgnoredWarnings, "\n", i) != '' && + \ i <= g:Tex_IgnoreLevel + let warningPat = s:Strntok(g:Tex_IgnoredWarnings, "\n", i) + let warningPat = escape(substitute(warningPat, '[\,]', '%\\\\&', 'g'), ' ') + + if warningPat =~? 'overfull' + let s:Ignored_Overfull = 1 + if ( v:version > 800 || v:version == 800 && has("patch26") ) + " Overfull warnings are ignored as 'warnings'. Therefore, we can gobble + " some of the following lines with %-C (see below) + exe 'setlocal efm+=%-W%.%#'.warningPat.'%.%#' + else + exe 'setlocal efm+=%-G%.%#'.warningPat.'%.%#' + endif + else + exe 'setlocal efm+=%-G%.%#'.warningPat.'%.%#' + endif + + let i = i + 1 + endwhile +endfunction + +" }}} +" SetLatexEfm: sets the 'efm' for the latex compiler {{{ +" Description: +function! SetLatexEfm() + + let pm = ( g:Tex_ShowallLines == 1 ? '+' : '-' ) + + " Add a dummy entry to overwrite the global setting. + setlocal efm=dummy_value + + if !g:Tex_ShowallLines + call s:IgnoreWarnings() + endif + + setlocal efm+=%E!\ LaTeX\ %trror:\ %m + setlocal efm+=%E!\ %m + setlocal efm+=%E%f:%l:\ %m + + " If we do not ignore 'overfull \hbox' messages, we care for them to get the + " line number. + if s:Ignored_Overfull == 0 + setlocal efm+=%+WOverfull\ %mat\ lines\ %l--%*\\d + setlocal efm+=%+WOverfull\ %mat\ line\ %l + endif + + " Add some generic warnings + setlocal efm+=%+WLaTeX\ %.%#Warning:\ %.%#line\ %l%.%# + setlocal efm+=%+W%.%#\ at\ lines\ %l--%*\\d + setlocal efm+=%+WLaTeX\ %.%#Warning:\ %m + setlocal efm+=%+WPackage\ %.%#Warning:\ %m + + " 'Overfull \hbox' messages are ended by: + exec 'setlocal efm+=%'.pm.'Z\ []' + + " Empty line ends multi-line messages + setlocal efm+=%-Z + + exec 'setlocal efm+=%'.pm.'C(%.%#)\ %#%m\ on\ input\ line\ %l.' + exec 'setlocal efm+=%'.pm.'C(%.%#)\ %#%m' + + exec 'setlocal efm+=%'.pm.'Cl.%l\ %m' + exec 'setlocal efm+=%'.pm.'Cl.%l\ ' + exec 'setlocal efm+=%'.pm.'C\ \ %m' + exec 'setlocal efm+=%'.pm.'C%.%#-%.%#' + exec 'setlocal efm+=%'.pm.'C%.%#[]%.%#' + exec 'setlocal efm+=%'.pm.'C[]%.%#' + exec 'setlocal efm+=%'.pm.'C%.%#%[{}\\]%.%#' + exec 'setlocal efm+=%'.pm.'C<%.%#>%m' + exec 'setlocal efm+=%'.pm.'C\ \ %m' + exec 'setlocal efm+=%'.pm.'GSee\ the\ LaTeX%m' + exec 'setlocal efm+=%'.pm.'GType\ \ H\ %m' + exec 'setlocal efm+=%'.pm.'G\ ...%.%#' + exec 'setlocal efm+=%'.pm.'G%.%#\ (C)\ %.%#' + exec 'setlocal efm+=%'.pm.'G(see\ the\ transcript%.%#)' + exec 'setlocal efm+=%'.pm.'G\\s%#' + + " After a 'overfull \hbox' message, there is some garbage from the input. + " We try to match it, such that parenthesis in this garbage does not + " confuse the OPQ-patterns below. + " Every line continues a multiline pattern (hopefully a 'overfull \hbox' + " message). + " Due to a bug in old versions of vim, this cannot be used if we ignore the + " 'overfull \hbox' messages, see vim/vim#1126. + if s:Ignored_Overfull == 0 || ( v:version > 800 || v:version == 800 && has("patch26") ) + exec 'setlocal efm+=%'.pm.'C%.%#' + endif + + " Now, we try to trace the used files. + " + " In principle, the following combinations could arise in the LaTeX logs: + " + " )* \((%f)\)* (%f + " [Close files, skip some files, open a file] + " + " (%f))* + " [Skip some files, close some files] + " + " And you will find many more awkward combinations... + " + " Even something like this is possible: + " [18] [19] [20] (./bla.bbl [21]) + " + " After a %[OPQ] is matched, the %r part is passed to the same and + " following patterns. Hence, we have to add many $[OPQ]-patterns. + " + " If you use vim to compile your documents, you might want to use + " :let $max_print_line=1024 + " such that latex will not wrap the filenames. Otherwise, you could use it + " as an environment variable or simply use + " max_print_line=1024 pdflatex ... + " in your terminal. If you are using latexmk, you should set + " $ENV{'max_print_line'} = '1024'; + " $log_wrap = $ENV{'max_print_line'}; + " in your ~/.latexmkrc + + " The first pattern is needed to match lines like + " '[10] [11] (some_file.txt)', + " where the first number correspond to an output page in the document + exec 'setlocal efm+=%'.pm.'O[%*\\d]%r' + + " Some close patters + exec 'setlocal efm+=%'.pm.'Q\ %#)%r' + exec 'setlocal efm+=%'.pm.'Q\ %#[%\\d%*[^()])%r' + " The next pattern is needed to match lines like + " ' ])', + exec 'setlocal efm+=%'.pm.'Q\ %#])%r' + + " Skip pattern + exec 'setlocal efm+=%'.pm.'O(%f)%r' + + " Some openings + exec 'setlocal efm+=%'.pm.'P(%f%r' + exec 'setlocal efm+=%'.pm.'P%*[^()](%f%r' + exec 'setlocal efm+=%'.pm.'P(%f%*[^()]' + exec 'setlocal efm+=%'.pm.'P[%\\d%[^()]%#(%f%r' + + + " Now, the sledgehammer to cope with awkward endless combinations (did you + " ever tried tikz/pgf?) + " We have to build up the string first, otherwise we cannot append it with + " '+='. + let PQO = '%'.pm.'P(%f%r,%'.pm.'Q)%r,%'.pm.'O(%f)%r,%'.pm.'O[%*\\d]%r' + let PQOs = PQO + for xxx in range(3) + let PQOs .= ',' . PQO + endfor + exec 'setlocal efm+=' . PQOs + + " Finally, there are some lonely page numbers after all the patterns. + exec 'setlocal efm+=%'.pm.'O[%*\\d' + + " This gobbles some entries consisting only of whitespace, in fact, it + " matches the empty line. + " See https://github.com/vim/vim/issues/807 + exec 'setlocal efm+=%'.pm.'O' + + if g:Tex_IgnoreUnmatched && !g:Tex_ShowallLines + " Ignore all lines which are unmatched so far. + setlocal efm+=%-G%.%# + " Sometimes, there is some garbage after a ')' + setlocal efm+=%-O%.%# + endif + + " Finally, remove the dummy entry. + setlocal efm-=dummy_value + +endfunction + +" }}} +" Strntok: extract the n^th token from a list {{{ +" example: Strntok('1,23,3', ',', 2) = 23 +fun! Strntok(s, tok, n) + return matchstr( a:s.a:tok[0], '\v(\zs([^'.a:tok.']*)\ze['.a:tok.']){'.a:n.'}') +endfun + +" }}} +" SetTexCompilerLevel: sets the "level" for the latex compiler {{{ +function! SetTexCompilerLevel(...) + if a:0 > 0 + let level = a:1 + else + call Tex_ResetIncrementNumber(0) + echo substitute(g:Tex_IgnoredWarnings, + \ '^\|\n\zs\S', '\=Tex_IncrementNumber(1)." ".submatch(0)', 'g') + let level = input("\nChoose an ignore level: ") + if level == '' + return + endif + endif + if level == 'strict' + let g:Tex_ShowallLines = 1 + elseif level =~ '^\d\+$' + let g:Tex_ShowallLines = 0 + let g:Tex_IgnoreLevel = level + else + echoerr "SetTexCompilerLevel: Unkwown option [".level."]" + end + call s:SetLatexEfm() +endfunction + +com! -nargs=? TCLevel :call SetTexCompilerLevel() +" }}} + +" }}} +" ============================================================================== + +call s:SetLatexEfm() + +" Set the errorfile if not already set by somebody else +if &errorfile ==# '' || &errorfile ==# 'errors.err' + execute 'set errorfile=' . fnameescape(Tex_GetMainFileName(':p:r') . '.log') +endif + + +if !exists('*Tex_Debug') + function! Tex_Debug(...) + endfunction +endif + +call Tex_Debug("compiler/tex.vim: sourcing this file", "comp") + +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4 diff --git a/.vim/ftplugin/mail.vim b/.vim/ftplugin/mail.vim index 8e801e5..1be7a59 100644 --- a/.vim/ftplugin/mail.vim +++ b/.vim/ftplugin/mail.vim @@ -50,10 +50,7 @@ fun! DelegateCompletion(next) endfun nmap 1 :w:%!mailplate --keep-unknown --auto -nmap 2 :w:%!mailplate --keep-unknown sgn -nmap 3 :w:%!mailplate --keep-unknown mjollnir +nmap 2 :w:%!mailplate --keep-unknown mjollnir +nmap 3 :w:%!mailplate --keep-unknown greens nmap 4 :w:%!mailplate --keep-unknown gmail -"nmap 4 :w:%!mailplate --keep-unknown catalyst -"nmap 5 :w:%!mailplate --keep-unknown mahara -"nmap 6 :w:%!mailplate --keep-unknown liip diff --git a/.vim/indent/tex.vim b/.vim/indent/tex.vim deleted file mode 120000 index 551e3a9..0000000 --- a/.vim/indent/tex.vim +++ /dev/null @@ -1 +0,0 @@ -/usr/share/vim/addons/indent/tex.vim \ No newline at end of file diff --git a/.vim/indent/tex.vim b/.vim/indent/tex.vim new file mode 100644 index 0000000..0e2fc26 --- /dev/null +++ b/.vim/indent/tex.vim @@ -0,0 +1,388 @@ +" Vim indent file +" +" Options: {{{ +" +" The options are mostly compatible with the indent/tex.vim distributed by +" vim. +" Here, we have one new option: g:tex_indent_ifelsefi +" +" To set the following options, add a line like +" let g:tex_indent_items = 1 +" to your ~/ftplugin/tex.vim. +" +" +" * g:tex_indent_brace = 1 +" +" If this variable is unset or non-zero, it will use smartindent-like style +" for "{}", "[]" and "()". +" +" +" * g:tex_indent_items = 1 +" +" If this variable is set, item-environments are indented like Emacs does +" it, i.e., continuation lines are indented with a shiftwidth. +" +" set unset +" ---------------------------------------------------------------- +" \begin{itemize} \begin{itemize} +" \item blablabla \item blablabla +" bla bla bla bla bla bla +" \item blablabla \item blablabla +" bla bla bla bla bla bla +" \end{itemize} \end{itemize} +" +" +" * g:tex_items = '\\bibitem\|\\item' +" +" A list of tokens to be considered as commands for the beginning of an item +" command. The tokens should be separated with '\|'. The initial '\' should +" be escaped. +" +" +" * g:tex_itemize_env = 'itemize\|description\|enumerate\|thebibliography'. +" +" A list of environment names, separated with '\|', where the items (item +" commands matching g:tex_items) may appear. +" +" +" * g:tex_noindent_env = 'document\|verbatim\|comment\|lstlisting' +" +" A list of environment names. separated with '\|', where no indentation is +" required. +" +" +" * g:tex_indent_ifelsefi = 1 +" +" If this is set to one, we try to indent something like +" \ifnum... +" bar +" \else +" foo +" \fi +" correctly. This is quite tough, since there are commands like +" \ifthenelse{condition}{then}{else}, which uses braces instead of \else and +" \fi. Our heuristic: only add indentation, if \if... is not followed by a +" '{', (and only if \if,\else,\or,\fi occur at the beginning of the line). +" +" }}} + +if exists('b:suppress_latex_suite') && b:suppress_latex_suite == 1 + finish +endif + +if exists("b:did_indent") + finish +endif +if v:version < 700 + echohl WarningMsg + echo "Indentation of latex-suite requires vim version >= 700.\n" + \ . "Fallback to default indentation." + echohl None + finish +endif +let b:did_indent = 1 + +" Check whether the options exist and assign default values +if !exists("g:tex_indent_brace") + let g:tex_indent_brace = 1 +endif +if !exists("g:tex_indent_items") + let g:tex_indent_items = 1 +endif +if !exists('g:tex_items') + let g:tex_items = '\\bibitem\|\\item' +endif +if !exists("g:tex_itemize_env") + let g:tex_itemize_env = 'itemize\|description\|enumerate\|thebibliography' +endif +if !exists("g:tex_noindent_env") + let g:tex_noindent_env = 'document\|verbatim\|comment\|lstlisting' +endif +if !exists("g:tex_indent_ifelsefi") + let g:tex_indent_ifelsefi = 1 +endif + +setlocal autoindent +setlocal nosmartindent +setlocal indentexpr=Tex_CalcIdent() +setlocal indentkeys+=},],.,) + +" Cache {{{ +" Internally, the indentation uses a cache for precompiled patterns +" and the last indented line. However, the cache cannot be used, if the +" options have changed. +" +" CacheOptions: puts options into a list {{{ +function! s:CacheOptions() + return [ + \ g:tex_indent_brace, + \ g:tex_indent_items, + \ g:tex_items, + \ g:tex_itemize_env, + \ g:tex_noindent_env, + \ g:tex_indent_ifelsefi, + \ ] +endfunction +" }}} +" SetCache: Remembers the options used to set up the cache. {{{ +function! s:SetCache() + let s:cache_options = s:CacheOptions() +endfunction +" }}} +" CanUseCache: Can we use the cache? {{{ +function! s:CanUseCache() + return s:cache_options == s:CacheOptions() +endfunction +" }}} +" Initialize the cache {{{ +let s:cache_options = [] +" }}} +" }}} + +" Function DeepestNesting: compute indentation of a line {{{ +" This function computes the deepest/smallest nesting on the current line. We +" start with 0, each match of openregexp increases nesting and each match of +" closeregexp decreases nesting. +" The return value is the deepest indentation of the current line and the +" additional indentation which should be used for the next line. +" Parameters: +" line This string should be indented +" +" All the regexps should be able to be combined via \|, preferably single +" atoms (enclose them in '\%(', '\)'!) +function! s:DeepestNesting(line) + let indent = 0 + let pos = 0 + + let deepest = 0 + + " Now, we look through the line for matching patterns + while pos >= 0 + " Look for the next match of one of the patterns. + + " Do we have the function matchstrpos() (introduced in version 7.4.1684)? + if exists('*matchstrpos') + " Here, we explicitly use the 'count' option of 'matchstrpos' such that + " '^' matches only at the beginning of the string (and not at 'pos') + let strpos = matchstrpos( a:line, s:all, pos, 1 ) + let pos = strpos[2] + let str = strpos[0] + else + " Here, we explicitly use the 'count' option of 'match'/'matchend' such that + " '^' matches only at the beginning of the string (and not at 'pos') + " Does not work with version < 7 + let start = match( a:line, s:all, pos, 1 ) + if start < 0 + " No more matches were found. + break + end + let pos = matchend( a:line, s:all, start, 1 ) + let str = a:line[ start : pos-1 ] + end + + if pos <= 0 + " No more matches were found. + break + endif + + " Check which pattern has matched + if str =~ '^' . s:openextraregexp . '$' + let indent += 2 + elseif str =~ '^' . s:closeextraregexp . '$' + let indent -= 2 + elseif str =~ '^' . s:openregexp . '$' + let indent += 1 + elseif str =~ '^' . s:closeregexp . '$' + let indent -= 1 + else + " For a hanging line, do not alter indent, + " but possibly update the deepest indentation + let deepest = min([deepest, indent - 1]) + endif + + " Update deepest indentation + let deepest = min([deepest, indent]) + endwhile + + return [deepest, indent - deepest] +endfunction +" }}} +" Function AssemblePatterns: pre-compute patterns{{{ +" This function uses the options to assemble various patterns. These patterns +" do not depend on the line which is indented and can be pre-computed. +" This function also sets option-dependent indentkeys +" Description Of Patterns: +" openregexp Causes 1 indentation more +" closeregexp Causes 1 indentation less +" openextraregexp Causes 2 indentations more +" closeextraregexp Causes 2 indentations less +" hangingregexp Only this line has 1 indentation less +function! s:AssemblePatterns() + " Add a 'shiftwidth' after beginning + " and subtract a 'shiftwidth' after the end of environments. + " Don't add it for \begin{document} and \begin{verbatim}, see + " g:tex_noindent_env + let open = '\\begin\s*{\%('.g:tex_noindent_env.'\)\@!.\{-\}}' + let close = '\\end\s*{\%('.g:tex_noindent_env.'\)\@!.\{-\}}' + + if g:tex_indent_brace + let open = open . '\|[[{(]\|\\left\.' + let close = close . '\|[]})]\|\\right\.' + endif + + if g:tex_indent_items + " For itemize-like environments: add or subtract two 'shiftwidth' + let s:openextraregexp = '\\begin\s*{\%('.g:tex_itemize_env.'\)\*\?}' + let s:closeextraregexp = '\\end\s*{\%('.g:tex_itemize_env.'\)\*\?}' + + " Special treatment for items, they will hang + let hanging = g:tex_items + else + " Extra environment indentation + let s:openextraregexp = '' + let s:closeextraregexp = '' + + " No hanging expression + let hanging = '' + endif + + if g:tex_indent_ifelsefi + " Do match '\if..' only if it is not followed by '{' + " Require \fi, and \if... only at beginning of line, + " otherwise, + " \newif\ifbarfoo + " would be indented. + " Expection: If a line starts with '\if...' and + " contains an '\fi', it is not indented, e.g.: + " \ifbarfoo\foobaz\fi + " Exception: '\expandafter\ifx\csname barfoo \endcsname' + " is quite common and indented. + let open .= '\|^\s*\%(\\expandafter\)\?\\if\a*\>{\@!\%(.*\\fi\)\@!' + let close .= '\|^\s*\\fi\>' + let elseor = '\\else\>\|\\or\>' + if hanging != '' + let hanging = elseor . '\|' . hanging + else + let hanging = elseor + end + end + + " Wrap open and close in parentheses + let s:openregexp = '\%(' . open . '\)' + let s:closeregexp = '\%(' . close . '\)' + + " Wrap hanging in parentheses, match only at beginning of line + let s:hangingregexp = '^\s*\%(' . hanging . '\)' + + " Accumulate all patterns. + let s:all = '' + if s:openregexp != '' + let s:all .= '\|' . s:openregexp + endif + if s:closeregexp != '' + let s:all .= '\|' . s:closeregexp + endif + if s:openextraregexp != '' + let s:all .= '\|' . s:openextraregexp + endif + if s:closeextraregexp != '' + let s:all .= '\|' . s:closeextraregexp + endif + if s:hangingregexp != '' + let s:all .= '\|' . s:hangingregexp + endif + if s:all == '' + " No expressions given. Replace by a regexp which matches nowhere + let s:all = '\_$.' + else + " Strip the first '\|' + let s:all = s:all[2:] + end + + + " Add indentkeys depending on options + let items_keys = substitute(g:tex_items, '^\|\(\\|\)', ',0=', 'g') + if g:tex_indent_items + exec 'setlocal indentkeys+=' . items_keys + else + exec 'setlocal indentkeys-=' . items_keys + endif + + let ifelsefi_keys = '0=\\else,0=\\or,0=\\fi' + if g:tex_indent_ifelsefi + exec 'setlocal indentkeys+=' . ifelsefi_keys + else + exec 'setlocal indentkeys-=' . ifelsefi_keys + endif +endfunction +" }}} +" Function Tex_CalcIndent: to be used as indentexpr {{{ +" This function can be used as indentexpr. +function! Tex_CalcIdent() + " Check whether we can use the cache + let can_use_cache = s:CanUseCache() + call s:SetCache() + + if !can_use_cache + call s:AssemblePatterns() + endif + + " Current line number + let clnum = v:lnum + + " Code for comment: If current line is a comment, do not alter the + " indentation + let cline = getline(clnum) " Content of current line + if cline =~ '^\s*%' + return indent(clnum) + endif + + " Strip comments + let cline = substitute(cline, '\\\@ 0 + let skipStart = a:1 + let skipEnd = a:2 + else + let skipStart = '' + let skipEnd = '' + end + if !exists('b:numFoldItems') + let b:numFoldItems = 0 + end + let b:numFoldItems = b:numFoldItems + 1 + + exe 'let b:startPat_'.b:numFoldItems.' = a:start' + exe 'let b:endPat_'.b:numFoldItems.' = a:end' + exe 'let b:startOff_'.b:numFoldItems.' = a:startoff' + exe 'let b:endOff_'.b:numFoldItems.' = a:endoff' + exe 'let b:skipStartPat_'.b:numFoldItems.' = skipStart' + exe 'let b:skipEndPat_'.b:numFoldItems.' = skipEnd' +endfunction +" }}} +" Function: MakeSyntaxFolds (force) {{{ +" Description: This function calls FoldRegionsWith[No]Skip() several times with the +" parameters specifying various regions resulting in a nested fold +" structure for the file. +function! MakeSyntaxFolds(force) + if exists('b:doneFolding') && a:force == 0 + return + end + let start = reltime() + + " Save cursor position + if exists('*getcurpos') + let curpos = getcurpos() + else + let curpos = getpos('.') + endif + + setlocal fdm=manual + normal! zE + + if !exists('b:numFoldItems') + echohl ErrorMsg + echomsg 'Error in MakeSyntaxFolds: You have to call AddSyntaxFoldItem() first!' + echohl None + return + end + + for i in range(1, b:numFoldItems) + exe 'let startPat = b:startPat_'.i + exe 'let endPat = b:endPat_'.i + exe 'let startOff = b:startOff_'.i + exe 'let endOff = b:endOff_'.i + exe 'let skipStart = b:skipStartPat_'.i + exe 'let skipEnd = b:skipEndPat_'.i + + if skipStart != '' + call s:FoldRegionsWithSkip(startPat, endPat, startOff, endOff, skipStart, skipEnd, 1, line('$')) + else + call s:FoldRegionsWithNoSkip(startPat, endPat, startOff, endOff, 1, line('$'), []) + end + call s:Debug('done folding ['.startPat.']') + + endfor + + " Close all folds. + normal! zM + + call setpos('.', curpos) + if foldlevel(curpos[1]) > 1 + exe "normal! ".(foldlevel(curpos[1]) - 1)."zo" + end + let b:doneFolding = 0 + + " Report a folding performance. + if exists('*Tex_Debug') + call Tex_Debug('Finished folding in ' . reltimestr(reltime(start)) . ' seconds.', 'SyntaxFolds') + end +endfunction +" }}} + +" Local Helper Functions +" Function: s:FoldRegionsWithSkip: folding things such as \item's which can be nested. {{{ +function! s:FoldRegionsWithSkip(startpat, endpat, startoff, endoff, startskip, endskip, line1, line2) + " Move cursor to (begin of) line1 + call setpos('.', [0, a:line1, 1, 0]) + + " count the regions which have been skipped as we go along. do not want to + " create a fold which with a beginning or end line in one of the skipped + " regions. + let skippedRegions = [] + + let BeginSkipArray = [] + + " start searching for either the starting pattern or the end pattern. + while search(a:startskip.'\|'.a:endskip, 'Wc') + + if getline('.') =~ a:endskip + + if len(BeginSkipArray) > 0 + " Pop last elements: + let lastBegin = remove(BeginSkipArray, -1) + let lastRegions = remove(skippedRegions, -1) + call s:Debug('popping '.lastBegin.' from stack and folding until '.line('.')) + + call s:FoldRegionsWithNoSkip(a:startpat, a:endpat, a:startoff, a:endoff, lastBegin, line('.'), lastRegions) + + " The found region should be skipped on higher levels: + if len(skippedRegions) > 0 + call add(skippedRegions[-1], [lastBegin, line('.')]) + end + else + call s:Debug('Found [' . a:endskip . '] on line ' . line('.') . ', but nothing is in BeginSkipArray. Something is wrong here.') + end + + elseif getline('.') =~ a:startskip + " if this is the beginning of a skip region, then, push this line as + " the beginning of a skipped region. + call s:Debug('pushing '.line('.').' ['.getline('.').'] into stack') + call add(BeginSkipArray, line('.')) + call add(skippedRegions, []) + + end + + if line('.') == line('$') + break + endif + " Move one line down + normal! j0 + endwhile + + if len(BeginSkipArray) > 0 + call s:Debug('Finished FoldRegionsWithSkip, but BeginSkipArray is not empty, something is wrong here') + for i in range(0,len(BeginSkipArray)-1) + call s:Debug('BeginSkipArray[' . i . '] = ' . BeginSkipArray[i] ) + endfor + end + + call s:Debug('FoldRegionsWithSkip finished') +endfunction +" }}} +" Function: s:FoldRegionsWithNoSkip: folding things such as \sections which do not nest. {{{ +function! s:FoldRegionsWithNoSkip(startpat, endpat, startoff, endoff, line1, line2, skippedRegions) + call s:Debug('line1 = '.a:line1.', line2 = ' . a:line2 . ', skippedRegions = ' . string(a:skippedRegions)) + + " Move cursor to (begin of) line1 + call setpos('.', [0, a:line1, 1, 0]) + + call s:Debug('searching for ['.a:startpat.']') + let lineBegin = s:MySearch(a:startpat, 'in') + call s:Debug('... and finding it at '.lineBegin) + + while lineBegin <= a:line2 + if s:IsInSkippedRegion(lineBegin, a:skippedRegions) + let lineBegin = s:MySearch(a:startpat, 'out') + call s:Debug(lineBegin.' is being skipped') + continue + end + + " Move to end of start pattern: + normal! 0 + call search(a:startpat, 'cWe') + + let lineEnd = s:MySearch(a:endpat, 'out') + while s:IsInSkippedRegion(lineEnd, a:skippedRegions) && lineEnd <= a:line2 + let lineEnd = s:MySearch(a:endpat, 'out') + endwhile + if lineEnd > a:line2 + exe (lineBegin + a:startoff).','.a:line2.' fold' + " Open all folds: + normal! zR + break + else + call s:Debug ('for ['.a:startpat.'] '.(lineBegin + a:startoff).','.(lineEnd + a:endoff).' fold') + exe (lineBegin + a:startoff).','.(lineEnd + a:endoff).' fold' + " Open all folds: + normal! zR + end + + call s:Debug('line1 = '.a:line1.', searching from '.line('.').'... for ['.a:startpat.']') + let lineBegin = s:MySearch(a:startpat, 'in') + call s:Debug('... and finding it at '.lineBegin) + endwhile + + " Move cursor to (end of) line2 + exe a:line2 + normal! $ + return +endfunction +" }}} +" Function: s:MySearch: just like search(), but returns large number on failure {{{ +function! s:MySearch(pat, opt) + if a:opt == 'in' + normal! 0 + let ret = search(a:pat, 'cW') + else + normal! $ + let ret = search(a:pat, 'W') + end + + if ret == 0 + let ret = line('$') + 1 + end + return ret +endfunction +" }}} +" Function: s:IsInSkippedRegion (lnum, regions) {{{ +" Description: finds whether a given line number is within one of the regions +" skipped. +function! s:IsInSkippedRegion(lnum, regions) + for region in a:regions + if a:lnum >= region[0] && a:lnum <= region[1] + return 1 + end + endfor + return 0 +endfunction +" }}} +" Function: s:Debug: A wrapper for Tex_Debug, if it exists and if g:SyntaxFolds_Debug == 1 {{{ +function! s:Debug(string) + if exists('g:SyntaxFolds_Debug') && g:SyntaxFolds_Debug == 1 && exists('*Tex_Debug') + call Tex_Debug(a:string,'SyntaxFolds') + end +endfunction +" }}} +" vim600:fdm=marker diff --git a/.vim/plugin/filebrowser.vim b/.vim/plugin/filebrowser.vim deleted file mode 120000 index de8cea6..0000000 --- a/.vim/plugin/filebrowser.vim +++ /dev/null @@ -1 +0,0 @@ -/usr/share/vim/addons/plugin/filebrowser.vim \ No newline at end of file diff --git a/.vim/plugin/filebrowser.vim b/.vim/plugin/filebrowser.vim new file mode 100644 index 0000000..b528d6c --- /dev/null +++ b/.vim/plugin/filebrowser.vim @@ -0,0 +1,249 @@ +" filebrowser.vim: utility file for vim 6.2+ +" +" Copyright: Srinath Avadhanula +" Parts of this file are taken from explorer.vim which is a plugin file +" distributed with vim under the Vim charityware license. +" License: distributed under the Vim charityware license. +" +" Settings: +" FB_CallBackFunction: the function name which gets called when the user +" presses on a file-name in the file browser. +" FB_AllowRegexp: A filename has to match this regexp to be displayed. +" FB_RejectRegexp: If a filename matches this regexp, then its not displayed. +" (Both these regexps are '' by default which means no filtering is +" done). + +if exists('b:suppress_latex_suite') && b:suppress_latex_suite == 1 + finish +endif + +" line continuation used here. +let s:save_cpo = &cpo +set cpo&vim + +"====================================================================== +" Globally visible functions (API) +"====================================================================== +" FB_OpenFileBrowser: opens a new buffer and displays the file list {{{ +" Description: +function! FB_OpenFileBrowser(dir) + if !isdirectory(a:dir) + return + endif + if exists('s:FB_BufferNumber') + if bufwinnr(s:FB_BufferNumber) != -1 + execute bufwinnr(s:FB_BufferNumber).' wincmd w' + return + endif + execute 'aboveleft split #'.s:FB_BufferNumber + else + aboveleft split __Choose_File__ + let s:FB_BufferNumber = bufnr('%') + endif + call FB_DisplayFiles(a:dir) +endfunction " }}} +" FB_DisplayFiles: displays the files in a given directory {{{ +" Description: +" Call this function only when the cursor is in a temporary buffer +function! FB_DisplayFiles(dir) + if !isdirectory(a:dir) + return + endif + call s:FB_SetSilentSettings() + " make this a "scratch" buffer + call s:FB_SetScratchSettings() + + let allowRegexp = s:FB_GetVar('FB_AllowRegexp', '') + let rejectRegexp = s:FB_GetVar('FB_RejectRegexp', '') + + " change to the directory to make processing simpler. + try + execute "lcd ".fnameescape(a:dir) + catch + echohl ErrorMsg + unsilent echomsg 'Cannot enter directory "' . fnamemodify(a:dir, ':p') . '"' + echohl None + return + endtry + " delete everything in the buffer. + " IMPORTANT: we need to be in a scratch buffer + 0,$ d_ + + let allFilenames = glob('*') + let dispFiles = "" + let subDirs = "../\n" + + let start = 0 + for filename in split(allFilenames, "\n") + + if isdirectory(filename) + let subDirs = subDirs.filename."/\n" + else + if allowRegexp != '' && filename !~ allowRegexp + elseif rejectRegexp != '' && filename =~ rejectRegexp + else + let dispFiles = dispFiles.filename."\n" + endif + endif + endfor + + 0put!=dispFiles + 0put!=subDirs + " delte the last empty line resulting from the put + $ d_ + + call s:FB_SetHighlighting() + call s:FB_DisplayHelp() + call s:FB_SetMaps() + + " goto the first file/directory + 0 + call search('^"=', 'w') + normal! j: + + set nomodified nomodifiable + + call s:FB_ResetSilentSettings() +endfunction " }}} +" FB_SetVar: sets script local variables from outside this script {{{ +" Description: +function! FB_SetVar(varname, value) + let s:{a:varname} = a:value +endfunction " }}} + +" ============================================================================== +" Script local functions below this +" ============================================================================== +" FB_SetHighlighting: sets syntax highlighting for the buffer {{{ +" Description: +" Origin: from explorer.vim in vim +function! FB_SetHighlighting() + " Set up syntax highlighting + " Something wrong with the evaluation of the conditional though... + if has("syntax") && exists("g:syntax_on") && !has("syntax_items") + syn match browseSynopsis "^\"[ -].*" + syn match browseDirectory "[^\"].*/ " + syn match browseDirectory "[^\"].*/$" + syn match browseCurDir "^\"= .*$" + + "hi def link browseSynopsis PreProc + hi def link browseSynopsis Special + hi def link browseDirectory Directory + hi def link browseCurDir Statement + hi def link browseSuffixes Type + endif +endfunction " }}} +" FB_SetMaps: sets buffer local maps {{{ +" Description: +function! FB_SetMaps() + nnoremap q :bdelete + nnoremap :bdelete + nnoremap :call FB_EditEntry() + nnoremap ? :call FB_ToggleHelp() + nnoremap C :CD + + command! -nargs=1 -buffer -complete=dir CD :silent call FB_DisplayFiles('') + + " lock the user in this window + nnoremap +endfunction " }}} +" FB_SetSilentSettings: some settings which make things silent {{{ +" Description: +" Origin: from explorer.vim distributed with vim. +function! FB_SetSilentSettings() + let s:save_report=&report + let s:save_showcmd = &sc + set report=10000 noshowcmd +endfunction +" FB_ResetSilentSettings: reset settings set by FB_SetSilentSettings +" Description: +function! FB_ResetSilentSettings() + let &report=s:save_report + let &showcmd = s:save_showcmd +endfunction " }}} +" FB_SetScratchSettings: makes the present buffer a scratch buffer {{{ +" Description: +function! FB_SetScratchSettings() + " Turn off the swapfile, set the buffer type so that it won't get + " written, and so that it will get deleted when it gets hidden. + setlocal noreadonly modifiable + setlocal noswapfile + setlocal buftype=nowrite + setlocal bufhidden=delete + " Don't wrap around long lines + setlocal nowrap +endfunction + +" }}} +" FB_ToggleHelp: toggles verbosity of help {{{ +" Description: +function! FB_ToggleHelp() + let s:FB_VerboseHelp = 1 - s:FB_GetVar('FB_VerboseHelp', 0) + + call FB_DisplayFiles('.') +endfunction " }}} +" FB_DisplayHelp: displays a helpful header {{{ +" Description: +function! FB_DisplayHelp() + let verboseHelp = s:FB_GetVar('FB_VerboseHelp', 0) + if verboseHelp + let txt = + \ "\" on file: choose the file and quit\n" + \ ."\" on dir : enter directory\n" + \ ."\" q/ : quit without choosing\n" + \ ."\" C/:CD : change directory\n" + \ ."\" ? : toggle help verbosity\n" + \ ."\"= ".getcwd() + else + let txt = "\" ?: toggle help verbosity\n" + \ ."\"= ".getcwd() + endif + 0put!=txt +endfunction " }}} +" FB_EditEntry: handles the user pressing on a line {{{ +" Description: +function! FB_EditEntry() + let line = getline('.') + + if isdirectory(line) + call FB_DisplayFiles(line) + endif + + " If the user has a call back function defined on choosing a file, handle + " it. + let cbf = s:FB_GetVar('FB_CallBackFunction', '') + if cbf != '' && line !~ '^" ' && filereadable(line) + let fname = fnamemodify(line, ':p') + bdelete + + let arguments = s:FB_GetVar('FB_CallBackFunctionArgs', '') + if arguments != '' + let arguments = ','.arguments + endif + if exists('*Tex_Debug') + call Tex_Debug('arguments = '.arguments, 'fb') + call Tex_Debug("call ".cbf."('".fname."'".arguments.')', 'fb') + endif + exec "call ".cbf."('".fname."'".arguments.')' + endif +endfunction " }}} +" FB_GetVar: gets the most local value of a variable {{{ +function! FB_GetVar(name, default) + if exists('s:'.a:name) + return s:{a:name} + elseif exists('w:'.a:name) + return w:{a:name} + elseif exists('b:'.a:name) + return b:{a:name} + elseif exists('g:'.a:name) + return g:{a:name} + else + return a:default + endif +endfunction + +" }}} + +let &cpo = s:save_cpo + +" vim:fdm=marker:ff=unix:noet:ts=4:sw=4:nowrap diff --git a/.vim/plugin/imaps.vim b/.vim/plugin/imaps.vim deleted file mode 120000 index 078bfb9..0000000 --- a/.vim/plugin/imaps.vim +++ /dev/null @@ -1 +0,0 @@ -/usr/share/vim/addons/plugin/imaps.vim \ No newline at end of file diff --git a/.vim/plugin/imaps.vim b/.vim/plugin/imaps.vim new file mode 100644 index 0000000..94ccfc8 --- /dev/null +++ b/.vim/plugin/imaps.vim @@ -0,0 +1,765 @@ +" File: imaps.vim +" Authors: Srinath Avadhanula +" Benji Fisher +" +" Description: insert mode template expander with cursor placement +" while preserving filetype indentation. +" +" +" Documentation: {{{ +" +" Motivation: +" this script provides a way to generate insert mode mappings which do not +" suffer from some of the problem of mappings and abbreviations while allowing +" cursor placement after the expansion. It can alternatively be thought of as +" a template expander. +" +" Consider an example. If you do +" +" imap lhs something +" +" then a mapping is set up. However, there will be the following problems: +" 1. the 'ttimeout' option will generally limit how easily you can type the +" lhs. if you type the left hand side too slowly, then the mapping will not +" be activated. +" 2. if you mistype one of the letters of the lhs, then the mapping is +" deactivated as soon as you backspace to correct the mistake. +" +" If, in order to take care of the above problems, you do instead +" +" iab lhs something +" +" then the timeout problem is solved and so is the problem of mistyping. +" however, abbreviations are only expanded after typing a non-word character. +" which causes problems of cursor placement after the expansion and invariably +" spurious spaces are inserted. +" +" Usage Example: +" this script attempts to solve all these problems by providing an emulation +" of imaps wchich does not suffer from its attendant problems. Because maps +" are activated without having to press additional characters, therefore +" cursor placement is possible. furthermore, file-type specific indentation is +" preserved, because the rhs is expanded as if the rhs is typed in literally +" by the user. +" +" Each "mapping" is of the form: +" +" call IMAP (lhs, rhs, ft) +" +" Some characters in the RHS have special meaning which help in cursor +" placement. +" +" Example One: +" +" call IMAP ("bit`", "\\begin{itemize}\\\item <++>\\\end{itemize}<++>", "tex") +" +" This effectively sets up the map for "bit`" whenever you edit a latex file. +" When you type in this sequence of letters, the following text is inserted: +" +" \begin{itemize} +" \item * +" \end{itemize}<++> +" +" where * shows the cursor position. The cursor position after inserting the +" text is decided by the position of the first "place-holder". Place holders +" are special characters which decide cursor placement and movement. In the +" example above, the place holder characters are <+ and +>. After you have typed +" in the item, press and you will be taken to the next set of <++>'s. +" Therefore by placing the <++> characters appropriately, you can minimize the +" use of movement keys. +" +" NOTE: Set g:Imap_UsePlaceHolders to 0 to disable placeholders altogether. +" Set +" g:Imap_PlaceHolderStart and g:Imap_PlaceHolderEnd +" to something else if you want different place holder characters. +" Also, b:Imap_PlaceHolderStart and b:Imap_PlaceHolderEnd override the values +" of g:Imap_PlaceHolderStart and g:Imap_PlaceHolderEnd respectively. This is +" useful for setting buffer specific place hoders. +" +" Example Two: +" You can use the command to insert dynamic elements such as dates. +" call IMAP ('date`', "\=strftime('%b %d %Y')\", '') +" +" sets up the map for date` to insert the current date. +" }}} + +if exists('b:suppress_latex_suite') && b:suppress_latex_suite == 1 + finish +endif + +" line continuation used here. +let s:save_cpo = &cpo +set cpo&vim + +" ============================================================================== +" Script Options / Variables +" ============================================================================== +" Options {{{ +if !exists('g:Imap_StickyPlaceHolders') + let g:Imap_StickyPlaceHolders = 1 +endif +if !exists('g:Imap_DeleteEmptyPlaceHolders') + let g:Imap_DeleteEmptyPlaceHolders = 1 +endif +if !exists('g:Imap_GoToSelectMode') + let g:Imap_GoToSelectMode = 1 +endif +" }}} +" Variables {{{ +" s:LHS_{ft}_{char} will be generated automatically. It will look like +" s:LHS_tex_o = 'fo\|foo\|boo' and contain all mapped sequences ending in "o". +" +" s:Map_{ft}_{lhs} will be generated automatically. It will look like +" s:Map_c_foo = 'for(<++>; <++>; <++>)', the mapping for "foo". +" +" s:LHS_{ft} will be generated automatically. It contains all chars for which +" s:LHS_{ft}_{char} is not empty. +" +" b:IMAP_imaps will be generated automatically. It contains all chars which +" were mapped in the current buffer. +" +" }}} + +" ============================================================================== +" functions for easy insert mode mappings. +" ============================================================================== +" IMAP: Adds a "fake" insert mode mapping. {{{ +" For example, doing +" IMAP('abc', 'def' ft) +" will mean that if the letters abc are pressed in insert mode, then +" they will be replaced by def. If ft != '', then the "mapping" will be +" buffer local. You have to call IMAP_infect() on new buffers of type ft. +" +" Using IMAP has a few advantages over simply doing: +" imap abc def +" 1. with imap, if you begin typing abc, the cursor will not advance and +" long as there is a possible completion, the letters a, b, c will be +" displayed on on top of the other. using this function avoids that. +" 2. with imap, if a backspace or arrow key is pressed before completing +" the word, then the mapping is lost. this function allows movement. +" (this ofcourse means that this function is only limited to +" left-hand-sides which do not have movement keys or unprintable +" characters) +" It works by only mapping the last character of the left-hand side. +" when this character is typed in, then a reverse lookup is done and if +" the previous characters consititute the left hand side of the mapping, +" the previously typed characters and erased and the right hand side is +" inserted + +" IMAP: set up a filetype specific mapping. +" Description: +" "maps" the lhs to rhs in files of type 'ft'. If supplied with 2 +" additional arguments, then those are assumed to be the placeholder +" characters in rhs. If unspecified, then the placeholder characters +" are assumed to be '<+' and '+>' These placeholder characters in +" a:rhs are replaced with the users setting of +" [bg]:Imap_PlaceHolderStart and [bg]:Imap_PlaceHolderEnd settings. +" +function! IMAP(lhs, rhs, ft, ...) + + " Find the place holders to save for IMAP_PutTextWithMovement() . + if a:0 < 2 + let phs = '<+' + let phe = '+>' + else + let phs = a:1 + let phe = a:2 + endif + + let hash = s:Hash(a:lhs) + let s:Map_{a:ft}_{hash} = a:rhs + let s:phs_{a:ft}_{hash} = phs + let s:phe_{a:ft}_{hash} = phe + + " Add a:lhs to the list of left-hand sides that end with lastLHSChar: + let lastLHSChar = s:MultiByteLastCharacter(a:lhs) + let hash = s:Hash(lastLHSChar) + if !exists("s:LHS_" . a:ft . "_" . hash) + let s:LHS_{a:ft}_{hash} = escape(a:lhs, '\') + else + " Check whether this lhs is already mapped. + if a:lhs !~# '\V\^\%(' . s:LHS_{a:ft}_{hash} . '\)\$' + let s:LHS_{a:ft}_{hash} = escape(a:lhs, '\') .'\|'. s:LHS_{a:ft}_{hash} + endif + endif + + " Add lastLHSChar to s:LHS_{ft} + if a:ft != '' + if !exists('s:LHS_'.a:ft) + let s:LHS_{a:ft} = [] + endif + if index(s:LHS_{a:ft}, lastLHSChar) < 0 + call add(s:LHS_{a:ft}, lastLHSChar ) + endif + endif + + " Only add a imap if it is a global IMAP or we are in the correct filetype + " (then, we add a -local imap, other buffers have to be infected + " with IMAP_infect). + if a:ft != '' + if &ft == a:ft + let buffer = '' + else + return + endif + else + let buffer = '' + endif + + " map only the last character of the left-hand side. + call s:IMAP_add_imap( lastLHSChar, buffer ) +endfunction + +" }}} +" IUNMAP: Removes a "fake" insert mode mapping. {{{ +function! IUNMAP(lhs, ft) + let lastLHSChar = s:MultiByteLastCharacter(a:lhs) + let charHash = s:Hash(lastLHSChar) + + " Check whether the mapping exists + if exists("s:LHS_" . a:ft . "_" . charHash) + \ && a:lhs =~# '\V\^\%(' . s:LHS_{a:ft}_{charHash} . '\)\$' + + " Remove lhs from the list of mappings + let s:LHS_{a:ft}_{charHash} = substitute(s:LHS_{a:ft}_{charHash}, + \ '\V\(\^\|\\|\)' . escape(escape(a:lhs, '\'), '\') . '\(\$\|\\|\)', + \ '\\|', '') + + " Remove leading/trailing '\|' + let s:LHS_{a:ft}_{charHash} = substitute(s:LHS_{a:ft}_{charHash}, '^\\|\|\\|$', '', '') + + let hash = s:Hash(a:lhs) + unlet s:Map_{a:ft}_{hash} + unlet s:phs_{a:ft}_{hash} + unlet s:phe_{a:ft}_{hash} + + if strlen(s:LHS_{a:ft}_{charHash}) == 0 + " No more mappings left for this lastLHSChar. + let idx = index(s:LHS_{a:ft}, lastLHSChar) + if idx >= 0 + call remove(s:LHS_{a:ft}, idx ) + endif + + " Check for ft and unmap the last character of the left-hand side. + " (if ft is set, other buffers with the same ft have to be updated with + " IMAP_desinfect() and IMAP_infect()). + if a:ft != '' + if &ft == a:ft + call s:IMAP_rm_imap( lastLHSChar, '' ) + endif + else + call s:IMAP_rm_imap( lastLHSChar, '' ) + endif + endif + + else + " a:lhs is not mapped! + " Do nothing. + endif +endfunction +" }}} +" IMAP_infect: Infect the current buffer with ft IMAPS. {{{ +function! IMAP_infect() + if &ft != '' && exists('s:LHS_'.&ft) + for lastLHSChar in s:LHS_{&ft} + call s:IMAP_add_imap( lastLHSChar, '' ) + endfor + endif +endfunction +" }}} +" IMAP_desinfect: Desinfect the current buffer with ft IMAPS. {{{ +function! IMAP_desinfect() + if exists('b:IMAP_imaps') + for lastLHSChar in copy(b:IMAP_imaps) + call s:IMAP_rm_imap( lastLHSChar, '' ) + endfor + endif +endfunction +" }}} +" IMAP_list: list the rhs and place holders corresponding to a:lhs {{{ +" +" Added mainly for debugging purposes, but maybe worth keeping. +function! IMAP_list(lhs) + let char = s:MultiByteLastCharacter(a:lhs) + let charHash = s:Hash(char) + if exists("s:LHS_" . &ft ."_". charHash) + \ && a:lhs =~# '\V\^\%(' . s:LHS_{&ft}_{charHash} . '\)\$' + let ft = &ft + elseif exists("s:LHS__" . charHash) + \ && a:lhs =~# '\V\^\%(' . s:LHS__{charHash} . '\)\$' + let ft = "" + else + return "" + endif + let hash = s:Hash(a:lhs) + return "rhs = " . strtrans( s:Map_{ft}_{hash} ) . " place holders = " . + \ s:phs_{ft}_{hash} . " and " . s:phe_{ft}_{hash} +endfunction +" }}} +" IMAP_list_all: list all the rhs and place holders with lhs ending in a:char {{{ +function! IMAP_list_all(char) + let result = '' + let charHash = s:Hash(a:char) + if &ft == '' + let ft_list = [''] + else + let ft_list = [&ft, ''] + endif + + " Loop over current file type and global IMAPs + for ft in ft_list + if ft == '' + let ft_display = 'global: ' + else + let ft_display = ft . ': ' + endif + if exists("s:LHS_" . ft ."_". charHash) + for lhs in split( s:LHS_{ft}_{charHash}, '\\|' ) + " Undo the escaping of backslashes in lhs + let lhs = substitute(lhs, '\\\\', '\', 'g') + let hash = s:Hash(lhs) + let result .= ft_display . lhs . " => " . strtrans( s:Map_{ft}_{hash} ) . "\n" + endfor + endif + endfor + return result +endfunction +" }}} +" LookupCharacter: inserts mapping corresponding to this character {{{ +" +" This function extracts from s:LHS_{&ft}_{a:char} or s:LHS__{a:char} +" the longest lhs matching the current text. Then it replaces lhs with the +" corresponding rhs saved in s:Map_{ft}_{lhs} . +" The place-holder variables are passed to IMAP_PutTextWithMovement() . +function! s:LookupCharacter(char) + if IMAP_GetVal('Imap_FreezeImap', 0) == 1 + return a:char + endif + let charHash = s:Hash(a:char) + + " The line so far, including the character that triggered this function: + let text = strpart(getline("."), 0, col(".")-1) . a:char + " Prefer a local map to a global one, even if the local map is shorter. + " Is this what we want? Do we care? + " Use '\V' (very no-magic) so that only '\' is special, and it was already + " escaped when building up s:LHS_{&ft}_{charHash} . + if exists("s:LHS_" . &ft . "_" . charHash) + \ && text =~ "\\C\\V\\%(" . s:LHS_{&ft}_{charHash} . "\\)\\$" + let ft = &ft + elseif exists("s:LHS__" . charHash) + \ && text =~ "\\C\\V\\%(" . s:LHS__{charHash} . "\\)\\$" + let ft = "" + else + " If this is a character which could have been used to trigger an + " abbreviation, check if an abbreviation exists. + if a:char !~ '\k' + let lastword = matchstr(getline('.'), '\k\+$', '') + call IMAP_Debug('getting lastword = ['.lastword.']', 'imap') + if lastword != '' + let abbreviationRHS = maparg( lastword, 'i', 1 ) + + call IMAP_Debug('getting abbreviationRHS = ['.abbreviationRHS.']', 'imap') + + if abbreviationRHS == '' + return a:char + endif + + let abbreviationRHS = escape(abbreviationRHS, '\<"') + exec 'let abbreviationRHS = "'.abbreviationRHS.'"' + + let lhs = lastword.a:char + let rhs = abbreviationRHS.a:char + let phs = IMAP_GetPlaceHolderStart() + let phe = IMAP_GetPlaceHolderEnd() + else + return a:char + endif + else + return a:char + endif + endif + " Find the longest left-hand side that matches the line so far. + " matchstr() returns the match that starts first. This automatically + " ensures that the longest LHS is used for the mapping. + if !exists('lhs') || !exists('rhs') + let lhs = matchstr(text, "\\C\\V\\%(" . s:LHS_{ft}_{charHash} . "\\)\\$") + let hash = s:Hash(lhs) + let rhs = s:Map_{ft}_{hash} + let phs = s:phs_{ft}_{hash} + let phe = s:phe_{ft}_{hash} + endif + + if strlen(lhs) == 0 + return a:char + endif + + " enough back-spaces to erase the left-hand side + let bs = repeat("\", s:MultiByteStrlen(lhs)) + + " \u inserts an undo point + let result = a:char . "\u" . bs . IMAP_PutTextWithMovement(rhs, phs, phe) + + if a:char !~? '[a-z0-9]' + " If 'a:char' is not a letter or number, insert it literally. + let result = "\" . result + endif + + return result +endfunction + +" }}} +" IMAP_PutTextWithMovement: returns the string with movement appended {{{ +" Description: +" If a:str contains "placeholders", then appends movement commands to +" str in a way that the user moves to the first placeholder and enters +" insert or select mode. If supplied with 2 additional arguments, then +" they are assumed to be the placeholder specs. Otherwise, they are +" assumed to be '<+' and '+>'. These placeholder chars are replaced +" with the users settings of [bg]:Imap_PlaceHolderStart and +" [bg]:Imap_PlaceHolderEnd. +function! IMAP_PutTextWithMovement(str, ...) + + " The placeholders used in the particular input string. These can be + " different from what the user wants to use. + if a:0 < 2 + let phs = '<+' + let phe = '+>' + else + let phs = escape(a:1, '\') + let phe = escape(a:2, '\') + endif + + let text = a:str + + " The user's placeholder settings. + let phsUser = IMAP_GetPlaceHolderStart() + let pheUser = IMAP_GetPlaceHolderEnd() + + let pattern = '\V\(\.\{-}\)' .phs. '\(\.\{-}\)' .phe. '\(\.\*\)' + " If there are no placeholders, just return the text. + if text !~ pattern + call IMAP_Debug('Not getting '.phs.' and '.phe.' in '.text, 'imap') + return text + endif + " Break text up into "initial <+template+> final"; any piece may be empty. + let initial = substitute(text, pattern, '\1', '') + let template = substitute(text, pattern, '\2', '') + let final = substitute(text, pattern, '\3', '') + + " If the user does not want to use placeholders, then remove all but the + " first placeholder. + " Otherwise, replace all occurences of the placeholders here with the + " user's choice of placeholder settings. + if exists('g:Imap_UsePlaceHolders') && !g:Imap_UsePlaceHolders + let final = substitute(final, '\V'.phs.'\.\{-}'.phe, '', 'g') + else + let final = substitute(final, '\V'.phs.'\(\.\{-}\)'.phe, + \ phsUser.'\1'.pheUser, 'g') + endif + + " Build up the text to insert: + " 1. the initial text plus an extra character; + " 2. go to Normal mode with , so it works even if 'insertmode' + " is set, and mark the position; + " 3. replace the extra character with tamplate and final; + " 4. back to Normal mode and restore the cursor position; + " 5. call IMAP_Jumpfunc(). + let template = phsUser . template . pheUser + " Old trick: insert and delete a character to get the same behavior at + " start, middle, or end of line and on empty lines. + let text = initial . "X\\:call IMAP_Mark('set')\\"_s" + let text = text . template . final + let text = text . "\\:call IMAP_Mark('go')\" + let text = text . ":call IMAP_Jumpfunc('', 1)\" + + call IMAP_Debug('IMAP_PutTextWithMovement: text = ['.text.']', 'imap') + return text +endfunction + +" }}} +" IMAP_Jumpfunc: takes user to next <+place-holder+> {{{ +" Author: Luc Hermitte +" Arguments: +" direction: flag for the search() function. If set to '', search forwards, +" if 'b', then search backwards. See the {flags} argument of the +" |search()| function for valid values. +" inclusive: In vim, the search() function is 'exclusive', i.e we always goto +" next cursor match even if there is a match starting from the +" current cursor position. Setting this argument to 1 makes +" IMAP_Jumpfunc() also respect a match at the current cursor +" position. 'inclusive'ness is necessary for IMAP() because a +" placeholder string can occur at the very beginning of a map which +" we want to select. +" We use a non-zero value only in special conditions. Most mappings +" should use a zero value. +function! IMAP_Jumpfunc(direction, inclusive) + + " The user's placeholder settings. + let phsUser = IMAP_GetPlaceHolderStart() + let pheUser = IMAP_GetPlaceHolderEnd() + + " Set up flags for the search() function + let flags = a:direction + if a:inclusive + let flags .= 'c' + end + + let searchString = '\V'.phsUser.'\_.\{-}'.pheUser + + " If we didn't find any placeholders return quietly. + if !search(searchString, flags) + return + endif + + " Open any closed folds and make this part of the text visible. + silent! foldopen! + + " We are at the starting placeholder. Start visual mode. + normal! v + + " Calculate if we have an empty placeholder. It is empty if both + " placeholders appear one after the other. + " Check also whether the empty placeholder ends at the end of the line. + let curline = strpart(getline('.'), col('.')-1) + let phUser = phsUser.pheUser + let placeHolderEmpty = (strpart(curline,0,strlen(phUser)) ==# phUser) + let placeHolderEOL = (curline ==# phUser) + + " Search for the end placeholder and position the cursor. + call search(searchString, 'ce') + + " If we are selecting in exclusive mode, then we need to move one step to + " the right + if &selection == 'exclusive' + normal! l + endif + + " Now either goto insert mode, visual mode or select mode. + if placeHolderEmpty && g:Imap_DeleteEmptyPlaceHolders + " Delete the empty placeholder into the blackhole. + normal! "_d + " Start insert mode. If the placeholder was at the end of the line, use + " startinsert! (equivalent to 'A'), otherwise startinsert (equiv. 'i') + if placeHolderEOL + startinsert! + else + startinsert + endif + else + if g:Imap_GoToSelectMode + " Go to select mode + execute "normal! \" + else + " Do not go to select mode + endif + endif +endfunction +" }}} +" Maps for IMAP_Jumpfunc {{{ +" +" These mappings use and thus provide for easy user customization. When +" the user wants to map some other key to jump forward, he can do for +" instance: +" nmap ,f IMAP_JumpForward +" etc. + +" jumping forward and back in insert mode. +inoremap IMAP_JumpForward :call IMAP_Jumpfunc('', 0) +inoremap IMAP_JumpBack :call IMAP_Jumpfunc('b', 0) + +" jumping in normal mode +nnoremap IMAP_JumpForward :call IMAP_Jumpfunc('', 0) +nnoremap IMAP_JumpBack :call IMAP_Jumpfunc('b', 0) + +" deleting the present selection and then jumping forward. +vnoremap IMAP_DeleteAndJumpForward "_:call IMAP_Jumpfunc('', 0) +vnoremap IMAP_DeleteAndJumpBack "_:call IMAP_Jumpfunc('b', 0) + +" jumping forward without deleting present selection. +vnoremap IMAP_JumpForward :call IMAP_Jumpfunc('', 0) +vnoremap IMAP_JumpBack `<:call IMAP_Jumpfunc('b', 0) + +" }}} +" Default maps for IMAP_Jumpfunc {{{ +" map only if there is no mapping already. allows for user customization. +" NOTE: Default mappings for jumping to the previous placeholder are not +" provided. It is assumed that if the user will create such mappings +" hself if e so desires. +if !hasmapto('IMAP_JumpForward', 'i') + imap IMAP_JumpForward +endif +if !hasmapto('IMAP_JumpForward', 'n') + nmap IMAP_JumpForward +endif +if exists('g:Imap_StickyPlaceHolders') && g:Imap_StickyPlaceHolders + if !hasmapto('IMAP_JumpForward', 'v') + vmap IMAP_JumpForward + endif +else + if !hasmapto('IMAP_DeleteAndJumpForward', 'v') + vmap IMAP_DeleteAndJumpForward + endif +endif +" }}} + +" ============================================================================== +" helper functions +" ============================================================================== +" s:Hash: Return a version of a string that can be used as part of a variable" {{{ +" name. +" Converts every non alphanumeric character into _{ascii}_ where {ascii} is +" the ASCII code for that character... +fun! s:Hash(text) + return substitute(a:text, '\([^[:alnum:]]\)', + \ '\="_".char2nr(submatch(1))."_"', 'g') +endfun +"" }}} +" s:IMAP_add_imap() Adds the imap for IMAP {{{ +function! s:IMAP_add_imap( lastLHSChar, buffer ) + if a:lastLHSChar == ' ' + for lastLHSChar in ['', '', '', ''] + call s:IMAP_add_imap( lastLHSChar, a:buffer ) + endfor + else + if a:buffer =~# '' + if !exists('b:IMAP_imaps') + let b:IMAP_imaps = [] + endif + if index(b:IMAP_imaps, a:lastLHSChar) < 0 + call add(b:IMAP_imaps, a:lastLHSChar ) + endif + endif + exe 'inoremap ' . a:buffer + \ escape(a:lastLHSChar, '|') + \ '=LookupCharacter("' . + \ escape(a:lastLHSChar, '\|"') . + \ '")' + endif +endfunction +" }}} +" s:IMAP_rm_imap() Removes the imap for IMAP {{{ +function! s:IMAP_rm_imap( lastLHSChar, buffer ) + if a:lastLHSChar == ' ' + for lastLHSChar in ['', '', '', ''] + call s:IMAP_rm_imap( lastLHSChar, a:buffer ) + endfor + else + if a:buffer =~# '' && exists('b:IMAP_imaps') + let idx = index(b:IMAP_imaps, a:lastLHSChar) + if idx >= 0 + call remove(b:IMAP_imaps, idx) + endif + endif + exe 'iunmap ' . a:buffer escape(a:lastLHSChar, '|') + endif +endfunction +" }}} +" IMAP_GetPlaceHolderStart and IMAP_GetPlaceHolderEnd: "{{{ +" return the buffer local placeholder variables, or the global one, or the default. +function! IMAP_GetPlaceHolderStart() + if exists("b:Imap_PlaceHolderStart") && strlen(b:Imap_PlaceHolderEnd) + return b:Imap_PlaceHolderStart + elseif exists("g:Imap_PlaceHolderStart") && strlen(g:Imap_PlaceHolderEnd) + return g:Imap_PlaceHolderStart + else + return "<+" +endfun +function! IMAP_GetPlaceHolderEnd() + if exists("b:Imap_PlaceHolderEnd") && strlen(b:Imap_PlaceHolderEnd) + return b:Imap_PlaceHolderEnd + elseif exists("g:Imap_PlaceHolderEnd") && strlen(g:Imap_PlaceHolderEnd) + return g:Imap_PlaceHolderEnd + else + return "+>" +endfun +" }}} +" IMAP_Debug: interface to Tex_Debug if available, otherwise emulate it {{{ +" Description: +" Do not want a memory leak! Set this to zero so that imaps always +" starts out in a non-debugging mode. +if !exists('g:Imap_Debug') + let g:Imap_Debug = 0 +endif +function! IMAP_Debug(string, pattern) + if !g:Imap_Debug + return + endif + if exists('*Tex_Debug') + call Tex_Debug(a:string, a:pattern) + else + if !exists('s:debug_'.a:pattern) + let s:debug_{a:pattern} = a:string + else + let s:debug_{a:pattern} = s:debug_{a:pattern}.a:string + endif + endif +endfunction " }}} +" IMAP_DebugClear: interface to Tex_DebugClear if avaialable, otherwise emulate it {{{ +" Description: +function! IMAP_DebugClear(pattern) + if exists('*Tex_DebugClear') + call Tex_DebugClear(a:pattern) + else + let s:debug_{a:pattern} = '' + endif +endfunction " }}} +" IMAP_PrintDebug: interface to Tex_DebugPrint if avaialable, otherwise emulate it {{{ +" Description: +function! IMAP_PrintDebug(pattern) + if exists('*Tex_PrintDebug') + call Tex_PrintDebug(a:pattern) + else + if exists('s:debug_'.a:pattern) + echo s:debug_{a:pattern} + endif + endif +endfunction " }}} +" IMAP_Mark: Save the cursor position (if a:action == 'set') in a" {{{ +" script-local variable; restore this position if a:action == 'go'. +let s:Mark = "(0,0)" +let s:initBlanks = '' +function! IMAP_Mark(action) + if a:action == 'set' + let s:Mark = "(" . line(".") . "," . col(".") . ")" + let s:initBlanks = matchstr(getline('.'), '^\s*') + elseif a:action == 'go' + execute "call cursor" s:Mark + let blanksNow = matchstr(getline('.'), '^\s*') + if strlen(blanksNow) > strlen(s:initBlanks) + execute 'silent! normal! '.(strlen(blanksNow) - strlen(s:initBlanks)).'l' + elseif strlen(blanksNow) < strlen(s:initBlanks) + execute 'silent! normal! '.(strlen(s:initBlanks) - strlen(blanksNow)).'h' + endif + endif +endfunction "" }}} +" IMAP_GetVal: gets the value of a variable {{{ +" Description: first checks window local, then buffer local etc. +function! IMAP_GetVal(name, ...) + if a:0 > 0 + let default = a:1 + else + let default = '' + endif + if exists('w:'.a:name) + return w:{a:name} + elseif exists('b:'.a:name) + return b:{a:name} + elseif exists('g:'.a:name) + return g:{a:name} + else + return default + endif +endfunction " }}} +" s:MultiByteStrlen: Same as strlen() but counts multibyte characters {{{ +" instead of bytes. +function! s:MultiByteStrlen(str) + return strlen(substitute(a:str, ".", "x", "g")) +endfunction " }}} +" s:MultiByteLastCharacter: Return last multibyte characters {{{ +function! s:MultiByteLastCharacter(str) + return matchstr(a:str, ".$") +endfunction " }}} + +let &cpo = s:save_cpo + +" vim:ft=vim:ts=4:sw=4:noet:fdm=marker:commentstring=\"\ %s:nowrap diff --git a/.vim/plugin/libList.vim b/.vim/plugin/libList.vim deleted file mode 120000 index b9192da..0000000 --- a/.vim/plugin/libList.vim +++ /dev/null @@ -1 +0,0 @@ -/usr/share/vim/addons/plugin/libList.vim \ No newline at end of file diff --git a/.vim/plugin/remoteOpen.vim b/.vim/plugin/remoteOpen.vim deleted file mode 120000 index 3a06168..0000000 --- a/.vim/plugin/remoteOpen.vim +++ /dev/null @@ -1 +0,0 @@ -/usr/share/vim/addons/plugin/remoteOpen.vim \ No newline at end of file diff --git a/.vim/plugin/remoteOpen.vim b/.vim/plugin/remoteOpen.vim new file mode 100644 index 0000000..a0b11d8 --- /dev/null +++ b/.vim/plugin/remoteOpen.vim @@ -0,0 +1,154 @@ +" File: remoteOpen.vim +" Author: Srinath Avadhanula +" +" Description: +" Often times, an external program needs to open a file in gvim from the +" command line. However, it will not know if the file is already opened in a +" previous vim session. It is not sufficient to simply specify +" +" gvim --remote-silent +" +" because this simply opens up in the first remote gvim session it +" sees. This script provides a command RemoteOpen which is meant to be used +" from the command line as follows: +" +" gvim -c ":RemoteOpen + " +" +" where is the line-number you wish to open to. What will +" happen is that a new gvim will start up and enquire from all previous +" sessions if is already open in any of them. If it is, then it +" will edit the file in that session and bring it to the foreground and itself +" quit. Otherwise, it will not quit and instead open up the file for editing +" at . +" +" This was mainly created to be used with Yap (the dvi previewer in miktex), +" so you can specify the program for "inverse search" as specified above. +" This ensures that the inverse search uses the correct gvim each time. +" +" Ofcourse, this requires vim with +clientserver. If not, then RemoteOpen just +" opens in the present session. + +if exists('b:suppress_latex_suite') && b:suppress_latex_suite == 1 + finish +endif + +" Enclose in single quotes so it can be passed as a function argument. +com! -nargs=1 RemoteOpen :call RemoteOpen('') +com! -nargs=? RemoteInsert :call RemoteInsert('') + +" RemoteOpen: open a file remotely (if possible) {{{ +" Description: checks all open vim windows to see if this file has been opened +" anywhere and if so, opens it there instead of in this session. +function! RemoteOpen(arglist) + + " First construct line number and filename from argument. a:arglist is of + " the form: + " +10 c:\path\to\file + " or just + " c:\path\to\file + if a:arglist =~ '^\s*+\d\+' + let linenum = matchstr(a:arglist, '^\s*+\zs\d\+\ze') + let filename = matchstr(a:arglist, '^\s*+\d\+\s*\zs.*\ze') + else + let linenum = 1 + let filename = matchstr(a:arglist, '^\s*\zs.*\ze') + endif + let filename = escape(filename, ' ') + if exists('*Tex_Debug') + call Tex_Debug("linenum = ".linenum.', filename = '.filename, "RemoteOpen") + endif + + " If there is no clientserver functionality, then just open in the present + " session and return + if !has('clientserver') + if exists('*Tex_Debug') + call Tex_Debug("-clientserver, opening locally and returning", "RemoteOpen") + endif + exec "e ".filename + exec linenum + normal! zv + return + endif + + " Otherwise, loop through all available servers + let servers = split(serverlist(), '\n') + let targetServer = '' + + for server in servers + " Find out if there was any server which was used by remoteOpen before + " this. If a new gvim session was ever started via remoteOpen, then + " g:Remote_Server will be set. + if remote_expr(server, 'exists("g:Remote_Server")') + let targetServer = server + endif + + " Ask each server if that file is being edited by them. + let bufnum = remote_expr(server, "bufnr('".filename."')") + " If it is... + if bufnum != -1 + " ask the server to edit that file and come to the foreground. + " set a variable g:Remote_Server to indicate that this server + " session has at least one file opened via RemoteOpen + let targetServer = server + break + end + endfor + + " If there are no servers, open file locally. + if targetServer == '' + if exists('*Tex_Debug') + call Tex_Debug("no open servers, opening locally", "RemoteOpen") + endif + exec "e ".filename + exec linenum + let g:Remote_Server = 1 + normal! zv + return + endif + + " If none of the servers have the file open, then open this file in the + " first server. This has the advantage if yap tries to make vim open + " multiple vims, then at least they will all be opened by the same gvim + " server. + call remote_send(targetServer, + \ "\\". + \ ":let g:Remote_Server = 1\". + \ ":drop ".filename."\". + \ ":".linenum."\zv" + \ ) + call remote_foreground(targetServer) + " quit this vim session + if v:servername != targetServer + q + endif +endfunction " }}} +" RemoteInsert: inserts a \cite'ation remotely (if possible) {{{ +" Description: +function! RemoteInsert(...) + + let citation = matchstr(argv(0), "\\[InsText('.cite{\\zs.\\{-}\\ze}');\\]") + if citation == "" + q + endif + + " Otherwise, loop through all available servers + let servers = split(serverlist(), '\n') + let targetServer = v:servername + + for server in servers + if remote_expr(server, 'exists("g:Remote_WaitingForCite")') + call remote_send(server, citation . "\") + call remote_foreground(server) + if v:servername != server + q + else + return + endif + endif + endfor + + q + +endfunction " }}} + +" vim:ft=vim:ts=4:sw=4:noet:fdm=marker:commentstring=\"\ %s:nowrap diff --git a/.vim/spell/en.utf-8.add b/.vim/spell/en.utf-8.add index 088e4b3..9057d86 100644 --- a/.vim/spell/en.utf-8.add +++ b/.vim/spell/en.utf-8.add @@ -24,3 +24,472 @@ UI PREV php cron +interpretivism +Pākehā +problematise +interpretivist +positionality +verstehen +Garfinkel +reimagining +Garfinkel's +habitus +Bourdieu +DiAngelo +Epistemologies +epistemologies +Haraway +problematises +positionalities +normativity +knowers +Mohanty +coalitional +Sholock +problematize +Noffke +reinscribe +unproblematized +undeniability +decolonial +liberatory +unseeable +Hiemstra +periscoping +masculinist +Heimstra +situationality +coloniality +reinscribing +uninterrogated +antiracist +Māori +autoethnographers +autoethnographic +Tolich +autoethnography +nom +operationalise +autoethographical +Rifkin +universalisation +Pākehāness +unmarkedness +tangata +whenua +Tiriti +essentialised +delegitimise +syncretic +weaponised +personhood +unreflexive +Mackey +hybridity +essentialism +CANZUS +recenters +sociopolitical +selfhood +performative +homemaking +indigeneity +Boler +aa +unknowable +indigeneous +alterity +positionings +indigene +Sneddon +commonsense +exnomination +Confessionalism +incommensurability +unknowability +Lévinas +decentering +unsettlement +decentres +Lévinasian +Pratt +p +hermeneutical +epistemically +cozy +Lugones +Lorde +quo +situatedness +se +neoliberal +decentred +decentre +unracialised +blindspot +reframe +Bourdieu's +behaviors +sedimented +centered +reinscribes +paralyzing +allyship +problematisation +CWS +racialization +problematizes +intersubjectivity +dialogical +nativism +Biculturalism +deconstruct +Pasifika +GWRC +Ōhāriu +O'Malley +O'Malley's +Parihaka +Ihumātao +waiata +te +reo +tikanga +outdoorsiness +boaty +boatiness +Taupō +Whiti +Kēnana +Rua +Kooti +uhh +Ahhh +Excactly +hapū +Mmm +whatevers +Ummmm +Dividedness +kaitiakitanga +reembrace +exoticisation +fetishisation +YYY +Delahunty +fait +aaah +Māoris +Ummmmmm +ummmm +Ngata +Pania +uhhh +CCC +DDD +Ooooh +EEE +FFF +GGG +HHH +JJJ +LLL +Hughs +biculturalism +s +intersubjective +th +commodified +shitload +overthinking +Airbnb +uncomforting +Oranga +Tamariki +Tika +Pennys +playcentre +Nooo +Kapa +maunga +kaupapa +iPhone +app +anonymised +XX +otherly +un +tauiwi +Facebook +investedness +Kotare +mmm +Belich's +Heke +ANZACs +Binney's +Urewera +bicultural +whakawhanaungatanga +rangatahi +Ngāpuhi +Kākā +noho +remember +indigenisation +rela +Ngā +Tauira +Yan +altru +g +prob +Pākehā's +Homi +Bhabha +Hoskings +aaaah +pou +tino +rangatiratanga +AGM +Teanau +kaiwhakahaere +Rōpū +Kerekere +kaitiaki +Teanau's +rūnanga +recentering +tautoko +workgroups +Wānanga +kaiako +whanaungatanga +ao +hui +doey +Jacinda +Ardern +ness +Marama +Wiremu +Katy +Wiremu's +outdoorsey +colonialised +uncomfortableness +woah +Nah +nah +maraes +fullstop +nother +styley +ish +Hosking +bestest +world +frickin +whataboutism +nooooo +ugggh +Commodifies +girly +goth +Wangas +gothic +subjectification +themself +conversating +spose +groupthink +BTP +UKIP +intersectional +whakaaro +commodification +textbfX +textbfP +Swandri +Fabienne +B +mainstreaming +C +Binney +problematised +F +impactful +lockdown +Sāmoan +colourblind +motu +Diangelo's +D +H +Newstalk +ZB +Plunket +Youtube +Lamingtons +Gingernuts +Merkel +stompy +Kaihautū +pillock +Māoridom +packin +geez +Overton +Brexit +Tūranganui +Kiwa +Kāpiti +Golriz +Ghahraman +Ōtaki +yup +Maserati +Torvalds +Stallman +DMV +gnarly +FOMO +Swarbrick +Chlöe +kaitiakitangi +tolerator +Enacter +governmentality +Washpo +Tamatoa +Pākehātanga +nconscious +Freire +Žižek +settledness +Awatere +colonisation's +problematized +Pakehatanga +Zealandness +troublingly +Ahu +relationality +Hage +reinstantiates +Keyness +Addy +marginalities +unimplicated +antisubordination +PoC +Emersion +Logue +imbricated +ethnicised +Antiracism +confessionism +checklist +disjuncture +overanalysis +Nietzschean +transformative +conscientizaçao +on +Probyn +t +e +Drucker +worldview +txt +washpo +Relatedly +raters +fncydesc +tex +Ngāi +Belich +mihi +Tii +o +Ngāruawāhia +cp +hav +DiAngelo's +R +aybe +Hagean +reframing +confessionalism +Fabienne's +Houghton +actionresearch +color +Matias +problematising +Atawhai +Harding's +conscientisation +Black's +Masterate +pa +expat +litreview +Alcoff +reimagine +Postcolonial +postcolonial +wildcard +creat +st +nothing's +multigenerational +tapu +wāhi +searchthemes +blindspots +performativity +generationality +recentres +tech +Michalia +Winitana +Shacklady +Arathimos +Bethan +Veronika +Krafft +Freire's +agential +Barad +interventional +Barad's +Baradian +spective +ised +tanga +emily +Nera +Maitai +bushline +dreadlocked +icecream +Propellerhead +beerbonged +beerbonging +campervan +Hataitai +accessorising +cvitems +Liip +vspace +baselineskip +mentoring +lifecycle +GeoNet +geohazards +Archaeozological +Archaeozoological +Convenors +Resourcify diff --git a/.vim/spell/en.utf-8.add.spl b/.vim/spell/en.utf-8.add.spl index dbe182a..f82de76 100644 Binary files a/.vim/spell/en.utf-8.add.spl and b/.vim/spell/en.utf-8.add.spl differ diff --git a/.vimrc b/.vimrc index eccd0a1..fbecad5 100644 --- a/.vimrc +++ b/.vimrc @@ -113,3 +113,11 @@ let php_sql_query = 1 " don't let vimperator be annoying! autocmd BufWritePost */vimperator-*.tmp exe 'write ' . fnameescape((exists('$TMPDIR') ? $TMPDIR : '/tmp') . '/vimperator.ctrl-i.' . strftime('%Y.%m.%d.%H%M%S')) + + +" latex stuff +let g:tex_flavor='latex' + + +set number "line numbers +set textwidth=80