File: plugin.vim

package info (click to toggle)
vim-textobj-user 0.7.6-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 208 kB
  • sloc: makefile: 2
file content (65 lines) | stat: -rw-r--r-- 1,962 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
call textobj#user#plugin('fruit', {
\   'apple': {
\     '*pattern*': '\<\d\{4}\>',
\     'select': ['aa', 'ia'],
\     'move-n': 'ja',
\     'move-p': 'ka',
\   },
\   'banana': {
\     '*pattern*': ['<<', '>>'],
\     'select-a': 'ab',
\     'select-i': 'ib',
\   },
\   '-': {
\     '*select-function*': 'SelectCherry',
\     'select': ['ac', 'ic'],
\   },
\ })

function! RhsesOf(lhs)
  return map(['n', 'x', 's', 'o', 'i', 'c', 'l'],
  \          'maparg(' . string(a:lhs) . ', v:val)')
endfunction
function! StatusOf(lhs)
  return map(RhsesOf(a:lhs), 'v:val != ""')
endfunction

describe 'textobj#user#plugin'
  it 'defines default UI key mappings'
    let x = ''

    let o = '<Plug>(textobj-fruit-apple)'
    Expect RhsesOf('aa') ==# [x, o, x, o, x, x, x]
    Expect RhsesOf('ia') ==# [x, o, x, o, x, x, x]
    let o = '<Plug>(textobj-fruit-apple-n)'
    Expect RhsesOf('ja') ==# [o, o, x, o, x, x, x]
    let o = '<Plug>(textobj-fruit-apple-p)'
    Expect RhsesOf('ka') ==# [o, o, x, o, x, x, x]

    let o = '<Plug>(textobj-fruit-banana-a)'
    Expect RhsesOf('ab') ==# [x, o, x, o, x, x, x]
    let o = '<Plug>(textobj-fruit-banana-i)'
    Expect RhsesOf('ib') ==# [x, o, x, o, x, x, x]

    let o = '<Plug>(textobj-fruit)'
    Expect RhsesOf('ac') ==# [x, o, x, o, x, x, x]
    Expect RhsesOf('ic') ==# [x, o, x, o, x, x, x]
  end

  it 'defines named key mappings'
    Expect StatusOf('<Plug>(textobj-fruit-apple)') ==# [0, 1, 1, 1, 0, 0, 0]
    Expect StatusOf('<Plug>(textobj-fruit-apple-n)') ==# [1, 1, 1, 1, 0, 0, 0]
    Expect StatusOf('<Plug>(textobj-fruit-apple-p)') ==# [1, 1, 1, 1, 0, 0, 0]
    Expect StatusOf('<Plug>(textobj-fruit-banana-a)') ==# [0, 1, 1, 1, 0, 0, 0]
    Expect StatusOf('<Plug>(textobj-fruit-banana-i)') ==# [0, 1, 1, 1, 0, 0, 0]
    Expect StatusOf('<Plug>(textobj-fruit)') ==# [0, 1, 1, 1, 0, 0, 0]
  end

  it 'defines an Ex command to define default UI key mappings'
    TODO
  end

  it 'works'
    TODO
  end
end