@@ -6,68 +6,11 @@ if exists('g:loaded_textobj_variable_segment')
6
6
finish
7
7
endif
8
8
9
-
10
9
call textobj#user#plugin (' variable' , {
11
10
\ ' -' : {
12
11
\ ' sfile' : expand (' <sfile>:p' ),
13
- \ ' select-a' : ' av' , ' select-a-function' : ' s: select_a' ,
14
- \ ' select-i' : ' iv' , ' select-i-function' : ' s: select_i' ,
12
+ \ ' select-a' : ' av' , ' select-a-function' : ' textobj#variable_segment# select_a' ,
13
+ \ ' select-i' : ' iv' , ' select-i-function' : ' textobj#variable_segment# select_i' ,
15
14
\ }})
16
15
17
-
18
- function ! s: select (object_type, right_boundary)
19
- let left_boundaries = [' _\+\i' , ' \<' , ' \l\u' , ' \u\u\ze\l' , ' \a\d' , ' \d\a' ]
20
- call search (join (left_boundaries, ' \|' ), ' bce' )
21
- let start_position = getpos (' .' )
22
-
23
- call search (' \>' , ' c' )
24
- let word_end = getpos (' .' )
25
- call setpos (' .' , start_position)
26
-
27
- call search (a: right_boundary , ' c' )
28
- for _ in range (v: count1 - 1 )
29
- if getpos (' .' ) != word_end
30
- call search (a: right_boundary )
31
- endif
32
- endfor
33
- let end_position = getpos (' .' )
34
-
35
- return [' v' , start_position, end_position]
36
- endfunction
37
-
38
-
39
- function ! s: select_a ()
40
- let right_boundaries = [' _' , ' \l\u' , ' \u\u\l' , ' \a\d' , ' \d\a' , ' \i\>' ]
41
- let right_boundary = join (right_boundaries, ' \|' )
42
- let [type , start_position, end_position] = s: select (' a' , right_boundary)
43
- let [_, start_line, start_column, _] = start_position
44
-
45
- call search (' \i\>' , ' c' )
46
- if end_position == getpos (' .' ) &&
47
- \ getline (start_line)[start_column - 2 ] = ~# ' _'
48
- let start_position[2 ] -= 1
49
- endif
50
-
51
- let was_small_camel = match (expand (' <cword>' ), ' ^_*\l.*\u' ) != -1
52
- if was_small_camel
53
- call search (' \<' , ' bc' )
54
- let [_, _, word_start, _] = getpos (' .' )
55
-
56
- if start_column - 2 <= word_start ||
57
- \ getline (start_line)[:start_column - 2 ] = ~# ' ^_*$'
58
- call setpos (' .' , end_position)
59
- normal ! l ~
60
- endif
61
- endif
62
-
63
- return [type , start_position, end_position]
64
- endfunction
65
-
66
-
67
- function ! s: select_i ()
68
- let right_boundaries = [' \i_' , ' \l\u' , ' \u\u\l' , ' \a\d' , ' \d\a' , ' \i\>' ]
69
- return s: select (' i' , join (right_boundaries, ' \|' ))
70
- endfunction
71
-
72
-
73
16
let g: loaded_textobj_variable_segment = 1
0 commit comments