All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
2 " Returns recent visual-mode range.
4 function! lsp#utils#range#_get_recent_visual_range() abort
5 let l:start_pos = getpos("'<")[1 : 2]
6 let l:end_pos = getpos("'>")[1 : 2]
7 let l:end_pos[1] += 1 " To exclusive
10 let l:end_line = getline(l:end_pos[0])
11 if l:end_pos[1] > strlen(l:end_line)
12 let l:end_pos[1] = strlen(l:end_line) + 1
16 let l:range['start'] = lsp#utils#position#vim_to_lsp('%', l:start_pos)
17 let l:range['end'] = lsp#utils#position#vim_to_lsp('%', l:end_pos)
22 " Returns current line range.
24 function! lsp#utils#range#_get_current_line_range() abort
25 let l:pos = getpos('.')[1 : 2]
27 let l:range['start'] = lsp#utils#position#vim_to_lsp('%', l:pos)
28 let l:range['end'] = lsp#utils#position#vim_to_lsp('%', [l:pos[0], l:pos[1] + strlen(getline(l:pos[0])) + 1])
32 " Convert a LSP range to one or more vim match positions.
33 " If the range spans over multiple lines, break it down to multiple
34 " positions, one for each line.
35 " Return a list of positions.
36 function! lsp#utils#range#lsp_to_vim(bufnr, range) abort
39 let [l:start_line, l:start_col] = lsp#utils#position#lsp_to_vim(a:bufnr, a:range['start'])
40 let [l:end_line, l:end_col] = lsp#utils#position#lsp_to_vim(a:bufnr, a:range['end'])
41 if l:end_line == l:start_line
45 \ l:end_col - l:start_col
56 call add(l:position, [
63 let l:middle_lines = map(
64 \ range(l:start_line + 1, l:end_line - 1),
65 \ {_, l -> [l, 0, 999]}
68 call extend(l:position, l:middle_lines)
74 function! lsp#utils#range#get_range() abort
75 let l:char = lsp#utils#to_char('%', line('$'), col('$'))
76 return {'start': {'line': 0, 'character': 0}, 'end': {'line': line('$')-1, 'character': l:char}}
79 function! lsp#utils#range#get_range_curline() abort
80 let l:char = lsp#utils#to_char('%', line('.'), col('$'))
81 return {'start': {'line': line('.')-1, 'character': 0}, 'end': {'line': line('.')-1, 'character': l:char}}