Permalink
Browse files

A lot of stuff

  • Loading branch information...
1 parent 502609e commit 344318a796f8ebf80aa8b95a8ccbec658ad7ef97 @carllerche committed Mar 28, 2011
View
3 .gitmodules
@@ -13,3 +13,6 @@
[submodule "bundle/nerdtree"]
path = bundle/nerdtree
url = git://github.com/scrooloose/nerdtree.git
+[submodule "bundle/vimerl"]
+ path = bundle/vimerl
+ url = https://github.com/oscarh/vimerl.git
1 bundle/vim-clojure
@@ -0,0 +1 @@
+Subproject commit 181913d810270d29bb2e93f08a398247751cb158
View
155 bundle/vim-textobj-indent/autoload/textobj/indent.vim
@@ -0,0 +1,155 @@
+" textobj-indent - Text objects for indented blocks of lines
+" Version: 0.0.3
+" Copyright (C) 2009 kana <http://whileimautomaton.net/>
+" License: MIT license {{{
+" Permission is hereby granted, free of charge, to any person obtaining
+" a copy of this software and associated documentation files (the
+" "Software"), to deal in the Software without restriction, including
+" without limitation the rights to use, copy, modify, merge, publish,
+" distribute, sublicense, and/or sell copies of the Software, and to
+" permit persons to whom the Software is furnished to do so, subject to
+" the following conditions:
+"
+" The above copyright notice and this permission notice shall be included
+" in all copies or substantial portions of the Software.
+"
+" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+" }}}
+" Interface "{{{1
+function! textobj#indent#select_a() "{{{2
+ return s:select(!0, 'same-or-deep')
+endfunction
+
+
+
+
+function! textobj#indent#select_i() "{{{2
+ return s:select(!!0, 'same-or-deep')
+endfunction
+
+
+
+
+function! textobj#indent#select_same_a() "{{{2
+ return s:select(!0, 'same')
+endfunction
+
+
+
+
+function! textobj#indent#select_same_i() "{{{2
+ return s:select(!!0, 'same')
+endfunction
+
+
+
+
+
+
+
+
+" Misc. "{{{1
+" Constants "{{{2
+let s:EMPTY_LINE = -1
+
+
+
+
+function! s:select(include_empty_lines_p, block_border_type) "{{{2
+ " Check the indentation level of the current or below line.
+ let cursor_linenr = line('.')
+ let base_linenr = cursor_linenr
+ while !0
+ let base_indent = s:indent_level_of(base_linenr)
+ if base_indent != s:EMPTY_LINE || base_linenr == line('$')
+ break
+ endif
+ let base_linenr += 1
+ endwhile
+
+ " Check the end of a block.
+ let end_linenr = base_linenr + 1
+ while end_linenr <= line('$')
+ let end_indent = s:indent_level_of(end_linenr)
+ if s:block_border_p(end_indent, base_indent,
+ \ a:include_empty_lines_p, a:block_border_type)
+ break
+ endif
+ let end_linenr += 1
+ endwhile
+ let end_linenr -= 1
+
+ " Check the start of a block.
+ let start_linenr = base_linenr
+ while 1 <= start_linenr
+ let start_indent = s:indent_level_of(start_linenr)
+ if s:block_border_p(start_indent, base_indent,
+ \ a:include_empty_lines_p, a:block_border_type)
+ break
+ endif
+ let start_linenr -= 1
+ endwhile
+ let start_linenr += 1
+ if line('$') < start_linenr
+ let start_linenr = line('$')
+ endif
+
+ " Select the cursor line only
+ " if <Plug>(textobj-indent-i) is executed in the last empty lines.
+ if ((!a:include_empty_lines_p)
+ \ && start_linenr == end_linenr
+ \ && start_indent == s:EMPTY_LINE)
+ let start_linenr = cursor_linenr
+ let end_linenr = cursor_linenr
+ endif
+
+ return ['V',
+ \ [0, start_linenr, 1, 0],
+ \ [0, end_linenr, len(getline(end_linenr)) + 1, 0]]
+endfunction
+
+
+
+
+function! s:indent_level_of(linenr) "{{{2
+ let _ = getline(a:linenr)
+ if _ == ''
+ return s:EMPTY_LINE
+ else
+ return indent(a:linenr)
+ endif
+endfunction
+
+
+
+
+function! s:block_border_p(indent,base_indent,include_empty_lines_p,type) "{{{2
+ if a:type ==# 'same-or-deep'
+ return a:include_empty_lines_p
+ \ ? a:indent != s:EMPTY_LINE && a:indent < a:base_indent
+ \ : a:indent == s:EMPTY_LINE || a:indent < a:base_indent
+ elseif a:type ==# 'same'
+ return a:include_empty_lines_p
+ \ ? a:indent != s:EMPTY_LINE && a:indent != a:base_indent
+ \ : a:indent == s:EMPTY_LINE || a:indent != a:base_indent
+ else
+ echoerr 'Unexpected type:' string(a:type)
+ return 0
+ endif
+endfunction
+
+
+
+
+
+
+
+
+" __END__ "{{{1
+" vim: foldmethod=marker
View
239 bundle/vim-textobj-indent/doc/textobj-indent.txt
@@ -0,0 +1,239 @@
+*textobj-indent.txt* Text objects for indented blocks of lines
+
+Version 0.0.3
+Script ID: 2484
+Copyright (C) 2008 kana <http://whileimautomaton.net/>
+License: MIT license {{{
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+}}}
+
+CONTENTS *textobj-indent-contents*
+
+Introduction |textobj-indent-introduction|
+Interface |textobj-indent-interface|
+ Commands |textobj-indent-commands|
+ Functions |textobj-indent-functions|
+ Mappings |textobj-indent-mappings|
+Bugs |textobj-indent-bugs|
+Changelog |textobj-indent-changelog|
+
+
+
+
+==============================================================================
+INTRODUCTION *textobj-indent-introduction*
+
+*textobj-indent* is a Vim plugin to provide text objects to select a block of
+lines which are similarly indented to the current line.
+
+For example, if the content of a buffer as follows:
+(here ">" means the current line under the cursor,
+and "_" means a space to indent)
+>
+ if some_condition_is_satisfied
+ > __if another_condition_is_satisfied
+ ____call s:do_x()
+ __endif
+
+ __...
+ __endif
+ else
+ __...
+ endif
+<
+|<Plug>(textobj-indent-a)| will select lines as follows:
+(here "|" indicates the selected line)
+>
+ if some_condition_is_satisfied
+ >|__if another_condition_is_satisfied
+ |____call s:do_x()
+ |__endif
+ |
+ |__...
+ |__endif
+ else
+ __...
+ endif
+<
+|<Plug>(textobj-indent-i)| will select lines as follows:
+>
+ if some_condition_is_satisfied
+ >|__if another_condition_is_satisfied
+ |____call s:do_x()
+ |__endif
+
+ __...
+ __endif
+ else
+ __...
+ endif
+<
+More variants are also available. See |textobj-indnet-mapping| for the
+details.
+
+
+Requirements:
+- Vim 7.2 or later
+- |textobj-user| 0.3.8 or later (vimscript#2100)
+
+Latest version:
+http://github.com/kana/config/commits/vim-textobj-indent
+
+Document in HTML format:
+http://kana.github.com/config/vim/textobj-indent.html
+
+
+
+
+==============================================================================
+INTERFACE *textobj-indent-interface*
+
+------------------------------------------------------------------------------
+MAPPINGS *textobj-indent-mappings*
+
+These key mappings are defined in Visual mode and Operator-pending mode.
+
+<Plug>(textobj-indent-a) *<Plug>(textobj-indent-a)*
+ Select a block of lines which are similarly indented
+ to the current line. More precisely, it selects lines
+ which are:
+ - adjacent to the current line, and
+ - indented the same or more amount
+ as the current line, or empty line.
+
+ If the current line is empty, the indentation of the
+ next line will be used to select. If that line is
+ also ampty, the indentation of the next line of that
+ line will be used instead. And so forth.
+
+ See also |textobj-indent-introduction| for figures
+ which describe what lines to be selected by this
+ command.
+
+<Plug>(textobj-indent-i) *<Plug>(textobj-indent-i)*
+ Like |<Plug>(textobj-indent-a)|, but it doesn't
+ include empty lines.
+
+<Plug>(textobj-indent-same-a) *<Plug>(textobj-indent-same-a)*
+<Plug>(textobj-indent-same-i) *<Plug>(textobj-indent-same-i)*
+ Like |<Plug>(textobj-indent-a)| or
+ |<Plug>(textobj-indent-i)|, but select a block of
+ lines with the same indentation level, not including
+ lines which are more indented than the current line.
+
+ For example, suppose you edit the following text:
+ (here ">" denotes the cursor position and "|" denotes
+ the current selection.)
+>
+ if some_condition_is_satisfied
+ call special_stuff()
+ > endif
+ call normal_stuff()
+<
+ |<Plug>(textobj-indent-same-a)| selects lines as
+ follows:
+>
+ if some_condition_is_satisfied
+ call special_stuff()
+ >|endif
+ |call normal_stuff()
+<
+ While |<Plug>(textobj-indent-a)| selects lines as
+ follows:
+>
+ |if some_condition_is_satisfied
+ | call special_stuff()
+ >|endif
+ |call normal_stuff()
+<
+
+
+
+
+==============================================================================
+CUSTOMIZING *textobj-indent-customizing*
+
+ *g:textobj_indent_no_default_key_mappings*
+ *:TextobjIndentDefaultKeyMappings*
+This plugin will define the following key mappings in Visual mode and
+Operator-pending mode automatically. If you don't want these key mappings,
+define |g:textobj_indent_no_default_key_mappings| before this plugin is loaded
+(e.g. in your |vimrc|). You can also use |:TextobjIndentDefaultKeyMappings|
+to redefine these key mappings. This command doesn't override existing {lhs}s
+unless [!] is given.
+
+ {lhs} {rhs} ~
+ ----- ---------------------- ~
+ ai <Plug>(textobj-indent-a)
+ ii <Plug>(textobj-indent-i)
+ aI <Plug>(textobj-indent-same-a)
+ iI <Plug>(textobj-indent-same-i)
+
+
+
+
+==============================================================================
+BUGS *textobj-indent-bugs*
+
+- The current selection is not extended like |aw| nor |ip|
+ whenever |<Plug>(textobj-indent-a)| or |<Plug>(textobj-indent-i)| is
+ repeated in Visual mode.
+
+- So that [count] is just ignored.
+
+- See |textobj-user-bugs| for further information.
+
+
+
+
+==============================================================================
+CHANGELOG *textobj-indent-changelog*
+
+0.0.3 2009-08-30T12:06:37+09:00 *textobj-indent-changelog-0.0.3*
+ Incompatible changes:
+ - Requrie |textobj-user| 0.3.8 or later.
+
+ Major improvements:
+ - Add |<Plug>(textobj-indent-same-a)| and
+ |<Plug>(textobj-indent-same-i)|.
+
+ Minor improvements:
+ - Revise the document a bit.
+ - Add tests.
+ - Fix a minor bug.
+ - Revise to be autoloaded.
+
+0.0.2 2009-04-17T17:45:31+09:00 *textobj-indent-changelog-0.0.2*
+ - Fix the bug to calculate indentation levels. Now these text objects
+ target a set of lines with the same indentation as you see.
+
+0.0.1 2009-02-27T13:04:37+09:00 *textobj-indent-changelog-0.0.1*
+ - Add |<Plug>(textobj-indent-a)| and |<Plug>(textobj-indent-i)|.
+ - Remove |<Plug>(textobj-indent)|.
+ Use |<Plug>(textobj-indent-a)| instead.
+
+0.0.0 2008-12-13T23:04:37+09:00 *textobj-indent-changelog-0.0.0*
+ - Initial version.
+
+
+
+
+==============================================================================
+vim:tw=78:ts=8:ft=help:norl:fen:fdl=0:fdm=marker:
View
69 bundle/vim-textobj-indent/plugin/textobj/indent.vim
@@ -0,0 +1,69 @@
+" textobj-indent - Text objects for indented blocks of lines
+" Version: 0.0.3
+" Copyright (C) 2008 kana <http://whileimautomaton.net/>
+" License: MIT license {{{
+" Permission is hereby granted, free of charge, to any person obtaining
+" a copy of this software and associated documentation files (the
+" "Software"), to deal in the Software without restriction, including
+" without limitation the rights to use, copy, modify, merge, publish,
+" distribute, sublicense, and/or sell copies of the Software, and to
+" permit persons to whom the Software is furnished to do so, subject to
+" the following conditions:
+"
+" The above copyright notice and this permission notice shall be included
+" in all copies or substantial portions of the Software.
+"
+" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+" }}}
+if exists('g:loaded_textobj_indent') "{{{1
+ finish
+endif
+
+
+
+
+
+
+
+
+" Interface "{{{1
+
+call textobj#user#plugin('indent', {
+\ '-': {
+\ 'select-a': 'ai', '*select-a-function*': 'textobj#indent#select_a',
+\ 'select-i': 'ii', '*select-i-function*': 'textobj#indent#select_i',
+\ },
+\ 'same': {
+\ 'select-a': 'aI',
+\ '*select-a-function*': 'textobj#indent#select_same_a',
+\ 'select-i': 'iI',
+\ '*select-i-function*': 'textobj#indent#select_same_i',
+\ }
+\ })
+
+
+
+
+
+
+
+
+" Fin. "{{{1
+
+let g:loaded_textobj_indent = 1
+
+
+
+
+
+
+
+
+" __END__
+" vim: foldmethod=marker
View
6 bundle/vim-textobj-user/.mduem/cache/Makefile.variables
@@ -0,0 +1,6 @@
+all_files_in_repos := Makefile autoload/textobj/user.vim doc/textobj-user.txt test/plugin.expected test/plugin.input
+current_branch := master
+origin_name := origin
+origin_uri := ../.
+repos_name := vim-textobj-user
+version := 0.3.9
View
13 bundle/vim-textobj-user/Makefile
@@ -0,0 +1,13 @@
+# Makefile for vim-textobj-user
+
+REPOS_TYPE := vim-script
+INSTALLATION_DIR := $(HOME)/.vim
+TARGETS_STATIC = $(filter %.vim %.txt,$(all_files_in_repos))
+TARGETS_ARCHIVED = $(all_files_in_repos) mduem/Makefile
+
+
+
+
+include mduem/Makefile
+
+# __END__
View
587 bundle/vim-textobj-user/autoload/textobj/user.vim
@@ -0,0 +1,587 @@
+" textobj-user - Support for user-defined text objects
+" Version: 0.3.9
+" Copyright (C) 2007-2010 kana <http://whileimautomaton.net/>
+" License: So-called MIT/X license {{{
+" Permission is hereby granted, free of charge, to any person obtaining
+" a copy of this software and associated documentation files (the
+" "Software"), to deal in the Software without restriction, including
+" without limitation the rights to use, copy, modify, merge, publish,
+" distribute, sublicense, and/or sell copies of the Software, and to
+" permit persons to whom the Software is furnished to do so, subject to
+" the following conditions:
+"
+" The above copyright notice and this permission notice shall be included
+" in all copies or substantial portions of the Software.
+"
+" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+" }}}
+" Interfaces "{{{1
+" simple "{{{2
+
+function! textobj#user#move(pattern, flags, previous_mode)
+ call s:prepare_movement(a:previous_mode)
+
+ let i = v:count1
+ while 0 < i
+ let result = searchpos(a:pattern, a:flags.'W')
+ let i = i - 1
+ endwhile
+ return result
+endfunction
+
+
+" FIXME: growing the current selection like iw/aw, is/as, and others.
+" FIXME: countable.
+" FIXME: In a case of a:pattern matches with one character.
+function! textobj#user#select(pattern, flags, previous_mode)
+ call s:prepare_selection(a:previous_mode)
+ let ORIG_POS = s:gpos_to_spos(getpos('.'))
+
+ let posf_tail = searchpos(a:pattern, 'ceW')
+ let posf_head = searchpos(a:pattern, 'bW')
+ call cursor(ORIG_POS)
+ let posb_head = searchpos(a:pattern, 'bcW')
+ let posb_tail = searchpos(a:pattern, 'eW')
+
+ " search() family with 'c' flag may not be matched to a pattern which
+ " matches to multiple lines. To choose appropriate range, we have to check
+ " another range whether it contains the cursor or not.
+ if (a:flags =~# 'b'
+ \ || (s:range_containsp(posb_head, posb_tail, ORIG_POS)
+ \ && s:range_validp(posb_head, posb_tail)))
+ let [pos_head, pos_tail] = [posb_head, posb_tail]
+ else
+ let [pos_head, pos_tail] = [posf_head, posf_tail]
+ endif
+
+ if s:range_validp(pos_head, pos_tail)
+ execute 'normal!' s:wise('v')
+ call cursor(pos_head)
+ normal! o
+ call cursor(pos_tail)
+ return [pos_head, pos_tail]
+ else
+ return s:cancel_selection(a:previous_mode, ORIG_POS)
+ endif
+endfunction
+
+
+
+
+" pair "{{{2
+
+" FIXME: NIY, but is this necessary?
+" function! textobj#user#move_pair(pattern1, pattern2, flags)
+" endfunction
+
+
+" BUGS: With o_CTRL-V, this may not work properly.
+function! textobj#user#select_pair(pattern1, pattern2, flags, previous_mode)
+ call s:prepare_selection(a:previous_mode)
+ let ORIG_POS = s:gpos_to_spos(getpos('.'))
+
+ " adjust the cursor to the head of a:pattern2 if it's already in the range.
+ let pos2c_tail = searchpos(a:pattern2, 'ceW')
+ let pos2c_head = searchpos(a:pattern2, 'bcW')
+ if !s:range_validp(pos2c_head, pos2c_tail)
+ return s:cancel_selection(a:previous_mode, ORIG_POS)
+ endif
+ if s:range_containsp(pos2c_head, pos2c_tail, ORIG_POS)
+ let more_flags = 'c'
+ else
+ let more_flags = ''
+ call cursor(ORIG_POS)
+ endif
+
+ " get the positions of a:pattern1 and a:pattern2.
+ let pos2p_head = searchpairpos(a:pattern1, '', a:pattern2, 'W'.more_flags)
+ let pos2p_tail = searchpos(a:pattern2, 'ceW')
+ if !s:range_validp(pos2p_head, pos2p_tail)
+ return s:cancel_selection(a:previous_mode, ORIG_POS)
+ endif
+ call cursor(pos2p_head)
+ let pos1p_head = searchpairpos(a:pattern1, '', a:pattern2, 'bW')
+ let pos1p_tail = searchpos(a:pattern1, 'ceW')
+ if !s:range_validp(pos1p_head, pos1p_tail)
+ return s:cancel_selection(a:previous_mode, ORIG_POS)
+ endif
+
+ " select the range, then adjust if necessary.
+ if a:flags =~# 'i'
+ if s:range_no_text_without_edgesp(pos1p_tail, pos2p_head)
+ return s:cancel_selection(a:previous_mode, ORIG_POS)
+ endif
+ call s:range_select(pos1p_tail, pos2p_head)
+
+ " adjust the range.
+ let whichwrap_orig = &whichwrap
+ let &whichwrap = '<,>'
+ execute "normal! \<Left>o\<Right>"
+ let &whichwrap = whichwrap_orig
+ else
+ call s:range_select(pos1p_head, pos2p_tail)
+ endif
+ return
+endfunction
+
+
+
+
+function! textobj#user#define(pat0, pat1, pat2, guideline) "{{{2
+ let pat0 = s:rhs_escape(a:pat0)
+ let pat1 = s:rhs_escape(a:pat1)
+ let pat2 = s:rhs_escape(a:pat2)
+ for function_name in keys(a:guideline)
+ let _lhss = a:guideline[function_name]
+ if type(_lhss) == type('')
+ let lhss = [_lhss]
+ else
+ let lhss = _lhss
+ endif
+
+ for lhs in lhss
+ if function_name == 'move-to-next'
+ execute 'nnoremap' s:mapargs_single_move(lhs, pat0, '', 'n')
+ execute 'vnoremap' s:mapargs_single_move(lhs, pat0, '', 'v')
+ execute 'onoremap' s:mapargs_single_move(lhs, pat0, '', 'o')
+ elseif function_name == 'move-to-next-end'
+ execute 'nnoremap' s:mapargs_single_move(lhs, pat0, 'e', 'n')
+ execute 'vnoremap' s:mapargs_single_move(lhs, pat0, 'e', 'v')
+ execute 'onoremap' s:mapargs_single_move(lhs, pat0, 'e', 'o')
+ elseif function_name == 'move-to-prev'
+ execute 'nnoremap' s:mapargs_single_move(lhs, pat0, 'b', 'n')
+ execute 'vnoremap' s:mapargs_single_move(lhs, pat0, 'b', 'v')
+ execute 'onoremap' s:mapargs_single_move(lhs, pat0, 'b', 'o')
+ elseif function_name == 'move-to-prev-end'
+ execute 'nnoremap' s:mapargs_single_move(lhs, pat0, 'be', 'n')
+ execute 'vnoremap' s:mapargs_single_move(lhs, pat0, 'be', 'v')
+ execute 'onoremap' s:mapargs_single_move(lhs, pat0, 'be', 'o')
+ elseif function_name == 'select-next' || function_name == 'select'
+ execute 'vnoremap' s:mapargs_single_select(lhs, pat0, '', 'v')
+ execute 'onoremap' s:mapargs_single_select(lhs, pat0, '', 'o')
+ elseif function_name == 'select-prev'
+ execute 'vnoremap' s:mapargs_single_select(lhs, pat0, 'b', 'v')
+ execute 'onoremap' s:mapargs_single_select(lhs, pat0, 'b', 'o')
+ elseif function_name == 'select-pair-all'
+ execute 'vnoremap' s:mapargs_pair_select(lhs, pat1, pat2, 'a', 'v')
+ execute 'onoremap' s:mapargs_pair_select(lhs, pat1, pat2, 'a', 'o')
+ elseif function_name == 'select-pair-inner'
+ execute 'vnoremap' s:mapargs_pair_select(lhs, pat1, pat2, 'i', 'v')
+ execute 'onoremap' s:mapargs_pair_select(lhs, pat1, pat2, 'i', 'o')
+ else
+ throw 'Unknown function name: ' . string(function_name)
+ endif
+ endfor
+ endfor
+endfunction
+
+
+
+
+function! textobj#user#plugin(plugin_name, obj_specs) "{{{2
+ if a:plugin_name =~# '\L'
+ throw '{plugin} contains non-lowercase alphabet: ' . string(a:plugin_name)
+ endif
+ let plugin = a:plugin_name
+ let Plugin = substitute(a:plugin_name, '^\(\l\)', '\u\1', 0)
+
+ let g:__textobj_{plugin} = s:plugin.new(a:plugin_name, a:obj_specs)
+
+ execute
+ \ 'command! -bang -bar -nargs=0 Textobj'.Plugin.'DefaultKeyMappings'
+ \ 'call g:__textobj_'.plugin.'.define_default_key_mappings("<bang>" == "!")'
+ call g:__textobj_{plugin}.define_interface_key_mappings()
+ if (!has_key(a:obj_specs, '*no-default-key-mappings*'))
+ \ && (!exists('g:textobj_'.plugin.'_no_default_key_mappings'))
+ execute 'Textobj'.Plugin.'DefaultKeyMappings'
+ endif
+
+ return g:__textobj_{plugin}
+endfunction
+
+
+
+
+
+
+
+
+" Misc. "{{{1
+" pos "{{{2
+
+" Terms:
+" gpos [bufnum, lnum, col, off] - a value returned by getpos()
+" spos [lnum, col] - a value returned by searchpos()
+" pos same as spos
+function! s:gpos_to_spos(gpos)
+ return a:gpos[1:2]
+endfunction
+
+
+function! s:pos_headp(pos)
+ return a:pos[1] <= 1
+endfunction
+
+function! s:pos_lastp(pos)
+ return a:pos[1] == len(getline(a:pos[0]))
+endfunction
+
+
+function! s:pos_le(pos1, pos2) " less than or equal
+ return ((a:pos1[0] < a:pos2[0])
+ \ || (a:pos1[0] == a:pos2[0] && a:pos1[1] <= a:pos2[1]))
+endfunction
+
+
+
+
+" range "{{{2
+
+function! s:range_containsp(range_head, range_tail, target_pos)
+ return (s:pos_le(a:range_head, a:target_pos)
+ \ && s:pos_le(a:target_pos, a:range_tail))
+endfunction
+
+
+function! s:range_no_text_without_edgesp(range_head, range_tail)
+ let [hl, hc] = a:range_head
+ let [tl, tc] = a:range_tail
+ return ((hl == tl && hc - tc == -1)
+ \ || (hl - tl == -1
+ \ && (s:pos_lastp(a:range_head) && s:pos_headp(a:range_tail))))
+endfunction
+
+
+function! s:range_validp(range_head, range_tail)
+ let NULL_POS = [0, 0]
+ return (a:range_head != NULL_POS) && (a:range_tail != NULL_POS)
+endfunction
+
+
+function! s:range_select(range_head, range_tail)
+ execute 'normal!' s:wise('v')
+ call cursor(a:range_head)
+ normal! o
+ call cursor(a:range_tail)
+endfunction
+
+
+
+
+" for textobj#user#define() "{{{2
+
+function! s:rhs_escape(pattern)
+ let r = a:pattern
+ let r = substitute(r, '<', '<LT>', 'g')
+ let r = substitute(r, '|', '<Bar>', 'g')
+ return r
+endfunction
+
+
+function! s:mapargs_single_move(lhs, pattern, flags, previous_mode)
+ return printf('<silent> %s :<C-u>call textobj#user#move(%s, %s, %s)<CR>',
+ \ a:lhs,
+ \ string(a:pattern), string(a:flags), string(a:previous_mode))
+endfunction
+
+function! s:mapargs_single_select(lhs, pattern, flags, previous_mode)
+ return printf('<silent> %s :<C-u>call textobj#user#select(%s, %s, %s)<CR>',
+ \ a:lhs,
+ \ string(a:pattern), string(a:flags), string(a:previous_mode))
+endfunction
+
+function! s:mapargs_pair_select(lhs, pattern1, pattern2, flags, previous_mode)
+ return printf(
+ \ '<silent> %s :<C-u>call textobj#user#select_pair(%s,%s,%s,%s)<CR>',
+ \ a:lhs,
+ \ string(a:pattern1), string(a:pattern2),
+ \ string(a:flags), string(a:previous_mode)
+ \ )
+endfunction
+
+
+
+
+" for textobj#user#plugin() "{{{2
+" basics "{{{3
+let s:plugin = {}
+
+function s:plugin.new(plugin_name, obj_specs)
+ let _ = extend({'name': a:plugin_name, 'obj_specs': a:obj_specs},
+ \ s:plugin, 'keep')
+ call _.normalize()
+ return _
+endfunction
+
+function s:plugin.normalize()
+ for [obj_name, specs] in items(self.obj_specs)
+ for [spec_name, spec_info] in items(specs)
+ if spec_name =~# '^\(move-[npNP]\|select\(\|-[ai]\)\)$'
+ if type(spec_info) == type('')
+ let specs[spec_name] = [spec_info]
+ endif
+ endif
+
+ if spec_name =~# '^\*.*-function\*$'
+ if spec_info =~# '^s:'
+ if has_key(specs, '*sfile*')
+ let specs[spec_name] = substitute(spec_info,
+ \ '^s:',
+ \ s:snr_prefix(specs['*sfile*']),
+ \ '')
+ else
+ echoerr 'Script-local function is given without *sfile*:'
+ \ string(spec_name) '/' string(spec_info)
+ endif
+ else
+ " Nothing to do.
+ endif
+ endif
+
+ unlet spec_info " to avoid E706.
+ endfor
+ endfor
+endfunction
+
+
+function! s:plugin.define_default_key_mappings(banged_p) "{{{3
+ for [obj_name, specs] in items(self.obj_specs)
+ for [spec_name, spec_info] in items(specs)
+ let rhs = self.interface_mapping_name(obj_name, spec_name)
+ if spec_name =~# '^\*.*\*$'
+ " ignore
+ elseif spec_name =~# '^move-[npNP]$'
+ for lhs in spec_info
+ call s:map(a:banged_p, lhs, rhs)
+ endfor
+ elseif spec_name =~# '^select\(\|-[ai]\)$'
+ for lhs in spec_info
+ call s:objmap(a:banged_p, lhs, rhs)
+ endfor
+ else
+ throw 'Unknown command: ' . string(spec_name)
+ endif
+
+ unlet spec_info " to avoid E706.
+ endfor
+ endfor
+endfunction
+
+
+function! s:plugin.define_interface_key_mappings() "{{{3
+ let RHS_PATTERN = ':<C-u>call g:__textobj_' . self.name . '.%s'
+ \ . '("%s", "%s", "<mode>")<Return>'
+ let RHS_FUNCTION = ':<C-u>call <SID>select_function_wrapper('
+ \ . 'g:__textobj_' . self.name . '.obj_specs["%s"]["%s"],'
+ \ . '"<mode>"'
+ \ . ')<Return>'
+
+ for [obj_name, specs] in items(self.obj_specs)
+ for spec_name in filter(keys(specs), 'v:val[0] != "*" && v:val[-1] != "*"')
+ " lhs
+ let lhs = '<silent> ' . self.interface_mapping_name(obj_name, spec_name)
+
+ " rhs
+ let _ = '*' . spec_name . '-function*'
+ if has_key(specs, _)
+ let rhs = printf(RHS_FUNCTION, obj_name, _)
+ elseif has_key(specs, '*pattern*')
+ if spec_name =~# '^move-[npNP]$'
+ let flags = ''
+ let flags .= (spec_name =~ '[pP]$' ? 'b' : '')
+ let flags .= (spec_name =~ '[NP]$' ? 'e' : '')
+ let impl_fname = 'move'
+ elseif spec_name ==# 'select'
+ let flags = ''
+ let impl_fname = 'select'
+ elseif spec_name =~# '^select-[ai]$'
+ let flags = ''
+ let flags .= (spec_name =~ 'a$' ? 'a' : '')
+ let flags .= (spec_name =~ 'i$' ? 'i' : '')
+ let impl_fname = 'select_pair'
+ else
+ echoerr 'Unknown spec:' string(spec_name)
+ continue
+ endif
+ let rhs = printf(RHS_PATTERN, impl_fname, obj_name, flags)
+ else
+ " skip to allow to define user's own {rhs} of the interface mapping.
+ continue
+ endif
+
+ " map
+ if spec_name =~# '^move'
+ let MapFunction = function('s:noremap')
+ else " spec_name =~# '^select'
+ let MapFunction = function('s:objnoremap')
+ endif
+ call MapFunction(1, lhs, rhs)
+ endfor
+ endfor
+endfunction
+
+
+function! s:plugin.interface_mapping_name(obj_name, spec_name) "{{{3
+ let _ = printf('<Plug>(textobj-%s-%s-%s)',
+ \ self.name,
+ \ a:obj_name,
+ \ substitute(a:spec_name, '^\(move\|select\)', '', ''))
+ let _ = substitute(_, '-\+', '-', 'g')
+ let _ = substitute(_, '-\ze)$', '', '')
+ return _
+endfunction
+
+
+" *pattern* implementations "{{{3
+function! s:plugin.move(obj_name, flags, previous_mode)
+ let specs = self.obj_specs[a:obj_name]
+ call textobj#user#move(specs['*pattern*'], a:flags, a:previous_mode)
+endfunction
+
+function! s:plugin.select(obj_name, flags, previous_mode)
+ let specs = self.obj_specs[a:obj_name]
+ call textobj#user#select(specs['*pattern*'], a:flags, a:previous_mode)
+endfunction
+
+function! s:plugin.select_pair(obj_name, flags, previous_mode)
+ let specs = self.obj_specs[a:obj_name]
+ call textobj#user#select_pair(specs['*pattern*'][0], specs['*pattern*'][1],
+ \ a:flags, a:previous_mode)
+endfunction
+
+
+" map wrappers "{{{3
+function! s:_map(map_commands, forced_p, lhs, rhs)
+ for _ in a:map_commands
+ execute 'silent!' (_) (a:forced_p ? '' : '<unique>') a:lhs
+ \ substitute(a:rhs, '<mode>', _[0], 'g')
+ endfor
+endfunction
+
+
+function! s:noremap(forced_p, lhs, rhs)
+ let v = s:proper_visual_mode(a:lhs)
+ call s:_map(['nnoremap', v.'noremap', 'onoremap'], a:forced_p, a:lhs, a:rhs)
+endfunction
+
+function! s:objnoremap(forced_p, lhs, rhs)
+ let v = s:proper_visual_mode(a:lhs)
+ call s:_map([v.'noremap', 'onoremap'], a:forced_p, a:lhs, a:rhs)
+endfunction
+
+
+function! s:map(forced_p, lhs, rhs)
+ let v = s:proper_visual_mode(a:lhs)
+ call s:_map(['nmap', v.'map', 'omap'], a:forced_p, a:lhs, a:rhs)
+endfunction
+
+function! s:objmap(forced_p, lhs, rhs)
+ let v = s:proper_visual_mode(a:lhs)
+ call s:_map([v.'map', 'omap'], a:forced_p, a:lhs, a:rhs)
+endfunction
+
+
+" *select-function* wrapper "{{{3
+function! s:select_function_wrapper(function_name, previous_mode)
+ let ORIG_POS = s:gpos_to_spos(getpos('.'))
+ call s:prepare_selection(a:previous_mode)
+
+ let _ = function(a:function_name)()
+ if _ is 0
+ call s:cancel_selection(a:previous_mode, ORIG_POS)
+ else
+ let [motion_type, start_position, end_position] = _
+ execute 'normal!' s:wise(motion_type)
+ call setpos('.', start_position)
+ normal! o
+ call setpos('.', end_position)
+ endif
+endfunction
+
+
+
+
+" Etc "{{{2
+
+function! s:prepare_movement(previous_mode)
+ if a:previous_mode ==# 'v'
+ normal! gv
+ endif
+endfunction
+
+function! s:prepare_selection(previous_mode)
+ if a:previous_mode ==# 'v'
+ execute 'normal!' "gv\<Esc>"
+ endif
+endfunction
+
+
+function! s:cancel_selection(previous_mode, orig_pos)
+ if a:previous_mode ==# 'v'
+ normal! gv
+ else " if a:previous_mode ==# 'o'
+ call cursor(a:orig_pos)
+ endif
+endfunction
+
+
+function! s:snr_prefix(sfile)
+ redir => result
+ silent scriptnames
+ redir END
+
+ for line in split(result, '\n')
+ let _ = matchlist(line, '^\s*\(\d\+\):\s*\(.*\)$')
+ if a:sfile ==# _[2]
+ return printf("\<SNR>%d_", _[1])
+ endif
+ endfor
+
+ return 's:'
+endfunction
+
+
+function! s:wise(default)
+ return (exists('v:motion_force') && v:motion_force != ''
+ \ ? v:motion_force
+ \ : a:default)
+endfunction
+
+
+function! s:proper_visual_mode(lhs)
+ " Return the mode prefix of proper "visual" mode for a:lhs key sequence.
+ " a:lhs should not be defined in Select mode if a:lhs starts with
+ " a printable character. Otherwise a:lhs may be defined in Select mode.
+
+ " a:lhs may be prefixed with :map-arguments such as <buffer>.
+ " It's necessary to remove them to determine the first character in a:lhs.
+ let s1 = substitute(
+ \ a:lhs,
+ \ '\v^(\<(buffer|silent|special|script|expr|unique)\>\s*)*',
+ \ '',
+ \ ''
+ \ )
+ " All characters in a:lhs are printable characters, so it's necessary to
+ " convert <>-escaped notation into corresponding characters.
+ let s2 = substitute(s1,
+ \ '^\(<[^<>]\+>\)',
+ \ '\=eval("\"\\" . submatch(1) . "\"")',
+ \ '')
+ return s2 =~# '^\p' ? 'x' : 'v'
+endfunction
+
+
+
+
+
+
+
+
+" __END__ "{{{1
+" vim: foldmethod=marker
View
401 bundle/vim-textobj-user/doc/textobj-user.txt
@@ -0,0 +1,401 @@
+*textobj-user.txt* Support for user-defined text objects
+
+Version 0.3.9
+Script ID: 2100
+Copyright (C) 2007-2010 kana <http://whileimautomaton.net/>
+License: So-called MIT/X license {{{
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+}}}
+
+CONTENTS *textobj-user-contents*
+
+Introduction |textobj-user-introduction|
+Interface |textobj-user-interface|
+ Functions |textobj-user-functions|
+Bugs |textobj-user-bugs|
+Changelog |textobj-user-changelog|
+
+
+
+
+==============================================================================
+INTRODUCTION *textobj-user-introduction*
+
+*textobj-user* is a Vim plugin to SUPPORT writing user-defined text objects,
+especially, simple text objects which can be defined by regular expression.
+
+Note that this plugin only provides functions to support writing user-defined
+text objects, and this plugin does not provide any useful text objects. That
+is your work.
+
+
+Requirements:
+- Vim 7.0 or later
+
+Latest version:
+http://github.com/kana/vim-textobj-user
+
+Document in HTML format:
+http://kana.github.com/config/vim/textobj-user.html
+
+
+
+
+==============================================================================
+INTERFACE *textobj-user-interface*
+
+------------------------------------------------------------------------------
+FUNCTIONS *textobj-user-function*
+
+ *textobj#user#move()*
+textobj#user#move({pattern}, {flags}, {previous-mode})
+ Move the cursor to the appropriate object defined by {pattern}.
+
+ {flags} is a string, which can contain the following character flags:
+ char meaning ~
+ ---- ------- ~
+ 'b' search backward instead of forward.
+ 'e' move to the end of the match.
+
+ {previous-mode} is a string representing the "previous" mode,
+ that is, which mode of mapping causes the calling of this function.
+ For example, if this function is called via a mapping for
+ Operator-pending mode, {previous-mode} must be 'o'.
+ char meaning ~
+ ---- ------- ~
+ 'n' Normal mode
+ 'o' Operator-pending mode
+ 'v' Visual mode
+
+ Return value is same as |searchpos()|.
+
+ *textobj#user#select()*
+textobj#user#select({pattern}, {flags}, {prevous-mode})
+ Select the appropriate object defined by {pattern}.
+ If the cursor is already in the range of an object, select it.
+ If the cursor is not in the range of an object, select the nearest
+ object after the cursor.
+
+ {flags} is a string, which can contain the following character flags:
+ char meaning ~
+ ---- ------- ~
+ 'b' select the nearest object BEFORE the cursor if the
+ cursor is not in the range of an object.
+
+ For the detail of {previous-mode}, see |textobj#user#move()|.
+
+ Return value is not defined.
+
+ *textobj#user#select_pair()*
+textobj#user#select_pair({pattern1}, {pattern2}, {flags}, {previous-mode})
+ Select the appropriate object which starts with {pattern1} and ends
+ with {pattern2}.
+
+ {flags} is a string, which can contain the following character flags:
+ char meaning ~
+ ---- ------- ~
+ 'a' select the range including {pattern1} and {pattern2},
+ like |at|.
+ 'i' select the range excluding {pattern1} and {pattern2},
+ like |it|. This is the default behavior unless 'a' is
+ explicitly specified. If the cursor is not in a text
+ between {pattern1} and {pattern2}, this function does
+ nothing.
+
+ For the detail of {previous-mode}, see |textobj#user#move()|.
+
+ Return value is not defined.
+
+ *textobj#user#define()*
+textobj#user#define({pattern}, {pattern1}, {pattern2}, {guideline})
+ Support function to define key mappings for the text object defined by
+ {pattern}, or {pattern1} and {pattern2}. {guideline} is a dictionary
+ consists of key-value pairs where key is a string to represent the
+ name of function and value is a list of strings (each string
+ represents {lhs} for corresponding key).
+
+ function name meaning ~
+ ------------- ------- ~
+ 'move-to-next' textobj#user#move({pattern}, '')
+ 'move-to-prev' textobj#user#move({pattern}, 'b')
+ 'move-to-next-end' textobj#user#move({pattern}, 'e')
+ 'move-to-prev-end' textobj#user#move({pattern}, 'be')
+ 'select' synonym for 'select-next'
+ 'select-next' textobj#user#select({pattern}, '',
+ {previous-mode})
+ 'select-prev' textobj#user#select({pattern}, 'b',
+ {previous-mode})
+ 'select-pair-all' textobj#user#select_pair({pattern1},
+ {pattern2},
+ 'a', {previous-mode})
+ 'select-pair-inner' textobj#user#select_pair({pattern1},
+ {pattern2},
+ 'i', {previous-mode})
+
+ Example: >
+ call textobj#user#define('foo', '', '',
+ \ {'move-to-next': 'gj',
+ \ 'move-to-prev': 'gk',
+ \ 'select': ['ig', 'ag']})
+<
+ *textobj#user#plugin()*
+textobj#user#plugin({plugin}, {obj-specs})
+ Define key mappings and a command to support writing a plugin which
+ provides various user-defined text objects.
+
+ Example: If textobj#user#plugin() is called like the following: >
+
+ call textobj#user#plugin('foo', {
+ \ 'cdata': {
+ \ '*pattern*': ['<!\[CDATA\[', '\]\]>'],
+ \ 'select-a': 'aC',
+ \ 'select-i': 'iC',
+ \ },
+ \ 'date': {
+ \ '*pattern*': '\<\d\{4}-\d\{2}-\d\{2}\>',
+ \ 'select': ['ad', 'id'],
+ \ },
+ \ 'helptag': {
+ \ '*pattern*': '\*[^*]\+\*',
+ \ 'move-n': ',j',
+ \ 'move-p': ',k',
+ \ 'move-N': ',J',
+ \ 'move-P': ',K',
+ \ },
+ \ '-': {
+ \ '*select-function*': 'SelectFoo',
+ \ 'select': ['ax', 'ix'],
+ \ },
+ \ })
+<
+ (1) New command :TextobjFooDefaultKeyMappings will be defined.
+ This command defines the following key mappings as the default
+ ones for the new text objects (this command doesn't override
+ existing {lhs}s unless "!" is given): >
+
+ omap aC <Plug>(textobj-foo-cdata-a)
+ vmap aC <Plug>(textobj-foo-cdata-a)
+ omap iC <Plug>(textobj-foo-cdata-i)
+ vmap iC <Plug>(textobj-foo-cdata-i)
+ omap ad <Plug>(textobj-foo-date)
+ vmap ad <Plug>(textobj-foo-date)
+ omap id <Plug>(textobj-foo-date)
+ vmap id <Plug>(textobj-foo-date)
+ omap ax <Plug>(textobj-foo)
+ vmap ax <Plug>(textobj-foo)
+ omap ix <Plug>(textobj-foo)
+ vmap ix <Plug>(textobj-foo)
+ map ,j <Plug>(textobj-foo-helptag-n)
+ map ,k <Plug>(textobj-foo-helptag-p)
+ map ,J <Plug>(textobj-foo-helptag-N)
+ map ,K <Plug>(textobj-foo-helptag-P)
+<
+ (2) New variable g:__textobj_foo will be defined. This is
+ a dictionary which contains various functions and values.
+
+ (3) Key mappings <Plug>(textobj-foo-...) which execute
+ appropriate actions will be defined if "*pattern*" or
+ "*{spec}-function*" is given for a {spec}. Otherwise,
+ <Plug>(textobj-foo-...) will not be defined.
+
+ (4) :TextobjFooDefaultKeyMappings will be executed unless
+ {specs} contains the key "*no-default-key-mappings" or the
+ variable g:textobj_foo_no_default_key_mappings is defined.
+
+ {plugin} is the name of a plugin. It must be a string which consits
+ of only lowercase alphabets.
+
+ {obj-specs} is a dictionary (and given value is cached by this
+ plugin, so you have to pass copied one if necessary). In this
+ dictionary, each key/value pair expresses one text object:
+ - each key is a string of the name of the text object, and
+ - each value (called as "specs") is a dictionary which denotes some
+ details of the text object.
+
+ The following specs are available:
+
+ "move-n" {lhs} or [{lhs}, ...]
+ A string which is a key sequence to move the cursor to the
+ next text object. If the value is a list of strings, each
+ string is mapped to move the cursor.
+
+ "move-p" {lhs} or [{lhs}, ...]
+ "move-N" {lhs} or [{lhs}, ...]
+ "move-P" {lhs} or [{lhs}, ...]
+ Like "move-n", but each string is treated as a key sequence to
+ move the cursor to the previous text object, the end of the
+ next text object, or the end of the previous text object.
+
+ "select" {lhs} or [{lhs}, ...]
+ Like "move-n", but each string is treated as a key sequence to
+ select the text object.
+
+ "select-a" {lhs} or [{lhs}, ...]
+ "select-i" {lhs} or [{lhs}, ...]
+ Like "select", but each string is treated as a key sequence
+ to select "a" text object or "inner" text object.
+
+ "*pattern*" {regexp} or [{regexp}, {regexp}]
+ A regular expression which matches to a text object. If the
+ value is a list of two regular expressions, it denotes that
+ the text object starts with the first regular expression and
+ ends with the second regular expression.
+
+ "*no-default-key-mappings*" anything
+ If this key exists, :Textobj{Plugin}DefaultKeyMappings will
+ not be executed when textobj#user#plugin() is called. The
+ corresponding value doesn't matter.
+
+ "*{spec}-function*" {fname}
+ If this key exists, use the function named {fname} instead of
+ the default algorithm based on regular expression to select
+ a text for {spec}.
+
+ The function must take no argument and it must return a list
+ to denote the area to be selected or 0 to denote that there is
+ nothing to select. The detail of a list is as follows:
+ [motion_type, start_position, end_position]
+ - "motion_type" denotes the default type of motion. Valid
+ values are "v", "V" or "\<C-v>". The meaning of the values
+ are characterwise, linewise or blockwise.
+ - "start_position" denotes the start position of the area to
+ be selected. The detail of this value is the same as
+ |getpos()|.
+ - "end_position" is like "start_position", but it denotes the
+ end position of the area to be selected.
+
+ Example definition: >
+ funcion! SelectSomething()
+ if SomethinWrong()
+ return 0
+ endif
+
+ return ['v', getpos("'["), getpos("']")]
+ endfunction
+<
+ "*sfile*" {string}
+ Value must be expand('<sfile>'). This value is used to
+ calculate <SNR> prefix for script-local functions which are
+ specified "*{spec}-function*".
+
+
+
+
+==============================================================================
+BUGS *textobj-user-bugs*
+
+- textobj#user#select() and textobj#user#select_pair() override the current
+ {Visual}, unlike built-in text objects such as iw/aw, is/as, and so forth.
+
+- textobj#user#select() and textobj#user#select_pair() cannot be used with
+ [count].
+
+- textobj#user#select_pair() with |o_CTRL-V| may not work properly.
+
+
+
+
+==============================================================================
+CHANGELOG *textobj-user-changelog*
+
+0.3.9 2010-04-19T22:02:03+09:00 *textobj-user-changelog-0.3.9*
+ - |textobj#user#plugin()|: Fix not to define key mappings in Select
+ mode if appropriate. Now it works smoothly with plugins which
+ utilize and depend on the default behavior in Select mode.
+
+0.3.8 2009-07-18T10:02:40+09:00 *textobj-user-changelog-0.3.8*
+ - Fix a bug that it was not possible to select any range which starts
+ with the end of a line.
+ - |textobj#user#plugin()|: Fix a bug that it did not accept
+ any function which is not script-local as a value for
+ "*{spec}-function*".
+
+0.3.7 2008-10-24T02:25:59+09:00 *textobj-user-changelog-0.3.7*
+ - |textobj#user#select()|: Fix a bug that it didn't select an object
+ which: (1) matches to multiple lines and (2) contains the cursor.
+ - |textobj#user#select()|, |textobj#user#select_pair()|,
+ |textobj#user#plugin()| with "*{spec}-function*":
+ Support |o_v| and others. To use this feature, you have to apply
+ the following patch to Vim:
+ http://github.com/kana/vim/commits/hack/vimvar-motion_force
+
+0.3.6 2008-08-31T03:17:55+09:00 *textobj-user-changelog-0.3.6*
+ - Remove unnecessary messages for some cases. They were just for
+ debugging.
+
+0.3.5 2008-08-24T23:01:45+09:00 *textobj-user-changelog-0.3.5*
+ Incompatible changes with 0.3.4 or ealier:
+ - |textobj#user#plugin()|: Change the specification of functions for
+ "*{spec}-function*".
+
+ Other changes:
+ - |textobj#user#plugin()|: Add missing description of functions for
+ "*{spec}-function*".
+
+0.3.4 2008-06-26T14:13:33+09:00 *textobj-user-changelog-0.3.4*
+ - |textobj#user#plugin()|:
+ - Add "*{spec}-function*" to customize the way to move the cursor or
+ to select a text by the given function instead of regular
+ expression based selection.
+
+0.3.3 2008-06-11T21:16:53+09:00 *textobj-user-changelog-0.3.3*
+ - |textobj#user#plugin()|:
+ - Rename the spec "*pattern*" instead of "pattern".
+ - Fix incorrect processing on "*no-default-key-mappings*".
+
+0.3.2 2008-06-11T02:53:41+09:00 *textobj-user-changelog-0.3.2*
+ - |textobj#user#plugin()|: Change the names of interface mappings for
+ the text object of which name is '-'.
+ Old: <Plug>(textobj-{plugin}---a)
+ New: <Plug>(textobj-{plugin}-a)
+
+0.3.1 2008-06-08T22:05:02+09:00 *textobj-user-changelog-0.3.1*
+ - |textobj#user#plugin()|: Execute :Textobj{Plugin}DefaultKeyMappings
+ if necessary.
+
+0.3 2008-06-04T21:16:02+09:00 *textobj-user-changelog-0.3*
+ - |textobj#user#plugin()|: New.
+ - |textobj#user#define()|: Now obsolete. Use textobj#user#define().
+
+0.2.2 2008-06-02T06:26:12+09:00 *textobj-user-changelog-0.2.2*
+ - Fix wrong sentences in the document.
+
+0.2.1 2008-05-22T00:17:24+09:00 *textobj-user-changelog-0.2.1*
+ - textobj#user#select_pair(): Fix the bug that it selects wrong text
+ in Operator-pending mode.
+
+0.2 2008-01-07T08:44:14+09:00 *textobj-user-changelog-0.2*
+ - textobj#user#select(): Fix the wrong selecting in Operator-pending
+ mode.
+ - textobj#user#move(): Modify to be able to use in Visual and
+ Operator-pending mode.
+
+0.1 2007-11-16T01:17:45+09:00 *textobj-user-changelog-0.1*
+ - Modify to be autoloaded.
+ - Change the names of all API.
+
+0.0 2007-10-15T20:41:34+09:00 *textobj-user-changelog-0.0*
+ - First release.
+
+
+
+
+==============================================================================
+vim:tw=78:ts=8:ft=help:norl:fen:fdl=0:fdm=marker:
View
431 bundle/vim-textobj-user/mduem/Makefile
@@ -0,0 +1,431 @@
+# mduem - Little utility for little software development
+#
+# This is a library Makefile to maintain software development, especially for
+# Vim script. Note that this Makefile requires GNU make to use.
+# Coding Rules #{{{1
+#
+# - Use non-empty string as true and empty string as false.
+#
+#
+# Naming Rules:
+#
+# - Use UPPER_CASE variables to be configured by user.
+#
+# - Use lower_case variables for internal use of mduem.
+#
+# - Use suffix "_p" to indicate that a boolean value is resulted from
+# a variable.
+# Example: SHOULD_INSTALL_ASIS_P
+#
+# - Use noun for ordinary variables.
+# Example: repos_name, TARGETS_GENERATED
+#
+# - Use verb for variables as functions.
+# Example: resolve_dep_uri, RENAME_TARGET
+#
+# - Use prefix "generate_rule_" for variables to generate make rules.
+# Example: generate_rule_to_install_a_target
+#
+# - Use abbreviations for words which names are too long to code.
+# Example: dependency => dep, directory => dir, repository => repos
+#
+# - Use lower-case names for phony targets.
+#
+# - Use verb for phony targets.
+# Example: clean, install, pack, ...
+#
+# - Use hyphens to join words in names of phony targets.
+# Example: clean-junks, fetch-deps
+#
+# - Use prefix "," for names of files which are automatically generated by
+# mduem and they are temporary ones.
+# Example: test/,good-case.output
+#
+# - Use directory ".mduem" to contain stuffs for internal use.
+# Example: .mduem/cache/
+#
+# - All rules may be violated if there is a strong custom from old times.
+# Example: all (phony target)
+
+
+
+
+
+
+
+
+# Common #{{{1
+
+all: # Ensure that this is the default target.
+
+SHELL := /bin/bash
+this_makefile := $(lastword $(MAKEFILE_LIST))
+cache_makefile := .mduem/cache/Makefile.variables
+user_makefiles := $(filter-out \
+ $(this_makefile) $(cache_makefile), \
+ $(MAKEFILE_LIST))
+
+not = $(if $(1),,t)
+toplevel_dir := $(shell git rev-parse --show-toplevel 2>/dev/null)
+inner_dir := $(shell git rev-parse --show-prefix 2>/dev/null)
+git_controlled_p := $(toplevel_dir)
+toplevel_dir_p := $(and $(git_controlled_p),$(call not,$(inner_dir)))
+
+ifneq '$(git_controlled_p)' ''
+$(cache_makefile): \
+ $(toplevel_dir)/.git/config \
+ $(toplevel_dir)/.git/index \
+ $(this_makefile)
+ @echo 'GENERATE $@'
+ @mkdir -p '$(dir $@)'
+ @{ \
+ current_branch="$$(git symbolic-ref -q HEAD \
+ | sed -e 's|^refs/heads/||')"; \
+ _origin_name="$$(git config "branch.$$current_branch.remote")"; \
+ origin_name="$${_origin_name:-origin}"; \
+ _origin_uri="$$(git config "remote.$$origin_name.url")"; \
+ origin_uri="$${_origin_uri:-../.}"; \
+ \
+ echo "all_files_in_repos := \
+ $(filter-out .gitmodules \
+ $(shell cd $(toplevel_dir) && \
+ git submodule foreach 'echo "$$path"'),\
+ $(shell git ls-files))"; \
+ echo "current_branch := $${current_branch}"; \
+ echo "origin_name := $${origin_name}"; \
+ echo "origin_uri := $${origin_uri}"; \
+ echo 'repos_name := $(notdir $(shell pwd))'; \
+ echo 'version := $(shell git describe --tags --always --dirty)'; \
+ } >'$@'
+endif
+include $(cache_makefile)
+
+ # The type of a repository. It must be one of the following values:
+ #
+ # generic For any software.
+ # vim-script For Vim plugins, etc.
+REPOS_TYPE ?= $(if $(filter vim-%,$(repos_name)),vim-script,generic)
+vim_script_repos_p := $(filter vim-script,$(REPOS_TYPE))
+
+
+
+
+
+
+
+
+# all #{{{1
+
+.PHONY: all
+all: build
+
+
+
+
+
+
+
+
+# build #{{{1
+
+TARGETS_ARCHIVED ?= $(all_files_in_repos)
+TARGETS_GENERATED ?=# Empty
+TARGETS_STATIC ?=# Empty
+
+targets_all_installed := $(TARGETS_GENERATED) $(TARGETS_STATIC)
+targets_all_archived := $(sort \
+ $(TARGETS_ARCHIVED) \
+ $(targets_all_installed) \
+ $(cache_makefile) \
+ )
+
+
+
+
+.PHONY: build
+build: $(targets_all_installed)
+
+
+
+
+
+
+
+
+# clean #{{{1
+
+.PHONY: clean
+clean: clean-generated clean-junks
+
+.PHONY: clean-generated
+clean-generated:
+ @echo 'CLEAN-GENERATED'
+ @rm -rf $(TARGETS_GENERATED)
+ @find -name '.mduem' | xargs rm -rf
+
+.PHONY: clean-junks
+clean-junks:
+ @echo 'CLEAN-JUNKS'
+ @find -name '*~' -or -name ',*' | xargs rm -rf
+
+
+
+
+
+
+
+
+# fetch-deps #{{{1
+
+DEPS ?=# Empty
+vim_script_deps := $(if $(vim_script_repos_p),vim-vspec vimup,)
+all_deps := $(vim_script_deps) $(DEPS)
+
+DEP_vim_vspec_URI ?= ../vim-vspec
+DEP_vim_vspec_VERSION ?= 0.0.3
+
+DEP_vimup_URI ?= ../vimup
+DEP_vimup_VERSION ?= 0.0.0a3
+
+
+ # BUGS: This resolves "../" just once, but it's enough for usual cases.
+resolve_dep_uri = $(strip $(if $(filter ../%,$(1)), \
+ $(dir $(origin_uri))$(1:../%=%), \
+ $(1)))
+normalize_dep_name = $(subst -,_,$(1))
+get_dep_raw_uri = $(DEP_$(call normalize_dep_name,$(1))_URI)
+get_dep_dir_name = $(patsubst %.git,%,$(notdir $(call get_dep_uri,$(1))))
+
+get_dep_uri = $(call resolve_dep_uri,$(call get_dep_raw_uri,$(1)))
+get_dep_version = $(DEP_$(call normalize_dep_name,$(1))_VERSION)
+get_dep_dir = .mduem/deps/$(call get_dep_dir_name,$(1))
+
+
+
+
+.PHONY: fetch-deps
+fetch-deps: $(all_deps:%=.mduem/deps/,%)
+
+# FIXME: Update for changes on only DEPS and other values.
+.mduem/deps/,%: $(user_makefiles)
+ @echo 'FETCH-DEP $*'
+ @mkdir -p '$(dir $@)'
+ @ ( \
+ if [ -d '$(call get_dep_dir,$*)' ] \
+ ; then \
+ cd './$(call get_dep_dir,$*)' \
+ && git fetch \
+ && git checkout -f mduem-master \
+ ; else \
+ git clone '$(call get_dep_uri,$*)' '$(call get_dep_dir,$*)'\
+ && cd './$(call get_dep_dir,$*)' \
+ && git checkout -b mduem-master \
+ ; fi \
+ && git reset --hard '$(call get_dep_version,$*)' \
+ ; ) &>'$@.log' \
+ || { cat '$@.log'; false; }
+ @touch '$@'
+
+
+
+
+
+
+
+
+# install #{{{1
+# Core #{{{2
+
+INSTALLATION_DIR ?= $(error Please set INSTALLATION_DIR)
+
+RENAME_TARGET ?= $(patsubst %,$(INSTALLATION_DIR)/%,$(1))
+SHOULD_INSTALL_ASIS_P ?=# All files are version-filtered by default.
+
+
+
+
+.PHONY: install
+install: build
+
+
+define generate_rule_to_install_a_target # (build_target, install_target)
+install: $(2)
+$(2): $(1)
+ @echo 'INSTALL $(1)'
+ @mkdir -p '$(dir $(2))'
+ifneq '$(call SHOULD_INSTALL_ASIS_P,$(1))' ''
+ @cp '$(1)' '$(2)'
+else
+ @sed -e 's/0.3.9/$(version)/' '$(1)' >'$(2)'
+endif
+
+endef
+$(eval \
+ $(foreach t, \
+ $(targets_all_installed), \
+ $(call generate_rule_to_install_a_target,$(t),$(call RENAME_TARGET,$(t)))))
+
+
+# This should be placed at the last to ensure that post-install is executed
+# after any other rules to install.
+install: post-install
+
+
+
+
+# post-install #{{{2
+
+TARGETS_POST_INSTALL ?=# Empty
+targets_post_install_builtin :=# Empty
+
+
+ifneq '$(vim_script_repos_p)' ''
+target_vim_helptags := $(call RENAME_TARGET,doc/tags)
+$(target_vim_helptags): $(filter doc/%.txt,$(targets_all_installed))
+ @echo 'POST-INSTALL vim helptags'
+ @vim -n -N -u NONE -U NONE -e -c 'helptags $(dir $@) | qall!'
+
+targets_post_install_builtin += $(target_vim_helptags)
+endif
+
+
+.PHONY: post-install
+post-install: $(targets_post_install_builtin) $(TARGETS_POST_INSTALL)
+
+
+
+
+
+
+
+
+# pack #{{{1
+
+archive_basename = $(repos_name)-$(version)
+archive_name = $(archive_basename).zip
+
+
+.PHONY: pack
+pack: $(archive_name)
+
+$(archive_name): $(cache_makefile)
+ rm -rf '$(archive_basename)' '$(archive_name)'
+ $(MAKE) \
+ 'INSTALLATION_DIR=$(archive_basename)' \
+ 'targets_all_installed=$(targets_all_archived)' \
+ install
+ zip -r $(archive_name) $(archive_basename)/
+ rm -rf '$(archive_basename)'
+
+
+
+
+
+
+
+
+# release #{{{1
+
+.PHONY: release
+release: $(if $(vim_script_repos_p),release-vim-script,release-default)
+
+
+.PHONY: release-default
+release-default:
+ @echo 'Rules to release are not defined.'
+
+
+.PHONY: release-vim-script
+release-vim-script: fetch-deps $(repos_name).vimup pack
+ ./.mduem/deps/vimup/vimup update-script $(repos_name)
+ rm $(repos_name).vimup
+
+.PHONY: release-new-vim-script
+release-new-vim-script: fetch-deps $(repos_name).vimup pack
+ ./.mduem/deps/vimup/vimup new-script $(repos_name)
+ rm $(repos_name).vimup
+
+$(repos_name).vimup: $(firstword $(sort $(filter doc/%.txt, \
+ $(all_files_in_repos))))
+ ./.mduem/deps/vimup/vimup-info-generator \
+ <$< \
+ >$(repos_name).vimup
+
+
+
+
+
+
+
+
+# test #{{{1
+
+test_cases := $(patsubst test/%.expected,%, \
+ $(filter test/%.expected,$(all_files_in_repos)))
+
+
+default_test_rule_deps := $(MAKEFILE_LIST)
+define default_test_rule
+ source './$<' &>'$@' || { cat '$@'; false; }
+endef
+
+ifneq '$(vim_script_repos_p)' ''
+all_vim_scripts := $(filter %.vim,$(all_files_in_repos))
+vim_script_test_rule_deps := .mduem/deps/vim-vspec/bin/vspec $(all_vim_scripts)
+define vim_script_test_rule
+ ./$(call get_dep_dir,vim-vspec)/bin/vspec \
+ $< \
+ "$$PWD" \
+ $(foreach d,$(all_deps),$(call get_dep_dir,$(d))) \
+ &>$@
+endef
+endif
+
+TEST_RULE ?= $(if $(vim_script_repos_p), \
+ $(vim_script_test_rule), \
+ $(default_test_rule))
+TEST_RULE_DEPS ?=# Empty
+
+builtin_test_rule_deps := $(if $(vim_script_repos_p), \
+ $(vim_script_test_rule_deps), \
+ $(default_test_rule_deps))
+all_test_rule_deps := $(builtin_test_rule_deps) $(TEST_RULE_DEPS)
+
+
+
+
+.PHONY: test
+test: fetch-deps test/,ok
+
+test/,ok: $(test_cases:%=test/,%.ok)
+ @echo 'ALL TESTS ARE PASSED.'
+ @touch $@
+
+test/,%.ok: test/%.input $(all_test_rule_deps)
+ @echo -n 'TEST $* ... '
+ @$(MAKE) --silent '$(@:.ok=.diff)'
+ @if ! [ -s $(@:.ok=.diff) ]; then \
+ echo 'OK'; \
+ else \
+ echo 'FAILED'; \
+ cat $(@:.ok=.diff); \
+ echo 'END'; \
+ false; \
+ fi
+ @touch $@
+
+test/,%.diff: test/%.expected test/,%.output
+ @diff -u $^ >$@; true
+
+test/,%.output: test/%.input $(all_test_rule_deps)
+ @$(TEST_RULE)
+
+
+
+
+
+
+
+
+# __END__ #{{{1
+# vim: foldmethod=marker
View
16 bundle/vim-textobj-user/test/plugin.expected
@@ -0,0 +1,16 @@
+==== textobj_user_plugin
+---- It should define default UI key mappings.
+........
+---- It should define named key mappings.
+......
+---- It should define an Ex command to define default UI key mappings.
+
+---- It should work.
+
+
+
+
+**** Result ****
+
+
+14 examples, 0 failures
View
67 bundle/vim-textobj-user/test/plugin.input
@@ -0,0 +1,67 @@
+function s:describe__textobj_user_plugin() "{{{1
+ call textobj#user#plugin('fruit', {
+ \ 'apple': {
+ \ '*pattern*': '\<\d\{4}\>',
+ \ 'select': ['aa', 'ia'],
+ \ 'move-n': 'ja',
+ \ 'move-p': 'ka',
+ \ },
+ \ 'banana': {
+ \ '*pattern*': ['<<', '>>'],
+ \ 'select-a': 'ab',
+ \ 'select-i': 'ib',
+ \ },
+ \ '-': {
+ \ '*select-function*': 'SelectCherry',
+ \ 'select': ['ac', 'ic'],
+ \ },
+ \ })
+
+ It should define default UI key mappings.
+
+ function! Test1(lhs)
+ return map(['n', 'x', 's', 'o', 'i', 'c', 'l'],
+ \ 'maparg(' . string(a:lhs) . ', v:val)')
+ endfunction
+ function! Test2(lhs)
+ return map(Test1(a:lhs), 'v:val != ""')
+ endfunction
+ let x = ''
+
+ let o = '<Plug>(textobj-fruit-apple)'
+ Should Test1('aa') ==# [x, o, x, o, x, x, x]
+ Should Test1('ia') ==# [x, o, x, o, x, x, x]
+ let o = '<Plug>(textobj-fruit-apple-n)'
+ Should Test1('ja') ==# [o, o, x, o, x, x, x]
+ let o = '<Plug>(textobj-fruit-apple-p)'
+ Should Test1('ka') ==# [o, o, x, o, x, x, x]
+
+ let o = '<Plug>(textobj-fruit-banana-a)'
+ Should Test1('ab') ==# [x, o, x, o, x, x, x]
+ let o = '<Plug>(textobj-fruit-banana-i)'
+ Should Test1('ib') ==# [x, o, x, o, x, x, x]
+
+ let o = '<Plug>(textobj-fruit)'
+ Should Test1('ac') ==# [x, o, x, o, x, x, x]
+ Should Test1('ic') ==# [x, o, x, o, x, x, x]
+
+ It should define named key mappings.
+
+ Should Test2('<Plug>(textobj-fruit-apple)') ==# [0, 1, 1, 1, 0, 0, 0]
+ Should Test2('<Plug>(textobj-fruit-apple-n)') ==# [1, 1, 1, 1, 0, 0, 0]
+ Should Test2('<Plug>(textobj-fruit-apple-p)') ==# [1, 1, 1, 1, 0, 0, 0]
+ Should Test2('<Plug>(textobj-fruit-banana-a)') ==# [0, 1, 1, 1, 0, 0, 0]
+ Should Test2('<Plug>(textobj-fruit-banana-i)') ==# [0, 1, 1, 1, 0, 0, 0]
+ Should Test2('<Plug>(textobj-fruit)') ==# [0, 1, 1, 1, 0, 0, 0]
+
+ It should define an Ex command to define default UI key mappings.
+ It should work.
+
+ " FIXME: NIY
+endfunction
+
+
+
+
+" __END__ "{{{1
+" vim: filetype=vim foldmethod=marker
1 bundle/vim-vividchalk
@@ -1 +0,0 @@
-Subproject commit c824c2a5c1d96a7d2ec2df6baf7231dcee621130
1 bundle/vimerl
@@ -0,0 +1 @@
+Subproject commit 548de8bbd5ec8c0967c33a94eded0a5bf3919ae8
1 bundle/zoom-win
@@ -0,0 +1 @@
+Subproject commit e7ee18e2e7ed60509aa951cd34b57193fa14e5ab
View
4 gvimrc
@@ -1 +1,5 @@
color molokai
+set guioptions-=T
+
+" NERDTree
+map <Leader>nt :NERDTree<CR>
View
149 syntax/ragel.vim
@@ -0,0 +1,149 @@
+" Vim syntax file
+"
+" Language: Ragel
+" Author: Adrian Thurston
+
+syntax clear
+
+"
+" Outside code
+"
+
+" Comments
+syntax region ocComment start="\/\*" end="\*\/"
+syntax match ocComment "\/\/.*$"
+
+" Anything preprocessor
+syntax match ocPreproc "#\(.\|\\\n\)*$"
+syntax region ocPreproc start="#" end="[^\\]$"
+
+" Strings
+syntax match ocLiteral "'\(\\.\|[^'\\]\)*'"
+syntax match ocLiteral "\"\(\\.\|[^\"\\]\)*\""
+
+" C/C++ Keywords
+syntax keyword ocType unsigned signed void char short int long float double bool
+syntax keyword ocType inline static extern register const volatile auto
+syntax keyword ocType union enum struct class typedef
+syntax keyword ocType namespace template typename mutable
+syntax keyword ocKeyword break continue default do else for
+syntax keyword ocKeyword goto if return switch while
+syntax keyword ocKeyword new delete this using friend public private protected sizeof
+syntax keyword ocKeyword throw try catch operator typeid
+syntax keyword ocKeyword and bitor xor compl bitand and_eq or_eq xor_eq not not_eq
+syntax keyword ocKeyword static_cast dynamic_cast
+
+" Numbers
+syntax match ocNumber "[0-9][0-9]*"
+syntax match ocNumber "0x[0-9a-fA-F][0-9a-fA-F]*"
+
+" Booleans
+syntax keyword ocBoolean true false
+
+" Identifiers
+syntax match anyId "[a-zA-Z_][a-zA-Z_0-9]*"
+
+" Inline code only
+syntax keyword fsmType fpc fc fcurs fbuf fblen ftargs fstack
+syntax keyword fsmKeyword fhold fgoto fcall fret fentry fnext fexec fbreak
+
+syntax cluster rlItems contains=rlComment,rlLiteral,rlAugmentOps,rlOtherOps,rlKeywords,rlWrite,rlCodeCurly,rlCodeSemi,rlNumber,anyId,rlLabelColon,rlExprKeywords
+
+syntax region machineSpec1 matchgroup=beginRL start="%%{" end="}%%" contains=@rlItems
+syntax region machineSpec2 matchgroup=beginRL start="%%[^{]"rs=e-1 end="$" keepend contains=@rlItems
+syntax region machineSpec2 matchgroup=beginRL start="%%$" end="$" keepend contains=@rlItems
+
+" Comments
+syntax match rlComment "#.*$" contained
+
+" Literals
+syntax match rlLiteral "'\(\\.\|[^'\\]\)*'[i]*" contained
+syntax match rlLiteral "\"\(\\.\|[^\"\\]\)*\"[i]*" contained
+syntax match rlLiteral /\/\(\\.\|[^\/\\]\)*\/[i]*/ contained
+syntax match rlLiteral "\[\(\\.\|[^\]\\]\)*\]" contained
+
+" Numbers
+syntax match rlNumber "[0-9][0-9]*" contained
+syntax match rlNumber "0x[0-9a-fA-F][0-9a-fA-F]*" contained
+
+" Operators
+syntax match rlAugmentOps "[>$%@]" contained
+syntax match rlAugmentOps "<>\|<" contained
+syntax match rlAugmentOps "[>\<$%@][!\^/*~]" contained
+syntax match rlAugmentOps "[>$%]?" contained
+syntax match rlAugmentOps "<>[!\^/*~]" contained
+syntax match rlAugmentOps "=>" contained
+syntax match rlOtherOps "->" contained
+
+syntax match rlOtherOps ":>" contained
+syntax match rlOtherOps ":>>" contained
+syntax match rlOtherOps "<:" contained
+
+" Keywords
+" FIXME: Enable the range keyword post 5.17.
+" syntax keyword rlKeywords machine action context include range contained
+syntax keyword rlKeywords machine action context include import export prepush postpop contained
+syntax keyword rlExprKeywords when inwhen outwhen err lerr eof from to contained
+
+" Case Labels
+syntax keyword caseLabelKeyword case contained
+syntax cluster caseLabelItems contains=ocComment,ocPreproc,ocLiteral,ocType,ocKeyword,caseLabelKeyword,ocNumber,ocBoolean,anyId,fsmType,fsmKeyword
+syntax match caseLabelColon "case" contains=@caseLabelItems
+syntax match caseLabelColon "case[\t ]\+.*:$" contains=@caseLabelItems
+syntax match caseLabelColon "case[\t ]\+.*:[^=:]"me=e-1 contains=@caseLabelItems
+
+" Labels
+syntax match ocLabelColon "^[\t ]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:$" contains=anyLabel
+syntax match ocLabelColon "^[\t ]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:[^=:]"me=e-1 contains=anyLabel
+
+syntax match rlLabelColon "[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:$" contained contains=anyLabel
+syntax match rlLabelColon "[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:[^=:>]"me=e-1 contained contains=anyLabel
+syntax match anyLabel "[a-zA-Z_][a-zA-Z_0-9]*" contained
+
+" All items that can go in a code block.
+
+syntax cluster inlineItems contains=rlCodeCurly,ocComment,ocPreproc,ocLiteral,ocType,ocKeyword,ocNumber,ocBoolean,ocLabelColon,anyId,fsmType,fsmKeyword,caseLabelColon
+
+" Blocks of code. rlCodeCurly is recursive.
+syntax region rlCodeCurly matchgroup=NONE start="{" end="}" contained contains=@inlineItems
+syntax region rlCodeSemi matchgroup=Type start="\<alphtype\>" start="\<getkey\>" start="\<access\>" start="\<variable\>" matchgroup=NONE end=";" contained contains=@inlineItems
+
+syntax region rlWrite matchgroup=Type start="\<write\>" matchgroup=NONE end="[;)]" contained contains=rlWriteKeywords,rlWriteOptions
+
+syntax keyword rlWriteKeywords init data exec exports start error first_final contained
+syntax keyword rlWriteOptions noerror nofinal noprefix noend nocs contained
+
+"
+" Sync at the start of machine specs.
+"
+" Match The ragel delimiters only if there quotes no ahead on the same line.
+" On the open marker, use & to consume the leader.
+syntax sync match ragelSyncPat grouphere NONE "^[^\'\"%]*%%{&^[^\'\"%]*"
+syntax sync match ragelSyncPat grouphere NONE "^[^\'\"%]*%%[^{]&^[^\'\"%]*"
+syntax sync match ragelSyncPat grouphere NONE "^[^\'\"]*}%%"
+
+"
+" Specifying Groups
+"
+hi link ocComment Comment
+hi link ocPreproc Macro
+hi link ocLiteral String
+hi link ocType Type
+hi link ocKeyword Keyword
+hi link ocNumber Number
+hi link ocBoolean Boolean
+hi link rlComment Comment
+hi link rlNumber Number
+hi link rlLiteral String
+hi link rlAugmentOps Keyword
+hi link rlExprKeywords Keyword
+hi link rlWriteKeywords Keyword
+hi link rlWriteOptions Keyword
+hi link rlKeywords Type
+hi link fsmType Type
+hi link fsmKeyword Keyword
+hi link anyLabel Label
+hi link caseLabelKeyword Keyword
+hi link beginRL Type
+
+let b:current_syntax = "ragel"
View
37 vimrc
@@ -1,8 +1,10 @@
set nocompatible
-" Setup pathogen
-filetype off
-call pathogen#runtime_append_all_bundles()
+if has("gui")
+ " Setup pathogen
+ filetype off
+ call pathogen#runtime_append_all_bundles()
+endif
set number
set ruler
@@ -21,5 +23,30 @@ set incsearch
set ignorecase
set smartcase
-" NERDTree
-map <Leader>nt :NERDTree<CR>
+" allow backspacing over everything in insert mode
+set backspace=indent,eol,start
+
+" load the plugin and indent settings for the detected filetype
+filetype plugin indent on
+
+" swp files are annoying. Let's hope vim doesn't crash
+set nobackup
+set nowritebackup
+set noswapfile
+
+function s:setupWrapping()
+ set wrap
+ set wm=2
+ set textwidth=72
+endfunction
+
+" Autocommands
+au BufRead,BufNewFile {Gemfile,Capfile,Kirkfile,Rakefile,Thorfile,config.ru} set ft=ruby
+au BufRead,BufNewFile *.rl set ft=ragel
+au BufRead,BufNewFile *.txt call s:setupWrapping()
+
+" CTags
+map <Leader>rt :!ctags --extra=+f -R *<CR><CR>
+
+" Clojure
+let vimclojure#HighlightBuiltins = 1

0 comments on commit 344318a

Please sign in to comment.