changeset 183:fca0df810041

Add after-object plugin
author zegervdv <zegervdv@me.com>
date Wed, 05 Nov 2014 22:18:41 +0100
parents 3dc6a4eec6ac
children 4c6e4d53f8f6
files .hgsub .hgsubstate vimrc
diffstat 3 files changed, 5 insertions(+), 138 deletions(-) [+]
line wrap: on
line diff
--- a/.hgsub	Wed Nov 05 22:11:31 2014 +0100
+++ b/.hgsub	Wed Nov 05 22:18:41 2014 +0100
@@ -51,3 +51,4 @@
 zsh/plugins/zsh-autosuggestions = [git]https://github.com/tarruda/zsh-autosuggestions
 vim/bundle/coffeescript = [git]https://github.com/kchmck/vim-coffee-script.git
 vim/bundle/pathogen = [git]https://github.com/tpope/vim-pathogen.git
+vim/bundle/after-object = [git]https://github.com/junegunn/vim-after-object.git
--- a/.hgsubstate	Wed Nov 05 22:11:31 2014 +0100
+++ b/.hgsubstate	Wed Nov 05 22:18:41 2014 +0100
@@ -2,6 +2,7 @@
 2cbe946206ec622d9d8cf2c99317f204c4d41885 vim/bundle/a
 d932b4491a35a0a85f1334223e315caac5e5cb0d vim/bundle/abolish
 0c5612fa31ee434ba055e21c76f456244b3b5109 vim/bundle/addon-mw-utils
+32727525735d683257d9e648374fe1c5a9a616d4 vim/bundle/after-object
 246c217562dfd8541ee0d64600a628daa4195dd2 vim/bundle/airline
 c2f60ca2e57fb65d2230c6fe58e7aba5ab065b2e vim/bundle/auto-pairs
 48abb774c72732a75f8ab05ee7493b1041dd8ae8 vim/bundle/bundler
--- a/vimrc	Wed Nov 05 22:11:31 2014 +0100
+++ b/vimrc	Wed Nov 05 22:18:41 2014 +0100
@@ -274,144 +274,6 @@
 endfunction " }}}
 set foldtext=MyFoldText()
 
-" Next and Last {{{
-"
-" Motion for "next/last object".  "Last" here means "previous", not "final".
-" Unfortunately the "p" motion was already taken for paragraphs.
-"
-" Next acts on the next object of the given type, last acts on the previous
-" object of the given type.  These don't necessarily have to be in the current
-" line.
-"
-" Currently works for (, [, {, and their shortcuts b, r, B.
-"
-" Next kind of works for ' and " as long as there are no escaped versions of
-" them in the string (TODO: fix that).  Last is currently broken for quotes
-" (TODO: fix that).
-"
-" Some examples (C marks cursor positions, V means visually selected):
-"
-" din'  -> delete in next single quotes                foo = bar('spam')
-"                                                      C
-"                                                      foo = bar('')
-"                                                                C
-"
-" canb  -> change around next parens                   foo = bar('spam')
-"                                                      C
-"                                                      foo = bar
-"                                                               C
-"
-" vin"  -> select inside next double quotes            print "hello ", name
-"                                                       C
-"                                                      print "hello ", name
-"                                                             VVVVVV
-
-onoremap an :<c-u>call <SID>NextTextObject('a', '/')<cr>
-xnoremap an :<c-u>call <SID>NextTextObject('a', '/')<cr>
-onoremap in :<c-u>call <SID>NextTextObject('i', '/')<cr>
-xnoremap in :<c-u>call <SID>NextTextObject('i', '/')<cr>
-
-onoremap al :<c-u>call <SID>NextTextObject('a', '?')<cr>
-xnoremap al :<c-u>call <SID>NextTextObject('a', '?')<cr>
-onoremap il :<c-u>call <SID>NextTextObject('i', '?')<cr>
-xnoremap il :<c-u>call <SID>NextTextObject('i', '?')<cr>
-
-
-function! s:NextTextObject(motion, dir)
-  let c = nr2char(getchar())
-  let d = ''
-
-  if c ==# "b" || c ==# "(" || c ==# ")"
-    let c = "("
-  elseif c ==# "B" || c ==# "{" || c ==# "}"
-    let c = "{"
-  elseif c ==# "r" || c ==# "[" || c ==# "]"
-    let c = "["
-  elseif c ==# "'"
-    let c = "'"
-  elseif c ==# '"'
-    let c = '"'
-  else
-    return
-  endif
-
-  " Find the next opening-whatever.
-  execute "normal! " . a:dir . c . "\<cr>"
-
-  if a:motion ==# 'a'
-    " If we're doing an 'around' method, we just need to select around it
-    " and we can bail out to Vim.
-    execute "normal! va" . c
-  else
-    " Otherwise we're looking at an 'inside' motion.  Unfortunately these
-    " get tricky when you're dealing with an empty set of delimiters because
-    " Vim does the wrong thing when you say vi(.
-
-    let open = ''
-    let close = ''
-
-    if c ==# "("
-      let open = "("
-      let close = ")"
-    elseif c ==# "{"
-      let open = "{"
-      let close = "}"
-    elseif c ==# "["
-      let open = "\\["
-      let close = "\\]"
-    elseif c ==# "'"
-      let open = "'"
-      let close = "'"
-    elseif c ==# '"'
-      let open = '"'
-      let close = '"'
-    endif
-
-    " We'll start at the current delimiter.
-    let start_pos = getpos('.')
-    let start_l = start_pos[1]
-    let start_c = start_pos[2]
-
-    " Then we'll find it's matching end delimiter.
-    if c ==# "'" || c ==# '"'
-      " searchpairpos() doesn't work for quotes, because fuck me.
-      let end_pos = searchpos(open)
-    else
-      let end_pos = searchpairpos(open, '', close)
-    endif
-
-    let end_l = end_pos[0]
-    let end_c = end_pos[1]
-
-    call setpos('.', start_pos)
-
-    if start_l == end_l && start_c == (end_c - 1)
-      " We're in an empty set of delimiters.  We'll append an "x"
-      " character and select that so most Vim commands will do something
-      " sane.  v is gonna be weird, and so is y.  Oh well.
-      execute "normal! ax\<esc>\<left>"
-      execute "normal! vi" . c
-    elseif start_l == end_l && start_c == (end_c - 2)
-      " We're on a set of delimiters that contain a single, non-newline
-      " character.  We can just select that and we're done.
-      execute "normal! vi" . c
-    else
-      " Otherwise these delimiters contain something.  But we're still not
-      " sure Vim's gonna work, because if they contain nothing but
-      " newlines Vim still does the wrong thing.  So we'll manually select
-      " the guts ourselves.
-      let whichwrap = &whichwrap
-      set whichwrap+=h,l
-
-      execute "normal! va" . c . "hol"
-
-      let &whichwrap = whichwrap
-    endif
-  endif
-endfunction
-
-" }}}
-
 " VHDL ctags
 let g:tlist_vhdl_settings   = 'vhdl;d:package declarations;b:package bodies;e:entities;a:architecture specifications;t:type declarations;p:processes;f:functions;r:procedures'
 " }}}
@@ -623,6 +485,9 @@
 " Tmuxline {{{
 let g:tmuxline_powerline_separators=0
 " }}}
+" After-objects {{{
+autocmd VimEnter * call after_object#enable('=', ':', '-', '#', ' ')
+" }}}
 
 " Load local vimrc
 if filereadable($HOME . "/.vimrc.local")