summaryrefslogtreecommitdiff
path: root/.config/vim/plugin
diff options
context:
space:
mode:
Diffstat (limited to '.config/vim/plugin')
-rw-r--r--.config/vim/plugin/SeeTab.vim116
-rw-r--r--.config/vim/plugin/imaps.vim822
-rw-r--r--.config/vim/plugin/jad.vim66
-rw-r--r--.config/vim/plugin/lodgeit.vim134
-rw-r--r--.config/vim/plugin/pastie.vim537
-rwxr-xr-x.config/vim/plugin/templates.vim105
6 files changed, 0 insertions, 1780 deletions
diff --git a/.config/vim/plugin/SeeTab.vim b/.config/vim/plugin/SeeTab.vim
deleted file mode 100644
index 6291f9b..0000000
--- a/.config/vim/plugin/SeeTab.vim
+++ /dev/null
@@ -1,116 +0,0 @@
-" SeeTab: displays a bar for each tab
-" Author: Charles E. Campbell, Jr.
-" Date: Aug 26, 2004
-" Version: 3
-"
-" GetLatestVimScripts: :AutoInstall: 628 1 SeeTab.vim
-" Usage: :SeeTab (toggles tab-bars) {{{1
-"
-" Variables:
-" g:SeeTabFG : nominal foreground color (default: magenta)
-" g:SeeTabBG : nominal background color (default: black)
-
-" allow user to bypass loading, also implements only-load-once
-"
-" GetLatestVimScripts: 628 1 :AutoInstall: SeeTab.vim
-
-" ---------------------------------------------------------------------
-" One Loading Only: {{{1
-if exists("g:loaded_SeeTab")
- finish
-endif
-let g:loaded_SeeTab= "v3"
-
-" ---------------------------------------------------------------------
-" Highlighting Overrides: {{{1
-" user may override either or both of these colors in his/her <.vimrc>
-if &bg == "dark"
- if !exists("g:SeeTabCtermFG")
- let g:SeeTabCtermFG="magenta"
- endif
- if !exists("g:SeeTabCtermBG")
- let g:SeeTabCtermBG="black"
- endif
- if !exists("g:SeeTabGuiFG")
- let g:SeeTabGuiFG="magenta"
- endif
- if !exists("g:SeeTabGuiBG")
- let g:SeeTabGuiBG="black"
- endif
-else
- if !exists("g:SeeTabCtermFG")
- let g:SeeTabCtermFG="black"
- endif
- if !exists("g:SeeTabCtermBG")
- let g:SeeTabCtermBG="magenta"
- endif
- if !exists("g:SeeTabGuiFG")
- let g:SeeTabGuiFG="black"
- endif
- if !exists("g:SeeTabGuiBG")
- let g:SeeTabGuiBG="magenta"
- endif
-endif
-
-" ---------------------------------------------------------------------
-" Public Interface: {{{1
-com! -nargs=0 SeeTab :call <SID>SeeTab()
-
-" ---------------------------------------------------------------------
-" SeeTab: toggles between showing tabs and using standard listchars {{{1
-fun! s:SeeTab()
-" call Dfunc("SeeTab()")
-
- if !exists("g:SeeTabEnabled")
-" call Decho("make tab bars visible (et=".&et.")")
- " -----------------------
- " Make tab bar(s) visible
- " -----------------------
- let g:SeeTabEnabled= 1
-
- " record original SpecialKey, change SpecialKey
- let regA= @a
- redir @a
- silent! hi SpecialKey
- redir END
- let s:SeeTabSpecialKey= @a
- let @a = regA
- hi clear SpecialKey
-
- if &et
- syn clear
- syn match SeeTabMatch /^\s\+/ contains=SeeTabBar
- let tsm1= &ts - 1
- exe 'syn match SeeTabBar / \{'.tsm1.'}/hs=s,he=s+1 contained'
- hi link SeeTabBar SpecialKey
-" call Decho('et: exe silent! hi SpecialKey ctermfg='.g:SeeTabCtermBG.' ctermbg='.g:SeeTabCtermFG.' guifg=.'g:SeeTabGuiBG.' guibg='.g:SeeTabGuiFG)
- exe 'silent! hi SpecialKey ctermfg='.g:SeeTabCtermBG.' ctermbg='.g:SeeTabCtermFG.' guifg=.'g:SeeTabGuiBG.' guibg='.g:SeeTabGuiFG
- else
- let s:SeeTab_list = &list
- let s:SeeTab_listchars = &listchars
-
- " note that list uses SpecialKey highlighting
- set list
- set listchars=tab:\|\
- exe 'silent! hi SpecialKey ctermfg='.g:SeeTabCtermFG.' ctermbg='.g:SeeTabCtermBG.' guifg='.g:SeeTabGuiFG.' guibg=.'g:SeeTabGuiBG
- endif
-
- else
-" call Decho("remove tab bars from display")
- " -------------------------
- " restore display to normal
- " -------------------------
- silent! exe "hi ".substitute(s:SeeTabSpecialKey,'xxx','','e')
- if &et
- syn clear SeeTabMatch SeeTabBar
- unlet g:SeeTabEnabled
- else
- let &list = s:SeeTab_list
- let &listchars = &listchars
- " restore SpecialKey
- unlet g:SeeTabEnabled s:SeeTab_list s:SeeTab_listchars
- endif
- endif
-endfun
-" ---------------------------------------------------------------------
-" vim: ts=4 fdm=marker
diff --git a/.config/vim/plugin/imaps.vim b/.config/vim/plugin/imaps.vim
deleted file mode 100644
index 9738936..0000000
--- a/.config/vim/plugin/imaps.vim
+++ /dev/null
@@ -1,822 +0,0 @@
-" File: imaps.vim
-" Authors: Srinath Avadhanula <srinath AT fastmail.fm>
-" Benji Fisher <benji AT member.AMS.org>
-"
-" 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,v 1.39 2004/05/30 07:35:40 srinathava Exp $
-"
-" 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}\<cr>\\item <++>\<cr>\\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 <C-j> 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 <C-r> command to insert dynamic elements such as dates.
-" call IMAP ('date`', "\<c-r>=strftime('%b %d %Y')\<cr>", '')
-"
-" 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
-"--------------------------------------%<--------------------------------------
-" }}}
-
-" ==============================================================================
-" 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 = '<space>'
- end
- exe 'inoremap <silent>'
- \ escape(lastLHSChar, '|')
- \ '<C-r>=<SID>LookupCharacter("' .
- \ escape(lastLHSChar, '\|"') .
- \ '")<CR>'
-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\+$', '')
- 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")
-
- 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), ".", "\<bs>", "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 <C-\><C-N>, 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\<C-\>\<C-N>:call IMAP_Mark('set')\<CR>\"_s"
- let text = text . template . final
- let text = text . "\<C-\>\<C-N>:call IMAP_Mark('go')\<CR>"
- let text = text . "i\<C-r>=IMAP_Jumpfunc('', 1)\<CR>"
-
- 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 = "\<C-o>v/\\V".pheUser."/e\<CR>".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\<C-o>:".s:RemoveLastHistoryItem."\<CR>"
- else
- return movement."\<C-\>\<C-N>:".s:RemoveLastHistoryItem."\<CR>gv\<C-g>"
- endif
-
-endfunction
-
-" }}}
-" Maps for IMAP_Jumpfunc {{{
-"
-" These mappings use <Plug> 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 <plug>IMAP_JumpForward
-" etc.
-
-" jumping forward and back in insert mode.
-imap <silent> <Plug>IMAP_JumpForward <c-r>=IMAP_Jumpfunc('', 0)<CR>
-imap <silent> <Plug>IMAP_JumpBack <c-r>=IMAP_Jumpfunc('b', 0)<CR>
-
-" jumping in normal mode
-nmap <silent> <Plug>IMAP_JumpForward i<c-r>=IMAP_Jumpfunc('', 0)<CR>
-nmap <silent> <Plug>IMAP_JumpBack i<c-r>=IMAP_Jumpfunc('b', 0)<CR>
-
-" deleting the present selection and then jumping forward.
-vmap <silent> <Plug>IMAP_DeleteAndJumpForward "_<Del>i<c-r>=IMAP_Jumpfunc('', 0)<CR>
-vmap <silent> <Plug>IMAP_DeleteAndJumpBack "_<Del>i<c-r>=IMAP_Jumpfunc('b', 0)<CR>
-
-" jumping forward without deleting present selection.
-vmap <silent> <Plug>IMAP_JumpForward <C-\><C-N>i<c-r>=IMAP_Jumpfunc('', 0)<CR>
-vmap <silent> <Plug>IMAP_JumpBack <C-\><C-N>`<i<c-r>=IMAP_Jumpfunc('b', 0)<CR>
-
-" }}}
-" 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('<Plug>IMAP_JumpForward', 'i')
- imap <C-J> <Plug>IMAP_JumpForward
-endif
-if !hasmapto('<Plug>IMAP_JumpForward', 'n')
- nmap <C-J> <Plug>IMAP_JumpForward
-endif
-if exists('g:Imap_StickyPlaceHolders') && g:Imap_StickyPlaceHolders
- if !hasmapto('<Plug>IMAP_JumpForward', 'v')
- vmap <C-J> <Plug>IMAP_JumpForward
- endif
-else
- if !hasmapto('<Plug>IMAP_DeleteAndJumpForward', 'v')
- vmap <C-J> <Plug>IMAP_DeleteAndJumpForward
- endif
-endif
-" }}}
-
-nmap <silent> <script> <plug><+SelectRegion+> `<v`>
-
-" ==============================================================================
-" enclosing selected region.
-" ==============================================================================
-" VEnclose: encloses the visually selected region with given arguments {{{
-" Description: allows for differing action based on visual line wise
-" selection or visual characterwise selection. preserves the
-" marks and search history.
-function! VEnclose(vstart, vend, VStart, VEnd)
-
- " its characterwise if
- " 1. characterwise selection and valid values for vstart and vend.
- " OR
- " 2. linewise selection and invalid values for VStart and VEnd
- if (visualmode() == 'v' && (a:vstart != '' || a:vend != '')) || (a:VStart == '' && a:VEnd == '')
-
- let newline = ""
- let _r = @r
-
- let normcmd = "normal! \<C-\>\<C-n>`<v`>\"_s"
-
- exe "normal! \<C-\>\<C-n>`<v`>\"ry"
- if @r =~ "\n$"
- let newline = "\n"
- let @r = substitute(@r, "\n$", '', '')
- endif
-
- " In exclusive selection, we need to select an extra character.
- if &selection == 'exclusive'
- let movement = 8
- else
- let movement = 7
- endif
- let normcmd = normcmd.
- \ a:vstart."!!mark!!".a:vend.newline.
- \ "\<C-\>\<C-N>?!!mark!!\<CR>v".movement."l\"_s\<C-r>r\<C-\>\<C-n>"
-
- " this little if statement is because till very recently, vim used to
- " report col("'>") > length of selected line when `> is $. on some
- " systems it reports a -ve number.
- if col("'>") < 0 || col("'>") > strlen(getline("'>"))
- let lastcol = strlen(getline("'>"))
- else
- let lastcol = col("'>")
- endif
- if lastcol - col("'<") != 0
- let len = lastcol - col("'<")
- else
- let len = ''
- endif
-
- " the next normal! is for restoring the marks.
- let normcmd = normcmd."`<v".len."l\<C-\>\<C-N>"
-
- " 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 = @/
-
- silent! exe normcmd
- " this is to restore the r register.
- let @r = _r
- " and finally, this is to restore the search history.
- execute s:RemoveLastHistoryItem
-
- else
-
- exec 'normal! `<O'.a:VStart."\<C-\>\<C-n>"
- exec 'normal! `>o'.a:VEnd."\<C-\>\<C-n>"
- if &indentexpr != ''
- silent! normal! `<kV`>j=
- endif
- silent! normal! `>
- endif
-endfunction
-
-" }}}
-" ExecMap: adds the ability to correct an normal/visual mode mapping. {{{
-" Author: Hari Krishna Dara <hari_vim@yahoo.com>
-" Reads a normal mode mapping at the command line and executes it with the
-" given prefix. Press <BS> to correct and <Esc> to cancel.
-function! ExecMap(prefix, mode)
- " Temporarily remove the mapping, otherwise it will interfere with the
- " mapcheck call below:
- let myMap = maparg(a:prefix, a:mode)
- exec a:mode."unmap ".a:prefix
-
- " Generate a line with spaces to clear the previous message.
- let i = 1
- let clearLine = "\r"
- while i < &columns
- let clearLine = clearLine . ' '
- let i = i + 1
- endwhile
-
- let mapCmd = a:prefix
- let foundMap = 0
- let breakLoop = 0
- echon "\rEnter Map: " . mapCmd
- while !breakLoop
- let char = getchar()
- if char !~ '^\d\+$'
- if char == "\<BS>"
- let mapCmd = strpart(mapCmd, 0, strlen(mapCmd) - 1)
- endif
- else " It is the ascii code.
- let char = nr2char(char)
- if char == "\<Esc>"
- let breakLoop = 1
- else
- let mapCmd = mapCmd . char
- if maparg(mapCmd, a:mode) != ""
- let foundMap = 1
- let breakLoop = 1
- elseif mapcheck(mapCmd, a:mode) == ""
- let mapCmd = strpart(mapCmd, 0, strlen(mapCmd) - 1)
- endif
- endif
- endif
- echon clearLine
- echon "\rEnter Map: " . mapCmd
- endwhile
- if foundMap
- if a:mode == 'v'
- " use a plug to select the region instead of using something like
- " `<v`> to avoid problems caused by some of the characters in
- " '`<v`>' being mapped.
- let gotoc = "\<plug><+SelectRegion+>"
- else
- let gotoc = ''
- endif
- exec "normal ".gotoc.mapCmd
- endif
- exec a:mode.'noremap '.a:prefix.' '.myMap
-endfunction
-
-" }}}
-
-" ==============================================================================
-" helper functions
-" ==============================================================================
-" Strntok: extract the n^th token from a list {{{
-" example: Strntok('1,23,3', ',', 2) = 23
-fun! <SID>Strntok(s, tok, n)
- return matchstr( a:s.a:tok[0], '\v(\zs([^'.a:tok.']*)\ze['.a:tok.']){'.a:n.'}')
-endfun
-
-" }}}
-" s:RemoveLastHistoryItem: removes last search item from search history {{{
-" Description: Execute this string to clean up the search history.
-let s:RemoveLastHistoryItem = ':call histdel("/", -1)|let @/=g:Tex_LastSearchPattern'
-
-" }}}
-" 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
-"" }}}
-" 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
-" }}}
-" s:Iconv: a wrapper for iconv()" {{{
-" Problem: after
-" let text = "\xab"
-" (or using the raw 8-bit ASCII character in a file with 'fenc' set to
-" "latin1") if 'encoding' is set to utf-8, then text does not match itself:
-" echo text =~ text
-" returns 0.
-" Solution: When this happens, a re-encoded version of text does match text:
-" echo iconv(text, "latin1", "utf8") =~ text
-" returns 1. In this case, convert text to utf-8 with iconv().
-" TODO: Is it better to use &encoding instead of "utf8"? Internally, vim
-" uses utf-8, and can convert between latin1 and utf-8 even when compiled with
-" -iconv, so let's try using utf-8.
-" Arguments:
-" a:text = text to be encoded or decoded
-" a:mode = "encode" (latin1 to utf8) or "decode" (utf8 to latin1)
-" Caution: do not encode and then decode without checking whether the text
-" has changed, becuase of the :if clause in encoding!
-function! s:Iconv(text, mode)
- if a:mode == "decode"
- return iconv(a:text, "utf8", "latin1")
- endif
- if a:text =~ '\V\^' . escape(a:text, '\') . '\$'
- return a:text
- endif
- let textEnc = iconv(a:text, "latin1", "utf8")
- if textEnc !~ '\V\^' . escape(a:text, '\') . '\$'
- call IMAP_Debug('Encoding problems with text '.a:text.' ', 'imap')
- endif
- return textEnc
-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 " }}}
-
-" ==============================================================================
-" A bonus function: Snip()
-" ==============================================================================
-" Snip: puts a scissor string above and below block of text {{{
-" Desciption:
-"-------------------------------------%<-------------------------------------
-" this puts a the string "--------%<---------" above and below the visually
-" selected block of lines. the length of the 'tearoff' string depends on the
-" maximum string length in the selected range. this is an aesthetically more
-" pleasing alternative instead of hardcoding a length.
-"-------------------------------------%<-------------------------------------
-function! <SID>Snip() range
- let i = a:firstline
- let maxlen = -2
- " find out the maximum virtual length of each line.
- while i <= a:lastline
- exe i
- let length = virtcol('$')
- let maxlen = (length > maxlen ? length : maxlen)
- let i = i + 1
- endwhile
- let maxlen = (maxlen > &tw && &tw != 0 ? &tw : maxlen)
- let half = maxlen/2
- exe a:lastline
- " put a string below
- exe "norm! o\<esc>".(half - 1)."a-\<esc>A%<\<esc>".(half - 1)."a-"
- " and above. its necessary to put the string below the block of lines
- " first because that way the first line number doesnt change...
- exe a:firstline
- exe "norm! O\<esc>".(half - 1)."a-\<esc>A%<\<esc>".(half - 1)."a-"
-endfunction
-
-com! -nargs=0 -range Snip :<line1>,<line2>call <SID>Snip()
-" }}}
-
-" vim:ft=vim:ts=4:sw=4:noet:fdm=marker:commentstring=\"\ %s:nowrap
diff --git a/.config/vim/plugin/jad.vim b/.config/vim/plugin/jad.vim
deleted file mode 100644
index f6e7741..0000000
--- a/.config/vim/plugin/jad.vim
+++ /dev/null
@@ -1,66 +0,0 @@
-" File: jad.vim
-" Purpose: Vim plugin for viewing decompiled class files using 'jad' decompiler.
-" Ideas: Allow for a default to be set in the vimrc
-" - map a keystroke to decompile and edit, or decompile and view in split window
-" Date Created: 10-14-2002
-" Last Modified:10-22-2002
-" Version: 1.3
-
-if exists("loaded_jad") || &cp || exists("#BufReadPre#*.class")
- finish
-endif
-let loaded_jad = 1
-
-augroup class
- " Remove all jad autocommands
- au!
- " Enable editing of jaded files
- " set binary mode before reading the file
- " add your preferable flags after "jad" (for instance "jad -f -dead -ff -a")
- autocmd BufReadPre,FileReadPre *.class set bin
- autocmd BufReadPost,FileReadPost *.class call s:read("jad")
-augroup END
-
-" Function to check that executing "cmd [-f]" works.
-" The result is cached in s:have_"cmd" for speed.
-fun s:check(cmd)
- let name = substitute(a:cmd, '\(\S*\).*', '\1', '')
- if !exists("s:have_" . name)
- let e = executable(name)
- if e < 0
- let r = system(name . " --version")
- let e = (r !~ "not found" && r != "")
- endif
- exe "let s:have_" . name . "=" . e
- endif
- exe "return s:have_" . name
-endfun
-
-" After reading decompiled file: Decompiled text in buffer with "cmd"
-fun s:read(cmd)
- " don't do anything if the cmd is not supported
- if !s:check(a:cmd)
- return
- endif
- " make 'patchmode' empty, we don't want a copy of the written file
- let pm_save = &pm
- set pm =
- " set 'modifiable'
- set ma
- " when filtering the whole buffer, it will become empty
- let empty = line("'[") == 1 && line("']") == line("$")
- let jadfile = expand("<afile>:r") . ".jad"
- let orig = expand("<afile>")
- " now we have no binary file, so set 'nobinary'
- set nobin
- "Split and show code in a new window
- g/.*/d
- execute "silent r !" a:cmd . " -p " . orig
- 1
- " set file name, type and file syntax to java
- execute ":file " . jadfile
- set ft =java
- set syntax =java
- " recover global variables
- let &pm = pm_save
-endfun
diff --git a/.config/vim/plugin/lodgeit.vim b/.config/vim/plugin/lodgeit.vim
deleted file mode 100644
index 4053b0b..0000000
--- a/.config/vim/plugin/lodgeit.vim
+++ /dev/null
@@ -1,134 +0,0 @@
-" lodgeit.vim: Vim plugin for paste.pocoo.org
-" Maintainer: Armin Ronacher <armin.ronacher@active-4.com>
-" Version: 0.1.5
-
-" Usage:
-" :Lodgeit create a paste from the current buffer of selection
-" :e <url> download a paste. If you then use :Lodgeit you can
-" reply to that paste.
-"
-" If you want to paste on ctrl + p just add this to your vimrc:
-" map ^P :Lodgeit<CR>
-" (where ^P is entered using ctrl + v, ctrl + p in vim)
-
-function! s:LodgeitInit()
-python << EOF
-
-import vim
-import re
-from xmlrpclib import ServerProxy
-srv = ServerProxy('http://paste.pocoo.org/xmlrpc/', allow_none=True)
-
-new_paste = srv.pastes.newPaste
-get_paste = srv.pastes.getPaste
-
-language_mapping = {
- 'python': 'python',
- 'php': 'html+php',
- 'smarty': 'smarty',
- 'tex': 'tex',
- 'rst': 'rst',
- 'cs': 'csharp',
- 'haskell': 'haskell',
- 'xml': 'xml',
- 'html': 'html',
- 'xhtml': 'html',
- 'htmldjango': 'html+django',
- 'django': 'html+django',
- 'htmljinja': 'html+django',
- 'jinja': 'html+django',
- 'lua': 'lua',
- 'scheme': 'scheme',
- 'mako': 'html+mako',
- 'c': 'c',
- 'cpp': 'cpp',
- 'javascript': 'js',
- 'jsp': 'jsp',
- 'ruby': 'ruby',
- 'bash': 'bash',
- 'bat': 'bat',
- 'd': 'd',
- 'genshi': 'html+genshi'
-}
-
-language_reverse_mapping = {}
-for key, value in language_mapping.iteritems():
- language_reverse_mapping[value] = key
-
-def paste_id_from_url(url):
- regex = re.compile(r'^http://paste.pocoo.org/show/(\d+)/?$')
- m = regex.match(url)
- if m is not None:
- return int(m.group(1))
-
-def make_utf8(code):
- enc = vim.eval('&fenc') or vim.eval('&enc')
- return code.decode(enc, 'ignore').encode('utf-8')
-
-EOF
-endfunction
-
-
-function! s:Lodgeit(line1,line2,count,...)
-call s:LodgeitInit()
-python << endpython
-
-# download paste
-if vim.eval('a:0') == '1':
- paste = paste_id = None
- arg = vim.eval('a:1')
-
- if arg.startswith('#'):
- try:
- paste_id = int(arg[1:])
- except:
- pass
- if paste_id is None:
- paste_id = paste_id_from_url(vim.eval('a:1'))
- if paste_id is not None:
- paste = get_paste(paste_id)
-
- if paste:
- vim.command('tabnew')
- vim.command('file Lodgeit\ Paste\ \#%d"' % paste_id)
- vim.current.buffer[:] = paste['code'].splitlines()
- vim.command('setlocal ft=' + language_reverse_mapping.
- get(paste['language'], 'text'))
- vim.command('setlocal nomodified')
- vim.command('let b:lodgeit_paste_id=%d' % paste_id)
- else:
- print 'Paste not Found'
-
-# new paste or reply
-else:
- rng_start = int(vim.eval('a:line1')) - 1
- rng_end = int(vim.eval('a:line2'))
- if int(vim.eval('a:count')):
- code = '\n'.join(vim.current.buffer[rng_start:rng_end])
- else:
- code = '\n'.join(vim.current.buffer)
- code = make_utf8(code)
-
- parent = None
- update_buffer_info = False
- if vim.eval('exists("b:lodgeit_paste_id")') == '1':
- parent = int(vim.eval('b:lodgeit_paste_id'))
- update_buffer_info = True
-
- lng_code = language_mapping.get(vim.eval('&ft'), 'text')
- paste_id = new_paste(lng_code, code, parent)
- url = 'http://paste.pocoo.org/show/%d' % paste_id
-
- print 'Pasted #%d to %s' % (paste_id, url)
- vim.command(':call setreg(\'+\', %r)' % url)
-
- if update_buffer_info:
- vim.command('file Lodgeit\ Paste\ \#%d"' % paste_id)
- vim.command('setlocal nomodified')
- vim.command('let b:lodgeit_paste_id=%d' % paste_id)
-
-endpython
-endfunction
-
-
-command! -range=0 -nargs=* Lodgeit :call s:Lodgeit(<line1>,<line2>,<count>,<f-args>)
diff --git a/.config/vim/plugin/pastie.vim b/.config/vim/plugin/pastie.vim
deleted file mode 100644
index b001508..0000000
--- a/.config/vim/plugin/pastie.vim
+++ /dev/null
@@ -1,537 +0,0 @@
-" pastie.vim: Vim plugin for pastie.caboo.se
-" Maintainer: Tim Pope <vimNOSPAM@tpope.info>
-" URL: http://www.vim.org/scripts/script.php?script_id=1624
-" GetLatestVimScripts: 1624 1
-" $Id: pastie.vim,v 1.15 2007-12-13 16:44:26 tpope Exp $
-
-" Installation:
-" Place in ~/.vim/plugin or vimfiles/plugin
-" A working ruby install is required (Vim interface not necessary).
-
-" Usage:
-" :Pastie creates a new paste (example arguments shown below). Use :w to save
-" it by posting it to the server (the parser used is derived from the Vim
-" filetype). This updates the filename and stores the new url in the primary
-" selection/clipboard when successful. :Pastie! creates a paste, saves, and
-" closes the buffer, except when loading an existing paste.
-
-" :Pastie Create a paste from all open windows
-" :Pastie! Create a paste from all open windows and paste it
-" :1,10Pastie Create a paste from the specified range
-" :%Pastie Use the entire current file to create a new paste
-" :Pastie foo.txt bar.txt Create a paste from foo.txt and bar.txt
-" :Pastie! foo.txt Paste directly from foo.txt
-" :Pastie a Create a paste from the "a register
-" :Pastie @ Create a paste from the default (unnamed) register
-" :Pastie * Create a paste from the primary selection/clipboard
-" :Pastie _ Create a new, blank paste
-" :768Pastie Load existing paste 768
-" :0Pastie Load the newest paste
-" :Pastie http://pastie.caboo.se/768 Load existing paste 768
-" :Pastie http://pastie.caboo.se/123456?key=... Use login from pastie bot
-
-" Regardless of the command used, on the first write, this script will create
-" a new paste, and on subsequent writes, it will update the existing paste.
-" If a bang is passed to a command that load an existing paste (:768), the
-" first write will update as well. If the loaded paste was not created in the
-" same vim session, or with an account extracted from your Firefox cookies,
-" updates will almost certainly silently fail. (Advanced users can muck
-" around with g:pastie_session_id if desired).
-
-" As hinted at earlier, pastie.vim will snoop around in your Firefox cookies,
-" and use an account cookie if one is found. The only way to create one of
-" these account cookies is by talking to pastie on IRC.
-
-" At the shell you can directly create a new pastie with a command like
-" $ vim +Pastie
-" or, assuming no other plugins conflict
-" $ vim +Pa
-" And, to read an existing paste
-" $ vim +768Pa
-" You could even paste a file directly
-" $ vim '+Pa!~/.irbrc' +q
-" You can even edit a pastie URL directly, but this is not recommended because
-" netrw can sometimes interfere.
-
-" Lines ending in #!! will be sent as lines beginning with !!. This alternate
-" format is easier to read and is less likely to interfere with code
-" execution. In Vim 7 highlighting is done with :2match (use ":2match none"
-" to disable it) and in previous versions, :match (use ":match none" to
-" disable).
-"
-" Known Issues:
-" URL sometimes disappears with the bang (:Pastie!) variant. You can still
-" retrieve it from the clipboard.
-
-if exists("g:loaded_pastie") || &cp
- finish
-endif
-let g:loaded_pastie = 1
-
-augroup pastie
- autocmd!
- autocmd BufReadPre http://pastie.caboo.se/*[0-9]?key=* call s:extractcookies(expand("<amatch>"))
- autocmd BufReadPost http://pastie.caboo.se/*[0-9]?key=* call s:PastieSwapout(expand("<amatch>"))
- autocmd BufReadPost http://pastie.caboo.se/*[0-9] call s:PastieSwapout(expand("<amatch>"))
- autocmd BufReadPost http://pastie.caboo.se/pastes/*[0-9]/download call s:PastieRead(expand("<amatch>"))
- autocmd BufReadPost http://pastie.caboo.se/*[0-9].* call s:PastieRead(expand("<amatch>"))
- autocmd BufWriteCmd http://pastie.caboo.se/pastes/*[0-9]/download call s:PastieWrite(expand("<amatch>"))
- autocmd BufWriteCmd http://pastie.caboo.se/*[0-9].* call s:PastieWrite(expand("<amatch>"))
- autocmd BufWriteCmd http://pastie.caboo.se/pastes/ call s:PastieWrite(expand("<amatch>"))
-augroup END
-
-let s:domain = "pastie.caboo.se"
-
-let s:dl_suffix = ".txt" " Used only for :file
-
-if !exists("g:pastie_destination")
- if version >= 700
- let g:pastie_destination = 'tab'
- else
- let g:pastie_destination = 'window'
- endif
- "let g:pastie_destination = 'buffer'
-endif
-
-command! -bar -bang -nargs=* -range=0 -complete=file Pastie :call s:Pastie(<bang>0,<line1>,<line2>,<count>,<f-args>)
-
-function! s:Pastie(bang,line1,line2,count,...)
- if exists(":tab")
- let tabnr = tabpagenr()
- endif
- let newfile = "http://".s:domain."/pastes/"
- let loggedin = 0
- let ft = &ft
- let num = 0
- if a:0 == 0 && a:count == a:line1 && a:count > line('$')
- let num = a:count
- elseif a:0 == 0 && a:line1 == 0 && a:line2 == 0
- let num = s:latestid()
- if num == 0
- return s:error("Could not determine latest paste")
- endif
- elseif !a:count && a:0 == 1
- if a:1 == '*'
- let numcheck = @*
- elseif a:1 == '+'
- let numcheck = @+
- elseif a:1 == '@'
- let numcheck = @@
- else
- let numcheck = a:1
- endif
- let numcheck = substitute(numcheck,'\n\+$','','')
- let numcheck = substitute(numcheck,'^\n\+','','g')
- if numcheck =~ '\n'
- let numcheck = ''
- endif
- if numcheck =~ '^\d\d+$'
- let num = numcheck
- elseif numcheck =~ '\%(^\|/\)\d\+?key=\x\{8,\}'
- if exists("b:pastie_fake_login")
- unlet b:pastie_fake_login
- else
- call s:extractcookies('/'.matchstr(numcheck,'\%(^\|/\)\zs\d\+?.*'))
- endif
- if exists("g:pastie_account")
- let loggedin = 1
- endif
- let num = matchstr(numcheck,'\%(^\|/\)\zs\d\+\ze?')
- elseif numcheck =~ '\%(^\|^/\|^http://.*\)\d\+\%([/?]\|$\)'
- let num = matchstr(numcheck,'\%(^\|/\)\zs\d\+')
- endif
- endif
- if num
- call s:newwindow()
- let file = "http://".s:domain."/".num.s:dl_suffix
- silent exe 'doautocmd BufReadPre '.file
- silent exe 'read !ruby -rnet/http -e "r = Net::HTTP.get_response(\%{'.s:domain.'}, \%{/pastes/'.num.'/download}); if r.code == \%{200} then print r.body else exit 10+r.code.to_i/100 end"'
- if v:shell_error && v:shell_error != 14 && v:shell_error !=15
- return s:error("Something went wrong: shell returned ".v:shell_error)
- else
- let err = v:shell_error
- silent exe "file ".file
- 1d_
- set nomodified
- call s:dobufreadpost()
- if err
- if loggedin
- let b:pastie_update = 1
- else
- echohl WarningMsg
- echo "Warning: Failed to retrieve existing paste"
- echohl None
- endif
- endif
- "call s:PastieRead(file)
- if a:bang
- " Instead of saving an identical paste, take ! to mean "do not
- " create a new paste on first save"
- let b:pastie_update = 1
- endif
- return
- endif
- elseif a:0 == 0 && !a:count && a:bang && expand("%") =~ '^http://'.s:domain.'/\d\+'
- " If the :Pastie! form is used in an existing paste, switch to
- " updating instead of creating.
- "echohl Question
- echo "Will update, not create"
- echohl None
- let b:pastie_update = 1
- return
- elseif a:0 == 1 && !a:count && a:1 =~ '^[&?]\x\{32,\}'
- " Set session id with :Pastie&deadbeefcafebabe
- let g:pastie_session_id = strpart(a:1,1)
- elseif a:0 == 1 && !a:count && (a:1 == '&' || a:1 == '?')
- " Extract session id with :Pastie&
- call s:cookies()
- if exists("g:pastie_session_id")
- echo g:pastie_session_id
- "silent! let @* = g:pastie_session_id
- endif
- elseif a:0 == 0 && !a:count && a:line1
- let ft = 'conf'
- let sum = ""
- let cnt = 0
- let keep = @"
- windo let tmp = s:grabwin() | if tmp != "" | let cnt = cnt + 1 | let sum = sum . tmp | end
- let sum = substitute(sum,'\n\+$',"\n",'')
- if cnt == 1
- let ft = matchstr(sum,'^##.\{-\} \[\zs\w*\ze\]')
- if ft != ""
- let sum = substitute(sum,'^##.\{-\} \[\w*\]\n','','')
- endif
- endif
- call s:newwindow()
- silent exe "file ".newfile
- "silent exe "doautocmd BufReadPre ".newfile
- if sum != ""
- let @" = sum
- silent $put
- 1d _
- endif
- if ft == 'plaintext' || ft == 'plain_text'
- "set ft=conf
- elseif ft != '' && sum != ""
- let &ft = ft
- endif
- let @" = keep
- call s:dobufreadpost()
- else
- let keep = @"
- let args = ""
- if a:0 > 0 && a:1 =~ '^[-"@0-9a-zA-Z:.%#*+~_/]$'
- let i = 1
- let register = a:1
- else
- let i = 0
- let register = ""
- endif
- while i < a:0
- let i = i+1
- if strlen(a:{i})
- let file = fnamemodify(expand(a:{i}),':~:.')
- let args = args . file . "\n"
- endif
- endwhile
- let range = ""
- if a:count
- silent exe a:line1.",".a:line2."yank"
- let range = @"
- let @" = keep
- endif
- call s:newwindow()
- silent exe "file ".newfile
- "silent exe "doautocmd BufReadPre ".newfile
- if range != ""
- let &ft = ft
- let @" = range
- silent $put
- endif
- if register != '' && register != '_'
- "exe "let regvalue = @".register
- silent exe "$put ".(register =~ '^[@"]$' ? '' : register)
- endif
- while args != ''
- let file = matchstr(args,'^.\{-\}\ze\n')
- let args = substitute(args,'^.\{-\}\n','','')
- let @" = "## ".file." [".s:parser(file)."]\n"
- if a:0 != 1 || a:count
- silent $put
- else
- let &ft = s:filetype(file)
- endif
- silent exe "$read ".substitute(file,' ','\ ','g')
- endwhile
- let @" = keep
- 1d_
- call s:dobufreadpost()
- if (a:0 + (a:count > 0)) > 1
- set ft=conf
- endif
- endif
- 1
- call s:afterload()
- if a:bang
- write
- let name = bufname('%')
- " TODO: re-echo the URL in a way that doesn't disappear. Stupid Vim.
- silent! bdel
- if exists("tabnr")
- silent exe "norm! ".tabnr."gt"
- endif
- endif
-endfunction
-
-function! s:dobufreadpost()
- if expand("%") =~ '/\d\+\.\@!'
- silent exe "doautocmd BufReadPost ".expand("%")
- else
- silent exe "doautocmd BufNewFile ".expand("%")
- endif
-endfunction
-
-function! s:PastieSwapout(file)
- if a:file =~ '?key='
- let b:pastie_fake_login = 1
- endif
- exe "Pastie ".a:file
-endfunction
-
-function! s:PastieRead(file)
- let lnum = line(".")
- silent %s/^!!\(.*\)/\1 #!!/e
- exe lnum
- set nomodified
- let num = matchstr(a:file,'/\@<!/\zs\d\+')
- let url = "http://".s:domain."/pastes/".num
- "let url = substitute(a:file,'\c/\%(download/\=\|text/\=\)\=$','','')
- let url = url."/download"
- let result = system('ruby -rnet/http -e "puts Net::HTTP.get_response(URI.parse(%{'.url.'}))[%{Content-Disposition}]"')
- let fn = matchstr(result,'filename="\zs.*\ze"')
- let &ft = s:filetype(fn)
- if &ft =~ '^\%(html\|ruby\)$' && getline(1).getline(2).getline(3) =~ '<%'
- set ft=eruby
- endif
- call s:afterload()
-endfunction
-
-function! s:afterload()
- set commentstring=%s\ #!! "
- hi def link pastieIgnore Ignore
- hi def link pastieNonText NonText
- if exists(":match")
- hi def link pastieHighlight MatchParen
- if version >= 700
- 2match pastieHighlight /^!!\s*.*\|^.\{-\}\ze\s*#!!\s*$/
- else
- match pastieHighlight /^!!\s*.*\|^.\{-\}\ze\s*#!!\s*$/
- endif
- else
- hi def link pastieHighlight Search
- syn match pastieHighlight '^.\{-\}\ze\s*#!!\s*$' nextgroup=pastieIgnore skipwhite
- syn region pastieHighlight start='^!!\s*' end='$' contains=pastieNonText
- endif
- syn match pastieIgnore '#!!\ze\s*$' containedin=rubyComment,rubyString
- syn match pastieNonText '^!!' containedin=rubyString
-endfunction
-
-function! s:PastieWrite(file)
- let parser = s:parser(&ft)
- let tmp = tempname()
- let num = matchstr(a:file,'/\@<!/\zs\d\+')
- if num == ''
- let num = 'pastes'
- endif
- if exists("b:pastie_update") && s:cookies() != '' && num != ""
- let url = "/pastes/".num
- let method = "_method=put&"
- else
- let url = "/pastes"
- let method = ""
- endif
- if exists("b:pastie_display_name")
- let pdn = "&paste[display_name]=".s:urlencode(b:pastie_display_name)
- elseif exists("g:pastie_display_name")
- let pdn = "&paste[display_name]=".s:urlencode(g:pastie_display_name)
- else
- let pdn = ""
- endif
- silent exe "write ".tmp
- let result = ""
- let rubycmd = 'obj = Net::HTTP.start(%{'.s:domain.'}){|h|h.post(%{'.url.'}, %q{'.method.'paste[parser]='.parser.pdn.'&paste[authorization]=burger&paste[key]=&paste[body]=} + File.read(%q{'.tmp.'}).gsub(/^(.*?) *#\!\! *#{36.chr}/,%{!\!}+92.chr+%{1}).gsub(/[^a-zA-Z0-9_.-]/n) {|s| %{%%%02x} % s[0]},{%{Cookie} => %{'.s:cookies().'}})}; print obj[%{Location}].to_s+%{ }+obj[%{Set-Cookie}].to_s'
- let result = system('ruby -rnet/http -e "'.rubycmd.'"')
- let redirect = matchstr(result,'^[^ ]*')
- let cookies = matchstr(result,'^[^ ]* \zs.*')
- call s:extractcookiesfromheader(cookies)
- call delete(tmp)
- if redirect =~ '^\w\+://'
- set nomodified
- let b:pastie_update = 1
- "silent! let @+ = result
- silent! let @* = redirect
- silent exe "file ".redirect.s:dl_suffix
- " TODO: make a proper status message
- echo '"'.redirect.'" written'
- silent exe "doautocmd BufWritePost ".redirect.s:dl_suffix
- else
- if redirect == ''
- let redirect = "Could not post to ".url
- endif
- let redirect = substitute(redirect,'^-e:1:\s*','','')
- call s:error(redirect)
- endif
-endfunction
-
-function! s:error(msg)
- echohl Error
- echo a:msg
- echohl NONE
- let v:errmsg = a:msg
-endfunction
-
-function! s:filetype(type)
- " Accepts a filename, extension, pastie parser, or vim filetype
- let type = tolower(substitute(a:type,'.*\.','',''))
- if type =~ '^\%(x\=html\|asp\w*\)$'
- return 'html'
- elseif type =~ '^\%(eruby\|erb\|rhtml\)$'
- return 'eruby'
- elseif type =~ '^\%(ruby\|ruby_on_rails\|rb\|rake\|builder\|rjs\|irbrc\)'
- return 'ruby'
- elseif type == 'js' || type == 'javascript'
- return 'javascript'
- elseif type == 'c' || type == 'cpp' || type == 'c++'
- return 'cpp'
- elseif type =~ '^\%(css\|diff\|java\|php\|python\|sql\|sh\|shell-unix-generic\)$'
- return type
- else
- return ''
- endif
-endfunction
-
-function! s:parser(type)
- let type = s:filetype(a:type)
- if type == 'text' || type == ''
- return 'plain_text'
- elseif type == 'eruby'
- return 'html_rails'
- elseif type == 'ruby'
- return 'ruby_on_rails'
- elseif type == 'sh'
- return 'shell-unix-generic'
- elseif type == 'cpp'
- return 'c++'
- else
- return type
- endif
-endfunction
-
-function! s:grabwin()
- let ft = (&ft == '' ? expand("%:e") : &ft)
- let top = "## ".expand("%:~:.")." [".s:parser(ft)."]\n"
- let keep = @"
- silent %yank
- let file = @"
- let @" = keep
- if file == "" || file == "\n"
- return ""
- else
- return top.file."\n"
- endif
-endfunction
-
-function! s:cookies()
- if exists("g:pastie_session_id")
- let cookies = "_pastie_session_id=".g:pastie_session_id
- else
- call s:extractcookies('/')
- if !exists("g:pastie_session_id")
- if !exists("s:session_warning")
- echohl WarningMsg
- echo "Warning: could not extract session id"
- let s:session_warning = 1
- echohl NONE
- endif
- let cookies = ""
- else
- let cookies = "_pastie_session_id=".g:pastie_session_id
- endif
- endif
- if !exists("g:pastie_account")
- let rubycmd = '%w(~/.mozilla/firefox ~/.firefox/default ~/.phoenix/default ~/Application\ Data/Mozilla/Firefox/Profiles ~/Library/Application\ Support/Firefox/Profiles)'
- let rubycmd = rubycmd . '.each {|dir| Dir[File.join(File.expand_path(dir),%{*})].select {|p| File.exists?(File.join(p,%{cookies.txt}))}.each {|p| File.open(File.join(p,%{cookies.txt})).each_line { |l| a=l.split(9.chr); puts [a[4],a[6]].join(%{ }) if a[0] =~ /pastie\.caboo\.se#{36.chr}/ && Time.now.to_i < a[4].to_i && a[5] == %{account} }}}'
- let output = ''
- let output = system('ruby -e "'.rubycmd.'"')
- if output =~ '\n' && output !~ '-e:'
- let output = substitute(output,'\n.*','','')
- let g:pastie_account = matchstr(output,' \zs.*')
- let g:pastie_account_expires = matchstr(output,'.\{-\}\ze ')
- else
- let g:pastie_account = ''
- endif
- endif
- if exists("g:pastie_account") && g:pastie_account != ""
- " You cannot set this arbitrarily, it must be a valid cookie
- let cookies = cookies . (cookies == "" ? "" : "; ")
- let cookies = cookies . 'account='.substitute(g:pastie_account,':','%3A','g')
- endif
- return cookies
-endfunction
-
-function! s:extractcookies(path)
- let path = substitute(a:path,'\c^http://'.s:domain,'','')
- if path !~ '^/'
- let path = '/'.path
- endif
- let cookie = system('ruby -rnet/http -e "print Net::HTTP.get_response(%{'.s:domain.'},%{'.path.'})[%{Set-Cookie}]"')
- if exists("g:pastie_debug")
- let g:pastie_cookies_path = path
- let g:pastie_cookies = cookie
- endif
- return s:extractcookiesfromheader(cookie)
-endfunction
-
-function! s:extractcookiesfromheader(cookie)
- let cookie = a:cookie
- if cookie !~ '-e:'
- let session_id = matchstr(cookie,'\<_pastie_session_id=\zs.\{-\}\ze\%([;,]\|$\)')
- let account = matchstr(cookie,'\<account=\zs.\{-\}\ze\%([;,]\|$\)')
- if session_id != ""
- let g:pastie_session_id = session_id
- endif
- if account != ""
- let g:pastie_account = account
- let time = matchstr(cookie,'\<[Ee]xpires=\zs\w\w\w,.\{-\}\ze\%([;,]\|$\)')
- if time != ""
- let g:pastie_account_expires = system('ruby -e "print Time.parse(%{'.time.'}).to_i"')
- endif
- endif
- endif
-endfunction
-
-function! s:latestid()
- return system('ruby -rnet/http -e "print Net::HTTP.get_response(URI.parse(%{http://'.s:domain.'/all})).body.match(%r{<a href=.http://'.s:domain.'/(\d+).>View})[1]"')
-endfunction
-
-function! s:urlencode(str)
- " Vim 6.2, how did we ever live with you?
- return substitute(substitute(a:str,"[\001-\037%&?=\\\\]",'\="%".printf("%02X",char2nr(submatch(0)))','g'),' ','%20','g')
-endfunction
-
-function! s:newwindow()
- if !(&modified) && (expand("%") == '' || (version >= 700 && winnr("$") == 1 && tabpagenr("$") == 1))
- enew
- else
- if g:pastie_destination == 'tab'
- tabnew
- elseif g:pastie_destination == 'window'
- new
- else
- enew
- endif
- endif
- setlocal noswapfile
-endfunction
-
-" vim:set sw=4 sts=4 et:
diff --git a/.config/vim/plugin/templates.vim b/.config/vim/plugin/templates.vim
deleted file mode 100755
index b24dfb5..0000000
--- a/.config/vim/plugin/templates.vim
+++ /dev/null
@@ -1,105 +0,0 @@
-" vim:fileencoding=iso-8859-1
-if has("python")
-py <<EOF
-"""
- Templates for VIM
- by Phillip Berndt, www.pberndt.com
-
-
- Phillip Berndt, Sat Apr 14 22:20:31 CEST 2007:
- Nihil (nihil <at> jabber.ccc.de) reported some problems in his
- VIM environment, which inserts a CR after the first character
- in templates. He came up with a workaround. Replace the
- imap command in the end with
- command('imap <unique> ^D ^[:py template_complete()<CR>a')
- to make it work.
-
-"""
-import sys
-#sys.path.remove("")
-from vim import *
-from cStringIO import StringIO
-import re, os
-template_buffer = {}
-
-def template_complete():
- global template_buffer
-
- # Check for a template
- currentPos = current.window.cursor[1]
- template = ""
- while currentPos >= 0 and len(current.line) > 0 and not current.line[currentPos].isspace():
- template = current.line[currentPos] + template
- currentPos = currentPos - 1
- currentPos = currentPos + 1
-
- if template is "":
- return
-
- # Search for that template
- fileType = eval("&ft")
- if fileType not in template_buffer or template not in template_buffer[fileType]:
- if fileType not in template_buffer:
- template_buffer[fileType] = {}
- searchPath = eval("g:templatePath")
-
- searchPaths = [
- "%s/%s/%s" % (searchPath, fileType, template),
- "%s/%s" % (searchPath, template),
- "%s/%s/%s.py" % (searchPath, fileType, template),
- "%s/%s.py" % (searchPath, template)
- ]
- for templateFile in searchPaths:
- if not os.access(templateFile, os.F_OK):
- continue
- try:
- if templateFile[-3:] == ".py":
- template_buffer[fileType][template] = open(templateFile, "r").read()
- else:
- template_buffer[fileType][template] = open(templateFile, "r").readlines()
- break
- except:
- continue
- else:
- template_buffer[fileType][template] = False
- if template_buffer[fileType][template] is not False:
- # Insert template
- indention = re.search("^\s+", current.line)
- if indention is None:
- indention = ""
- else:
- indention = indention.group(0)
- endOfLine = current.line[current.window.cursor[1] + 1:]
- current.line = current.line[:currentPos]
- range = current.buffer.range(current.window.cursor[0], current.window.cursor[0])
-
- if type(template_buffer[fileType][template]) == str:
- # Execute as python code
- backup = sys.stdout
- sys.stdout = StringIO()
- code = template_buffer[fileType][template]
- exec code in {}, {"_vim": current, "_command": command}
- insert = sys.stdout.getvalue().split("\n")
- sys.stdout = backup
- else:
- insert = template_buffer[fileType][template]
-
- firstLine = True
- sentVar = False
- for line in insert:
- if line.find("<++>") is not -1:
- sentVar = True
- if firstLine:
- range.append(line)
- else:
- range.append(indention + line)
- firstLine = False
- if sentVar:
- range.append(endOfLine)
- else:
- range.append("<++>%s" % endOfLine)
- command('normal J')
-
-command('imap <unique>  :py template_complete()<CR>a<C-J>')
-EOF
-endif