File tree Expand file tree Collapse file tree 3 files changed +38
-20
lines changed Expand file tree Collapse file tree 3 files changed +38
-20
lines changed Original file line number Diff line number Diff line change @@ -88,14 +88,7 @@ endfunction
88
88
89
89
" s:get_lines {{{1
90
90
function ! s: get_lines () abort
91
- let signlist = sy#util#execute (' sign place buffer=' . b: sy .buffer )
92
-
93
- let lines = []
94
- for line in split (signlist, ' \n' )[2 :]
95
- call insert (lines , matchlist (line , ' \v^\s+line\=(\d+)' )[1 ], 0 )
96
- endfor
97
-
98
- return reverse (lines )
91
+ return map (sy#util#get_signs (b: sy .buffer ), {_, val - > val.lnum})
99
92
endfunction
100
93
101
94
" s:get_levels {{{1
Original file line number Diff line number Diff line change @@ -28,24 +28,19 @@ function! sy#sign#get_current_signs(sy) abort
28
28
let a: sy .internal = {}
29
29
let a: sy .external = {}
30
30
31
- let signlist = sy#util#execute ( ' sign place buffer= ' . a: sy .buffer )
31
+ let signlist = sy#util#get_signs ( a: sy .buffer )
32
32
33
- for signline in split (signlist, ' \n' )[2 :]
34
- let tokens = matchlist (signline, ' \v^\s+\S+\=(\d+)\s+\S+\=(\d+)\s+\S+\=(.*)$' )
35
- let line = str2nr (tokens[1 ])
36
- let id = str2nr (tokens[2 ])
37
- let type = tokens[3 ]
38
-
39
- if type = ~# ' ^Signify'
33
+ for sign in signlist
34
+ if sign .name = ~# ' ^Signify'
40
35
" Handle ambiguous signs. Assume you have signs on line 3 and 4.
41
36
" Removing line 3 would lead to the second sign to be shifted up
42
37
" to line 3. Now there are still 2 signs, both one line 3.
43
- if has_key (a: sy .internal, line )
44
- execute ' sign unplace' a: sy .internal[line ].id ' buffer=' .a: sy .buffer
38
+ if has_key (a: sy .internal, sign .lnum )
39
+ execute ' sign unplace' a: sy .internal[sign .lnum ].id ' buffer=' .a: sy .buffer
45
40
endif
46
- let a: sy .internal[line ] = { ' type' : type , ' id' : id }
41
+ let a: sy .internal[sign .lnum ] = { ' type' : sign .name , ' id' : sign . id }
47
42
else
48
- let a: sy .external[line ] = id
43
+ let a: sy .external[sign .lnum ] = sign . id
49
44
endif
50
45
endfor
51
46
endfunction
Original file line number Diff line number Diff line change @@ -229,3 +229,33 @@ function! s:offset() abort
229
229
endif
230
230
return offset
231
231
endfunction
232
+
233
+ " #get_signs {{{1
234
+ if exists (' *sign_getplaced' )
235
+ function ! sy#util#get_signs (bufnr )
236
+ return sign_getplaced (a: bufnr )[0 ].signs
237
+ endfunction
238
+ else
239
+ function ! sy#util#get_signs (bufnr )
240
+ let buf = bufnr (a: bufnr )
241
+ let signs = []
242
+
243
+ let signlist = execute (' sign place buffer=' . buf )
244
+ for signline in split (signlist, ' \n' )[2 :]
245
+ let tokens = matchlist (signline, ' \v^\s+\S+\=(\d+)\s+\S+\=(\d+)\s+\S+\=(.*)\s+\S+\=(\d+)$' )
246
+ let line = str2nr (tokens[1 ])
247
+ let id = str2nr (tokens[2 ])
248
+ let name = tokens[3 ]
249
+ let priority = str2nr (tokens[4 ])
250
+ call add (signs, {
251
+ \ ' lnum' : line ,
252
+ \ ' id' : id,
253
+ \ ' name' : name,
254
+ \ ' priority' : priority,
255
+ \ ' group' : ' '
256
+ \ })
257
+ endfor
258
+
259
+ return signs
260
+ endfunction
261
+ endif
You can’t perform that action at this time.
0 commit comments