25d5eafb3add

Moar.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 23 Nov 2011 12:12:13 -0500
parents 80e85654e5cb
children 5a5bcdfd8b54
branches/tags (none)
files .hgsubstate vim/.vimrc vim/ftplugin/html.vim

Changes

--- a/.hgsubstate	Fri Nov 18 09:37:17 2011 -0500
+++ b/.hgsubstate	Wed Nov 23 12:12:13 2011 -0500
@@ -13,7 +13,7 @@
 34e28b3f6f6d702ff2963b8196eccae9344ed4bc vim/bundle/markdown
 2dd198c6c412b4ddd361b43586b01981e8383239 vim/bundle/nerdtree
 b7889db57c90824ff5092da4fdde9e05689f24fa vim/bundle/nosecompiler
-5a79d14e3979dd03e979ec3719970a030537d445 vim/bundle/python-mode
+67033ee4b9ee6d4916752da5e360b65ddf2fb525 vim/bundle/python-mode
 fa3563dda862c1dc46ddac32d8a9f939e9077379 vim/bundle/rainbow-parentheses
 fbc884de41302bb08b93b9d4d9c6921248a31a4c vim/bundle/slimv
 c6197a10ace82e0fe0c08e5cf5c017b7069a978e vim/bundle/sparkup
--- a/vim/.vimrc	Fri Nov 18 09:37:17 2011 -0500
+++ b/vim/.vimrc	Wed Nov 23 12:12:13 2011 -0500
@@ -246,14 +246,14 @@
 "             Location List     QuickFix Window
 "            (e.g. Syntastic)     (e.g. Ack)
 "            ----------------------------------
-" Next      |     M-k               M-Down     |
-" Previous  |     M-l                M-Up      |
+" Next      |     M-j               M-Down     |
+" Previous  |     M-k                M-Up      |
 "            ----------------------------------
 "
-nnoremap ˚ :lnext<cr>zvzz
-nnoremap ¬ :lprevious<cr>zvzz
-inoremap ˚ <esc>:lnext<cr>zvzz
-inoremap ¬ <esc>:lprevious<cr>zvzz
+nnoremap ∆ :lnext<cr>zvzz
+nnoremap ˚ :lprevious<cr>zvzz
+inoremap ∆ <esc>:lnext<cr>zvzz
+inoremap ˚ <esc>:lprevious<cr>zvzz
 nnoremap <m-Down> :cnext<cr>zvzz
 nnoremap <m-Up> :cprevious<cr>zvzz
 " }}}
@@ -876,6 +876,13 @@
 " }}}
 
 " }}}
+" Training mappings ------------------------------------------------------- {{{
+
+" Use L, dammit.
+nnoremap Ajk <nop>
+nnoremap A<esc> <nop>
+
+" }}}
 " Plugin settings --------------------------------------------------------- {{{
 
 " Ack {{{
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vim/ftplugin/html.vim	Wed Nov 23 12:12:13 2011 -0500
@@ -0,0 +1,82 @@
+" Vim plugin for showing matching html tags.
+" Maintainer:  Greg Sexton <gregsexton@gmail.com>
+" Credits: Bram Moolenar and the 'matchparen' plugin from which this draws heavily.
+
+if exists("b:did_ftplugin")
+    finish
+endif
+
+augroup matchhtmlparen
+  autocmd! CursorMoved,CursorMovedI,WinEnter <buffer> call s:Highlight_Matching_Pair()
+augroup END
+
+fu! s:Highlight_Matching_Pair()
+    " Remove any previous match.
+    if exists('w:tag_hl_on') && w:tag_hl_on
+        2match none
+        let w:tag_hl_on = 0
+    endif
+
+    " Avoid that we remove the popup menu.
+    " Return when there are no colors (looks like the cursor jumps).
+    if pumvisible() || (&t_Co < 8 && !has("gui_running"))
+        return
+    endif
+
+    "get html tag under cursor
+    let tagname = s:GetCurrentCursorTag()
+    if tagname == ""|return|endif
+
+    if tagname[0] == '/'
+        let position = s:SearchForMatchingTag(tagname[1:], 0)
+    else
+        let position = s:SearchForMatchingTag(tagname, 1)
+    endif
+    call s:HighlightTagAtPosition(position)
+endfu
+
+fu! s:GetCurrentCursorTag()
+    "returns the tag under the cursor, includes the '/' if on a closing tag.
+
+    let c_col  = col('.')
+    let matched = matchstr(getline('.'), '\(<[^<>]*\%'.c_col.'c.\{-}>\)\|\(\%'.c_col.'c<.\{-}>\)')
+    if matched == ""
+        return matched
+    endif
+
+    let tagname = matchstr(matched, '<\zs.\{-}\ze[ >]')
+    return tagname
+endfu
+
+fu! s:SearchForMatchingTag(tagname, forwards)
+    "returns the position of a matching tag or [0 0]
+
+    let starttag = '<'.a:tagname.'.\{-}>'
+    let midtag = ''
+    let endtag = '</'.a:tagname.'.\{-}>'.(a:forwards?'':'\zs')
+    let flags = 'nW'.(a:forwards?'':'b')
+
+    " When not in a string or comment ignore matches inside them.
+    let skip ='synIDattr(synID(line("."), col("."), 0), "name") ' .
+                \ '=~?  "htmlString\\|htmlCommentPart"'
+    execute 'if' skip '| let skip = 0 | endif'
+
+    " Limit the search to lines visible in the window.
+    let stopline = a:forwards ? line('w$') : line('w0')
+    let timeout = 300
+
+    return searchpairpos(starttag, midtag, endtag, flags, skip, stopline, timeout)
+endfu
+
+fu! s:HighlightTagAtPosition(position)
+    if a:position == [0, 0]
+        return
+    endif
+
+    let [m_lnum, m_col] = a:position
+    exe '2match MatchParen /\(\%' . m_lnum . 'l\%' . m_col .  'c<\zs.\{-}\ze[ >]\)\|'
+                \ .'\(\%' . line('.') . 'l\%' . col('.') .  'c<\zs.\{-}\ze[ >]\)\|'
+                \ .'\(\%' . line('.') . 'l<\zs[^<> ]*\%' . col('.') . 'c.\{-}\ze[ >]\)\|'
+                \ .'\(\%' . line('.') . 'l<\zs[^<>]\{-}\ze\s[^<>]*\%' . col('.') . 'c.\{-}>\)/'
+    let w:tag_hl_on = 1
+endfu