From e92461b88e8b15f435afc940b6293f4cda43596b Mon Sep 17 00:00:00 2001 From: Anton Bobov Date: Thu, 14 Nov 2013 11:28:27 +0600 Subject: Remove unused vim plugins. --- files/.vim/plugin/CSApprox.vim | 987 ---------------------------- files/.vim/plugin/SyntaxFolds.vim | 323 --------- files/.vim/plugin/XMLFolding.vim | 105 --- files/.vim/plugin/filebrowser.vim | 251 ------- files/.vim/plugin/imaps.vim | 831 ------------------------ files/.vim/plugin/libList.vim | 249 ------- files/.vim/plugin/matchit.vim | 812 ----------------------- files/.vim/plugin/project.vim | 1293 ------------------------------------- files/.vim/plugin/remoteOpen.vim | 163 ----- 9 files changed, 5014 deletions(-) delete mode 100644 files/.vim/plugin/CSApprox.vim delete mode 100644 files/.vim/plugin/SyntaxFolds.vim delete mode 100755 files/.vim/plugin/XMLFolding.vim delete mode 100644 files/.vim/plugin/filebrowser.vim delete mode 100644 files/.vim/plugin/imaps.vim delete mode 100644 files/.vim/plugin/libList.vim delete mode 100644 files/.vim/plugin/matchit.vim delete mode 100644 files/.vim/plugin/project.vim delete mode 100644 files/.vim/plugin/remoteOpen.vim (limited to 'files/.vim/plugin') diff --git a/files/.vim/plugin/CSApprox.vim b/files/.vim/plugin/CSApprox.vim deleted file mode 100644 index 0cb727f..0000000 --- a/files/.vim/plugin/CSApprox.vim +++ /dev/null @@ -1,987 +0,0 @@ -" CSApprox: Make gvim-only colorschemes Just Work terminal vim -" Maintainer: Matthew Wozniski (mjw@drexel.edu) -" Date: Wed, 01 Apr 2009 22:10:19 -0400 -" Version: 3.50 -" History: :help csapprox-changelog -" -" Long Description: -" It's hard to find colorschemes for terminal Vim. Most colorschemes are -" written to only support GVim, and don't work at all in terminal Vim. -" -" This plugin makes GVim-only colorschemes Just Work in terminal Vim, as long -" as the terminal supports 88 or 256 colors - and most do these days. This -" usually requires no user interaction (but see below for what to do if things -" don't Just Work). After getting this plugin happily installed, any time you -" use :colorscheme it will do its magic and make the colorscheme Just Work. -" -" Whenever you change colorschemes using the :colorscheme command this script -" will be executed. It will take the colors that the scheme specified for use -" in the GUI and use an approximation algorithm to try to gracefully degrade -" them to the closest color available in your terminal. If you are running in -" a GUI or if your terminal doesn't support 88 or 256 colors, no changes are -" made. Also, no changes will be made if the colorscheme seems to have been -" high color already. -" -" License: -" Copyright (c) 2009, Matthew J. Wozniski -" All rights reserved. -" -" Redistribution and use in source and binary forms, with or without -" modification, are permitted provided that the following conditions are met: -" * Redistributions of source code must retain the above copyright notice, -" this list of conditions and the following disclaimer. -" * Redistributions in binary form must reproduce the above copyright -" notice, this list of conditions and the following disclaimer in the -" documentation and/or other materials provided with the distribution. -" * The names of the contributors may not be used to endorse or promote -" products derived from this software without specific prior written -" permission. -" -" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS -" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -" NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, -" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -" OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -" {>1} Basic plugin setup - -" {>2} Check preconditions -" Quit if the user doesn't want or need us or is missing the gui feature. We -" need +gui to be able to check the gui color settings; vim doesn't bother to -" store them if it is not built with +gui. -if !has('gui') || exists('g:CSApprox_loaded') - " XXX This depends upon knowing the default for g:CSApprox_verbose_level - let s:verbose = 1 - if exists("g:CSApprox_verbose_level") - let s:verbose = g:CSApprox_verbose_level - endif - - if ! has('gui') && s:verbose > 0 - echomsg "CSApprox needs gui support - not loading." - echomsg " See :help |csapprox-+gui| for possible workarounds." - endif - - unlet s:verbose - - finish -endif - -" {1} Mark us as loaded, and disable all compatibility options for now. -let g:CSApprox_loaded = 1 - -let s:savecpo = &cpo -set cpo&vim - -" {>1} Built-in approximation algorithm - -" {>2} Cube definitions -let s:xterm_colors = [ 0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF ] -let s:eterm_colors = [ 0x00, 0x2A, 0x55, 0x7F, 0xAA, 0xD4 ] -let s:konsole_colors = [ 0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF ] -let s:xterm_greys = [ 0x08, 0x12, 0x1C, 0x26, 0x30, 0x3A, - \ 0x44, 0x4E, 0x58, 0x62, 0x6C, 0x76, - \ 0x80, 0x8A, 0x94, 0x9E, 0xA8, 0xB2, - \ 0xBC, 0xC6, 0xD0, 0xDA, 0xE4, 0xEE ] - -let s:urxvt_colors = [ 0x00, 0x8B, 0xCD, 0xFF ] -let s:urxvt_greys = [ 0x2E, 0x5C, 0x73, 0x8B, - \ 0xA2, 0xB9, 0xD0, 0xE7 ] - -" {>2} Integer comparator -" Used to sort the complete list of possible colors -function! s:IntCompare(i1, i2) - return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1 -endfunc - -" {>2} Approximator -" Takes 3 decimal values for r, g, and b, and returns the closest cube number. -" Uses &term to determine which cube should be used, though if &term is set to -" "xterm" or begins with "screen", the variables g:CSApprox_eterm and -" g:CSApprox_konsole can be used to select a different palette. -" -" This approximator considers closeness based upon the individiual components. -" For each of r, g, and b, it finds the closest cube component available on -" the cube. If the three closest matches can combine to form a valid color, -" this color is used, otherwise we repeat the search with the greys removed, -" meaning that the three new matches must make a valid color when combined. -function! s:ApproximatePerComponent(r,g,b) - let hex = printf("%02x%02x%02x", a:r, a:g, a:b) - - let greys = (&t_Co == 88 ? s:urxvt_greys : s:xterm_greys) - - if &t_Co == 88 - let colors = s:urxvt_colors - let type = 'urxvt' - elseif ((&term ==# 'xterm' || &term =~# '^screen' || &term==# 'builtin_gui') - \ && exists('g:CSApprox_konsole') && g:CSApprox_konsole) - \ || &term =~? '^konsole' - let colors = s:konsole_colors - let type = 'konsole' - elseif ((&term ==# 'xterm' || &term =~# '^screen' || &term==# 'builtin_gui') - \ && exists('g:CSApprox_eterm') && g:CSApprox_eterm) - \ || &term =~? '^eterm' - let colors = s:eterm_colors - let type = 'eterm' - else - let colors = s:xterm_colors - let type = 'xterm' - endif - - if !exists('s:approximator_cache_'.type) - let s:approximator_cache_{type} = {} - endif - - let rv = get(s:approximator_cache_{type}, hex, -1) - if rv != -1 - return rv - endif - - " Only obtain sorted list once - if !exists("s:".type."_greys_colors") - let s:{type}_greys_colors = sort(greys + colors, "s:IntCompare") - endif - - let greys_colors = s:{type}_greys_colors - - let r = s:NearestElemInList(a:r, greys_colors) - let g = s:NearestElemInList(a:g, greys_colors) - let b = s:NearestElemInList(a:b, greys_colors) - - let len = len(colors) - if (r == g && g == b && index(greys, r) != -1) - let rv = 16 + len * len * len + index(greys, r) - else - let r = s:NearestElemInList(a:r, colors) - let g = s:NearestElemInList(a:g, colors) - let b = s:NearestElemInList(a:b, colors) - let rv = index(colors, r) * len * len - \ + index(colors, g) * len - \ + index(colors, b) - \ + 16 - endif - - let s:approximator_cache_{type}[hex] = rv - return rv -endfunction - -" {>2} Color comparator -" Finds the nearest element to the given element in the given list -function! s:NearestElemInList(elem, list) - let len = len(a:list) - for i in range(len-1) - if (a:elem <= (a:list[i] + a:list[i+1]) / 2) - return a:list[i] - endif - endfor - return a:list[len-1] -endfunction - -" {>1} Collect info for the set highlights - -" {>2} Determine if synIDattr is usable -" synIDattr() couldn't support 'guisp' until 7.2.052. This function returns -" true if :redir is needed to find the 'guisp' attribute, false if synIDattr() -" is functional. This test can be overridden by setting the global variable -" g:CSApprox_redirfallback to 1 (to force use of :redir) or to 0 (to force use -" of synIDattr()). -function! s:NeedRedirFallback() - if !exists("g:CSApprox_redirfallback") - let g:CSApprox_redirfallback = (v:version == 702 && !has('patch52')) - \ || v:version < 702 - endif - return g:CSApprox_redirfallback -endfunction - -" {>2} Collect and store the highlights -" Get a dictionary containing information for every highlight group not merely -" linked to another group. Return value is a dictionary, with highlight group -" numbers for keys and values that are dictionaries with four keys each, -" 'name', 'term', 'cterm', and 'gui'. 'name' holds the group name, and each -" of the others holds highlight information for that particular mode. -function! s:Highlights(modes) - let rv = {} - - let i = 0 - while 1 - let i += 1 - - " Only interested in groups that exist and aren't linked - if synIDtrans(i) == 0 - break - endif - - " Handle vim bug allowing groups with name == "" to be created - if synIDtrans(i) != i || len(synIDattr(i, "name")) == 0 - continue - endif - - let rv[i] = {} - let rv[i].name = synIDattr(i, "name") - - for where in a:modes - let rv[i][where] = {} - for attr in [ "bold", "italic", "reverse", "underline", "undercurl" ] - let rv[i][where][attr] = synIDattr(i, attr, where) - endfor - - for attr in [ "fg", "bg" ] - let rv[i][where][attr] = synIDattr(i, attr.'#', where) - endfor - - if where == "gui" - let rv[i][where]["sp"] = s:SynGuiSp(i, rv[i].name) - else - let rv[i][where]["sp"] = -1 - endif - - for attr in [ "fg", "bg", "sp" ] - if rv[i][where][attr] == -1 - let rv[i][where][attr] = '' - endif - endfor - endfor - endwhile - - return rv -endfunction - -" {>2} Retrieve guisp - -" Get guisp using whichever method is specified by _redir_fallback -function! s:SynGuiSp(idx, name) - if !s:NeedRedirFallback() - return s:SynGuiSpAttr(a:idx) - else - return s:SynGuiSpRedir(a:name) - endif -endfunction - -" {>3} Implementation for retrieving guisp with redir hack -function! s:SynGuiSpRedir(name) - redir => temp - exe 'sil hi ' . a:name - redir END - let temp = matchstr(temp, 'guisp=\zs.*') - if len(temp) == 0 || temp[0] =~ '\s' - let temp = "" - else - " Make sure we can handle guisp='dark red' - let temp = substitute(temp, '[\x00].*', '', '') - let temp = substitute(temp, '\s*\(c\=term\|gui\).*', '', '') - let temp = substitute(temp, '\s*$', '', '') - endif - return temp -endfunction - -" {>3} Implementation for retrieving guisp with synIDattr() -function! s:SynGuiSpAttr(idx) - return synIDattr(a:idx, 'sp#', 'gui') -endfunction - -" {>1} Handle color names - -" Place to store rgb.txt name to color mappings - lazy loaded if needed -let s:rgb = {} - -" {>2} Builtin gui color names -" gui_x11.c and gui_gtk_x11.c have some default colors names that are searched -" if the x server doesn't know about a color. If 'showrgb' is available, -" we'll default to using these color names and values, and overwrite them with -" other values if 'showrgb' tells us about those colors. -let s:rgb_defaults = { "lightred" : "#FFBBBB", - \ "lightgreen" : "#88FF88", - \ "lightmagenta" : "#FFBBFF", - \ "darkcyan" : "#008888", - \ "darkblue" : "#0000BB", - \ "darkred" : "#BB0000", - \ "darkmagenta" : "#BB00BB", - \ "darkgrey" : "#BBBBBB", - \ "darkyellow" : "#BBBB00", - \ "gray10" : "#1A1A1A", - \ "grey10" : "#1A1A1A", - \ "gray20" : "#333333", - \ "grey20" : "#333333", - \ "gray30" : "#4D4D4D", - \ "grey30" : "#4D4D4D", - \ "gray40" : "#666666", - \ "grey40" : "#666666", - \ "gray50" : "#7F7F7F", - \ "grey50" : "#7F7F7F", - \ "gray60" : "#999999", - \ "grey60" : "#999999", - \ "gray70" : "#B3B3B3", - \ "grey70" : "#B3B3B3", - \ "gray80" : "#CCCCCC", - \ "grey80" : "#CCCCCC", - \ "gray90" : "#E5E5E5", - \ "grey90" : "#E5E5E5" } - -" {>2} Colors that vim will use by name in one of the default schemes, either -" for bg=light or for bg=dark. This lets us avoid loading the entire rgb.txt -" database when the scheme itself doesn't ask for colors by name. -let s:rgb_presets = { "black" : "#000000", - \ "blue" : "#0000ff", - \ "brown" : "#a52a2a", - \ "cyan" : "#00ffff", - \ "darkblue" : "#00008b", - \ "darkcyan" : "#008b8b", - \ "darkgrey" : "#a9a9a9", - \ "darkmagenta" : "#8b008b", - \ "green" : "#00ff00", - \ "grey" : "#bebebe", - \ "grey40" : "#666666", - \ "grey90" : "#e5e5e5", - \ "lightblue" : "#add8e6", - \ "lightcyan" : "#e0ffff", - \ "lightgrey" : "#d3d3d3", - \ "lightmagenta" : "#ffbbff", - \ "magenta" : "#ff00ff", - \ "red" : "#ff0000", - \ "seagreen" : "#2e8b57", - \ "white" : "#ffffff", - \ "yellow" : "#ffff00" } - -" {>2} Find available color names -" Find the valid named colors. By default, use our own rgb list, but try to -" retrieve the system's list if g:CSApprox_use_showrgb is set to true. Store -" the color names and color values to the dictionary s:rgb - the keys are -" color names (in lowercase), the values are strings representing color values -" (as '#rrggbb'). -function! s:UpdateRgbHash() - try - if !exists("g:CSApprox_use_showrgb") || !g:CSApprox_use_showrgb - throw "Not using showrgb" - endif - - " We want to use the 'showrgb' program, if it's around - let lines = split(system('showrgb'), '\n') - - if v:shell_error || !exists('lines') || empty(lines) - throw "'showrgb' didn't give us an rgb.txt" - endif - - let s:rgb = copy(s:rgb_defaults) - - " fmt is (blanks?)(red)(blanks)(green)(blanks)(blue)(blanks)(name) - let parsepat = '^\s*\(\d\+\)\s\+\(\d\+\)\s\+\(\d\+\)\s\+\(.*\)$' - - for line in lines - let v = matchlist(line, parsepat) - if len(v) < 0 - throw "CSApprox: Bad RGB line: " . string(line) - endif - let s:rgb[tolower(v[4])] = printf("#%02x%02x%02x", v[1], v[2], v[3]) - endfor - catch - try - let s:rgb = csapprox#rgb() - catch - echohl ErrorMsg - echomsg "Can't call rgb() from autoload/csapprox.vim" - echomsg "Named colors will not be available!" - echohl None - endtry - endtry - - return 0 -endfunction - -" {>1} Derive and set cterm attributes - -" {>2} Attribute overrides -" Allow the user to override a specified attribute with another attribute. -" For example, the default is to map 'italic' to 'underline' (since many -" terminals cannot display italic text, and gvim itself will replace italics -" with underlines where italicizing is impossible), and to replace 'sp' with -" 'fg' (since terminals can't use one color for the underline and another for -" the foreground, we color the entire word). This default can of course be -" overridden by the user, by setting g:CSApprox_attr_map. This map must be -" a dictionary of string keys, representing the same attributes that synIDattr -" can look up, to string values, representing the attribute mapped to or an -" empty string to disable the given attribute entirely. -function! s:attr_map(attr) - let rv = get(g:CSApprox_attr_map, a:attr, a:attr) - - return rv -endfunction - -function! s:NormalizeAttrMap(map) - let old = copy(a:map) - let new = filter(a:map, '0') - - let valid_attrs = [ 'bg', 'fg', 'sp', 'bold', 'italic', - \ 'reverse', 'underline', 'undercurl' ] - - let colorattrs = [ 'fg', 'bg', 'sp' ] - - for olhs in keys(old) - if olhs ==? 'inverse' - let nlhs = 'reverse' - endif - - let orhs = old[olhs] - - if orhs ==? 'inverse' - let nrhs = 'reverse' - endif - - let nlhs = tolower(olhs) - let nrhs = tolower(orhs) - - try - if index(valid_attrs, nlhs) == -1 - echomsg "CSApprox: Bad attr map (removing unrecognized attribute " . olhs . ")" - elseif nrhs != '' && index(valid_attrs, nrhs) == -1 - echomsg "CSApprox: Bad attr map (removing unrecognized attribute " . orhs . ")" - elseif nrhs != '' && !!(index(colorattrs, nlhs)+1) != !!(index(colorattrs, nrhs)+1) - echomsg "CSApprox: Bad attr map (removing " . olhs . "; type mismatch with " . orhs . ")" - elseif nrhs == 'sp' - echomsg "CSApprox: Bad attr map (removing " . olhs . "; can't map to 'sp')" - else - let new[nlhs] = nrhs - endif - catch - echo v:exception - endtry - endfor -endfunction - -" {>2} Normalize the GUI settings of a highlight group -" If the Normal group is cleared, set it to gvim's default, black on white -" Though this would be a really weird thing for a scheme to do... *shrug* -function! s:FixupGuiInfo(highlights) - if a:highlights[s:hlid_normal].gui.bg == '' - let a:highlights[s:hlid_normal].gui.bg = 'white' - endif - - if a:highlights[s:hlid_normal].gui.fg == '' - let a:highlights[s:hlid_normal].gui.fg = 'black' - endif -endfunction - -" {>2} Map gui settings to cterm settings -" Given information about a highlight group, replace the cterm settings with -" the mapped gui settings, applying any attribute overrides along the way. In -" particular, this gives special treatment to the 'reverse' attribute and the -" 'guisp' attribute. In particular, if the 'reverse' attribute is set for -" gvim, we unset it for the terminal and instead set ctermfg to match guibg -" and vice versa, since terminals can consider a 'reverse' flag to mean using -" default-bg-on-default-fg instead of current-bg-on-current-fg. We also -" ensure that the 'sp' attribute is never set for cterm, since no terminal can -" handle that particular highlight. If the user wants to display the guisp -" color, he should map it to either 'fg' or 'bg' using g:CSApprox_attr_map. -function! s:FixupCtermInfo(highlights) - for hl in values(a:highlights) - - if !has_key(hl, 'cterm') - let hl["cterm"] = {} - endif - - " Find attributes to be set in the terminal - for attr in [ "bold", "italic", "reverse", "underline", "undercurl" ] - let hl.cterm[attr] = '' - if hl.gui[attr] == 1 - if s:attr_map(attr) != '' - let hl.cterm[ s:attr_map(attr) ] = 1 - endif - endif - endfor - - for color in [ "bg", "fg" ] - let eff_color = color - if hl.cterm['reverse'] - let eff_color = (color == 'bg' ? 'fg' : 'bg') - endif - - let hl.cterm[color] = get(hl.gui, s:attr_map(eff_color), '') - endfor - - if hl.gui['sp'] != '' && s:attr_map('sp') != '' - let hl.cterm[s:attr_map('sp')] = hl.gui['sp'] - endif - - if hl.cterm['reverse'] && hl.cterm.bg == '' - let hl.cterm.bg = 'fg' - endif - - if hl.cterm['reverse'] && hl.cterm.fg == '' - let hl.cterm.fg = 'bg' - endif - - if hl.cterm['reverse'] - let hl.cterm.reverse = '' - endif - endfor -endfunction - -" {>2} Set cterm colors for a highlight group -" Given the information for a single highlight group (ie, the value of -" one of the items in s:Highlights() already normalized with s:FixupCtermInfo -" and s:FixupGuiInfo), handle matching the gvim colors to the closest cterm -" colors by calling the appropriate approximator as specified with the -" g:CSApprox_approximator_function variable and set the colors and attributes -" appropriately to match the gui. -function! s:SetCtermFromGui(hl) - let hl = a:hl - - " Set up the default approximator function, if needed - if !exists("g:CSApprox_approximator_function") - let g:CSApprox_approximator_function=function("s:ApproximatePerComponent") - endif - - " Clear existing highlights - exe 'hi ' . hl.name . ' cterm=NONE ctermbg=NONE ctermfg=NONE' - - for which in [ 'bg', 'fg' ] - let val = hl.cterm[which] - - " Skip unset colors - if val == -1 || val == "" - continue - endif - - " Try translating anything but 'fg', 'bg', #rrggbb, and rrggbb from an - " rgb.txt color to a #rrggbb color - if val !~? '^[fb]g$' && val !~ '^#\=\x\{6}$' - try - " First see if it is in our preset-by-vim rgb list - let val = s:rgb_presets[tolower(val)] - catch - " Then try loading and checking our real rgb list - if empty(s:rgb) - call s:UpdateRgbHash() - endif - try - let val = s:rgb[tolower(val)] - catch - " And then barf if we still haven't found it - if &verbose - echomsg "CSApprox: Colorscheme uses unknown color \"" . val . "\"" - endif - continue - endtry - endtry - endif - - if val =~? '^[fb]g$' - exe 'hi ' . hl.name . ' cterm' . which . '=' . val - let hl.cterm[which] = val - elseif val =~ '^#\=\x\{6}$' - let val = substitute(val, '^#', '', '') - let r = str2nr(val[0:1], 16) - let g = str2nr(val[2:3], 16) - let b = str2nr(val[4:5], 16) - let hl.cterm[which] = g:CSApprox_approximator_function(r, g, b) - exe 'hi ' . hl.name . ' cterm' . which . '=' . hl.cterm[which] - else - throw "Internal error handling color: " . val - endif - endfor - - " Finally, set the attributes - let attrs = [ 'bold', 'italic', 'underline', 'undercurl' ] - call filter(attrs, 'hl.cterm[v:val] == 1') - - if !empty(attrs) - exe 'hi ' . hl.name . ' cterm=' . join(attrs, ',') - endif -endfunction - - -" {>1} Top-level control - -" Cache the highlight ID of the normal group; it's used often and won't change -let s:hlid_normal = hlID('Normal') - -" {>2} Builtin cterm color names above 15 -" Vim defines some color name to high color mappings internally (see -" syntax.c:do_highlight). Since we don't want to overwrite a colorscheme that -" was actually written for a high color terminal with our choices, but have no -" way to tell if a colorscheme was written for a high color terminal, we fall -" back on guessing. If any highlight group has a cterm color set to 16 or -" higher, we assume that the user has used a high color colorscheme - unless -" that color is one of the below, which vim can set internally when a color is -" requested by name. -let s:presets_88 = [] -let s:presets_88 += [32] " Brown -let s:presets_88 += [72] " DarkYellow -let s:presets_88 += [84] " Gray -let s:presets_88 += [84] " Grey -let s:presets_88 += [82] " DarkGray -let s:presets_88 += [82] " DarkGrey -let s:presets_88 += [43] " LightBlue -let s:presets_88 += [61] " LightGreen -let s:presets_88 += [63] " LightCyan -let s:presets_88 += [74] " LightRed -let s:presets_88 += [75] " LightMagenta -let s:presets_88 += [78] " LightYellow - -let s:presets_256 = [] -let s:presets_256 += [130] " Brown -let s:presets_256 += [130] " DarkYellow -let s:presets_256 += [248] " Gray -let s:presets_256 += [248] " Grey -let s:presets_256 += [242] " DarkGray -let s:presets_256 += [242] " DarkGrey -let s:presets_256 += [ 81] " LightBlue -let s:presets_256 += [121] " LightGreen -let s:presets_256 += [159] " LightCyan -let s:presets_256 += [224] " LightRed -let s:presets_256 += [225] " LightMagenta -let s:presets_256 += [229] " LightYellow - -" {>2} Wrapper around :exe to allow :executing multiple commands. -" "cmd" is the command to be :executed. -" If the variable is a String, it is :executed. -" If the variable is a List, each element is :executed. -function! s:exe(cmd) - if type(a:cmd) == type('') - exe a:cmd - else - for cmd in a:cmd - call s:exe(cmd) - endfor - endif -endfunction - -" {>2} Function to handle hooks -" Prototype: HandleHooks(type [, scheme]) -" "type" is the type of hook to be executed, ie. "pre" or "post" -" "scheme" is the name of the colorscheme that is currently active, if known -" -" If the variables g:CSApprox_hook_{type} and g:CSApprox_hook_{scheme}_{type} -" exist, this will :execute them in that order. If one does not exist, it -" will silently be ignored. -" -" If the scheme name contains characters that are invalid in a variable name, -" they will simply be removed. Ie, g:colors_name = "123 foo_bar-baz456" -" becomes "foo_barbaz456" -" -" NOTE: Exceptions will be printed out, rather than end processing early. The -" rationale is that it is worse for the user to fix the hook in an editor with -" broken colors. :) -function! s:HandleHooks(type, ...) - let type = a:type - let scheme = (a:0 == 1 ? a:1 : "") - let scheme = substitute(scheme, '[^[:alnum:]_]', '', 'g') - let scheme = substitute(scheme, '^\d\+', '', '') - - for cmd in [ 'g:CSApprox_hook_' . type, - \ 'g:CSApprox_' . scheme . '_hook_' . type, - \ 'g:CSApprox_hook_' . scheme . '_' . type ] - if exists(cmd) - try - call s:exe(eval(cmd)) - catch - echomsg "Error processing " . cmd . ":" - echomsg v:exception - endtry - endif - endfor -endfunction - -" {>2} Main function -" Wrapper around the actual implementation to make it easier to ensure that -" all temporary settings are restored by the time we return, whether or not -" something was thrown. Additionally, sets the 'verbose' option to the max of -" g:CSApprox_verbose_level (default 1) and &verbose for the duration of the -" main function. This allows us to default to a message whenever any error, -" even a recoverable one, occurs, meaning the user quickly finds out when -" something's wrong, but makes it very easy for the user to make us silent. -function! s:CSApprox() - try - let savelz = &lz - - set lz - - if exists("g:CSApprox_attr_map") && type(g:CSApprox_attr_map) == type({}) - call s:NormalizeAttrMap(g:CSApprox_attr_map) - else - let g:CSApprox_attr_map = { 'italic' : 'underline', 'sp' : 'fg' } - endif - - " colors_name must be unset and reset, or vim will helpfully reload the - " colorscheme when we set the background for the Normal group. - " See the help entries ':hi-normal-cterm' and 'g:colors_name' - if exists("g:colors_name") - let colors_name = g:colors_name - unlet g:colors_name - endif - - " Similarly, the global variable "syntax_cmd" must be set to something vim - " doesn't recognize, lest vim helpfully switch all colors back to the - " default whenever the Normal group is changed (in syncolor.vim)... - if exists("g:syntax_cmd") - let syntax_cmd = g:syntax_cmd - endif - let g:syntax_cmd = "PLEASE DON'T CHANGE ANY COLORS!!!" - - " Set up our verbosity level, if needed. - " Default to 1, so the user can know if something's wrong. - if !exists("g:CSApprox_verbose_level") - let g:CSApprox_verbose_level = 1 - endif - - call s:HandleHooks("pre", (exists("colors_name") ? colors_name : "")) - - " Set 'verbose' set to the maximum of &verbose and CSApprox_verbose_level - exe max([&vbs, g:CSApprox_verbose_level]) 'verbose call s:CSApproxImpl()' - - call s:HandleHooks("post", (exists("colors_name") ? colors_name : "")) - finally - if exists("colors_name") - let g:colors_name = colors_name - endif - - unlet g:syntax_cmd - if exists("syntax_cmd") - let g:syntax_cmd = syntax_cmd - endif - - let &lz = savelz - endtry -endfunction - -" {>2} CSApprox implementation -" Verifies that the user has not started the gui, and that vim recognizes his -" terminal as having enough colors for us to go on, then gathers the existing -" highlights and sets the cterm colors to match the gui colors for all those -" highlights (unless the colorscheme was already high-color). -function! s:CSApproxImpl() - " Return if not running in an 88/256 color terminal - if &t_Co != 256 && &t_Co != 88 - if &verbose && !has('gui_running') - echomsg "CSApprox skipped; terminal only has" &t_Co "colors, not 88/256" - echomsg "Try checking :help csapprox-terminal for workarounds" - endif - - return - endif - - " Get the current highlight colors - let highlights = s:Highlights(["gui"]) - - let hinums = keys(highlights) - - " Make sure that the script is not already 256 color by checking to make - " sure that no groups are set to a value above 256, unless the color they're - " set to can be set internally by vim (gotten by scraping - " color_numbers_{88,256} in syntax.c:do_highlight) - " - " XXX: s:inhibit_hicolor_test allows this test to be skipped for snapshots - if !exists("s:inhibit_hicolor_test") || !s:inhibit_hicolor_test - for hlid in hinums - for type in [ 'bg', 'fg' ] - let color = synIDattr(hlid, type, 'cterm') - - if color > 15 && index(s:presets_{&t_Co}, str2nr(color)) < 0 - " The value is set above 15, and wasn't set by vim. - if &verbose >= 2 - echomsg 'CSApprox: Exiting - high' type 'color found for' highlights[hlid].name - endif - return - endif - endfor - endfor - endif - - call s:FixupGuiInfo(highlights) - call s:FixupCtermInfo(highlights) - - " We need to set the Normal group first so 'bg' and 'fg' work as colors - call insert(hinums, remove(hinums, index(hinums, string(s:hlid_normal)))) - - " then set each color's cterm attributes to match gui - for hlid in hinums - call s:SetCtermFromGui(highlights[hlid]) - endfor -endfunction - -" {>2} Write out the current colors to an 88/256 color colorscheme file. -" "file" - destination filename -" "overwrite" - overwrite an existing file -function! s:CSApproxSnapshot(file, overwrite) - let force = a:overwrite - let file = fnamemodify(a:file, ":p") - - if empty(file) - throw "Bad file name: \"" . file . "\"" - elseif (filewritable(fnamemodify(file, ':h')) != 2) - throw "Cannot write to directory \"" . fnamemodify(file, ':h') . "\"" - elseif (glob(file) || filereadable(file)) && !force - " TODO - respect 'confirm' here and prompt if it's set. - echohl ErrorMsg - echomsg "E13: File exists (add ! to override)" - echohl None - return - endif - - " Sigh... This is basically a bug, but one that I have no chance of fixing. - " Vim decides that Pmenu should be highlighted in 'LightMagenta' in terminal - " vim and as 'Magenta' in gvim... And I can't ask it what color it actually - " *wants*. As far as I can see, there's no way for me to learn that - " I should output 'Magenta' when 'LightMagenta' is provided by vim for the - " terminal. - if !has('gui_running') - echohl WarningMsg - echomsg "Warning: The written colorscheme may have incorrect colors" - echomsg " when CSApproxSnapshot is used in terminal vim!" - echohl None - endif - - let save_t_Co = &t_Co - let s:inhibit_hicolor_test = 1 - if exists("g:CSApprox_konsole") - let save_CSApprox_konsole = g:CSApprox_konsole - endif - if exists("g:CSApprox_eterm") - let save_CSApprox_eterm = g:CSApprox_eterm - endif - - " Needed just like in CSApprox() - if exists("g:colors_name") - let colors_name = g:colors_name - unlet g:colors_name - endif - - " Needed just like in CSApprox() - if exists("g:syntax_cmd") - let syntax_cmd = g:syntax_cmd - endif - let g:syntax_cmd = "PLEASE DON'T CHANGE ANY COLORS!!!" - - try - let lines = [] - let lines += [ '" This scheme was created by CSApproxSnapshot' ] - let lines += [ '" on ' . strftime("%a, %d %b %Y") ] - let lines += [ '' ] - let lines += [ 'hi clear' ] - let lines += [ 'if exists("syntax_on")' ] - let lines += [ ' syntax reset' ] - let lines += [ 'endif' ] - let lines += [ '' ] - let lines += [ 'if v:version < 700' ] - let lines += [ ' let g:colors_name = expand(":t:r")' ] - let lines += [ ' command! -nargs=+ CSAHi exe "hi" substitute(substitute(, "undercurl", "underline", "g"), "guisp\\S\\+", "", "g")' ] - let lines += [ 'else' ] - let lines += [ ' let g:colors_name = expand(":t:r")' ] - let lines += [ ' command! -nargs=+ CSAHi exe "hi" ' ] - let lines += [ 'endif' ] - let lines += [ '' ] - - let lines += [ 'if 0' ] - for round in [ 'konsole', 'eterm', 'xterm', 'urxvt' ] - sil! unlet g:CSApprox_eterm - sil! unlet g:CSApprox_konsole - - if round == 'konsole' - let g:CSApprox_konsole = 1 - elseif round == 'eterm' - let g:CSApprox_eterm = 1 - endif - - if round == 'urxvt' - set t_Co=88 - else - set t_Co=256 - endif - - call s:CSApprox() - - let highlights = s:Highlights(["term", "cterm", "gui"]) - call s:FixupGuiInfo(highlights) - - if round == 'konsole' || round == 'eterm' - let lines += [ 'elseif has("gui_running") || (&t_Co == ' . &t_Co - \ . ' && (&term ==# "xterm" || &term =~# "^screen")' - \ . ' && exists("g:CSApprox_' . round . '")' - \ . ' && g:CSApprox_' . round . ')' - \ . ' || &term =~? "^' . round . '"' ] - else - let lines += [ 'elseif has("gui_running") || &t_Co == ' . &t_Co ] - endif - - let hinums = keys(highlights) - - call insert(hinums, remove(hinums, index(hinums, string(s:hlid_normal)))) - - for hlnum in hinums - let hl = highlights[hlnum] - let line = ' CSAHi ' . hl.name - for type in [ 'term', 'cterm', 'gui' ] - let attrs = [ 'reverse', 'bold', 'italic', 'underline', 'undercurl' ] - call filter(attrs, 'hl[type][v:val] == 1') - let line .= ' ' . type . '=' . (empty(attrs) ? 'NONE' : join(attrs, ',')) - if type != 'term' - let line .= ' ' . type . 'bg=' . (len(hl[type].bg) ? hl[type].bg : 'bg') - let line .= ' ' . type . 'fg=' . (len(hl[type].fg) ? hl[type].fg : 'fg') - if type == 'gui' && hl.gui.sp !~ '^\s*$' - let line .= ' ' . type . 'sp=' . hl[type].sp - endif - endif - endfor - let lines += [ line ] - endfor - endfor - let lines += [ 'endif' ] - let lines += [ '' ] - let lines += [ 'if 1' ] - let lines += [ ' delcommand CSAHi' ] - let lines += [ 'endif' ] - call writefile(lines, file) - finally - let &t_Co = save_t_Co - - if exists("save_CSApprox_konsole") - let g:CSApprox_konsole = save_CSApprox_konsole - endif - if exists("save_CSApprox_eterm") - let g:CSApprox_eterm = save_CSApprox_eterm - endif - - if exists("colors_name") - let g:colors_name = colors_name - endif - - unlet g:syntax_cmd - if exists("syntax_cmd") - let g:syntax_cmd = syntax_cmd - endif - - call s:CSApprox() - - unlet s:inhibit_hicolor_test - endtry -endfunction - -" {>2} Snapshot user command -command! -bang -nargs=1 -complete=file -bar CSApproxSnapshot - \ call s:CSApproxSnapshot(, strlen("")) - -" {>1} Hooks - -" {>2} Autocmds -" Set up an autogroup to hook us on the completion of any :colorscheme command -augroup CSApprox - au! - au ColorScheme * call s:CSApprox() - "au User CSApproxPost highlight Normal ctermbg=none | highlight NonText ctermbg=None -augroup END - -" {>2} Execute -" The last thing to do when sourced is to run and actually fix up the colors. -if !has('gui_running') - call s:CSApprox() -endif - -" {>1} Restore compatibility options -let &cpo = s:savecpo -unlet s:savecpo - - -" {0} vim:sw=2:sts=2:et:fdm=expr:fde=substitute(matchstr(getline(v\:lnum),'^\\s*"\\s*{\\zs.\\{-}\\ze}'),'^$','=','') diff --git a/files/.vim/plugin/SyntaxFolds.vim b/files/.vim/plugin/SyntaxFolds.vim deleted file mode 100644 index 27c622c..0000000 --- a/files/.vim/plugin/SyntaxFolds.vim +++ /dev/null @@ -1,323 +0,0 @@ -" ============================================================================== -" File: syntaxFolds.vim -" Author: Srinath Avadhanula -" ( srinath@fastmail.fm ) -" Last Change: Sun Oct 27 01:00 AM 2002 PST -" Description: Emulation of the syntax folding capability of vim using manual -" folding -" -" This script provides an emulation of the syntax folding of vim using manual -" folding. Just as in syntax folding, the folds are defined by regions. Each -" region is specified by a call to FoldRegions() which accepts 4 parameters: -" -" call FoldRegions(startpat, endpat, startoff, endoff) -" -" startpat: a line matching this pattern defines the beginning of a fold. -" endpat : a line matching this pattern defines the end of a fold. -" startoff: this is the offset from the starting line at which folding will -" actually start -" endoff : like startoff, but gives the offset of the actual fold end from -" the line satisfying endpat. -" startoff and endoff are necessary when the folding region does -" not have a specific end pattern corresponding to a start -" pattern. for example in latex, -" \begin{section} -" defines the beginning of a section, but its not necessary to -" have a corresponding -" \end{section} -" the section is assumed to end 1 line _before_ another section -" starts. -" startskip: a pattern which defines the beginning of a "skipped" region. -" -" For example, suppose we define a \itemize fold as follows: -" startpat = '^\s*\\item', -" endpat = '^\s*\\item\|^\s*\\end{\(enumerate\|itemize\|description\)}', -" startoff = 0, -" endoff = -1 -" -" This defines a fold which starts with a line beginning with an -" \item and ending one line before a line beginning with an -" \item or \end{enumerate} etc. -" -" Then, as long as \item's are not nested things are fine. -" However, once items begin to nest, the fold started by one -" \item can end because of an \item in an \itemize -" environment within this \item. i.e, the following can happen: -" -" \begin{itemize} -" \item Some text <------- fold will start here -" This item will contain a nested item -" \begin{itemize} <----- fold will end here because next line contains \item... -" \item Hello -" \end{itemize} <----- ... instead of here. -" \item Next item of the parent itemize -" \end{itemize} -" -" Therefore, in order to completely define a folding item which -" allows nesting, we need to also define a "skip" pattern. -" startskip and end skip do that. -" Leave '' when there is no nesting. -" endskip: the pattern which defines the end of the "skip" pattern for -" nested folds. -" -" Example: -" 1. A syntax fold region for a latex section is -" startpat = "\\section{" -" endpat = "\\section{" -" startoff = 0 -" endoff = -1 -" startskip = '' -" endskip = '' -" Note that the start and end patterns are thus the same and endoff has a -" negative value to capture the effect of a section ending one line before -" the next starts. -" 2. A syntax fold region for the \itemize environment is: -" startpat = '^\s*\\item', -" endpat = '^\s*\\item\|^\s*\\end{\(enumerate\|itemize\|description\)}', -" startoff = 0, -" endoff = -1, -" startskip = '^\s*\\begin{\(enumerate\|itemize\|description\)}', -" endskip = '^\s*\\end{\(enumerate\|itemize\|description\)}' -" Note the use of startskip and endskip to allow nesting. -" -" -" Each time a call is made to FoldRegions(), all the regions (which might be -" disjoint, but not nested) are folded up. -" Nested folds can be created by successive calls to FoldRegions(). The first -" call defines the region which is deepest in the folding. See MakeTexFolds() -" for an idea of how this works for latex files. - -" Function: AddSyntaxFoldItem (start, end, startoff, endoff [, skipStart, skipEnd]) {{{ -function! AddSyntaxFoldItem(start, end, startoff, endoff, ...) - if a:0 > 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 FoldRegions() 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 skipEndPattern = '' - if a:0 > 0 - let line1 = a:1 - let skipEndPattern = '\|'.a:2 - else - let line1 = 1 - let r = line('.') - let c = virtcol('.') - - setlocal fdm=manual - normal! zE - end - if !exists('b:numFoldItems') - b:numFoldItems = 1000000 - end - - let i = 1 - - let maxline = line('.') - - while exists('b:startPat_'.i) && i <= 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 - - let skipStart = '' - let skipEnd = '' - if exists('b:skipStartPat_'.i) - exe 'let skipStart = b:skipStartPat_'.i - exe 'let skipEnd = b:skipEndPat_'.i - end - exe line1 - let lastLoc = line1 - - if skipStart != '' - call InitStack('BeginSkipArray') - call FoldRegionsWithSkip(startPat, endPat, startOff, endOff, skipStart, skipEnd, 1, line('$')) - " call PrintError('done folding ['.startPat.']') - else - call FoldRegionsWithNoSkip(startPat, endPat, startOff, endOff, 1, line('$'), '') - end - - let i = i + 1 - endwhile - - exe maxline - - if a:0 == 0 - exe r - exe "normal! ".c."|" - if foldlevel(r) > 1 - exe "normal! ".(foldlevel(r) - 1)."zo" - end - let b:doneFolding = 0 - end -endfunction - - -" }}} -" FoldRegionsWithSkip: folding things such as \item's which can be nested. {{{ -function! FoldRegionsWithSkip(startpat, endpat, startoff, endoff, startskip, endskip, line1, line2) - exe a:line1 - " 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 = '' - - " start searching for either the starting pattern or the end pattern. - while search(a:startskip.'\|'.a:endskip, 'W') - - if getline('.') =~ a:endskip - - let lastBegin = Pop('BeginSkipArray') - " call PrintError('popping '.lastBegin.' from stack and folding till '.line('.')) - call FoldRegionsWithNoSkip(a:startpat, a:endpat, a:startoff, a:endoff, lastBegin, line('.'), skippedRegions) - let skippedRegions = skippedRegions.lastBegin.','.line('.').'|' - - - " if this is the beginning of a skip region, then, push this line as - " the beginning of a skipped region. - elseif getline('.') =~ a:startskip - - " call PrintError('pushing '.line('.').' ['.getline('.').'] into stack') - call Push('BeginSkipArray', line('.')) - - end - endwhile - - " call PrintError('with skip starting at '.a:line1.' returning at line# '.line('.')) -endfunction - -" }}} -" FoldRegionsWithNoSkip: folding things such as \sections which do not nest. {{{ -function! FoldRegionsWithNoSkip(startpat, endpat, startoff, endoff, line1, line2, skippedRegions) - exe a:line1 - - " call PrintError('line1 = '.a:line1.', searching from '.line('.').'... for ['.a:startpat.'') - let lineBegin = s:MySearch(a:startpat, 'in') - " call PrintError('... and finding it at '.lineBegin) - - while lineBegin <= a:line2 - if IsInSkippedRegion(lineBegin, a:skippedRegions) - let lineBegin = s:MySearch(a:startpat, 'out') - " call PrintError(lineBegin.' is being skipped') - continue - end - let lineEnd = s:MySearch(a:endpat, 'out') - while 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' - break - else - " call PrintError ('for ['.a:startpat.'] '.(lineBegin + a:startoff).','.(lineEnd + a:endoff).' fold') - exe (lineBegin + a:startoff).','.(lineEnd + a:endoff).' fold' - end - - " call PrintError('line1 = '.a:line1.', searching from '.line('.').'... for ['.a:startpat.'') - let lineBegin = s:MySearch(a:startpat, 'in') - " call PrintError('... and finding it at '.lineBegin) - endwhile - - exe a:line2 - return -endfunction - -" }}} -" InitStack: initialize a stack {{{ -function! InitStack(name) - exe 'let s:'.a:name.'_numElems = 0' -endfunction -" }}} -" Push: push element into stack {{{ -function! Push(name, elem) - exe 'let numElems = s:'.a:name.'_numElems' - let numElems = numElems + 1 - exe 'let s:'.a:name.'_Element_'.numElems.' = a:elem' - exe 'let s:'.a:name.'_numElems = numElems' -endfunction -" }}} -" Pop: pops element off stack {{{ -function! Pop(name) - exe 'let numElems = s:'.a:name.'_numElems' - if numElems == 0 - return '' - else - exe 'let ret = s:'.a:name.'_Element_'.numElems - let numElems = numElems - 1 - exe 'let s:'.a:name.'_numElems = numElems' - return ret - end -endfunction -" }}} -" MySearch: just like search(), but returns large number on failure {{{ -function! MySearch(pat, opt) - if a:opt == 'in' - if getline('.') =~ a:pat - let ret = line('.') - else - let ret = search(a:pat, 'W') - end - else - normal! $ - let ret = search(a:pat, 'W') - end - - if ret == 0 - let ret = line('$') + 1 - end - return ret -endfunction -" }}} -" Function: IsInSkippedRegion (lnum, regions) {{{ -" Description: finds whether a given line number is within one of the regions -" skipped. -function! IsInSkippedRegion(lnum, regions) - let i = 1 - let subset = s:Strntok(a:regions, '|', i) - while subset != '' - let n1 = s:Strntok(subset, ',', 1) - let n2 = s:Strntok(subset, ',', 2) - if a:lnum >= n1 && a:lnum <= n2 - return 1 - end - - let subset = s:Strntok(a:regions, '|', i) - let i = i + 1 - endwhile - - return 0 -endfunction " }}} -" Function: Strntok (string, tok, n) {{{ -" extract the n^th token from s seperated by tok. -" 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 " }}} - -" vim600:fdm=marker diff --git a/files/.vim/plugin/XMLFolding.vim b/files/.vim/plugin/XMLFolding.vim deleted file mode 100755 index ec5487b..0000000 --- a/files/.vim/plugin/XMLFolding.vim +++ /dev/null @@ -1,105 +0,0 @@ -" About XMLFolding Script {{{ - -" XMLFolding version 1.1 - May 13th, 2006 -" Author: Thadeu Aparecido Coelho de Paula -" E-mail: thadeudepaula@gmail.com -" WebPage: http://mundolivre.hostrixonline.com -" -" This is my first vim script... at this point I already worked three -" continual weeks to make it. Never give up your objectives! -" I hope that you enjoy it, and use it to accomplish your projects! -" -" This script is under GNU Public License... use it, change it, sell it but -" never forget to mention the original author" -" -" Made using Vim 6.04 on Debian GNU/Linux -" -" This Script supports: -" -" Folding of comments "" -" Folding of open/close tags in different lines "<> " -" Folding between CDATA markers "" - -" }}} - -" Howto {{{ - - " Installing {{{ -" Copy this file for any location yow want to... I suggest that you put it on -" your ~/.vim/plugin directory. -" -" To load this script in your vim session, type on normal mode: -" :so ~/.vim/script/XMLFolding.vim -" (If you saved on local where I suggested!) - -"}}} - - " How to load this script automaticaly? {{{ -"You can use this script more easily configuring your vim to run it on start... -"You'll need to put this line in your /etc/vim/vimrc or ~/.vimrc: - -" au BufNewFile,BufRead *.xml,*.htm,*.html so ~/.vim/plugin/XMLFolding.vim - -" The "*.xml,*.html" can be changed for the file extensions that you want to -" use with this script. - "}}} - - " Limitatios... i.e, when the fold won't occurs {{{ - -" The syntax need to be perfectly to match correctly... the tags needs to be -" nested correctly... -" All the tags nested in the same line will not be folded... like this: -" -" blablablablablablaasdsad -" -" -" In this example only "start" will be folded... -" -" An other problem will occur when you end the line closing a tag different -" than the open tag that starts the line, because the matches ignore the lines -" that starts opening a tag and ends closing a tag... -" -" asdasdsd -" -" -" This will cause an error, because MATCHES ARE NOT MADE BY THE CONTENT OF A -" TAG, but by the presence of start and end aspect: <----> independent -" of the tag content... if it encounter an incorrect nesting, the folding for -" the document will be broken. -" -" This way, the script serves as an validator, limited but functional! - - "}}} - - -"}}} - -" Folding def commands {{{ - - " Basic vim commands for folding definition {{{ -syn sync fromstart -set foldmethod=syntax - "}}} - - " Matches and regions {{{ - -syn region XMLFold start=+^<\([^/?!><]*[^/]>\)\&.*\(<\1\|[[:alnum:]]\)$+ end=+^$+ fold transparent keepend extend - -syn match XMLCData "" fold transparent extend - -syn match XMLCommentFold "" fold transparent extend - - - "}}} - - " Label shown for folded lines {{{ -set foldtext=XMLFoldLabel() - fun! XMLFoldLabel() - let getcontent = substitute(getline(v:foldstart), "^[[:space:]]*", "", 'g') - let linestart = substitute(v:folddashes, ".", '»', 'g') - return linestart . " " . getcontent -endfunction - - "}}} - -"}}} diff --git a/files/.vim/plugin/filebrowser.vim b/files/.vim/plugin/filebrowser.vim deleted file mode 100644 index e9de049..0000000 --- a/files/.vim/plugin/filebrowser.vim +++ /dev/null @@ -1,251 +0,0 @@ -" 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). - -" 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. - execute "lcd ".a:dir - " 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 i = 1 - while 1 - let filename = s:FB_Strntok(allFilenames, "\n", i) - if filename == '' - break - endif - 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 - let i = i + 1 - endwhile - 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 " }}} - -" 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 "^\"= .*$" - syn match browseSortBy "^\" Sorted by .*$" contains=browseSuffixInfo - syn match browseSuffixInfo "(.*)$" contained - syn match browseFilter "^\" Not Showing:.*$" - syn match browseFiletime "«\d\+$" - - "hi def link browseSynopsis PreProc - hi def link browseSynopsis Special - hi def link browseDirectory Directory - hi def link browseCurDir Statement - hi def link browseSortBy String - hi def link browseSuffixInfo Type - hi def link browseFilter String - hi def link browseFiletime Ignore - hi def link browseSuffixes Type - endif -endfunction " }}} -" FB_SetMaps: sets buffer local maps {{{ -" Description: -function! FB_SetMaps() - nnoremap q :bdelete - nnoremap C :call FB_DisplayFiles(getcwd()) - nnoremap :bdelete - nnoremap :call FB_EditEntry() - nnoremap ? :call FB_ToggleHelp() - - " 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: change directory to getcwd()\n" - \ ."\" ?: toggle help verbosity\n" - \ ."\"= ".getcwd() - else - let txt = "\" ?: toggle help verbosity\n" - \ ."\"= ".getcwd() - endif - 0put!=txt -endfunction " }}} - -" Handles various actions in the file-browser -" 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 - call Tex_Debug('arguments = '.arguments, 'fb') - call Tex_Debug("call ".cbf."('".fname."'".arguments.')', 'fb') - exec "call ".cbf."('".fname."'".arguments.')' - endif -endfunction " }}} - -" FB_Strntok (string, tok, n) {{{ -" extract the n^th token from s seperated by tok. -" example: FB_Strntok('1,23,3', ',', 2) = 23 -fun! FB_Strntok(s, tok, n) - return matchstr( a:s.a:tok[0], '\v(\zs([^'.a:tok.']*)\ze['.a:tok.']){'.a:n.'}') -endfun " }}} -" 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/files/.vim/plugin/imaps.vim b/files/.vim/plugin/imaps.vim deleted file mode 100644 index d871aa1..0000000 --- a/files/.vim/plugin/imaps.vim +++ /dev/null @@ -1,831 +0,0 @@ -" File: imaps.vim -" Authors: Srinath Avadhanula -" Benji Fisher -" -" WWW: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/vim-latex/vimfiles/plugin/imaps.vim?only_with_tag=MAIN -" -" Description: insert mode template expander with cursor placement -" while preserving filetype indentation. -" -" $Id: imaps.vim 997 2006-03-20 09:45:45Z srinathava $ -" -" 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. -" -" The script already provides some default mappings. 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. -" -"--------------------------------------%<-------------------------------------- -" Bonus: This script also provides a command Snip which puts tearoff strings, -" '----%<----' above and below the visually selected range of lines. The -" length of the string is chosen to be equal to the longest line in the range. -" Recommended Usage: -" '<,'>Snip -"--------------------------------------%<-------------------------------------- -" }}} - -" 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 -" }}} -" 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". -" -" }}} - -" ============================================================================== -" 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 -" specific to the files 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 = a:lhs[strlen(a:lhs)-1] - let hash = s:Hash(lastLHSChar) - if !exists("s:LHS_" . a:ft . "_" . hash) - let s:LHS_{a:ft}_{hash} = escape(a:lhs, '\') - else - let s:LHS_{a:ft}_{hash} = escape(a:lhs, '\') .'\|'. s:LHS_{a:ft}_{hash} - endif - - " map only the last character of the left-hand side. - if lastLHSChar == ' ' - let lastLHSChar = '' - end - exe 'inoremap ' - \ escape(lastLHSChar, '|') - \ '=LookupCharacter("' . - \ escape(lastLHSChar, '\|"') . - \ '")' -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 = a:lhs[strlen(a:lhs)-1] - let charHash = s:Hash(char) - if exists("s:LHS_" . &ft ."_". charHash) && a:lhs =~ s:LHS_{&ft}_{charHash} - let ft = &ft - elseif exists("s:LHS__" . charHash) && a:lhs =~ s:LHS__{charHash} - let ft = "" - else - return "" - endif - let hash = s:Hash(a:lhs) - return "rhs = " . s:Map_{ft}_{hash} . " place holders = " . - \ s:phs_{ft}_{hash} . " and " . s:phe_{ft}_{hash} -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 != '' - " An extremeley wierd way to get around the fact that vim - " doesn't have the equivalent of the :mapcheck() function for - " abbreviations. - let _a = @a - exec "redir @a | silent! iab ".lastword." | redir END" - let abbreviationRHS = matchstr(@a."\n", "\n".'i\s\+'.lastword.'\s\+@\?\zs.*\ze'."\n") - - call IMAP_Debug('getting abbreviationRHS = ['.abbreviationRHS.']', 'imap') - - if @a =~ "No abbreviation found" || abbreviationRHS == "" - let @a = _a - return a:char - endif - - let @a = _a - 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; -1 for the last - " character typed: - let bs = substitute(strpart(lhs, 1), ".", "\", "g") - return bs . IMAP_PutTextWithMovement(rhs, phs, phe) -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() - - " Problem: depending on the setting of the 'encoding' option, a character - " such as "\xab" may not match itself. We try to get around this by - " changing the encoding of all our strings. At the end, we have to - " convert text back. - let phsEnc = s:Iconv(phs, "encode") - let pheEnc = s:Iconv(phe, "encode") - let phsUserEnc = s:Iconv(phsUser, "encode") - let pheUserEnc = s:Iconv(pheUser, "encode") - let textEnc = s:Iconv(text, "encode") - if textEnc != text - let textEncoded = 1 - else - let textEncoded = 0 - endif - - let pattern = '\V\(\.\{-}\)' .phs. '\(\.\{-}\)' .phe. '\(\.\*\)' - " If there are no placeholders, just return the text. - if textEnc !~ pattern - call IMAP_Debug('Not getting '.phs.' and '.phe.' in '.textEnc, 'imap') - return text - endif - " Break text up into "initial <+template+> final"; any piece may be empty. - let initialEnc = substitute(textEnc, pattern, '\1', '') - let templateEnc = substitute(textEnc, pattern, '\2', '') - let finalEnc = substitute(textEnc, 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 finalEnc = substitute(finalEnc, '\V'.phs.'\.\{-}'.phe, '', 'g') - else - let finalEnc = substitute(finalEnc, '\V'.phs.'\(\.\{-}\)'.phe, - \ phsUserEnc.'\1'.pheUserEnc, 'g') - endif - - " The substitutions are done, so convert back, if necessary. - if textEncoded - let initial = s:Iconv(initialEnc, "decode") - let template = s:Iconv(templateEnc, "decode") - let final = s:Iconv(finalEnc, "decode") - else - let initial = initialEnc - let template = templateEnc - let final = finalEnc - 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 . "i\=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() - - let searchString = '' - " If this is not an inclusive search or if it is inclusive, but the - " current cursor position does not contain a placeholder character, then - " search for the placeholder characters. - if !a:inclusive || strpart(getline('.'), col('.')-1) !~ '\V\^'.phsUser - let searchString = '\V'.phsUser.'\_.\{-}'.pheUser - endif - - " If we didn't find any placeholders return quietly. - if searchString != '' && !search(searchString, a:direction) - return '' - endif - - " Open any closed folds and make this part of the text visible. - silent! foldopen! - - " Calculate if we have an empty placeholder or if it contains some - " description. - let template = - \ matchstr(strpart(getline('.'), col('.')-1), - \ '\V\^'.phsUser.'\zs\.\{-}\ze\('.pheUser.'\|\$\)') - let placeHolderEmpty = !strlen(template) - - " If we are selecting in exclusive mode, then we need to move one step to - " the right - let extramove = '' - if &selection == 'exclusive' - let extramove = 'l' - endif - - " Select till the end placeholder character. - let movement = "\v/\\V".pheUser."/e\".extramove - - " First remember what the search pattern was. s:RemoveLastHistoryItem will - " reset @/ to this pattern so we do not create new highlighting. - let g:Tex_LastSearchPattern = @/ - - " Now either goto insert mode or select mode. - if placeHolderEmpty && g:Imap_DeleteEmptyPlaceHolders - " delete the empty placeholder into the blackhole. - return movement."\"_c\:".s:RemoveLastHistoryItem."\" - else - return movement."\\:".s:RemoveLastHistoryItem."\gv\" - 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. -imap IMAP_JumpForward =IMAP_Jumpfunc('', 0) -imap IMAP_JumpBack =IMAP_Jumpfunc('b', 0) - -" jumping in normal mode -nmap IMAP_JumpForward i=IMAP_Jumpfunc('', 0) -nmap IMAP_JumpBack i=IMAP_Jumpfunc('b', 0) - -" deleting the present selection and then jumping forward. -vmap IMAP_DeleteAndJumpForward "_i=IMAP_Jumpfunc('', 0) -vmap IMAP_DeleteAndJumpBack "_i=IMAP_Jumpfunc('b', 0) - -" jumping forward without deleting present selection. -vmap IMAP_JumpForward i=IMAP_Jumpfunc('', 0) -vmap IMAP_JumpBack `=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 -" }}} - -nmap