├── .editorconfig ├── .travis.yml ├── LICENSE.md ├── README.md ├── autoload └── sickness │ ├── alias.vim │ ├── expression.vim │ ├── field.vim │ ├── indentation.vim │ ├── line.vim │ ├── symbol.vim │ ├── textobj │ ├── alias.vim │ ├── expression.vim │ ├── field.vim │ ├── indentation.vim │ ├── line.vim │ ├── symbol.vim │ └── view.vim │ └── view.vim ├── plugin └── sickness.vim ├── test.sh └── tests ├── alias-spec.vader ├── expression-count-af-spec.vader ├── expression-count-if-spec.vader ├── expression-general-af-spec.vader ├── expression-general-if-spec.vader ├── expression-multiline-indented-spec.vader ├── expression-multiline-leading-spec.vader ├── expression-multiline-trailing-spec.vader ├── expression-nested-spec.vader ├── expression-nestedfurther-spec.vader ├── expression-whitespace-spec.vader ├── field-indented-af-spec.vader ├── field-indented-if-spec.vader ├── field-leading-af-spec.vader ├── field-leading-if-spec.vader ├── field-short-af-spec.vader ├── field-short-if-spec.vader ├── field-trailing-af-spec.vader ├── field-trailing-if-spec.vader ├── indent-block-spec.vader ├── indent-level-spec.vader ├── indent-paragraph-spec.vader ├── indent-top-spec.vader ├── symbol-all-spec.vader ├── symbol-percent-spec.vader └── vimrc-test.vim /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | insert_final_newline = true 8 | max_line_length = 85 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: minimal 3 | dist: trusty 4 | sudo: required 5 | notifications: 6 | email: false 7 | 8 | before_install: 9 | - git clone https://github.com/junegunn/vader.vim.git ~/.vim/plugged/vader.vim 10 | - git clone https://github.com/neovim/neovim.git 11 | - rvm use system 12 | 13 | install: 14 | - (cd neovim ; make CMAKE_BUILD_TYPE=Release; sudo make install) 15 | 16 | before_script: 17 | - export PATH="/usr/local/bin:${PATH}" 18 | 19 | env: 20 | matrix: 21 | - TARGET='alias' 22 | 23 | - TARGET='expression-general-if' 24 | - TARGET='expression-general-af' 25 | - TARGET='expression-count-if' 26 | - TARGET='expression-count-af' 27 | - TARGET='expression-multiline-indented' 28 | - TARGET='expression-multiline-leading' 29 | - TARGET='expression-multiline-trailing' 30 | - TARGET='expression-nested' 31 | - TARGET='expression-whitespace' 32 | 33 | - TARGET='field-indented-af' 34 | - TARGET='field-indented-if' 35 | - TARGET='field-leading-if' 36 | - TARGET='field-leading-af' 37 | - TARGET='field-short-if' 38 | - TARGET='field-short-af' 39 | - TARGET='field-trailing-if' 40 | - TARGET='field-trailing-af' 41 | 42 | - TARGET='indent-paragraph' 43 | - TARGET='indent-level' 44 | - TARGET='indent-block' 45 | - TARGET='indent-top' 46 | 47 | - TARGET='symbol-all' 48 | 49 | script: ./test.sh 50 | ... 51 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Henrik Giesel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # motion-sickness.nvim ![Build Status](https://travis-ci.org/hgiesel/vim-motion-sickness.svg?branch=master) ![Build Status](https://travis-ci.org/hgiesel/vim-motion-sickness.svg?branch=devel) 2 | 3 | This plugin adds a slew of new possible text objects. [Vader](https://github.com/junegunn/vader.vim) 4 | ensures they all work as intended. Only Neovim is supported at the moment. 5 | 6 | Each type of text object can be disabled with `let g:sickness#{type}_enabled = 0`, e.g.: 7 | 8 | ```vim 9 | let g:sickness#symbol#enabled = 0 10 | let g:sickness#view#enabled = 0 11 | ``` 12 | 13 | If you only want the `` metakeys and want to define the mappings yourself, set 14 | `let g:sickness#{type}#use_default_maps = 0`, e.g.: 15 | 16 | ```vim 17 | let g:sickness#symbol#use_default_maps = 0 18 | let g:sickness#view#use_default_maps = 0 19 | ``` 20 | 21 | #### List of text objects 22 | 23 | * **bracket text objects**: 24 | * [alias text objects](#alias-text-objects) 25 | * [expression text objects](#expression-text-objects) 26 | * [field text objects](#field-text-objects) 27 | 28 | * **other text objects**: 29 | * [indentation text objects](#indent-text-objects) 30 | * [line text objects](#line-text-objects) 31 | * [view text objects](#view-text-objects) 32 | * [symbol text objects](#symbol-text-objects) 33 | 34 | ## Alias text objects 35 | 36 | * inspired by [Tim Pope's vim-surround](https://github.com/tpope/vim-surround) 37 | 38 | | text object | effect | 39 | |--------------|-----------------------| 40 | | `ir`/`ar` | Aliases for `i[`/`a[` | 41 | | `ia`/`aa` | Aliases for `i<`/`a<` | 42 | 43 | * with these added, you have three full sets of text objects for the common brackets: 44 | 45 | | | parentheses | braces | square brackets | angle brackets | 46 | |--------------|--------------|-----------|-----------------|----------------| 47 | | *char* | `ib`/`ab` | `iB`/`aB` | `ir`/`ar` | `ia`/`aa` | 48 | | *opendelim* | `i(`/`a(` | `i{`/`a{` | `i[`/`a[` | `i<`/`a<` | 49 | | *closedelim* | `i)`/`a)` | `i}`/`a}` | `i]`/`a]` | `i>`/`a>` | 50 | 51 | * these text objects are exactly equal in functionality 52 | * this fact is important for the upcoming [expression text objects](#expression-text-objects) and [field text objects](#field-text-objects) 53 | 54 | ## Expression text objects 55 | 56 | * inspired by [vim-textobj-functioncall](https://github.com/machakann/vim-textobj-functioncall) 57 | 58 | Expression text objects are a generalization of *function calls*, *function definitions*, *arrays*, *C++ templates*, and more. 59 | The general expression of an expression text object is `[text][opendelim][text][closedelim]`. 60 | All of the following follow this criteria: 61 | 62 | ```c 63 | function_call(argument1, argument2, argument3) 64 | let dict = { "key1": value1, "key2", value2 } 65 | let a = ["hello", "world"] 66 | Array val = new Array 67 | ``` 68 | 69 | **Expression text objects** have the structure "{`[ia]`}`e`{`[b()]`/`[B{}]`/`[r[\]]`/`[a<>]`}". 70 | 71 | `ie*` selects the whole bracket (like "`a`") preceded by `[count]` [words](https://stackoverflow.com/questions/22931032/vim-word-vs-word). 72 | 73 | `ae*` selects the whole bracket (like "`a`") preceded by `[count]` [WORDs](https://stackoverflow.com/questions/22931032/vim-word-vs-word). 74 | However, if you don't supply a count, it will not default to "1 WORD" but rather it 75 | will jump to the start of the line. 76 | 77 | With both `ie*` and `ae*`, `motion-sickness` will be smart not to include partial brackets, etc. 78 | 79 | The variable `g:sickness#expression#preferred_shortcut_map` can be set use an alternative set of mappings. 80 | Utilizing the fact, that `ib`, `i(`, `i)` are [the same](#alias-text-objects), you can set 81 | them to the shorter version. Just put either of the following into your vimrc. 82 | 83 | ```vim 84 | let g:sickness#expression#preferred_shortcut_map = 'opendelim' " uses {i,a}{(,{,[,<} for expression text objects 85 | let g:sickness#expression#preferred_shortcut_map = 'closedelim' " uses {i,a}{),},],>} for expression text objects 86 | let g:sickness#expression#preferred_shortcut_map = 'char' " uses {i,a}{b,B,r,a} for expression text objects 87 | 88 | " or if you want to set your own mappings 89 | let g:sickness#expression#use_default_maps = 0 90 | 91 | omap ieb (textobj-sickness-expression-parenthesis-i) 92 | xmap ieb (textobj-sickness-expression-parenthesis-i) 93 | omap aeb (textobj-sickness-expression-parenthesis-a) 94 | xmap aeb (textobj-sickness-expression-parenthesis-a) 95 | 96 | omap ieB (textobj-sickness-expression-brace-i) 97 | xmap ieB (textobj-sickness-expression-brace-i) 98 | omap aeB (textobj-sickness-expression-brace-a) 99 | xmap aeB (textobj-sickness-expression-brace-a) 100 | 101 | omap ier (textobj-sickness-expression-bracket-i) 102 | xmap ier (textobj-sickness-expression-bracket-i) 103 | omap aer (textobj-sickness-expression-bracket-a) 104 | xmap aer (textobj-sickness-expression-bracket-a) 105 | 106 | omap iea (textobj-sickness-expression-chevron-i) 107 | xmap iea (textobj-sickness-expression-chevron-i) 108 | omap aea (textobj-sickness-expression-chevron-a) 109 | xmap aea (textobj-sickness-expression-chevron-a) 110 | ``` 111 | 112 | ## Field text objects 113 | 114 | * inspired by [vim-textobj-argument](https://github.com/gaving/vim-textobj-argument) 115 | 116 | **Field text objects** have the structure "{`i`,`a`}`f`{`b`/`(`/`)`,`B`/`{`/`}`,`r`/`[`/`]`,`a`/`<`/`>`}". 117 | 118 | An *inner field* selects the current field, enclosed in the specific brace. Think of 119 | arguments in function, list elements, dictionary entries, etc. 120 | 121 | An *all field* selects an inner field, together with the field delimiter (usually a comma) 122 | 123 | The variable `g:sickness#expression#maps` can be set use an alternative set of mappings. 124 | Utilizing the fact, that `ib`, `i(`, `i)` are [the same](#alias-text-objects), you can set 125 | them to the shorter version. Just put either of the following into your vimrc. 126 | 127 | ```vim 128 | let g:sickness#field#preferred_shortcut_map = 'opendelim' " uses {i,a}{(,{,[,<} for field motions 129 | let g:sickness#field#preferred_shortcut_map = 'closedelim' " uses {i,a}{),},],>} for field motions 130 | let g:sickness#field#preferred_shortcut_map = 'char' " uses {i,a}{b,B,r,a} for field motions 131 | 132 | " or if you want to set it entirely yourself 133 | let g:sickness#field#use_default_maps = 0 134 | 135 | omap ifb (textobj-sickness-field-parenthesis-i) 136 | vmap ifb (textobj-sickness-field-parenthesis-i) 137 | omap afb (textobj-sickness-field-parenthesis-a) 138 | vmap afb (textobj-sickness-field-parenthesis-a) 139 | 140 | omap ifB (textobj-sickness-field-brace-i) 141 | vmap ifB (textobj-sickness-field-brace-i) 142 | omap afB (textobj-sickness-field-brace-a) 143 | vmap afB (textobj-sickness-field-brace-a) 144 | 145 | omap ifr (textobj-sickness-field-bracket-i) 146 | vmap ifr (textobj-sickness-field-bracket-i) 147 | omap afr (textobj-sickness-field-bracket-a) 148 | vmap afr (textobj-sickness-field-bracket-a) 149 | 150 | omap ifa (textobj-sickness-field-chevron-i) 151 | vmap ifa (textobj-sickness-field-chevron-i) 152 | omap afa (textobj-sickness-field-chevron-a) 153 | vmap afa (textobj-sickness-field-chevron-a) 154 | ``` 155 | 156 | 4 types of list styles are supported. 157 | In other words, these are basis for the unit tests, and for the algorithm governing 158 | these text objects. 159 | 160 | #### short style 161 | 162 | ```c 163 | foo(arg1, arg2, arg3) 164 | ``` 165 | 166 | #### opening delimiter-indented style 167 | 168 | ```c 169 | foo_function(arg1, arg2, 170 | arg3, another_arg) 171 | ``` 172 | 173 | #### trailing-symbol style 174 | 175 | ```c 176 | foo_function( 177 | arg1, 178 | arg2, 179 | arg3 180 | ) 181 | ``` 182 | 183 | #### leading-symbol style 184 | 185 | ```c 186 | Foo ( arg1 187 | , arg2 188 | , arg2 189 | , arg3 190 | ) 191 | ``` 192 | 193 | The following gif showcases some examples of expression and field text objects: 194 | 195 | ![expression text objects cast](https://media.giphy.com/media/dApCdA2gycwomwrIGO/giphy.gif) 196 | 197 | ## Indent text objects 198 | 199 | * inspired by [vim-indent-object](https://github.com/michaeljsmith/vim-indent-object) 200 | 201 | These text objects are meant to support the `ip` and `ap` text objects for selecting 202 | paragraphs. `ip` and `ap` simply disregard indentation. 203 | 204 | | text object | effect | 205 | |--------------|-----------------------------------------------| 206 | | `iip`/`aip` | Similar to `ip`/`ap`, except it does not exceed the current indentation level. Does accept counts. Mnemonic is "inner/all indentation paragraph"| 207 | | `iil`/`ail` | Selects the entire current indentation level excluding / including leading and trailing empty lines. Does not accept counts. Mnemonic is "inner/all indentation level".| 208 | | `iib`/`aib` | Like `ail` and it selects one line of lower indent before and after the section. Does accept counts. Mnemonic is "inner/all indentation block". | 209 | | `iit`/`ait` | Like `ail` and it selects one line of lower indent before the section. Does accept counts. Mnemonic is "inner/all indentation top". | 210 | 211 | ![Indent text objects cast](https://media.giphy.com/media/hSEh6Plw8e40MhPf2e/giphy.gif) 212 | 213 | In a text like like the following, if you execute `iil` on any line within the 214 | function definition, the line featuring `argument3` will not be selected, but will 215 | be detected as probably belonging to the preceding line. This behavior is governed by 216 | the `g:sickness#indentation#exclude_leading_indents` variable. 217 | 218 | ```c 219 | int my_function(int argument1, int argument2, 220 | int argument3) { // <- will not be included in `iil` or `ail` text object 221 | // if you set g:sickness#indentation#excluse_leading_indents to 0 222 | line1(); 223 | line2(); 224 | line3(); 225 | ... 226 | lineN(); 227 | } 228 | ``` 229 | 230 | If you wish to set the indent mappings yourself, you can do so: 231 | 232 | ```vim 233 | let g:sickness#indentation#use_default_maps = 0 234 | 235 | omap iip (textobj-sickness-indentation-paragraph-i) 236 | vmap iip (textobj-sickness-indentation-paragraph-i) 237 | omap aip (textobj-sickness-indentation-paragraph-a) 238 | vmap aip (textobj-sickness-indentation-paragraph-a) 239 | 240 | omap iil (textobj-sickness-indentation-level-i) 241 | vmap iil (textobj-sickness-indentation-level-i) 242 | omap ail (textobj-sickness-indentation-level-a) 243 | vmap ail (textobj-sickness-indentation-level-a) 244 | 245 | omap iib (textobj-sickness-indentation-block-i) 246 | vmap iib (textobj-sickness-indentation-block-i) 247 | omap aib (textobj-sickness-indentation-block-a) 248 | vmap aib (textobj-sickness-indentation-block-a) 249 | 250 | omap iit (textobj-sickness-indentation-top-i) 251 | vmap iit (textobj-sickness-indentation-top-i) 252 | omap ait (textobj-sickness-indentation-top-a) 253 | vmap ait (textobj-sickness-indentation-top-a) 254 | ``` 255 | 256 | ## Line text objects 257 | 258 | * inspired by [vim-textobj-line](https://github.com/kana/vim-textobj-line) 259 | 260 | | text object | effect | 261 | |--------------|------------------------------------| 262 | | `il` | Select the current line excluding leading/trailing blank characters (from `^` to `g_`). Does not accept a count. | 263 | | `al` | Select the current line including leading/trailing blank characters (from `0` to `$`). Does not accept a count. | 264 | 265 | If you wish to set the mappings yourself, you can do so: 266 | 267 | ```vim 268 | let g:sickness#line#use_default_maps = 0 269 | 270 | omap il (textobj-sickness-line-i) 271 | xmap il (textobj-sickness-line-i) 272 | omap al (textobj-sickness-line-a) 273 | xmap al (textobj-sickness-line-a) 274 | ``` 275 | 276 | ## View text objects 277 | 278 | | text object | effect | 279 | |--------------|------------------------------------| 280 | | `iv` | Selects the currently visible window (from `H` to `L`). Does not accept a count. Saves the current position in the [jump list](http://vimdoc.sourceforge.net/htmldoc/motion.html#jumplist).| 281 | | `av` | Selects the entire buffer (from `gg` to `G`). Does not accept a count. Saves the current position in the [jump list](http://vimdoc.sourceforge.net/htmldoc/motion.html#jumplist).| 282 | 283 | If you wish to set the mappings yourself, you can do so: 284 | 285 | ```vim 286 | let g:sickness#view#use_default_maps = 0 287 | 288 | omap iv (textobj-sickness-view-i) 289 | xmap iv (textobj-sickness-view-i) 290 | omap av (textobj-sickness-view-a) 291 | xmap av (textobj-sickness-view-a) 292 | ``` 293 | 294 | ## Symbol text objects 295 | 296 | | text object | effect | 297 | |--------------|------------------------------------| 298 | | `i*`/`a*` | Similar to `i"`/`a"`, but for `*` | 299 | | `i_`/`a_` | Similar to `i"`/`a"`, but for `_` | 300 | | `i-`/`a-` | Similar to `i"`/`a"`, but for `-` | 301 | | `i:`/`a:` | Similar to `i"`/`a"`, but for `:` | 302 | | `i@`/`a@` | Similar to `i"`/`a"`, but for `@` | 303 | | `i!`/`a!` | Similar to `i"`/`a"`, but for `!` | 304 | | `i?`/`a?` | Similar to `i"`/`a"`, but for `?` | 305 | | `i/`/`a/` | Similar to `i"`/`a"`, but for `/` | 306 | | `i%`/`a%` | Similar to `i"`/`a"`, but for `%` | 307 | | `i\|`/`a\|` | Similar to `i"`/`a"`, but for `\|` | 308 | -------------------------------------------------------------------------------- /autoload/sickness/alias.vim: -------------------------------------------------------------------------------- 1 | 2 | function! sickness#alias#add() abort 3 | onoremap ir i[ 4 | xnoremap ir i[ 5 | onoremap ar a[ 6 | xnoremap ar a[ 7 | 8 | onoremap ia i< 9 | xnoremap ia i< 10 | onoremap aa a< 11 | xnoremap aa a< 12 | endfunction 13 | -------------------------------------------------------------------------------- /autoload/sickness/expression.vim: -------------------------------------------------------------------------------- 1 | " Expression function {{{1 2 | 3 | let g:sickness#expression#default_openclosedelims = 4 | \ [ ['parenthesis', 'b', '(', ')'] 5 | \ , ['brace' , 'B', '{', '}'] 6 | \ , ['bracket' , 'r', '[', ']'] 7 | \ , ['chevron' , 'a', '<', '>'] 8 | \ ] 9 | 10 | let g:sickness#expression#openclosedelims = get(g:, 'sickness#expression#openclosedelim', g:sickness#expression#default_openclosedelims) 11 | 12 | function! sickness#expression#add(openclosedelimdefs) abort 13 | for l:openclosedelimdef in a:openclosedelimdefs 14 | 15 | if get(g:, 'sickness#expression#use_default_maps', v:true) && exists('g:sickness#expression#preferred_shortcut_map') " use shortcut map 16 | let l:theindex = 1 17 | 18 | if g:sickness#expression#preferred_shortcut_map ==# 'char' 19 | let l:theindex = 1 20 | elseif g:sickness#expression#preferred_shortcut_map ==# 'opendelim' 21 | let l:theindex = 2 22 | elseif g:sickness#expression#preferred_shortcut_map ==# 'closedelim' 23 | let l:theindex = 3 24 | endif 25 | 26 | execute 'omap ie' . l:openclosedelimdef[l:theindex] . ' (textobj-sickness-expression-' . l:openclosedelimdef[0] . '-i)' 27 | execute 'xmap ie' . l:openclosedelimdef[l:theindex] . ' (textobj-sickness-expression-' . l:openclosedelimdef[0] . '-i)' 28 | execute 'omap ae' . l:openclosedelimdef[l:theindex] . ' (textobj-sickness-expression-' . l:openclosedelimdef[0] . '-a)' 29 | execute 'xmap ae' . l:openclosedelimdef[l:theindex] . ' (textobj-sickness-expression-' . l:openclosedelimdef[0] . '-a)' 30 | 31 | elseif get(g:, 'sickness#expression#use_default_maps', v:true) " use prefix maps 32 | execute 'omap ie' . l:openclosedelimdef[1] . ' (textobj-sickness-expression-' . l:openclosedelimdef[0] . '-i)' 33 | execute 'xmap ie' . l:openclosedelimdef[1] . ' (textobj-sickness-expression-' . l:openclosedelimdef[0] . '-i)' 34 | execute 'omap ae' . l:openclosedelimdef[1] . ' (textobj-sickness-expression-' . l:openclosedelimdef[0] . '-a)' 35 | execute 'xmap ae' . l:openclosedelimdef[1] . ' (textobj-sickness-expression-' . l:openclosedelimdef[0] . '-a)' 36 | 37 | execute 'omap ie' . l:openclosedelimdef[2] . ' (textobj-sickness-expression-' . l:openclosedelimdef[0] . '-i)' 38 | execute 'xmap ie' . l:openclosedelimdef[2] . ' (textobj-sickness-expression-' . l:openclosedelimdef[0] . '-i)' 39 | execute 'omap ae' . l:openclosedelimdef[2] . ' (textobj-sickness-expression-' . l:openclosedelimdef[0] . '-a)' 40 | execute 'xmap ae' . l:openclosedelimdef[2] . ' (textobj-sickness-expression-' . l:openclosedelimdef[0] . '-a)' 41 | 42 | execute 'omap ie' . l:openclosedelimdef[3] . ' (textobj-sickness-expression-' . l:openclosedelimdef[0] . '-i)' 43 | execute 'xmap ie' . l:openclosedelimdef[3] . ' (textobj-sickness-expression-' . l:openclosedelimdef[0] . '-i)' 44 | execute 'omap ae' . l:openclosedelimdef[3] . ' (textobj-sickness-expression-' . l:openclosedelimdef[0] . '-a)' 45 | execute 'xmap ae' . l:openclosedelimdef[3] . ' (textobj-sickness-expression-' . l:openclosedelimdef[0] . '-a)' 46 | endif 47 | 48 | " set textobj plugs 49 | execute "onoremap (textobj-sickness-expression-" . l:openclosedelimdef[0] . "-i) " . 50 | \ "call sickness#textobj#expression#motion('" . l:openclosedelimdef[2] . "', '" . l:openclosedelimdef[3] . "', 'b')" 51 | execute "xnoremap (textobj-sickness-expression-" . l:openclosedelimdef[0] . "-i) " . 52 | \ "call sickness#textobj#expression#motion('" . l:openclosedelimdef[2] . "', '" . l:openclosedelimdef[3] . "', 'b')" 53 | execute "xnoremap (textobj-sickness-expression-" . l:openclosedelimdef[0] . "-a) " . 54 | \ "call sickness#textobj#expression#motion('" . l:openclosedelimdef[2] . "', '" . l:openclosedelimdef[3] . "', 'B')" 55 | execute "onoremap (textobj-sickness-expression-" . l:openclosedelimdef[0] . "-a) " . 56 | \ "call sickness#textobj#expression#motion('" . l:openclosedelimdef[2] . "', '" . l:openclosedelimdef[3] . "', 'B')" 57 | 58 | endfor 59 | endfunction 60 | -------------------------------------------------------------------------------- /autoload/sickness/field.vim: -------------------------------------------------------------------------------- 1 | let g:sickness#field#default_openclosedelims = 2 | \ [ ['parenthesis', 'b', '(', ')'] 3 | \ , ['brace' , 'B', '{', '}'] 4 | \ , ['bracket' , 'r', '[', ']'] 5 | \ , ['chevron' , 'a', '<', '>'] 6 | \ ] 7 | 8 | let g:sickness#field#openclosedelims = get(g:, 'sickness#field#maps', g:sickness#field#default_openclosedelims) 9 | 10 | let g:sickness#field#default_fielddelims = 11 | \ [ 12 | \ ['comma', ','] 13 | \ ] 14 | 15 | let g:sickness#field#fielddelims = get(g:, 'sickness#field#delimiters', g:sickness#field#default_fielddelims) 16 | 17 | " Fields function {{{1 18 | function! sickness#field#add(openclosedelimdefs, fielddelimdefs) abort 19 | for l:openclosedelimdef in a:openclosedelimdefs 20 | 21 | if get(g:, 'sickness#field#use_default_maps', v:true) && exists('g:sickness#field#preferred_shortcut_map') " use preferred shortcut map 22 | let l:theindex = 1 23 | 24 | if g:sickness#field#preferred_shortcut_map ==# 'char' 25 | let l:theindex = 1 26 | elseif g:sickness#field#preferred_shortcut_map ==# 'opendelim' 27 | let l:theindex = 2 28 | elseif g:sickness#field#preferred_shortcut_map ==# 'closedelim' 29 | let l:theindex = 3 30 | endif 31 | 32 | execute 'omap i' . l:openclosedelimdef[l:theindex] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-i)' 33 | execute 'xmap i' . l:openclosedelimdef[l:theindex] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-i)' 34 | execute 'omap a' . l:openclosedelimdef[l:theindex] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-a)' 35 | execute 'xmap a' . l:openclosedelimdef[l:theindex] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-a)' 36 | 37 | for l:fielddelimdef in a:fielddelimdefs 38 | execute 'omap if' . l:fielddelimdef[1] . l:openclosedelimdef[l:theindex] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . '-i)' 39 | execute 'xmap if' . l:fielddelimdef[1] . l:openclosedelimdef[l:theindex] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . '-i)' 40 | execute 'omap af' . l:fielddelimdef[1] . l:openclosedelimdef[l:theindex] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . '-a)' 41 | execute 'xmap af' . l:fielddelimdef[1] . l:openclosedelimdef[l:theindex] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . '-a)' 42 | endfor 43 | 44 | elseif get(g:, 'sickness#field#use_default_maps', v:true) " use prefix maps 45 | execute 'omap if' . l:openclosedelimdef[1] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-i)' 46 | execute 'xmap if' . l:openclosedelimdef[1] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-i)' 47 | execute 'omap af' . l:openclosedelimdef[1] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-a)' 48 | execute 'xmap af' . l:openclosedelimdef[1] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-a)' 49 | 50 | execute 'omap if' . l:openclosedelimdef[2] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-i)' 51 | execute 'xmap if' . l:openclosedelimdef[2] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-i)' 52 | execute 'omap af' . l:openclosedelimdef[2] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-a)' 53 | execute 'xmap af' . l:openclosedelimdef[2] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-a)' 54 | 55 | execute 'omap if' . l:openclosedelimdef[3] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-i)' 56 | execute 'xmap if' . l:openclosedelimdef[3] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-i)' 57 | execute 'omap af' . l:openclosedelimdef[3] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-a)' 58 | execute 'xmap af' . l:openclosedelimdef[3] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-a)' 59 | 60 | for l:fielddelimdef in a:fielddelimdefs 61 | execute 'omap if' . l:fielddelimdef[1] . l:openclosedelimdef[1] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . '-i)' 62 | execute 'xmap if' . l:fielddelimdef[1] . l:openclosedelimdef[1] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . '-i)' 63 | execute 'omap af' . l:fielddelimdef[1] . l:openclosedelimdef[1] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . '-a)' 64 | execute 'xmap af' . l:fielddelimdef[1] . l:openclosedelimdef[1] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . '-a)' 65 | 66 | execute 'omap if' . l:fielddelimdef[1] . l:openclosedelimdef[2] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . '-i)' 67 | execute 'xmap if' . l:fielddelimdef[1] . l:openclosedelimdef[2] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . '-i)' 68 | execute 'omap af' . l:fielddelimdef[1] . l:openclosedelimdef[2] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . '-a)' 69 | execute 'xmap af' . l:fielddelimdef[1] . l:openclosedelimdef[2] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . '-a)' 70 | 71 | execute 'omap if' . l:fielddelimdef[1] . l:openclosedelimdef[3] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . '-i)' 72 | execute 'xmap if' . l:fielddelimdef[1] . l:openclosedelimdef[3] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . '-i)' 73 | execute 'omap af' . l:fielddelimdef[1] . l:openclosedelimdef[3] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . '-a)' 74 | execute 'xmap af' . l:fielddelimdef[1] . l:openclosedelimdef[3] . ' (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . '-a)' 75 | endfor 76 | endif 77 | 78 | " set textobj plugs 79 | execute 'onoremap (textobj-sickness-field-' . l:openclosedelimdef[0] . "-i)" 80 | \ " call sickness#textobj#field#motion(0, 0, '" . l:openclosedelimdef[2] . "', '" . l:openclosedelimdef[3] . "', ',')" 81 | execute 'xnoremap (textobj-sickness-field-' . l:openclosedelimdef[0] . "-i)" . 82 | \ " call sickness#textobj#field#motion(0, 1, '" . l:openclosedelimdef[2] . "', '" . l:openclosedelimdef[3] . "', ',')" 83 | execute 'onoremap (textobj-sickness-field-' . l:openclosedelimdef[0] . "-a)" . 84 | \ " call sickness#textobj#field#motion(1, 0, '" . l:openclosedelimdef[2] . "', '" . l:openclosedelimdef[3] . "', ',')" 85 | execute 'xnoremap (textobj-sickness-field-' . l:openclosedelimdef[0] . "-a)" . 86 | \ " call sickness#textobj#field#motion(1, 1, '" . l:openclosedelimdef[2] . "', '" . l:openclosedelimdef[3] . "', ',')" 87 | 88 | for l:fielddelimdef in a:fielddelimdefs 89 | execute 'onoremap (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . "-i)" . 90 | \ " call sickness#textobj#field#motion(0, 0, '" . l:openclosedelimdef[2] . "', '" . l:openclosedelimdef[3] . "', '" . l:fielddelimdef[1] . "')" 91 | execute 'xnoremap (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . "-i)" . 92 | \ " call sickness#textobj#field#motion(0, 1, '" . l:openclosedelimdef[2] . "', '" . l:openclosedelimdef[3] . "', '" . l:fielddelimdef[1] . "')" 93 | execute 'onoremap (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . "-a)" . 94 | \ " call sickness#textobj#field#motion(1, 0, '" . l:openclosedelimdef[2] . "', '" . l:openclosedelimdef[3] . "', '" . l:fielddelimdef[1] . "')" 95 | execute 'xnoremap (textobj-sickness-field-' . l:openclosedelimdef[0] . '-' . l:fielddelimdef[0] . "-a)" . 96 | \ " call sickness#textobj#field#motion(1, 1, '" . l:openclosedelimdef[2] . "', '" . l:openclosedelimdef[3] . "', '" . l:fielddelimdef[1] . "')" 97 | endfor 98 | 99 | endfor 100 | endfunction 101 | -------------------------------------------------------------------------------- /autoload/sickness/indentation.vim: -------------------------------------------------------------------------------- 1 | 2 | let g:sickness#indentation#exclude_leading_indents = get(g:, 'sickness#indentation#exclude_leading_indents', v:true) 3 | 4 | " Indentation Setting user mappings {{{1 5 | function! sickness#indentation#add() abort 6 | if get(g:, 'sickness#indent#use_default_maps', v:true) 7 | omap iip (textobj-sickness-indentation-paragraph-i) 8 | xmap iip (textobj-sickness-indentation-paragraph-i) 9 | omap aip (textobj-sickness-indentation-paragraph-a) 10 | xmap aip (textobj-sickness-indentation-paragraph-a) 11 | 12 | omap iil (textobj-sickness-indentation-level-i) 13 | xmap iil (textobj-sickness-indentation-level-i) 14 | omap ail (textobj-sickness-indentation-level-a) 15 | xmap ail (textobj-sickness-indentation-level-a) 16 | 17 | omap iib (textobj-sickness-indentation-block-i) 18 | xmap iib (textobj-sickness-indentation-block-i) 19 | omap aib (textobj-sickness-indentation-block-a) 20 | xmap aib (textobj-sickness-indentation-block-a) 21 | 22 | omap iit (textobj-sickness-indentation-top-i) 23 | xmap iit (textobj-sickness-indentation-top-i) 24 | omap ait (textobj-sickness-indentation-top-a) 25 | xmap ait (textobj-sickness-indentation-top-a) 26 | endif 27 | 28 | " Indentation Setting plug mappings {{{1 29 | onoremap (textobj-sickness-indentation-paragraph-i) 30 | \ call sickness#textobj#indentation#motion(v:false, 'p') 31 | xnoremap (textobj-sickness-indentation-paragraph-i) 32 | \ call sickness#textobj#indentation#motion(v:false, 'p') 33 | onoremap (textobj-sickness-indentation-paragraph-a) 34 | \ call sickness#textobj#indentation#motion(v:true, 'p') 35 | xnoremap (textobj-sickness-indentation-paragraph-a) 36 | \ call sickness#textobj#indentation#motion(v:true, 'p') 37 | 38 | onoremap (textobj-sickness-indentation-level-i) 39 | \ call sickness#textobj#indentation#motion(v:false, 'l') 40 | xnoremap (textobj-sickness-indentation-level-i) 41 | \ call sickness#textobj#indentation#motion(v:false, 'l') 42 | onoremap (textobj-sickness-indentation-level-a) 43 | \ call sickness#textobj#indentation#motion(v:true, 'l') 44 | xnoremap (textobj-sickness-indentation-level-a) 45 | \ call sickness#textobj#indentation#motion(v:true, 'l') 46 | 47 | onoremap (textobj-sickness-indentation-block-i) 48 | \ call sickness#textobj#indentation#motion(v:false, 'b') 49 | xnoremap (textobj-sickness-indentation-block-i) 50 | \ call sickness#textobj#indentation#motion(v:false, 'b') 51 | onoremap (textobj-sickness-indentation-block-a) 52 | \ call sickness#textobj#indentation#motion(v:true, 'b') 53 | xnoremap (textobj-sickness-indentation-block-a) 54 | \ call sickness#textobj#indentation#motion(v:true, 'b') 55 | 56 | onoremap (textobj-sickness-indentation-top-i) 57 | \ call sickness#textobj#indentation#motion(v:false, 't') 58 | xnoremap (textobj-sickness-indentation-top-i)\ 59 | \ call sickness#textobj#indentation#motion(v:false, 't') 60 | onoremap (textobj-sickness-indentation-top-a) 61 | \ call sickness#textobj#indentation#motion(v:true, 't') 62 | xnoremap (textobj-sickness-indentation-top-a) 63 | \ call sickness#textobj#indentation#motion(v:true, 't') 64 | endfunction 65 | -------------------------------------------------------------------------------- /autoload/sickness/line.vim: -------------------------------------------------------------------------------- 1 | 2 | " Line Setting user mappings {{{1 3 | function sickness#line#add() abort 4 | if get(g:, 'sickness#line#use_default_maps', v:true) 5 | omap il (textobj-sickness-line-i) 6 | vmap il (textobj-sickness-line-i) 7 | omap al (textobj-sickness-line-a) 8 | vmap al (textobj-sickness-line-a) 9 | endif 10 | 11 | " Line Setting plug mappings {{{1 12 | onoremap (textobj-sickness-line-i) call sickness#textobj#line#motion('i') 13 | vnoremap (textobj-sickness-line-i) call sickness#textobj#line#motion('i') 14 | onoremap (textobj-sickness-line-a) call sickness#textobj#line#motion('a') 15 | vnoremap (textobj-sickness-line-a) call sickness#textobj#line#motion('a') 16 | endfunction 17 | -------------------------------------------------------------------------------- /autoload/sickness/symbol.vim: -------------------------------------------------------------------------------- 1 | 2 | let g:sickness#symbol#default_maps = 3 | \ [ ['asterisk', '*'] 4 | \ , ['underscore', '_'] 5 | \ , ['dash', '-'] 6 | \ , ['colon', ':'] 7 | \ , ['at', '@'] 8 | \ , ['bang', '!'] 9 | \ , ['question', '?'] 10 | \ , ['slash', '/'] 11 | \ , ['bar', ''] 12 | \ ] 13 | 14 | let g:sickness#symbol#maps = get(g:, 'sickness#symbol#maps', g:sickness#symbol#default_maps) 15 | 16 | " Expression function {{{1 17 | function! sickness#symbol#add(matchpairs) abort 18 | for l:pair in a:matchpairs 19 | execute "onoremap (textobj-sickness-symbol-".pair[0]."-i) call sickness#textobj#symbol#motion(v:false, '".pair[1]."')" 20 | execute "xnoremap (textobj-sickness-symbol-".pair[0]."-i) call sickness#textobj#symbol#motion(v:false, '".pair[1]."')" 21 | execute "onoremap (textobj-sickness-symbol-".pair[0]."-a) call sickness#textobj#symbol#motion(v:true, '".pair[1]."')" 22 | execute "xnoremap (textobj-sickness-symbol-".pair[0]."-a) call sickness#textobj#symbol#motion(v:true, '".pair[1]."')" 23 | 24 | if get(g:, 'sick_symbol_default_mappings', v:true) 25 | execute "omap i".pair[1]." (textobj-sickness-symbol-".pair[0]."-i)" 26 | execute "xmap i".pair[1]." (textobj-sickness-symbol-".pair[0]."-i)" 27 | execute "omap a".pair[1]." (textobj-sickness-symbol-".pair[0]."-a)" 28 | execute "xmap a".pair[1]." (textobj-sickness-symbol-".pair[0]."-a)" 29 | endif 30 | endfor 31 | endfunction 32 | -------------------------------------------------------------------------------- /autoload/sickness/textobj/alias.vim: -------------------------------------------------------------------------------- 1 | " Empty... 2 | -------------------------------------------------------------------------------- /autoload/sickness/textobj/expression.vim: -------------------------------------------------------------------------------- 1 | " Defining functions {{{1 2 | function! sickness#textobj#expression#motion(opendelim, closedelim, reach) abort 3 | let l:curpos = getpos('.') 4 | let l:winsave = winsaveview() 5 | 6 | let l:count = v:count 7 | 8 | normal!  9 | 10 | if getline('.')[col('.') - 1] !=# a:opendelim 11 | \ && getline('.')[col('.') - 1] !=# a:closedelim 12 | execute 'normal! f'.a:opendelim 13 | endif 14 | 15 | execute 'normal! va'.a:opendelim 16 | let l:closedelim_pos = getpos('.') 17 | execute 'normal! o' 18 | let l:opendelim_pos = getpos('.') 19 | 20 | if l:opendelim_pos[2] ==# 1 || l:opendelim_pos ==# l:closedelim_pos 21 | " No expression starts on the first col OR No match is found by a 22 | normal!  23 | call setpos('.', l:curpos) 24 | call winrestview(l:winsave) 25 | return 26 | endif 27 | 28 | if len(getline(l:closedelim_pos[1])) !=# l:closedelim_pos[2] 29 | let l:onecharbefore = getline(l:opendelim_pos[1])[l:opendelim_pos[2] - 2] 30 | let l:onecharafter = getline(l:closedelim_pos[1])[l:closedelim_pos[2]] 31 | 32 | if l:onecharbefore ==# a:opendelim && l:onecharafter ==# a:closedelim 33 | execute "normal! \o o" 34 | endif 35 | endif 36 | 37 | if l:count ==# 0 && a:reach ==# 'b' 38 | let l:count = 1 39 | execute 'normal! '.l:count.a:reach 40 | elseif l:count ==# 0 && a:reach ==# 'B' 41 | execute 'normal! ^' 42 | else 43 | execute 'normal! '.l:count.a:reach 44 | endif 45 | 46 | " skip while you have non contained delim characters 47 | while !s:MatchOpenCloseDelims(s:GetInnerText(getpos('.'), l:opendelim_pos)) 48 | normal! 1 49 | endwhile 50 | 51 | " skip while you have blank characters 52 | while index([' ', ' '], getline('.')[col('.') - 1]) !=# -1 53 | normal! 1 54 | endwhile 55 | 56 | let l:beginpos = getpos('.') 57 | if !s:PosLiesWithin(l:beginpos, l:closedelim_pos, l:curpos) 58 | normal!  59 | call setpos('.', l:curpos) 60 | call winrestview(l:winsave) 61 | return 62 | endif 63 | 64 | normal! o 65 | endfunction 66 | 67 | function! s:PosLiesWithin(beginpos, endpos, middlepos) abort 68 | if a:beginpos[1] > a:middlepos[1] || a:middlepos[1] > a:endpos[1] 69 | return v:false 70 | elseif a:beginpos[1] == a:middlepos[1] && a:beginpos[2] > a:middlepos[2] 71 | return v:false 72 | elseif a:middlepos[1] == a:endpos[1] && a:middlepos[2] > a:endpos[2] 73 | return v:false 74 | endif 75 | 76 | return v:true 77 | endfunction 78 | 79 | function! s:MatchOpenCloseDelims(innertext) abort 80 | " substitute ' < ' and ' > ' from text because I assume 81 | " them to be comparison operators 82 | let l:innertext_joined = substitute(join(a:innertext), '\s[<>]\s', '', 'g') 83 | 84 | for l:openclosedelim in g:sickness#expression#openclosedelims 85 | if count(l:innertext_joined, l:openclosedelim[2]) !=# count(l:innertext_joined, l:openclosedelim[3]) 86 | return v:false 87 | endif 88 | endfor 89 | 90 | return v:true 91 | endfunction 92 | 93 | function! s:GetInnerText(opendelim_pos, closedelim_pos) abort 94 | " works different from sickness#textobj#field because 95 | " it includes the very first character of the selection 96 | let l:result = [] 97 | 98 | if a:closedelim_pos[1] < a:opendelim_pos[1] 99 | return l:result 100 | endif 101 | 102 | for i in range(a:opendelim_pos[1], a:closedelim_pos[1]) 103 | if (i ==# a:opendelim_pos[1] && i ==# a:closedelim_pos[1]) " single line 104 | let l:theline = strcharpart(getline(i), a:opendelim_pos[2] - 1, a:closedelim_pos[2] - a:opendelim_pos[2] - 1) 105 | 106 | elseif (i ==# a:opendelim_pos[1]) " firstline 107 | let l:theline = strcharpart(getline(i), a:opendelim_pos[2] - 1) 108 | 109 | elseif (i ==# a:closedelim_pos[1]) " lastline 110 | let l:theline = strcharpart(getline(i), 0, a:closedelim_pos[2] - 1) 111 | 112 | else " middleline 113 | let l:theline = getline(i) 114 | endif 115 | 116 | call add(l:result, l:theline) 117 | endfor 118 | 119 | return l:result 120 | endfunction 121 | -------------------------------------------------------------------------------- /autoload/sickness/textobj/field.vim: -------------------------------------------------------------------------------- 1 | " ORIGINAL Author: Takahiro SUZUKI 2 | " Version: 1.1.1 (Vim 7.1) 3 | " Licence: MIT Licence 4 | 5 | " Terminology: 6 | " - fielddelim: typically comma, might be semicolon, etc. 7 | " - opendelim: ({[< 8 | " - closedelim: )}]> 9 | " - blanks: space and tab 10 | " - field character: everything except blanks, linefeeds, and fielddelim 11 | " '[^ \t\n'.a:fielddelim.']' 12 | 13 | " Making an inner field to an all field: 14 | " Algorithm: 15 | " (*) for head element: 16 | " - delete elem 17 | " - delete right till first field character 18 | " - DONE 19 | 20 | " (*) for middle/tail element: 21 | " - delete elem 22 | " - check if on right is field character before newline 23 | " | if not: 24 | " - delete left until first field character 25 | " - DONE 26 | " | if yes: 27 | " - delete fielddelim and blanks on right 28 | " - DONE 29 | 30 | " (*) for single element: 31 | " - delete elem 32 | " - check if cursor on same line as opendelim, but not as closedelim 33 | " | if yes: 34 | " - delete left and remember col of opendelim 35 | " - delete right until newline 36 | " - look up col of closedelim on the next line 37 | " | if same as col of opendelim: 38 | " - DONE 39 | " | if not: 40 | " - delete right until closedelim 41 | " - DONE 42 | " | if not: 43 | " - delete left until you reach opendelim 44 | " - delete right until you reach closedelim 45 | " - DONE 46 | 47 | function! s:GetOutOfDoubleQuote() abort 48 | " get out of double quoteed string (one letter before the beginning) 49 | let line = getline('.') 50 | let pos_save = getpos('.') 51 | let mark_b = getpos("'<") 52 | let mark_e = getpos("'>") 53 | let repl = '_' 54 | 55 | if getline('.')[getpos('.')[2]-1] ==# '_' 56 | let repl = '?' 57 | endif 58 | 59 | while 1 60 | execute 'silent! normal ^va"' 61 | normal :\\ 62 | if getpos("'<") ==# getpos("'>") 63 | break 64 | endif 65 | execute 'normal gvr' . repl 66 | endwhile 67 | 68 | call setpos('.', pos_save) 69 | if getline('.')[getpos('.')[2]-1] ==# repl 70 | " in double quote 71 | call setline('.', line) 72 | if getpos('.') ==# getpos("'<") 73 | normal h 74 | else 75 | normal F" 76 | endif 77 | else 78 | " not in double quote 79 | call setline('.', line) 80 | endif 81 | endfunction 82 | 83 | function! s:GetDelimPos(opendelim) abort 84 | let l:winsave = winsaveview() 85 | let l:reg_save = @@ 86 | 87 | execute 'silent! normal! va' . a:opendelim 88 | let l:closedelim_pos = getpos('.') 89 | 90 | execute "silent! normal! %" 91 | let l:opendelim_pos = getpos('.') 92 | 93 | call winrestview(l:winsave) 94 | return [l:opendelim_pos, l:closedelim_pos] 95 | endfunction 96 | 97 | function! s:GetInnerText(opendelim_pos, closedelim_pos) abort 98 | let l:result = [] 99 | 100 | if a:closedelim_pos[1] < a:opendelim_pos[1] 101 | return l:result 102 | endif 103 | 104 | for i in range(a:opendelim_pos[1], a:closedelim_pos[1]) 105 | if (i ==# a:opendelim_pos[1] && i ==# a:closedelim_pos[1]) " single line 106 | let l:theline = strcharpart(getline(i), a:opendelim_pos[2], a:closedelim_pos[2] - a:opendelim_pos[2] - 1) 107 | 108 | elseif (i ==# a:opendelim_pos[1]) " firstline 109 | let l:theline = strcharpart(getline(i), a:opendelim_pos[2]) 110 | 111 | elseif (i ==# a:closedelim_pos[1]) " lastline 112 | let l:theline = strcharpart(getline(i), 0, a:closedelim_pos[2] - 1) 113 | 114 | else " middleline 115 | let l:theline = getline(i) 116 | endif 117 | 118 | call add(l:result, l:theline) 119 | endfor 120 | 121 | return l:result 122 | endfunction 123 | 124 | "" return [position, isheadfield] 125 | function! s:GetPrevCommaOrBeginArgs(innertext, offset, fielddelim) abort 126 | let commapos_prev = max([strridx(a:innertext, a:fielddelim, a:offset) + 1, 0]) 127 | 128 | if commapos_prev == 0 129 | return [commapos_prev, v:true] 130 | else 131 | return [commapos_prev, v:false] 132 | endif 133 | 134 | endfunction 135 | 136 | "" return [position, istailfield] 137 | function! s:GetNextCommaOrEndArgs(innertext, offset, fielddelim) abort 138 | let l:commapos_next = stridx(a:innertext, a:fielddelim, a:offset) 139 | 140 | if l:commapos_next ==# -1 141 | return [strlen(a:innertext) - 1, v:true] 142 | else 143 | return [l:commapos_next - 1, v:false] 144 | endif 145 | endfunction 146 | 147 | function! s:MoveToNextNonSpace() abort 148 | let oldp = getpos('.') 149 | let moved = 0 150 | while getline('.')[getpos('.')[2]-1] ==# ' ' || 151 | normal l 152 | if oldp == getpos('.') 153 | break 154 | endif 155 | let oldp = getpos('.') 156 | let moved += 1 157 | endwhile 158 | return moved 159 | endfunction 160 | 161 | function! s:Move(num) abort 162 | if a:num < 0 163 | execute 'normal ' . a:num . "\" 164 | elseif a:num > 0 165 | execute 'normal ' . a:num . ' ' 166 | endif 167 | endfunction 168 | 169 | """ 170 | " the offset means: 171 | " you can stand on a:startpoint and `execute 'normal! '.l:offset.' '` 172 | " you'll end up on a:pos 173 | 174 | " now gets the text offset in the text 175 | """ 176 | function! s:GetPositionOffset(startpoint, pos) abort 177 | let l:offset = 0 178 | 179 | if a:pos[1] < a:startpoint[1] || (a:pos[1] == a:startpoint[1] && a:pos[2] < a:startpoint[2]) 180 | " echomsg 'startpoint behind' 181 | return [-1, -1] 182 | endif 183 | 184 | for i in range(a:startpoint[1], a:pos[1]) 185 | if i ==# a:startpoint[1] 186 | if i ==# a:pos[1] 187 | let l:offset += (a:pos[2] - a:startpoint[2]) 188 | else 189 | let l:offset += strchars(getline(i)) - a:startpoint[2] 190 | end 191 | elseif i < a:pos[1] 192 | let l:offset += strchars(getline(i)) 193 | else 194 | let l:offset += a:pos[2] 195 | endif 196 | endfor 197 | 198 | let l:offsetInInnerText = l:offset - ((a:startpoint[1] - a:pos[1]) + 1) 199 | 200 | return [l:offset, l:offsetInInnerText] 201 | endfunction 202 | 203 | function! sickness#textobj#field#motion(all, visual, opendelim, closedelim, fielddelim) abort 204 | " echomsg mode() -> either "n" or "v" 205 | let winsave = winsaveview() 206 | let modesave = mode() 207 | let before_pos = getpos('.') 208 | let before_posv = getpos('v') 209 | 210 | if modesave == 'v' 211 | normal!  212 | endif 213 | 214 | if a:closedelim ==# ']' 215 | let l:closedelim_mod = '\'.a:closedelim 216 | else 217 | let l:closedelim_mod = a:closedelim 218 | endif 219 | 220 | if a:opendelim ==# '[' 221 | let l:opendelim_mod = '\'.a:opendelim 222 | else 223 | let l:opendelim_mod = a:opendelim 224 | endif 225 | 226 | " Avoid dealing with ambiguity on called field on fielddelim 227 | let current_c = strcharpart(getline('.'), col('.') - 1, 1) 228 | if current_c ==# a:opendelim || current_c ==# a:fielddelim 229 | normal 1 230 | endif 231 | 232 | let l:current_pos = getpos('.') 233 | 234 | " get out of "double quoted string" because [( does not take effect in it 235 | call s:GetOutOfDoubleQuote() 236 | 237 | let [l:opendelim_pos, l:closedelim_pos] = s:GetDelimPos(a:opendelim) 238 | let l:innertext_orig = s:GetInnerText(l:opendelim_pos, l:closedelim_pos) 239 | 240 | if empty(l:innertext_orig) 241 | silent normal!  242 | call winrestview(winsave) 243 | if modesave == 'v' 244 | call setpos('.', before_posv) 245 | silent normal! v 246 | call setpos('.', before_pos) 247 | endif 248 | return 249 | endif 250 | 251 | let l:innertext = join(l:innertext_orig, "\n") 252 | 253 | " replace all parentheses and commas inside them to '_' 254 | let l:innertext = substitute(l:innertext, "'".'\([^'."'".']\{-}\)'."'", '\="(".substitute(submatch(1), ".", "_", "g").")"', 'g') " replace '..' => (__) 255 | let l:innertext = substitute(l:innertext, '\[\([^'."'".']\{-}\)\]', '\="(".substitute(submatch(1), ".", "_", "g").")"', 'g') " replace [..] => (__) 256 | let l:innertext = substitute(l:innertext, '<\([^'."'".']\{-}\)>', '\="(".substitute(submatch(1), ".", "_", "g").")"', 'g') " replace <..> => (__I 257 | let l:innertext = substitute(l:innertext, '"\([^'."'".']\{-}\)"', '(\1)', 'g') " replace ''..'' => (..) 258 | 259 | " replaces commas: 260 | while stridx(l:innertext, a:opendelim) >= 0 261 | \ && stridx(l:innertext, a:closedelim) >= 0 262 | let l:innertext = substitute(l:innertext, '(\([^()]\{-}\))', '\="<".substitute(submatch(1), ",", "_", "g").">"', 'g') 263 | endwhile 264 | 265 | let [l:offsetJump, l:offset] = s:GetPositionOffset(l:opendelim_pos, l:current_pos) 266 | 267 | if l:offsetJump <=# 0 268 | silent normal!  269 | call winrestview(winsave) 270 | if modesave == 'v' 271 | call setpos('.', before_posv) 272 | silent normal! v 273 | call setpos('.', before_pos) 274 | endif 275 | return 276 | endif 277 | 278 | " the beginning/end of this argument they don't work 279 | let [l:fieldbegin, l:isheadfield] = s:GetPrevCommaOrBeginArgs(l:innertext, l:offset, a:fielddelim) 280 | let [l:fieldend, l:istailfield] = s:GetNextCommaOrEndArgs(l:innertext, l:offset, a:fielddelim) 281 | 282 | let l:fieldbeginJump = l:fieldbegin - (l:offset - l:offsetJump) " - (l:current_pos[1] - l:opendelim_pos[1]) 283 | let l:fieldendJump = l:fieldend - (l:offset - l:offsetJump) " - (l:closedelim_pos[1] - l:current_pos[1]) 284 | 285 | " echo l:innertext_orig 286 | " Deal with one off errors 287 | if match(l:innertext_orig[0], '[^ \t\n]') ==# -1 288 | " echo 'empty firstline' 289 | let l:fieldbeginJump += 1 290 | endif 291 | 292 | if match(l:innertext_orig[-1], '[^ \t\n]') ==# -1 293 | " echo 'empty lastline' 294 | let l:fieldendJump -= 1 295 | 296 | " deal with trailing symbol ambiguity 297 | if !l:istailfield && match(l:innertext_orig[-1], '[^ \t\n]') ==# -1 298 | let l:fieldendJump += 1 299 | endif 300 | endif 301 | 302 | " TODO Note that after this, opening delimiter indented field still have a one off error 303 | " in a middle argument on the second line, however this should not affect anything 304 | 305 | normal!  306 | 307 | " """" Positions 308 | " echo '=========================================' 309 | " echo 'innertext "'.string(l:innertext).'"' 310 | " echo 'opendelim_pos: "'.string(l:opendelim_pos).'"' 311 | " echo 'closedelim_pos: "'.string(l:closedelim_pos).'"' 312 | " echo '=========================================' 313 | 314 | " """" Offsets in l:innertext 315 | " echo 'fieldbegin: "'.string(l:fieldbegin).'" "'.l:innertext[l:fieldbegin].'"' 316 | " echo 'offset: "'.string(l:offset).'" "'.l:innertext[l:offset].'"' 317 | " echo 'fieldend: "'.string(l:fieldend).'" "'.l:innertext[l:fieldend].'"' 318 | " echo '=========================================' 319 | 320 | " """" Offsets in terms of moving with space/backspace 321 | " echo 'fieldbeginJump: "'.string(l:fieldbeginJump).'"' 322 | " echo 'offsetJump: "'.string(l:offsetJump).'"' 323 | " echo 'fieldendJump: "'.string(l:fieldendJump).'"' 324 | " echo '=========================================' 325 | 326 | """ GET START OF INNER FIELD 327 | call setpos('.', l:opendelim_pos) 328 | 329 | " start 1 space before field, so the search 330 | " starts in the first character of the field 331 | if ! l:isheadfield " (l:fieldbeginJump) ># 0 332 | execute 'normal! '.(l:fieldbeginJump).' ' 333 | endif 334 | 335 | call search('[^ \t\n'.a:fielddelim.l:opendelim_mod.']') 336 | let l:startpos = getpos('.') 337 | 338 | """ GET END OF INNER FIELD 339 | call setpos('.', l:opendelim_pos) 340 | execute 'normal! '.(l:fieldendJump + 1).' ' 341 | 342 | call search('[^ \t\n'.a:fielddelim.']', 'b') 343 | let l:endpos = getpos('.') 344 | 345 | """ SET FIELD 346 | 347 | " if field is empty and you're inner, you startpos will be behind endpos 348 | if (l:startpos[1] ># l:endpos[1]) || 349 | \ (l:startpos[1] ==# l:endpos[1] && l:startpos[2] ># l:endpos[2]) 350 | 351 | if a:all " you'll still be able delete the fielddelim 352 | let l:startpos = l:current_pos 353 | let l:endpos = l:current_pos 354 | else 355 | silent normal!  356 | call winrestview(winsave) 357 | if modesave == 'v' 358 | call setpos('.', before_posv) 359 | silent normal! v 360 | call setpos('.', before_pos) 361 | endif 362 | return 363 | endif 364 | endif 365 | 366 | let l:innerparen = v:false 367 | 368 | if a:all 369 | " (*) for single element: 370 | " - delete elem 371 | " - check if elem on same line as opendelim, but not as closedelim 372 | " | if yes: 373 | " - delete left and remember col of opendelim 374 | " - delete right until newline 375 | " - look up col of closedelim on the next line 376 | " | if same as col of opendelim: 377 | " - DONE 378 | " | if not: 379 | " - delete right until closedelim 380 | " - DONE 381 | " | if not: 382 | " - delete left until you reach opendelim 383 | " - delete right until you reach closedelim 384 | " - DONE 385 | 386 | if l:isheadfield && l:istailfield 387 | " " leading symbol style behaves a bit different than i 388 | 389 | " echo 'single elem' 390 | " trailing symbol style, leading symbol style 391 | if (l:opendelim_pos[1] ==# l:startpos[1]) && 392 | \ (l:endpos[1] !=# l:closedelim_pos[1]) 393 | call setpos('.', l:startpos) 394 | " echo 'single elem1' 395 | 396 | call search('[^ \t\n'.a:fielddelim.']', 'Wb') 397 | execute "normal! 1 " 398 | let l:startpos = getpos('.') 399 | 400 | " leading symbol style 401 | if l:opendelim_pos[2] == l:closedelim_pos[2] 402 | call setpos('.', l:opendelim_pos) 403 | execute "normal! 1 " 404 | let l:startpos = getpos('.') 405 | execute "normal! $" 406 | let l:endpos = getpos('.') 407 | 408 | else 409 | call setpos('.', l:endpos) 410 | call search('[^ \t\n'.a:fielddelim.']', 'W') 411 | execute "normal! 1\" 412 | let l:endpos = getpos('.') 413 | endif 414 | else 415 | " echo 'single elem2' 416 | call setpos('.', l:startpos) 417 | call search('[^ \t\n'.a:fielddelim.']', 'Wb') 418 | execute "normal! 1 " 419 | let l:startpos = getpos('.') 420 | 421 | call setpos('.', l:endpos) 422 | call search('[^ \t\n'.a:fielddelim.']', 'W') 423 | execute "normal! 1\" 424 | let l:endpos = getpos('.') 425 | 426 | let l:innerparen = v:true 427 | endif 428 | 429 | " " (*) for head element: 430 | " " - delete elem 431 | " " - delete right till first field character 432 | " " - DONE 433 | elseif l:isheadfield 434 | " echo 'head elem' 435 | call setpos('.', l:endpos) 436 | call search('[^ \t\n'.a:fielddelim.']', 'W') 437 | 438 | execute "normal! 1\" 439 | let l:endpos = getpos('.') 440 | 441 | " check if maybe actually single field 442 | " in trailing symbol style with trailing comma 443 | call search('[^ \t\n]', 'W') 444 | if getline('.')[col('.') - 1] == a:closedelim 445 | let l:innerparen = v:true 446 | endif 447 | 448 | " (*) for middle/tail element: 449 | " - delete elem 450 | " - check if on right is field character before you reach closedelim or eol 451 | " | if yes (short style OR opening-delim style, you don't want to delete the "gap"): 452 | " - delete right until first field character 453 | " - DONE 454 | " | if not: 455 | " - check if on fielddelim is on the left (for leading) 456 | " | if yes 457 | " - delete left till fielddelim (including) 458 | " - delete right till fielddelim or closeparen (excluding) 459 | " | if not 460 | " - delete left until first field character 461 | " - DONE 462 | else 463 | call setpos('.', l:endpos) 464 | 465 | let l:idx = match(getline('.'), '[^ \t\n'.a:fielddelim.']', col('.')) 466 | let l:maybeclosedelim = getline('.')[l:idx] 467 | 468 | if l:idx != -1 && l:maybeclosedelim != a:closedelim 469 | " echo 'idx: "'.l:idx.'"' 470 | " echo 'maybecldel: "'.l:maybeclosedelim.'"' 471 | " there is a field on the right 472 | " (e.g. short style, or delimiter intended style) 473 | call search('[^ \t\n'.a:fielddelim.']', 'W') 474 | execute "normal! 1\" 475 | let l:endpos = getpos('.') 476 | 477 | else 478 | call setpos('.', l:startpos) 479 | call search(a:fielddelim, 'Wb') 480 | 481 | if getpos('.')[1] ==# l:startpos[1] 482 | " leading symbol style 483 | let l:startpos = getpos('.') 484 | call setpos('.', l:endpos) 485 | call search('['.a:fielddelim.l:closedelim_mod.']', 'W') 486 | execute "normal! 1\" 487 | let l:endpos = getpos('.') 488 | 489 | else 490 | " trailing symbol style 491 | call search('[^ \t\n'.a:fielddelim.']', 'Wb') 492 | execute "normal! 1 " 493 | let l:startpos = getpos('.') 494 | endif 495 | 496 | endif 497 | end 498 | endif 499 | 500 | if l:innerparen 501 | execute "normal! vi".a:opendelim 502 | else 503 | call setpos('.', l:startpos) 504 | normal! v 505 | call setpos('.', l:endpos) 506 | endif 507 | endfunction 508 | -------------------------------------------------------------------------------- /autoload/sickness/textobj/indentation.vim: -------------------------------------------------------------------------------- 1 | " Defining functions {{{1 2 | 3 | " only having blank characters counts as empty 4 | function! s:IsLineEmpty(line) abort 5 | return match(a:line, '[^ \t]') ==# -1 6 | endfunction 7 | 8 | 9 | ""select the inner level independent of current mode etc 10 | function! s:SelectInnerLevel(minindent, include_emptylines) abort 11 | if mode() !=# 'V' 12 | execute 'normal! V' 13 | endif 14 | 15 | " get bottom line 16 | while (indent(line('.') + 1) >= a:minindent) || s:IsLineEmpty(getline(line('.') + 1)) 17 | execute 'normal! j' 18 | if line('.') == line('$') 19 | break 20 | endif 21 | endwhile 22 | 23 | if !a:include_emptylines 24 | while s:IsLineEmpty(getline('.')) 25 | execute 'normal! k' 26 | endwhile 27 | endif 28 | 29 | execute 'normal! o' 30 | 31 | " get top line 32 | while (indent(line('.') - 1) >= a:minindent) || s:IsLineEmpty(getline(line('.') - 1)) 33 | execute 'normal! k' 34 | if line('.') == 1 35 | break 36 | endif 37 | endwhile 38 | 39 | if g:sickness#indentation#exclude_leading_indents 40 | " e.g. useful when using opening delimiter indentation style 41 | " foo_function_name(bla bla, 42 | " foo foo) { 43 | " hello; <- iil will start here 44 | " world; 45 | " } 46 | " 47 | 48 | while indent(line('.')) > a:minindent && line('.') !=# line('$') 49 | execute 'normal! j' 50 | endwhile 51 | endif 52 | 53 | if !a:include_emptylines 54 | while s:IsLineEmpty(getline('.')) && line('.') !=# line('$') 55 | execute 'normal! j' 56 | endwhile 57 | endif 58 | 59 | "return with cursor at bottom 60 | execute 'normal! o' 61 | return 62 | endfunction 63 | 64 | " mode is either: 65 | " - 'p': mimics *p* motion - supports counts 66 | " - 'b': select an indentation *b*lock - supports counts 67 | " - 't': select an indentation level plus *t*op line - support counts 68 | 69 | " - 'l': select an entire indentation *l*evel - does not support counts 70 | function! sickness#textobj#indentation#motion(margin, mode) abort 71 | " difference between ii and ia is only the count 72 | 73 | " for indent paragraph motion 74 | " for other modes, the count means whether to include whitespace 75 | if a:mode == 'p' && a:margin 76 | let l:count = v:count1 * 2 77 | else 78 | let l:count = v:count1 79 | endif 80 | 81 | for i in range(l:count) 82 | if mode() ==# 'V' 83 | let l:linenos = range(min([line('.'), line('v')]), max([line('.'), line('v')])) 84 | let l:visualselection = map(copy(l:linenos), 'getline(v:val)') 85 | let l:lineindents = map( 86 | \ filter(copy(l:visualselection), 'v:val !=# ""'), 87 | \ 'strlen(substitute(substitute(v:val, ''\s*\zs.*\ze'', '''', ''''), ''\t'', repeat('' '', &tabstop), ''g''))') 88 | let l:minindent = min(l:lineindents) 89 | endif 90 | 91 | if mode() !=# 'V' 92 | " first `ii`/`ai` 93 | if !s:IsLineEmpty(getline('.')) 94 | " Get first viable block 95 | let l:minindent = indent('.') 96 | execute 'normal! V' 97 | 98 | while (!s:IsLineEmpty(getline(line('.') + 1)) && indent(line('.') + 1) >= l:minindent) 99 | execute 'normal! j' 100 | endwhile 101 | execute 'normal! o' 102 | 103 | while (!s:IsLineEmpty(getline(line('.') - 1)) && indent(line('.') - 1) >= l:minindent) 104 | execute 'normal! k' 105 | endwhile 106 | execute 'normal! o' 107 | 108 | else 109 | if mode() !=# 'v' 110 | execute 'normal! vip' 111 | else 112 | execute 'normal! ip' 113 | endif 114 | endif 115 | 116 | elseif len(l:lineindents) ==# 0 || s:IsLineEmpty(getline(line('.') + 1)) 117 | " a block of empty lines 118 | " behave like `ip`/`ap` 119 | normal! ip 120 | 121 | else 122 | " select down until you reach lower indent or empty line 123 | while !s:IsLineEmpty(getline(line('.') + 1)) && (indent(line('.') + 1) >= l:minindent) 124 | execute 'normal! j' 125 | endwhile 126 | endif 127 | 128 | """""""""""""""""""""""""""""""""""""""" 129 | " special cmds 130 | """""""""""""""""""""""""""""""""""""""" 131 | if a:mode !=# 'p' 132 | " set minindent 133 | if !exists('l:minindent') 134 | let l:winsave = winsaveview() 135 | while(s:IsLineEmpty(getline('.'))) 136 | execute 'normal! j' 137 | endwhile 138 | 139 | let l:minindent = indent(line('.')) 140 | call winrestview(l:winsave) 141 | endif 142 | 143 | let l:include_emptylines = a:margin 144 | call s:SelectInnerLevel(l:minindent, l:include_emptylines) 145 | 146 | "" reach up 147 | if a:mode ==# 'b' || a:mode ==# 't' 148 | " walk up and cach first lower indent level 149 | execute 'normal! o' 150 | 151 | while (v:true) 152 | execute 'normal! k' 153 | if ((indent('.') < l:minindent && !s:IsLineEmpty(getline('.'))) || line('.') ==# 1) 154 | break 155 | endif 156 | endwhile 157 | 158 | if l:include_emptylines 159 | " walk further up to include empty lines 160 | while line('.') !=# 1 && s:IsLineEmpty(getline(line('.') - 1)) 161 | execute 'normal! k' 162 | endwhile 163 | endif 164 | 165 | execute 'normal! o' 166 | endif 167 | 168 | " reach down 169 | if a:mode ==# 'b' 170 | 171 | while (v:true) 172 | execute 'normal! j' 173 | if ((indent('.') < l:minindent && !s:IsLineEmpty(getline('.'))) || line('.') ==# line('$')) 174 | break 175 | endif 176 | endwhile 177 | 178 | if l:include_emptylines 179 | " walk further down to include empty lines 180 | while line('.') !=# line('$') && s:IsLineEmpty(getline(line('.') + 1)) 181 | execute 'normal! j' 182 | endwhile 183 | endif 184 | 185 | endif 186 | 187 | endif 188 | endfor 189 | endfunction 190 | -------------------------------------------------------------------------------- /autoload/sickness/textobj/line.vim: -------------------------------------------------------------------------------- 1 | function! sickness#textobj#line#motion(mode) abort 2 | if !empty(getline('.')) 3 | normal!  4 | 5 | if a:mode ==# 'i' && match(getline('.'), '\S') !=# -1 6 | execute 'normal! ^vg_' 7 | 8 | elseif a:mode ==# 'a' 9 | execute "normal! 0v$\" 10 | endif 11 | endif 12 | endfunction 13 | -------------------------------------------------------------------------------- /autoload/sickness/textobj/symbol.vim: -------------------------------------------------------------------------------- 1 | " Defining functinos {{{1 2 | function! sickness#textobj#symbol#motion(wrap, symbol) abort 3 | let l:winsave = winsaveview() 4 | let l:curpos = getpos('.') 5 | 6 | let l:recdepth = 1 7 | if mode() ==# 'v' 8 | while getline('.')[col('.') - 1] ==# a:symbol 9 | normal! h 10 | let l:recdepth += 1 11 | endwhile 12 | endif 13 | 14 | normal!  15 | let l:newcurpos = getpos('.') 16 | 17 | for _ in range(l:recdepth) 18 | silent! execute 'normal! F' . a:symbol 19 | endfor 20 | 21 | if getpos('.') == l:newcurpos 22 | silent! execute 'normal! f' . a:symbol 23 | endif 24 | 25 | let l:beginpos = getpos('.') 26 | 27 | if !a:wrap 28 | normal! 1 29 | endif 30 | 31 | normal! v 32 | call setpos('.', l:newcurpos) 33 | 34 | for _ in range(l:recdepth) 35 | silent! execute 'normal! f' . a:symbol 36 | endfor 37 | 38 | let l:endpos = getpos('.') 39 | 40 | if !a:wrap 41 | execute "normal! \" 42 | endif 43 | 44 | if l:beginpos == l:endpos 45 | normal!  46 | call winrestview(l:winsave) 47 | call setpos('.', l:curpos) 48 | endif 49 | endfunction 50 | -------------------------------------------------------------------------------- /autoload/sickness/textobj/view.vim: -------------------------------------------------------------------------------- 1 | function! sickness#textobj#view#motion(mode) abort 2 | normal! m' 3 | 4 | if a:mode ==# 'i' 5 | execute 'keepjumps normal! HVL' 6 | 7 | elseif a:mode ==# 'a' 8 | 1 9 | normal! V 10 | $ 11 | endif 12 | endfunction 13 | -------------------------------------------------------------------------------- /autoload/sickness/view.vim: -------------------------------------------------------------------------------- 1 | function! sickness#view#add() abort 2 | " Line Setting user mappings {{{1 3 | if get(g:, 'sickness#view#use_default_maps', v:true) 4 | omap iv (textobj-sickness-view-i) 5 | xmap iv (textobj-sickness-view-i) 6 | omap av (textobj-sickness-view-a) 7 | xmap av (textobj-sickness-view-a) 8 | endif 9 | 10 | " Line Setting plug mappings {{{1 11 | onoremap (textobj-sickness-view-i) call sickness#textobj#view#motion('i') 12 | xnoremap (textobj-sickness-view-i) call sickness#textobj#view#motion('i') 13 | onoremap (textobj-sickness-view-a) call sickness#textobj#view#motion('a') 14 | xnoremap (textobj-sickness-view-a) call sickness#textobj#view#motion('a') 15 | endfunction 16 | -------------------------------------------------------------------------------- /plugin/sickness.vim: -------------------------------------------------------------------------------- 1 | " MOTION SICKNESS BRACKETS: 2 | 3 | if get(g:, 'sickness#alias#enabled', v:true) 4 | \ && !(get(g:, 'sickness#expression#preferred_shortcut_map', 'default') ==# 'char') 5 | \ && !(get(g:, 'sickness#field#preferred_shortcut_map', 'default') ==# 'char') 6 | call sickness#alias#add() 7 | endif 8 | 9 | if get(g:, 'sickness#expression#enabled', v:true) 10 | call sickness#expression#add(g:sickness#expression#openclosedelims) 11 | endif 12 | 13 | if get(g:, 'sickness#field#enabled', v:true) 14 | call sickness#field#add(g:sickness#field#openclosedelims, g:sickness#field#fielddelims) 15 | endif 16 | 17 | " MOTION SICKNESS OTHERS: 18 | 19 | if get(g:, 'sickness#indentation#enabled', v:true) 20 | call sickness#indentation#add() 21 | endif 22 | 23 | if get(g:, 'sickness#line#enabled', v:true) 24 | call sickness#line#add() 25 | endif 26 | 27 | if get(g:, 'sickness#view#enabled', v:true) 28 | call sickness#view#add() 29 | endif 30 | 31 | if get(g:, 'sickness#symbol#enabled', v:true) 32 | call sickness#symbol#add(g:sickness#symbol#maps) 33 | endif 34 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ "$1" ]]; then 4 | TARGET="$1" 5 | else 6 | if [[ ! "$TARGET" ]]; then 7 | TARGET='*' 8 | fi 9 | fi 10 | 11 | if [[ "$TARGET" == 'try' ]]; then 12 | exec nvim -u 'tests/vimrc-test.vim' <&1 # | egrep '^.*(Starting|Success).*$' | awk '1 ; (NR==1) || (NR>1 && NR%2==1) {printf"\n"}' 33 | 34 | else 35 | nvim -Es -u 'tests/vimrc-test.vim' -c "Vader! ${test_name}" 2>&1 36 | fi 37 | 38 | echo "Tests done with target '$TARGET'" 39 | -------------------------------------------------------------------------------- /tests/alias-spec.vader: -------------------------------------------------------------------------------- 1 | Given: 2 | foo[asdf] 3 | Before: 4 | normal! fd 5 | 6 | Do: 7 | dir 8 | Expect: 9 | foo[] 10 | Do: 11 | dar 12 | Expect: 13 | foo 14 | 15 | Given: 16 | foo 17 | Before: 18 | normal! fd 19 | 20 | Do: 21 | dia 22 | Expect: 23 | foo<> 24 | Do: 25 | daa 26 | Expect: 27 | foo 28 | -------------------------------------------------------------------------------- /tests/expression-count-af-spec.vader: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /tests/expression-count-if-spec.vader: -------------------------------------------------------------------------------- 1 | Given: 2 | {foo::bar(xyz)} 3 | 4 | Before: 5 | normal! fx 6 | 7 | Do: 8 | dieb 9 | Expect: 10 | {foo::} 11 | Do: 12 | d2ieb 13 | Expect: 14 | {foo} 15 | Do: 16 | d3ieb 17 | Expect: 18 | {} 19 | 20 | Do: 21 | daeb 22 | Expect: 23 | {} 24 | -------------------------------------------------------------------------------- /tests/expression-general-af-spec.vader: -------------------------------------------------------------------------------- 1 | " {{{1 Given: 2 | Given: 3 | foo(bar) 4 | 5 | Do: 6 | daeb 7 | Expect: 8 | 9 | 10 | Do: 11 | fbdaeb 12 | Expect: 13 | 14 | 15 | Do: 16 | f(daeb 17 | Expect: 18 | 19 | 20 | Do: 21 | f)daeb 22 | Expect: 23 | 24 | 25 | " {{{1 Given: 26 | Given: 27 | foo{bar} 28 | 29 | Do: 30 | daeB 31 | Expect: 32 | 33 | 34 | Do: 35 | fbdaeB 36 | Expect: 37 | 38 | 39 | Do: 40 | f{daeB 41 | Expect: 42 | 43 | 44 | Do: 45 | f}daeB 46 | Expect: 47 | 48 | 49 | " {{{1 Given: 50 | Given: 51 | foo[bar] 52 | 53 | Do: 54 | daer 55 | Expect: 56 | 57 | 58 | Do: 59 | fbdaer 60 | Expect: 61 | 62 | 63 | Do: 64 | f[daer 65 | Expect: 66 | 67 | 68 | Do: 69 | f]daer 70 | Expect: 71 | 72 | 73 | " {{{1 Given: 74 | Given: 75 | foo 76 | 77 | Do: 78 | daea 79 | Expect: 80 | 81 | 82 | Do: 83 | fbdaea 84 | Expect: 85 | 86 | 87 | Do: 88 | fdaea 94 | Expect: 95 | 96 | 97 | -------------------------------------------------------------------------------- /tests/expression-general-if-spec.vader: -------------------------------------------------------------------------------- 1 | " Using die {{{1 2 | " {{{2 Given: 3 | Given: 4 | foo(bar) 5 | 6 | Do: 7 | dieb 8 | Expect: 9 | 10 | 11 | Do: 12 | fbdieb 13 | Expect: 14 | 15 | 16 | Do: 17 | f(dieb 18 | Expect: 19 | 20 | 21 | Do: 22 | f)dieb 23 | Expect: 24 | 25 | 26 | " {{{2 Given: 27 | Given: 28 | foo{bar} 29 | 30 | Do: 31 | dieB 32 | Expect: 33 | 34 | 35 | Do: 36 | fbdieB 37 | Expect: 38 | 39 | 40 | Do: 41 | f{dieB 42 | Expect: 43 | 44 | 45 | Do: 46 | f}dieB 47 | Expect: 48 | 49 | 50 | " {{{2 Given: 51 | Given: 52 | foo[bar] 53 | 54 | Do: 55 | dier 56 | Expect: 57 | 58 | 59 | Do: 60 | fbdier 61 | Expect: 62 | 63 | 64 | Do: 65 | f[dier 66 | Expect: 67 | 68 | 69 | Do: 70 | f]dier 71 | Expect: 72 | 73 | 74 | " {{{2 Given: 75 | Given: 76 | foo 77 | 78 | Do: 79 | diea 80 | Expect: 81 | 82 | 83 | Do: 84 | fbdiea 85 | Expect: 86 | 87 | 88 | Do: 89 | fdiea 95 | Expect: 96 | 97 | 98 | -------------------------------------------------------------------------------- /tests/expression-multiline-indented-spec.vader: -------------------------------------------------------------------------------- 1 | " Using dieb {{{1 2 | Given: 3 | a_very_long_foo(bar, a_longer_word, 4 | meh, bla) 5 | 6 | Do: 7 | dieb 8 | Expect: 9 | 10 | 11 | Do: 12 | f(dieb 13 | Expect: 14 | 15 | 16 | Do: 17 | jdieb 18 | Expect: 19 | 20 | 21 | Given: 22 | a_very_long_foo(bar, a_longer_word, 23 | meh, bla) 24 | 25 | Do: 26 | jdieb 27 | Expect: 28 | 29 | -------------------------------------------------------------------------------- /tests/expression-multiline-leading-spec.vader: -------------------------------------------------------------------------------- 1 | " Using dieb {{{1 2 | Given: 3 | foo( bar 4 | , a_longer_word 5 | , another_word 6 | ) 7 | 8 | Do: 9 | dieb 10 | Expect: 11 | 12 | 13 | Do: 14 | f(dieb 15 | Expect: 16 | 17 | 18 | Do: 19 | jdieb 20 | Expect: 21 | 22 | 23 | Do: 24 | jjjdieb 25 | Expect: 26 | 27 | 28 | Do: 29 | jjfadieb 30 | Expect: 31 | 32 | 33 | Do: 34 | jjjdieb 35 | Expect: 36 | 37 | 38 | Given: 39 | foo( bar 40 | , a_longer_word 41 | ) 42 | 43 | Do: 44 | dieb 45 | Expect: 46 | 47 | 48 | Do: 49 | jj$ldieb 50 | Expect: 51 | foo( bar 52 | , a_longer_word 53 | ) 54 | -------------------------------------------------------------------------------- /tests/expression-multiline-trailing-spec.vader: -------------------------------------------------------------------------------- 1 | " Using dieb {{{1 2 | Given: 3 | foo( 4 | bar, 5 | a_longer_word 6 | ) 7 | 8 | Do: 9 | dieb 10 | Expect: 11 | 12 | 13 | Do: 14 | f(dieb 15 | Expect: 16 | 17 | 18 | Do: 19 | jdieb 20 | Expect: 21 | 22 | 23 | Do: 24 | jjfwdieb 25 | Expect: 26 | 27 | 28 | Do: 29 | jjjdieb 30 | Expect: 31 | 32 | 33 | Given: 34 | foo( 35 | bar, 36 | a_longer_word 37 | ) 38 | 39 | Do: 40 | dieb 41 | Expect: 42 | 43 | 44 | Do: 45 | jjjldieb 46 | Expect: 47 | foo( 48 | bar, 49 | a_longer_word 50 | ) 51 | -------------------------------------------------------------------------------- /tests/expression-nested-spec.vader: -------------------------------------------------------------------------------- 1 | " Using die {{{1 2 | " {{{2 Given: 3 | Given: 4 | xyz(def foo(bar)) 5 | 6 | Do: 7 | dieb 8 | Expect: 9 | 10 | 11 | Do: 12 | fddieb 13 | Expect: 14 | xyz(def foo(bar)) 15 | 16 | Do: 17 | fbdieb 18 | Expect: 19 | xyz(def ) 20 | 21 | Do: 22 | f(dieb 23 | Expect: 24 | 25 | 26 | Do: 27 | f)f)dieb 28 | Expect: 29 | 30 | 31 | " {{{2 Given: 32 | Given: 33 | xyz{def foo{bar}} 34 | 35 | Do: 36 | dieB 37 | Expect: 38 | 39 | 40 | Do: 41 | fddieB 42 | Expect: 43 | xyz{def foo{bar}} 44 | 45 | Do: 46 | fbdieB 47 | Expect: 48 | xyz{def } 49 | 50 | Do: 51 | f{dieB 52 | Expect: 53 | 54 | 55 | Do: 56 | f}f}dieB 57 | Expect: 58 | 59 | 60 | " {{{2 Given: 61 | Given: 62 | xyz[def foo[bar]] 63 | 64 | Do: 65 | dier 66 | Expect: 67 | 68 | 69 | Do: 70 | fddier 71 | Expect: 72 | xyz[def foo[bar]] 73 | 74 | Do: 75 | fbdier 76 | Expect: 77 | xyz[def ] 78 | 79 | Do: 80 | f[dier 81 | Expect: 82 | 83 | 84 | Do: 85 | f]f]dier 86 | Expect: 87 | 88 | 89 | " {{{2 Given: 90 | Given: 91 | xyz> 92 | 93 | Do: 94 | diea 95 | Expect: 96 | 97 | 98 | Do: 99 | fddiea 100 | Expect: 101 | xyz> 102 | 103 | Do: 104 | fbdiea 105 | Expect: 106 | xyz 107 | 108 | Do: 109 | ff>diea 115 | Expect: 116 | 117 | 118 | " {{{1 Using dae 119 | " {{{2 Given: 120 | Given: 121 | xyz(def foo(bar)) 122 | 123 | Do: 124 | daeb 125 | Expect: 126 | 127 | 128 | Do: 129 | fddaeb 130 | Expect: 131 | xyz() 132 | 133 | Do: 134 | fbdaeb 135 | Expect: 136 | xyz() 137 | 138 | Do: 139 | f(daeb 140 | Expect: 141 | 142 | 143 | Do: 144 | f)f)daeb 145 | Expect: 146 | 147 | 148 | " {{{2 Given: 149 | Given: 150 | xyz{def foo{bar}} 151 | 152 | Do: 153 | daeB 154 | Expect: 155 | 156 | 157 | Do: 158 | fddaeB 159 | Expect: 160 | xyz{} 161 | 162 | Do: 163 | fbdaeB 164 | Expect: 165 | xyz{} 166 | 167 | Do: 168 | f{daeB 169 | Expect: 170 | 171 | 172 | Do: 173 | f}f}daeB 174 | Expect: 175 | 176 | 177 | " {{{2 Given: 178 | Given: 179 | xyz[def foo[bar]] 180 | 181 | Do: 182 | daer 183 | Expect: 184 | 185 | 186 | Do: 187 | fddaer 188 | Expect: 189 | xyz[] 190 | 191 | Do: 192 | fbdaer 193 | Expect: 194 | xyz[] 195 | 196 | Do: 197 | f[daer 198 | Expect: 199 | 200 | 201 | Do: 202 | f]f]daer 203 | Expect: 204 | 205 | 206 | " {{{2 Given: 207 | Given: 208 | xyz> 209 | 210 | Do: 211 | daea 212 | Expect: 213 | 214 | 215 | Do: 216 | fddaea 217 | Expect: 218 | xyz<> 219 | 220 | Do: 221 | fbdaea 222 | Expect: 223 | xyz<> 224 | 225 | Do: 226 | ff>daea 232 | Expect: 233 | 234 | 235 | -------------------------------------------------------------------------------- /tests/expression-nestedfurther-spec.vader: -------------------------------------------------------------------------------- 1 | " Given: ((??foo(bar)??)) {{{1 2 | Given: 3 | ((((foo(bar))))) 4 | Do: 5 | fbdieb 6 | Expect: 7 | (((()))) 8 | 9 | Given: 10 | (({{foo(bar)}})) 11 | Do: 12 | fbdieb 13 | Expect: 14 | (({{}})) 15 | 16 | Given: 17 | (([[foo(bar)]])) 18 | Do: 19 | fbdieb 20 | Expect: 21 | (([[]])) 22 | 23 | Given: 24 | ((<>)) 25 | Do: 26 | fbdieb 27 | Expect: 28 | ((<<>>)) 29 | -------------------------------------------------------------------------------- /tests/expression-whitespace-spec.vader: -------------------------------------------------------------------------------- 1 | " Using die {{{1 2 | " {{{2 Given: 3 | Given: 4 | xyz foo(bar) 5 | 6 | Do: 7 | dieb 8 | Expect: 9 | xyz foo(bar) 10 | 11 | Do: 12 | fbdieb 13 | Expect: 14 | xyz 15 | 16 | Do: 17 | f(dieb 18 | Expect: 19 | xyz 20 | 21 | Do: 22 | f)dieb 23 | Expect: 24 | xyz 25 | 26 | " {{{2 Given: 27 | Given: 28 | xyz foo{bar} 29 | 30 | Do: 31 | dieB 32 | Expect: 33 | xyz foo{bar} 34 | 35 | Do: 36 | fbdieB 37 | Expect: 38 | xyz 39 | 40 | Do: 41 | f{dieB 42 | Expect: 43 | xyz 44 | 45 | Do: 46 | f}dieB 47 | Expect: 48 | xyz 49 | 50 | " {{{2 Given: 51 | Given: 52 | xyz foo[bar] 53 | 54 | Do: 55 | dier 56 | Expect: 57 | xyz foo[bar] 58 | 59 | Do: 60 | fbdier 61 | Expect: 62 | xyz 63 | 64 | Do: 65 | f[dier 66 | Expect: 67 | xyz 68 | 69 | Do: 70 | f]dier 71 | Expect: 72 | xyz 73 | 74 | " {{{2 Given: 75 | Given: 76 | xyz foo 77 | 78 | Do: 79 | diea 80 | Expect: 81 | xyz foo 82 | 83 | Do: 84 | fbdiea 85 | Expect: 86 | xyz 87 | 88 | Do: 89 | fdiea 95 | Expect: 96 | xyz 97 | 98 | " {{{1 Using dae 99 | " {{{2 Given: 100 | Given: 101 | xyz foo(bar) 102 | 103 | Do: 104 | daeb 105 | Expect: 106 | 107 | 108 | Do: 109 | fbdaeb 110 | Expect: 111 | 112 | 113 | Do: 114 | f(daeb 115 | Expect: 116 | 117 | 118 | Do: 119 | f)daeb 120 | Expect: 121 | 122 | 123 | " {{{2 Given: 124 | Given: 125 | xyz foo{bar} 126 | 127 | Do: 128 | daeB 129 | Expect: 130 | 131 | 132 | Do: 133 | fbdaeB 134 | Expect: 135 | 136 | 137 | Do: 138 | f{daeB 139 | Expect: 140 | 141 | 142 | Do: 143 | f}daeB 144 | Expect: 145 | 146 | 147 | " {{{2 Given: 148 | Given: 149 | xyz foo[bar] 150 | 151 | Do: 152 | daer 153 | Expect: 154 | 155 | 156 | Do: 157 | fbdaer 158 | Expect: 159 | 160 | 161 | Do: 162 | f[daer 163 | Expect: 164 | 165 | 166 | Do: 167 | f]daer 168 | Expect: 169 | 170 | 171 | " {{{2 Given: 172 | Given: 173 | xyz foo 174 | 175 | Do: 176 | daea 177 | Expect: 178 | 179 | 180 | Do: 181 | fbdaea 182 | Expect: 183 | 184 | 185 | Do: 186 | fdaea 192 | Expect: 193 | 194 | 195 | -------------------------------------------------------------------------------- /tests/field-indented-af-spec.vader: -------------------------------------------------------------------------------- 1 | " dafb with two line {{{1 2 | Given: 3 | foo(bar, arg, 4 | xyz) 5 | 6 | Do: 7 | dafb 8 | Expect: 9 | foo(bar, arg, 10 | xyz) 11 | 12 | Do: 13 | fbdafb 14 | Expect: 15 | foo(arg, 16 | xyz) 17 | 18 | Do: 19 | fbdafbdafb 20 | Expect: 21 | foo(xyz) 22 | 23 | Do: 24 | 2fadafb 25 | Expect: 26 | foo(bar, 27 | xyz) 28 | 29 | Do: 30 | jfxdafb 31 | Expect: 32 | foo(bar, arg) 33 | 34 | " dafB with two line {{{1 35 | Given: 36 | foo{bar, arg, 37 | xyz} 38 | 39 | Do: 40 | dafB 41 | Expect: 42 | foo{bar, arg, 43 | xyz} 44 | 45 | Do: 46 | fbdafB 47 | Expect: 48 | foo{arg, 49 | xyz} 50 | 51 | Do: 52 | fbdafBdafB 53 | Expect: 54 | foo{xyz} 55 | 56 | Do: 57 | 2fadafB 58 | Expect: 59 | foo{bar, 60 | xyz} 61 | 62 | Do: 63 | jfxdafB 64 | Expect: 65 | foo{bar, arg} 66 | 67 | " dafr with two line {{{1 68 | Given: 69 | foo[bar, arg, 70 | xyz] 71 | 72 | Do: 73 | dafr 74 | Expect: 75 | foo[bar, arg, 76 | xyz] 77 | 78 | Do: 79 | fbdafr 80 | Expect: 81 | foo[arg, 82 | xyz] 83 | 84 | Do: 85 | fbdafrdafr 86 | Expect: 87 | foo[xyz] 88 | 89 | Do: 90 | 2fadafr 91 | Expect: 92 | foo[bar, 93 | xyz] 94 | 95 | Do: 96 | jfxdafr 97 | Expect: 98 | foo[bar, arg] 99 | 100 | " dafa with two line {{{1 101 | Given: 102 | foo 104 | 105 | Do: 106 | dafa 107 | Expect: 108 | foo 110 | 111 | Do: 112 | fbdafa 113 | Expect: 114 | foo 116 | 117 | Do: 118 | fbdafadafa 119 | Expect: 120 | foo 121 | 122 | Do: 123 | 2fadafa 124 | Expect: 125 | foo 127 | 128 | Do: 129 | jfxdafa 130 | Expect: 131 | foo 132 | 133 | " dafb with two line {{{1 134 | Given: 135 | foo(bar, arg, 136 | xyz), g(hello, world) 137 | 138 | Do: 139 | dafb 140 | Expect: 141 | foo(bar, arg, 142 | xyz), g(hello, world) 143 | 144 | Do: 145 | fbdafb 146 | Expect: 147 | foo(arg, 148 | xyz), g(hello, world) 149 | 150 | Do: 151 | fbdafbdafb 152 | Expect: 153 | foo(xyz), g(hello, world) 154 | 155 | Do: 156 | 2fadafb 157 | Expect: 158 | foo(bar, 159 | xyz), g(hello, world) 160 | 161 | Do: 162 | jfxdafb 163 | Expect: 164 | foo(bar, arg), g(hello, world) 165 | 166 | -------------------------------------------------------------------------------- /tests/field-indented-if-spec.vader: -------------------------------------------------------------------------------- 1 | " difb with two line {{{1 2 | Given: 3 | foo(bar, arg, 4 | xyz) 5 | 6 | Do: 7 | difb 8 | Expect: 9 | foo(bar, arg, 10 | xyz) 11 | 12 | Do: 13 | fbdifb 14 | Expect: 15 | foo(, arg, 16 | xyz) 17 | 18 | Do: 19 | 2fadifb 20 | Expect: 21 | foo(bar, , 22 | xyz) 23 | 24 | Do: 25 | jfxdifb 26 | Expect: 27 | foo(bar, arg, 28 | ) 29 | 30 | " difB with two line {{{1 31 | Given: 32 | foo{bar, arg, 33 | xyz} 34 | 35 | Do: 36 | difB 37 | Expect: 38 | foo{bar, arg, 39 | xyz} 40 | 41 | Do: 42 | fbdifB 43 | Expect: 44 | foo{, arg, 45 | xyz} 46 | 47 | Do: 48 | 2fadifB 49 | Expect: 50 | foo{bar, , 51 | xyz} 52 | 53 | Do: 54 | jfxdifB 55 | Expect: 56 | foo{bar, arg, 57 | } 58 | 59 | " difr with two line {{{1 60 | Given: 61 | foo[bar, arg, 62 | xyz] 63 | 64 | Do: 65 | difr 66 | Expect: 67 | foo[bar, arg, 68 | xyz] 69 | 70 | Do: 71 | fbdifr 72 | Expect: 73 | foo[, arg, 74 | xyz] 75 | 76 | Do: 77 | 2fadifr 78 | Expect: 79 | foo[bar, , 80 | xyz] 81 | 82 | Do: 83 | jfxdifr 84 | Expect: 85 | foo[bar, arg, 86 | ] 87 | 88 | " difa with two line {{{1 89 | Given: 90 | foo 92 | 93 | Do: 94 | difa 95 | Expect: 96 | foo 98 | 99 | Do: 100 | fbdifa 101 | Expect: 102 | foo<, arg, 103 | xyz> 104 | 105 | Do: 106 | 2fadifa 107 | Expect: 108 | foo 110 | 111 | Do: 112 | jfxdifa 113 | Expect: 114 | foo 116 | -------------------------------------------------------------------------------- /tests/field-leading-af-spec.vader: -------------------------------------------------------------------------------- 1 | " dafb {{{1 2 | Given: 3 | foo( bar 4 | , arg 5 | , xyz 6 | ) 7 | 8 | Do: 9 | dafb 10 | Expect: 11 | foo( bar 12 | , arg 13 | , xyz 14 | ) 15 | 16 | Do: 17 | fbdafb 18 | Expect: 19 | foo( arg 20 | , xyz 21 | ) 22 | 23 | Do: 24 | fbdafbdafb 25 | Expect: 26 | foo( xyz 27 | ) 28 | 29 | Do: 30 | jfadafb 31 | Expect: 32 | foo( bar 33 | , xyz 34 | ) 35 | 36 | Do: 37 | jjfxdafb 38 | Expect: 39 | foo( bar 40 | , arg 41 | ) 42 | 43 | " dafB {{{1 44 | Given: 45 | foo{ bar 46 | , arg 47 | , xyz 48 | } 49 | 50 | Do: 51 | dafB 52 | Expect: 53 | foo{ bar 54 | , arg 55 | , xyz 56 | } 57 | 58 | Do: 59 | fbdafB 60 | Expect: 61 | foo{ arg 62 | , xyz 63 | } 64 | 65 | Do: 66 | fbdafBdafB 67 | Expect: 68 | foo{ xyz 69 | } 70 | 71 | Do: 72 | jfadafB 73 | Expect: 74 | foo{ bar 75 | , xyz 76 | } 77 | 78 | Do: 79 | jjfxdafB 80 | Expect: 81 | foo{ bar 82 | , arg 83 | } 84 | 85 | " dafr {{{1 86 | Given: 87 | foo[ bar 88 | , arg 89 | , xyz 90 | ] 91 | 92 | Do: 93 | dafr 94 | Expect: 95 | foo[ bar 96 | , arg 97 | , xyz 98 | ] 99 | 100 | Do: 101 | fbdafr 102 | Expect: 103 | foo[ arg 104 | , xyz 105 | ] 106 | 107 | Do: 108 | fbdafrdafr 109 | Expect: 110 | foo[ xyz 111 | ] 112 | 113 | Do: 114 | jfadafr 115 | Expect: 116 | foo[ bar 117 | , xyz 118 | ] 119 | 120 | Do: 121 | jjfxdafr 122 | Expect: 123 | foo[ bar 124 | , arg 125 | ] 126 | 127 | " dafa {{{1 128 | Given: 129 | foo< bar 130 | , arg 131 | , xyz 132 | > 133 | 134 | Do: 135 | dafa 136 | Expect: 137 | foo< bar 138 | , arg 139 | , xyz 140 | > 141 | 142 | Do: 143 | fbdafa 144 | Expect: 145 | foo< arg 146 | , xyz 147 | > 148 | 149 | Do: 150 | fbdafadafa 151 | Expect: 152 | foo< xyz 153 | > 154 | 155 | Do: 156 | jfadafa 157 | Expect: 158 | foo< bar 159 | , xyz 160 | > 161 | 162 | Do: 163 | jjfxdafa 164 | Expect: 165 | foo< bar 166 | , arg 167 | > 168 | -------------------------------------------------------------------------------- /tests/field-leading-if-spec.vader: -------------------------------------------------------------------------------- 1 | " difb {{{1 2 | Given: 3 | foo( bar 4 | , arg 5 | , xyz 6 | ) 7 | 8 | Do: 9 | difb 10 | Expect: 11 | foo( bar 12 | , arg 13 | , xyz 14 | ) 15 | 16 | Do: 17 | fbdifb 18 | Expect: 19 | foo( 20 | , arg 21 | , xyz 22 | ) 23 | 24 | Do: 25 | jfadifb 26 | Expect: 27 | foo( bar 28 | , 29 | , xyz 30 | ) 31 | 32 | Do: 33 | jjfxdifb 34 | Expect: 35 | foo( bar 36 | , arg 37 | , 38 | ) 39 | 40 | " difB {{{1 41 | Given: 42 | foo{ bar 43 | , arg 44 | , xyz 45 | } 46 | 47 | Do: 48 | difB 49 | Expect: 50 | foo{ bar 51 | , arg 52 | , xyz 53 | } 54 | 55 | Do: 56 | fbdifB 57 | Expect: 58 | foo{ 59 | , arg 60 | , xyz 61 | } 62 | 63 | Do: 64 | jfadifB 65 | Expect: 66 | foo{ bar 67 | , 68 | , xyz 69 | } 70 | 71 | Do: 72 | jjfxdifB 73 | Expect: 74 | foo{ bar 75 | , arg 76 | , 77 | } 78 | 79 | " difr {{{1 80 | Given: 81 | foo[ bar 82 | , arg 83 | , xyz 84 | ] 85 | 86 | Do: 87 | difr 88 | Expect: 89 | foo[ bar 90 | , arg 91 | , xyz 92 | ] 93 | 94 | Do: 95 | fbdifr 96 | Expect: 97 | foo[ 98 | , arg 99 | , xyz 100 | ] 101 | 102 | Do: 103 | jfadifr 104 | Expect: 105 | foo[ bar 106 | , 107 | , xyz 108 | ] 109 | 110 | Do: 111 | jjfxdifr 112 | Expect: 113 | foo[ bar 114 | , arg 115 | , 116 | ] 117 | 118 | " difa {{{1 119 | Given: 120 | foo< bar 121 | , arg 122 | , xyz 123 | > 124 | 125 | Do: 126 | difa 127 | Expect: 128 | foo< bar 129 | , arg 130 | , xyz 131 | > 132 | 133 | Do: 134 | fbdifa 135 | Expect: 136 | foo< 137 | , arg 138 | , xyz 139 | > 140 | 141 | Do: 142 | jfadifa 143 | Expect: 144 | foo< bar 145 | , 146 | , xyz 147 | > 148 | 149 | Do: 150 | jjfxdifa 151 | Expect: 152 | foo< bar 153 | , arg 154 | , 155 | > 156 | -------------------------------------------------------------------------------- /tests/field-short-af-spec.vader: -------------------------------------------------------------------------------- 1 | " Short style field spec with af commmands {{{1 2 | " dafb with doc foo(bar) {{{2 3 | Given: 4 | foo(bar, arg, xyz) 5 | 6 | Do: 7 | dafb 8 | Expect: 9 | foo(bar, arg, xyz) 10 | 11 | Do: 12 | fbdafb 13 | Expect: 14 | foo(arg, xyz) 15 | 16 | Do: 17 | 2fadafb 18 | Expect: 19 | foo(bar, xyz) 20 | 21 | Do: 22 | fxdafb 23 | Expect: 24 | foo(bar, arg) 25 | 26 | " dafB with doc foo(bar) {{{2 27 | Given: 28 | foo{bar, arg, xyz} 29 | 30 | Do: 31 | dafB 32 | Expect: 33 | foo{bar, arg, xyz} 34 | 35 | Do: 36 | fbdafB 37 | Expect: 38 | foo{arg, xyz} 39 | 40 | Do: 41 | 2fadafB 42 | Expect: 43 | foo{bar, xyz} 44 | 45 | Do: 46 | fxdafB 47 | Expect: 48 | foo{bar, arg} 49 | 50 | " dafr with doc foo(bar) {{{2 51 | Given: 52 | foo[bar, arg, xyz] 53 | 54 | Do: 55 | dafr 56 | Expect: 57 | foo[bar, arg, xyz] 58 | 59 | Do: 60 | fbdafr 61 | Expect: 62 | foo[arg, xyz] 63 | 64 | Do: 65 | 2fadafr 66 | Expect: 67 | foo[bar, xyz] 68 | 69 | Do: 70 | fxdafr 71 | Expect: 72 | foo[bar, arg] 73 | 74 | " dafa with doc foo(bar) {{{2 75 | Given: 76 | foo 77 | 78 | Do: 79 | dafa 80 | Expect: 81 | foo 82 | 83 | Do: 84 | fbdafa 85 | Expect: 86 | foo 87 | 88 | Do: 89 | 2fadafa 90 | Expect: 91 | foo 92 | 93 | Do: 94 | fxdafa 95 | Expect: 96 | foo 97 | -------------------------------------------------------------------------------- /tests/field-short-if-spec.vader: -------------------------------------------------------------------------------- 1 | " field short style spec with dif commands {{{1 2 | " difb with doc foo(bar) {{{2 3 | Given: 4 | foo(bar, arg, xyz) 5 | 6 | Do: 7 | difb 8 | Expect: 9 | foo(bar, arg, xyz) 10 | 11 | Do: 12 | fbdifb 13 | Expect: 14 | foo(, arg, xyz) 15 | 16 | Do: 17 | 2fadifb 18 | Expect: 19 | foo(bar, , xyz) 20 | 21 | Do: 22 | fxdifb 23 | Expect: 24 | foo(bar, arg, ) 25 | 26 | " difB with doc foo(bar) {{{2 27 | Given: 28 | foo{bar, arg, xyz} 29 | 30 | Do: 31 | difB 32 | Expect: 33 | foo{bar, arg, xyz} 34 | 35 | Do: 36 | fbdifB 37 | Expect: 38 | foo{, arg, xyz} 39 | 40 | Do: 41 | 2fadifB 42 | Expect: 43 | foo{bar, , xyz} 44 | 45 | Do: 46 | fxdifB 47 | Expect: 48 | foo{bar, arg, } 49 | 50 | " difr with doc foo(bar) {{{2 51 | Given: 52 | foo[bar, arg, xyz] 53 | 54 | Do: 55 | difr 56 | Expect: 57 | foo[bar, arg, xyz] 58 | 59 | Do: 60 | fbdifr 61 | Expect: 62 | foo[, arg, xyz] 63 | 64 | Do: 65 | 2fadifr 66 | Expect: 67 | foo[bar, , xyz] 68 | 69 | Do: 70 | fxdifr 71 | Expect: 72 | foo[bar, arg, ] 73 | 74 | " difa with doc foo(bar) {{{2 75 | Given: 76 | foo 77 | 78 | Do: 79 | difa 80 | Expect: 81 | foo 82 | 83 | Do: 84 | fbdifa 85 | Expect: 86 | foo<, arg, xyz> 87 | 88 | Do: 89 | 2fadifa 90 | Expect: 91 | foo 92 | 93 | Do: 94 | fxdifa 95 | Expect: 96 | foo 97 | 98 | -------------------------------------------------------------------------------- /tests/field-trailing-af-spec.vader: -------------------------------------------------------------------------------- 1 | " dafb without last trailing comma {{{2 2 | Given: 3 | foo( 4 | bar, 5 | arg, 6 | xyz 7 | ) 8 | 9 | Do: 10 | dafb 11 | Expect: 12 | foo( 13 | bar, 14 | arg, 15 | xyz 16 | ) 17 | 18 | Do: 19 | jfbdafb 20 | Expect: 21 | foo( 22 | arg, 23 | xyz 24 | ) 25 | 26 | Do: 27 | jfbdafbdafb 28 | Expect: 29 | foo( 30 | xyz 31 | ) 32 | 33 | Do: 34 | jjfadafb 35 | Expect: 36 | foo( 37 | bar, 38 | xyz 39 | ) 40 | 41 | Do: 42 | jjjfxdafb 43 | Expect: 44 | foo( 45 | bar, 46 | arg 47 | ) 48 | 49 | " dafB without last trailing comma {{{2 50 | Given: 51 | foo{ 52 | bar, 53 | arg, 54 | xyz 55 | } 56 | 57 | Do: 58 | dafB 59 | Expect: 60 | foo{ 61 | bar, 62 | arg, 63 | xyz 64 | } 65 | 66 | Do: 67 | jfbdafB 68 | Expect: 69 | foo{ 70 | arg, 71 | xyz 72 | } 73 | 74 | Do: 75 | jfbdafBdafB 76 | Expect: 77 | foo{ 78 | xyz 79 | } 80 | 81 | Do: 82 | jjfadafB 83 | Expect: 84 | foo{ 85 | bar, 86 | xyz 87 | } 88 | 89 | Do: 90 | jjjfxdafB 91 | Expect: 92 | foo{ 93 | bar, 94 | arg 95 | } 96 | 97 | " dafr without last trailing comma {{{2 98 | Given: 99 | foo[ 100 | bar, 101 | arg, 102 | xyz 103 | ] 104 | 105 | Do: 106 | dafr 107 | Expect: 108 | foo[ 109 | bar, 110 | arg, 111 | xyz 112 | ] 113 | 114 | Do: 115 | jfbdafr 116 | Expect: 117 | foo[ 118 | arg, 119 | xyz 120 | ] 121 | 122 | Do: 123 | jfbdafrdafr 124 | Expect: 125 | foo[ 126 | xyz 127 | ] 128 | 129 | Do: 130 | jjfadafr 131 | Expect: 132 | foo[ 133 | bar, 134 | xyz 135 | ] 136 | 137 | Do: 138 | jjjfxdafr 139 | Expect: 140 | foo[ 141 | bar, 142 | arg 143 | ] 144 | 145 | " dafa without last trailing comma {{{2 146 | Given: 147 | foo< 148 | bar, 149 | arg, 150 | xyz 151 | > 152 | 153 | Do: 154 | dafa 155 | Expect: 156 | foo< 157 | bar, 158 | arg, 159 | xyz 160 | > 161 | 162 | Do: 163 | jfbdafa 164 | Expect: 165 | foo< 166 | arg, 167 | xyz 168 | > 169 | 170 | Do: 171 | jfbdafadafa 172 | Expect: 173 | foo< 174 | xyz 175 | > 176 | 177 | Do: 178 | jjfadafa 179 | Expect: 180 | foo< 181 | bar, 182 | xyz 183 | > 184 | 185 | Do: 186 | jjjfxdafa 187 | Expect: 188 | foo< 189 | bar, 190 | arg 191 | > 192 | -------------------------------------------------------------------------------- /tests/field-trailing-if-spec.vader: -------------------------------------------------------------------------------- 1 | " difb without last trailing comma {{{2 2 | Given: 3 | foo( 4 | bar, 5 | arg, 6 | xyz 7 | ) 8 | 9 | Do: 10 | difb 11 | Expect: 12 | foo( 13 | bar, 14 | arg, 15 | xyz 16 | ) 17 | 18 | Do: 19 | jfbdifb 20 | Expect: 21 | foo( 22 | , 23 | arg, 24 | xyz 25 | ) 26 | 27 | Do: 28 | jjfadifb 29 | Expect: 30 | foo( 31 | bar, 32 | , 33 | xyz 34 | ) 35 | 36 | Do: 37 | jjjfxdifb 38 | Expect: 39 | foo( 40 | bar, 41 | arg, 42 | 43 | ) 44 | 45 | 46 | 47 | " difr without last trailing comma {{{2 48 | Given: 49 | foo[ 50 | bar, 51 | arg, 52 | xyz 53 | ] 54 | 55 | Do: 56 | difr 57 | Expect: 58 | foo[ 59 | bar, 60 | arg, 61 | xyz 62 | ] 63 | 64 | Do: 65 | jfbdifr 66 | Expect: 67 | foo[ 68 | , 69 | arg, 70 | xyz 71 | ] 72 | 73 | Do: 74 | jjfadifr 75 | Expect: 76 | foo[ 77 | bar, 78 | , 79 | xyz 80 | ] 81 | 82 | Do: 83 | jjjfxdifr 84 | Expect: 85 | foo[ 86 | bar, 87 | arg, 88 | 89 | ] 90 | -------------------------------------------------------------------------------- /tests/indent-block-spec.vader: -------------------------------------------------------------------------------- 1 | " iib aib 2 | Given: 3 | prevline(); 4 | 5 | int main(void) { 6 | 7 | hello(); 8 | world(); 9 | 10 | how(); 11 | are(); 12 | 13 | you(); 14 | } 15 | 16 | 17 | nextline(); 18 | 19 | Before: 20 | call search('world') 21 | 22 | Do: 23 | diib 24 | Expect: 25 | prevline(); 26 | 27 | 28 | 29 | nextline(); 30 | 31 | 32 | Do: 33 | daib 34 | Expect: 35 | prevline(); 36 | nextline(); 37 | 38 | Before: 39 | call search('world') 40 | 41 | Do: 42 | diib 43 | Expect: 44 | prevline(); 45 | 46 | 47 | 48 | nextline(); 49 | 50 | 51 | Do: 52 | daib 53 | Expect: 54 | prevline(); 55 | nextline(); 56 | -------------------------------------------------------------------------------- /tests/indent-level-spec.vader: -------------------------------------------------------------------------------- 1 | " iil ail 2 | Given: 3 | if and only if (cond1() == True and cond2() == True and 4 | cond2() == True and cond3() == True) 5 | 6 | hello(); 7 | 8 | world(); 9 | how(); 10 | 11 | are(); 12 | you(); 13 | 14 | 15 | nextline() 16 | 17 | Before: 18 | call search('hello') 19 | 20 | Do: 21 | diil 22 | Expect: 23 | if and only if (cond1() == True and cond2() == True and 24 | cond2() == True and cond3() == True) 25 | 26 | 27 | 28 | nextline() 29 | 30 | 31 | Do: 32 | dail 33 | Expect: 34 | if and only if (cond1() == True and cond2() == True and 35 | cond2() == True and cond3() == True) 36 | nextline() 37 | 38 | Before: 39 | call search('hello') 40 | 41 | Do: 42 | diil 43 | Expect: 44 | if and only if (cond1() == True and cond2() == True and 45 | cond2() == True and cond3() == True) 46 | 47 | 48 | 49 | nextline() 50 | 51 | 52 | Do: 53 | dail 54 | Expect: 55 | if and only if (cond1() == True and cond2() == True and 56 | cond2() == True and cond3() == True) 57 | nextline() 58 | -------------------------------------------------------------------------------- /tests/indent-paragraph-spec.vader: -------------------------------------------------------------------------------- 1 | " iip aip motions {{{1 2 | Given: 3 | arg 4 | 5 | abc 6 | foo 7 | bar 8 | baz 9 | foo 10 | Before: 11 | call search('baz') 12 | 13 | Do: 14 | diip 15 | Expect: 16 | arg 17 | 18 | abc 19 | foo 20 | foo 21 | 22 | Do: 23 | daip 24 | Expect: 25 | arg 26 | 27 | abc 28 | foo 29 | foo 30 | 31 | 32 | " iip aip with longer text starting at inner1 {{{1 33 | Given: 34 | if (cond) { 35 | foo; 36 | bar; 37 | 38 | line3; 39 | line4; 40 | 41 | { 42 | inner1; 43 | inner2; 44 | 45 | inner3; 46 | inner4; 47 | }; 48 | 49 | arg; 50 | baz; 51 | } 52 | 53 | Before: 54 | /inner1 55 | 56 | Do: 57 | diip 58 | Expect: 59 | if (cond) { 60 | foo; 61 | bar; 62 | 63 | line3; 64 | line4; 65 | 66 | { 67 | 68 | inner3; 69 | inner4; 70 | }; 71 | 72 | arg; 73 | baz; 74 | } 75 | 76 | Do: 77 | d2iip 78 | Expect: 79 | if (cond) { 80 | foo; 81 | bar; 82 | 83 | line3; 84 | line4; 85 | 86 | { 87 | inner3; 88 | inner4; 89 | }; 90 | 91 | arg; 92 | baz; 93 | } 94 | 95 | 96 | Do: 97 | d4iip 98 | Expect: 99 | if (cond) { 100 | foo; 101 | bar; 102 | 103 | line3; 104 | line4; 105 | 106 | { 107 | }; 108 | 109 | arg; 110 | baz; 111 | } 112 | 113 | 114 | Do: 115 | d6iip 116 | Expect: 117 | if (cond) { 118 | foo; 119 | bar; 120 | 121 | line3; 122 | line4; 123 | 124 | { 125 | }; 126 | 127 | arg; 128 | baz; 129 | } 130 | 131 | 132 | Do: 133 | daip 134 | Expect: 135 | if (cond) { 136 | foo; 137 | bar; 138 | 139 | line3; 140 | line4; 141 | 142 | { 143 | inner3; 144 | inner4; 145 | }; 146 | 147 | arg; 148 | baz; 149 | } 150 | 151 | 152 | Do: 153 | d2aip 154 | Expect: 155 | if (cond) { 156 | foo; 157 | bar; 158 | 159 | line3; 160 | line4; 161 | 162 | { 163 | }; 164 | 165 | arg; 166 | baz; 167 | } 168 | 169 | Do: 170 | d4aip 171 | Expect: 172 | if (cond) { 173 | foo; 174 | bar; 175 | 176 | line3; 177 | line4; 178 | 179 | { 180 | }; 181 | 182 | arg; 183 | baz; 184 | } 185 | 186 | " iip aip with longer text starting at inner1 {{{1 187 | Before: 188 | call search('inner3') 189 | 190 | Do: 191 | diip 192 | Expect: 193 | if (cond) { 194 | foo; 195 | bar; 196 | 197 | line3; 198 | line4; 199 | 200 | { 201 | inner1; 202 | inner2; 203 | 204 | }; 205 | 206 | arg; 207 | baz; 208 | } 209 | 210 | Do: 211 | d2iip 212 | Expect: 213 | if (cond) { 214 | foo; 215 | bar; 216 | 217 | line3; 218 | line4; 219 | 220 | { 221 | inner1; 222 | inner2; 223 | 224 | }; 225 | 226 | arg; 227 | baz; 228 | } 229 | 230 | Do: 231 | daip 232 | Expect: 233 | if (cond) { 234 | foo; 235 | bar; 236 | 237 | line3; 238 | line4; 239 | 240 | { 241 | inner1; 242 | inner2; 243 | 244 | }; 245 | 246 | arg; 247 | baz; 248 | } 249 | 250 | Do: 251 | d2aip 252 | Expect: 253 | if (cond) { 254 | foo; 255 | bar; 256 | 257 | line3; 258 | line4; 259 | 260 | { 261 | inner1; 262 | inner2; 263 | 264 | }; 265 | 266 | arg; 267 | baz; 268 | } 269 | 270 | " iip aip aip with lines filled with blank characters {{{1 271 | Given: 272 | { 273 | inner1; 274 | inner2; 275 | 276 | inner3; 277 | inner4; 278 | 279 | inner5; 280 | inner6; 281 | }; 282 | 283 | Before: 284 | normal! jjj 285 | 286 | Do: 287 | diip 288 | Expect: 289 | { 290 | inner1; 291 | inner2; 292 | inner3; 293 | inner4; 294 | 295 | inner5; 296 | inner6; 297 | }; 298 | Do: 299 | d2iip 300 | Expect: 301 | { 302 | inner1; 303 | inner2; 304 | 305 | inner5; 306 | inner6; 307 | }; 308 | 309 | Do: 310 | d4iip 311 | Expect: 312 | { 313 | inner1; 314 | inner2; 315 | }; 316 | 317 | Do: 318 | daip 319 | Expect: 320 | { 321 | inner1; 322 | inner2; 323 | 324 | inner5; 325 | inner6; 326 | }; 327 | 328 | Do: 329 | d2aip 330 | Expect: 331 | { 332 | inner1; 333 | inner2; 334 | }; 335 | -------------------------------------------------------------------------------- /tests/indent-top-spec.vader: -------------------------------------------------------------------------------- 1 | " iit ait 2 | Given: 3 | prevline() 4 | 5 | if and only if (cond1() == True and cond2() == True and 6 | cond2() == True and cond3() == True) 7 | 8 | hello(); 9 | 10 | world(); 11 | how(); 12 | 13 | are(); 14 | you(); 15 | 16 | 17 | nextline() 18 | 19 | Before: 20 | call search('hello') 21 | 22 | Do: 23 | diit 24 | Expect: 25 | prevline() 26 | 27 | 28 | 29 | nextline() 30 | 31 | 32 | Do: 33 | dait 34 | Expect: 35 | prevline() 36 | nextline() 37 | 38 | Before: 39 | call search('hello') 40 | 41 | Do: 42 | diit 43 | Expect: 44 | prevline() 45 | 46 | 47 | 48 | nextline() 49 | 50 | 51 | Do: 52 | dait 53 | Expect: 54 | prevline() 55 | nextline() 56 | -------------------------------------------------------------------------------- /tests/symbol-all-spec.vader: -------------------------------------------------------------------------------- 1 | Given: 2 | foo|bar| 3 | 4 | Do: 5 | fbdi| 6 | 7 | Expect: 8 | foo|| 9 | -------------------------------------------------------------------------------- /tests/symbol-percent-spec.vader: -------------------------------------------------------------------------------- 1 | " " % percent {{{1 2 | " " doc: doo%bar%xyz {{{2 3 | " Given: 4 | " foo%bar%xyz 5 | 6 | " " start at f {{{3 7 | " Do: 8 | " di% 9 | " Expect: 10 | " foo%%xyz 11 | 12 | " Do: 13 | " da% 14 | " Expect: 15 | " fooxyz 16 | 17 | " " start at b {{{3 18 | " Do: 19 | " fbdi% 20 | " Expect: 21 | " foo%%xyz 22 | 23 | " Do: 24 | " fbda% 25 | " Expect: 26 | " fooxyz 27 | 28 | " " start at x {{{3 29 | " Do: 30 | " fxdi% 31 | " Expect: 32 | " foo%bar%xyz 33 | 34 | " Do: 35 | " fxda% 36 | " Expect: 37 | " foo%bar%xyz 38 | 39 | " " doc: %foo\nbar% {{{2 40 | " Given: 41 | " %foo 42 | " bar% 43 | 44 | " " start at f {{{3 45 | " Do: 46 | " ffdi% 47 | " Expect: 48 | " %foo 49 | " bar% 50 | 51 | " Do: 52 | " ffda% 53 | " Expect: 54 | " %foo 55 | " bar% 56 | 57 | " " start b {{{3 58 | " Do: 59 | " +di% 60 | " Expect: 61 | " %foo 62 | " bar% 63 | 64 | " Do: 65 | " +da% 66 | " Expect: 67 | " %foo 68 | " bar% 69 | 70 | " " doc: foo%%foobar%% {{{2 71 | " Given: 72 | " foo%%foobar%% 73 | 74 | " " start at b {{{3 75 | " Do: 76 | " fbdi% 77 | " Expect: 78 | " foo%%%% 79 | 80 | " Do: 81 | " fbdi%di% 82 | " Expect: 83 | " foo%%%% 84 | 85 | " Do: 86 | " fbda% 87 | " Expect: 88 | " foo%% 89 | 90 | " Do: 91 | " fbda%da% 92 | " Expect: 93 | " foo 94 | 95 | " Do: 96 | " fbyi%x 97 | " Expect: 98 | " foo%%oobar%% 99 | 100 | " Do: 101 | " fbya%x 102 | " Expect: 103 | " foo%foobar%% 104 | 105 | " Do: 106 | " fbvi%d 107 | " Expect: 108 | " foo%%%% 109 | 110 | " Do: 111 | " fbva%d 112 | " Expect: 113 | " foo%% 114 | 115 | " Do: 116 | " fbva%a%d 117 | " Expect: 118 | " foo 119 | 120 | " " doc: foo%%b%% {{{2 121 | " Given: 122 | " foo%%b%% 123 | 124 | " " start at b 125 | " Do: 126 | " fbdi% 127 | " Expect: 128 | " foo%%%% 129 | 130 | " Do: 131 | " fbdi%di% 132 | " Expect: 133 | " foo%%%% 134 | 135 | " Do: 136 | " fbda% 137 | " Expect: 138 | " foo%% 139 | 140 | " Do: 141 | " fbda%da% 142 | " Expect: 143 | " foo 144 | 145 | " Do: 146 | " fbyi%x 147 | " Expect: 148 | " foo%%%% 149 | 150 | " Do: 151 | " fbya%x 152 | " Expect: 153 | " foo%b%% 154 | 155 | " Do: 156 | " fbvi%d 157 | " Expect: 158 | " foo%%%% 159 | 160 | " Do: 161 | " fbva%d 162 | " Expect: 163 | " foo%% 164 | 165 | " Do: 166 | " fbvi%i%d 167 | " Expect: 168 | " foo%%%% 169 | 170 | " Do: 171 | " fbva%a%d 172 | " Expect: 173 | " foo 174 | -------------------------------------------------------------------------------- /tests/vimrc-test.vim: -------------------------------------------------------------------------------- 1 | set nocompatible 2 | filetype off 3 | 4 | set rtp+=~/.vim/plugged/vader.vim 5 | set rtp+=~/.vim/plugged/vim-airline 6 | set rtp+=~/build/hgiesel/vim-motion-sickness 7 | set rtp+=. 8 | 9 | set matchpairs+=<:> 10 | 11 | filetype plugin indent on 12 | syntax enable 13 | --------------------------------------------------------------------------------