mirror of
https://github.com/prabirshrestha/vim-lsp.git
synced 2025-12-14 20:35:59 +01:00
* Improve code action * Add LspCodeActionSync * Fix miss argument * Fix for the review * Add utils and tests * Remove unused function
32 lines
950 B
VimL
32 lines
950 B
VimL
"
|
|
" Returns recent visual-mode range.
|
|
"
|
|
function! lsp#utils#range#_get_recent_visual_range() abort
|
|
let l:start_pos = getpos("'<")[1 : 2]
|
|
let l:end_pos = getpos("'>")[1 : 2]
|
|
let l:end_pos[1] += 1 " To exclusive
|
|
|
|
" Fix line selection.
|
|
let l:end_line = getline(l:end_pos[0])
|
|
if l:end_pos[1] > strlen(l:end_line)
|
|
let l:end_pos[1] = strlen(l:end_line) + 1
|
|
endif
|
|
|
|
let l:range = {}
|
|
let l:range['start'] = lsp#utils#position#_vim_to_lsp('%', l:start_pos)
|
|
let l:range['end'] = lsp#utils#position#_vim_to_lsp('%', l:end_pos)
|
|
return l:range
|
|
endfunction
|
|
|
|
"
|
|
" Returns current line range.
|
|
"
|
|
function! lsp#utils#range#_get_current_line_range() abort
|
|
let l:pos = getpos('.')[1 : 2]
|
|
let l:range = {}
|
|
let l:range['start'] = lsp#utils#position#_vim_to_lsp('%', l:pos)
|
|
let l:range['end'] = lsp#utils#position#_vim_to_lsp('%', [l:pos[0], l:pos[1] + strlen(getline(l:pos[0])) + 1])
|
|
return l:range
|
|
endfunction
|
|
|