1
0
mirror of https://github.com/amix/vimrc synced 2025-07-27 23:45:00 +08:00

Update Coc.nvim

This commit is contained in:
Kurtis Moxley
2022-05-27 15:57:56 +08:00
parent 15599f5565
commit 71e3f2fa49
18 changed files with 1247 additions and 542 deletions

View File

@ -104,20 +104,29 @@ function! coc#snippet#disable()
silent! execute 'sunmap <buffer> <silent> '.nextkey
endfunction
function! coc#snippet#select(position, text) abort
function! coc#snippet#select(start, end, text) abort
if pumvisible()
call coc#_cancel()
endif
if mode() == 's'
call feedkeys("\<Esc>", 'in')
endif
let cursor = coc#snippet#to_cursor(a:position)
call cursor([cursor[0], cursor[1] - (&selection !~# 'exclusive')])
let len = strchars(a:text) - (&selection !~# 'exclusive')
let cmd = ''
let cmd .= mode()[0] ==# 'i' ? "\<Esc>l" : ''
let cmd .= printf('v%s', len > 0 ? len . 'h' : '')
let cmd .= "o\<C-g>"
if &selection ==# 'exclusive'
let cursor = coc#snippet#to_cursor(a:start)
call cursor([cursor[0], cursor[1]])
let cmd = ''
let cmd .= mode()[0] ==# 'i' ? "\<Esc>".(col('.') == 1 ? '' : 'l') : ''
let cmd .= printf('v%s', strchars(a:text) . 'l')
let cmd .= "\<C-g>"
else
let cursor = coc#snippet#to_cursor(a:end)
call cursor([cursor[0], cursor[1] - 1])
let len = strchars(a:text) - 1
let cmd = ''
let cmd .= mode()[0] ==# 'i' ? "\<Esc>l" : ''
let cmd .= printf('v%s', len > 0 ? len . 'h' : '')
let cmd .= "o\<C-g>"
endif
call feedkeys(cmd, 'n')
endfunction