Update coc.nvim
This commit is contained in:
parent
8f2091a3e4
commit
6bd73b104c
7 changed files with 444 additions and 248 deletions
|
@ -2,9 +2,11 @@ scriptencoding utf-8
|
||||||
let s:is_vim = !has('nvim')
|
let s:is_vim = !has('nvim')
|
||||||
let s:root = expand('<sfile>:h:h:h')
|
let s:root = expand('<sfile>:h:h:h')
|
||||||
let s:prompt_win_bufnr = 0
|
let s:prompt_win_bufnr = 0
|
||||||
|
let s:list_win_bufnr = 0
|
||||||
let s:prompt_win_width = get(g:, 'coc_prompt_win_width', 32)
|
let s:prompt_win_width = get(g:, 'coc_prompt_win_width', 32)
|
||||||
let s:float_supported = exists('*nvim_open_win') || has('patch-8.1.1719')
|
let s:float_supported = exists('*nvim_open_win') || has('patch-8.1.1719')
|
||||||
let s:frames = ['· ', '·· ', '···', ' ··', ' ·', ' ']
|
let s:frames = ['· ', '·· ', '···', ' ··', ' ·', ' ']
|
||||||
|
let s:sign_group = 'PopUpCocDialog'
|
||||||
|
|
||||||
" Float window aside pum
|
" Float window aside pum
|
||||||
function! coc#dialog#create_pum_float(winid, bufnr, lines, config) abort
|
function! coc#dialog#create_pum_float(winid, bufnr, lines, config) abort
|
||||||
|
@ -109,12 +111,13 @@ function! coc#dialog#create_prompt_win(title, default, opts) abort
|
||||||
execute 'hi link CocPopupTerminal '.get(a:opts, 'highlight', 'CocFloating')
|
execute 'hi link CocPopupTerminal '.get(a:opts, 'highlight', 'CocFloating')
|
||||||
let node = expand(get(g:, 'coc_node_path', 'node'))
|
let node = expand(get(g:, 'coc_node_path', 'node'))
|
||||||
let bufnr = term_start([node, s:root . '/bin/prompt.js', a:default], {
|
let bufnr = term_start([node, s:root . '/bin/prompt.js', a:default], {
|
||||||
|
\ 'term_rows': 1,
|
||||||
\ 'term_highlight': 'CocPopupTerminal',
|
\ 'term_highlight': 'CocPopupTerminal',
|
||||||
\ 'hidden': 1,
|
\ 'hidden': 1,
|
||||||
\ 'term_finish': 'close'
|
\ 'term_finish': 'close'
|
||||||
\ })
|
\ })
|
||||||
call term_setapi(bufnr, 'Coc')
|
call term_setapi(bufnr, 'Coc')
|
||||||
call timer_start(100, { -> s:check_term_buffer(a:default, bufnr)})
|
call setbufvar(bufnr, 'current', type(a:default) == v:t_string ? a:default : '')
|
||||||
endif
|
endif
|
||||||
let config = s:get_prompt_dimension(a:title, a:default, a:opts)
|
let config = s:get_prompt_dimension(a:title, a:default, a:opts)
|
||||||
let res = coc#float#create_float_win(0, bufnr, extend(config, {
|
let res = coc#float#create_float_win(0, bufnr, extend(config, {
|
||||||
|
@ -138,24 +141,65 @@ function! coc#dialog#create_prompt_win(title, default, opts) abort
|
||||||
call nvim_set_current_win(winid)
|
call nvim_set_current_win(winid)
|
||||||
inoremap <buffer> <C-a> <Home>
|
inoremap <buffer> <C-a> <Home>
|
||||||
inoremap <buffer><expr><C-e> pumvisible() ? "\<C-e>" : "\<End>"
|
inoremap <buffer><expr><C-e> pumvisible() ? "\<C-e>" : "\<End>"
|
||||||
exe 'imap <silent><buffer> <esc> <esc><esc>'
|
exe 'imap <silent><nowait><buffer> <esc> <esc><esc>'
|
||||||
exe 'nnoremap <silent><buffer> <esc> :call coc#float#close('.winid.')<CR>'
|
exe 'nnoremap <silent><buffer> <esc> :call coc#float#close('.winid.')<CR>'
|
||||||
exe 'inoremap <silent><expr><nowait><buffer> <cr> "\<C-r>=coc#dialog#prompt_insert(getline(''.''))\<cr>\<esc>"'
|
exe 'inoremap <silent><expr><nowait><buffer> <cr> "\<C-r>=coc#dialog#prompt_insert(getline(''.''))\<cr>\<esc>"'
|
||||||
|
if get(a:opts, 'list', 0)
|
||||||
|
for key in ['<C-j>', '<C-k>', '<C-n>', '<C-p>', '<up>', '<down>', '<C-f>', '<C-b>', '<C-space>']
|
||||||
|
" Can't use < in remap
|
||||||
|
let escaped = key ==# '<C-space>' ? "C-@" : strcharpart(key, 1, strchars(key) - 2)
|
||||||
|
exe 'inoremap <nowait><buffer> '.key.' <Cmd>call coc#rpc#notify("PromptKeyPress", ['.bufnr.', "'.escaped.'"])<CR>'
|
||||||
|
endfor
|
||||||
|
endif
|
||||||
call feedkeys('A', 'in')
|
call feedkeys('A', 'in')
|
||||||
endif
|
endif
|
||||||
call coc#util#do_autocmd('CocOpenFloatPrompt')
|
call coc#util#do_autocmd('CocOpenFloatPrompt')
|
||||||
if s:is_vim
|
if s:is_vim
|
||||||
let pos = popup_getpos(winid)
|
let pos = popup_getpos(winid)
|
||||||
" width height row col
|
" width height row col
|
||||||
let dimension = [pos['width'], pos['height'], pos['line'], pos['col'] - 1]
|
let dimension = [pos['width'], pos['height'], pos['line'] - 1, pos['col'] - 1]
|
||||||
else
|
else
|
||||||
let id = coc#float#get_related(winid, 'border')
|
let id = coc#float#get_related(winid, 'border')
|
||||||
|
if !has('nvim-0.6.0')
|
||||||
|
redraw
|
||||||
|
endif
|
||||||
let pos = nvim_win_get_position(id)
|
let pos = nvim_win_get_position(id)
|
||||||
let dimension = [nvim_win_get_width(id), nvim_win_get_height(id), pos[0], pos[1]]
|
let dimension = [nvim_win_get_width(id), nvim_win_get_height(id), pos[0], pos[1]]
|
||||||
endif
|
endif
|
||||||
return [bufnr, winid, dimension]
|
return [bufnr, winid, dimension]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Create list window under target window
|
||||||
|
function! coc#dialog#create_list(target, dimension, opts) abort
|
||||||
|
let maxHeight = get(a:opts, 'maxHeight', 10)
|
||||||
|
let height = max([1, len(get(a:opts, 'lines', []))])
|
||||||
|
let height = min([maxHeight, height, &lines - &cmdheight - 1 - a:dimension['row'] + a:dimension['height']])
|
||||||
|
let chars = get(a:opts, 'rounded', 1) ? ['╯', '╰'] : ['┘', '└']
|
||||||
|
let config = extend(copy(a:opts), {
|
||||||
|
\ 'relative': 'editor',
|
||||||
|
\ 'row': a:dimension['row'] + a:dimension['height'],
|
||||||
|
\ 'col': a:dimension['col'],
|
||||||
|
\ 'width': a:dimension['width'] - 2,
|
||||||
|
\ 'height': height,
|
||||||
|
\ 'border': [1, 1, 1, 1],
|
||||||
|
\ 'scrollinside': 1,
|
||||||
|
\ 'borderchars': extend(['─', '│', '─', '│', '├', '┤'], chars)
|
||||||
|
\ })
|
||||||
|
let bufnr = 0
|
||||||
|
let result = coc#float#create_float_win(0, s:list_win_bufnr, config)
|
||||||
|
if empty(result)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
let winid = result[0]
|
||||||
|
call coc#float#add_related(winid, a:target)
|
||||||
|
call setwinvar(winid, 'auto_height', get(a:opts, 'autoHeight', 1))
|
||||||
|
call setwinvar(winid, 'max_height', maxHeight)
|
||||||
|
call setwinvar(winid, 'target_winid', a:target)
|
||||||
|
call setwinvar(winid, 'kind', 'list')
|
||||||
|
call coc#dialog#check_scroll_vim(a:target)
|
||||||
|
return result
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Create menu picker for pick single item
|
" Create menu picker for pick single item
|
||||||
function! coc#dialog#create_menu(lines, config) abort
|
function! coc#dialog#create_menu(lines, config) abort
|
||||||
call s:close_auto_hide_wins()
|
call s:close_auto_hide_wins()
|
||||||
|
@ -174,9 +218,6 @@ function! coc#dialog#create_menu(lines, config) abort
|
||||||
\ 'highlights': get(a:config, 'highlights', []),
|
\ 'highlights': get(a:config, 'highlights', []),
|
||||||
\ 'relative': relative,
|
\ 'relative': relative,
|
||||||
\ }
|
\ }
|
||||||
if s:is_vim
|
|
||||||
let opts['cursorline'] = 1
|
|
||||||
endif
|
|
||||||
if relative ==# 'editor'
|
if relative ==# 'editor'
|
||||||
let dimension = coc#dialog#get_config_editor(a:lines, opts)
|
let dimension = coc#dialog#get_config_editor(a:lines, opts)
|
||||||
else
|
else
|
||||||
|
@ -188,11 +229,10 @@ function! coc#dialog#create_menu(lines, config) abort
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let s:prompt_win_bufnr = res[1]
|
let s:prompt_win_bufnr = res[1]
|
||||||
|
call s:place_sign(s:prompt_win_bufnr, 1)
|
||||||
redraw
|
redraw
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
call coc#float#nvim_scrollbar(res[0])
|
call coc#float#nvim_scrollbar(res[0])
|
||||||
execute 'sign unplace 6 buffer='.s:prompt_win_bufnr
|
|
||||||
execute 'sign place 6 line=1 name=CocCurrentLine buffer='.s:prompt_win_bufnr
|
|
||||||
endif
|
endif
|
||||||
return res
|
return res
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -217,19 +257,16 @@ function! coc#dialog#create_dialog(lines, config) abort
|
||||||
\ 'borderhighlight': borderhighlight,
|
\ 'borderhighlight': borderhighlight,
|
||||||
\ 'getchar': get(a:config, 'getchar', 0)
|
\ 'getchar': get(a:config, 'getchar', 0)
|
||||||
\ }
|
\ }
|
||||||
if get(a:config, 'cursorline', 0)
|
|
||||||
let opts['cursorline'] = 1
|
|
||||||
endif
|
|
||||||
call extend(opts, coc#dialog#get_config_editor(a:lines, a:config))
|
call extend(opts, coc#dialog#get_config_editor(a:lines, a:config))
|
||||||
let bufnr = coc#float#create_buf(0, a:lines)
|
let bufnr = coc#float#create_buf(0, a:lines)
|
||||||
let res = coc#float#create_float_win(0, bufnr, opts)
|
let res = coc#float#create_float_win(0, bufnr, opts)
|
||||||
if empty(res)
|
if empty(res)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
if get(a:config, 'cursorline', 0)
|
||||||
|
call s:place_sign(bufnr, 1)
|
||||||
|
endif
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
if get(a:config, 'cursorline', 0)
|
|
||||||
execute 'sign place 6 line=1 name=CocCurrentLine buffer='.bufnr
|
|
||||||
endif
|
|
||||||
redraw
|
redraw
|
||||||
call coc#float#nvim_scrollbar(res[0])
|
call coc#float#nvim_scrollbar(res[0])
|
||||||
endif
|
endif
|
||||||
|
@ -474,13 +511,68 @@ function! coc#dialog#change_loading(winid, loading) abort
|
||||||
call setwinvar(winid, '&winhl', getwinvar(a:winid, '&winhl'))
|
call setwinvar(winid, '&winhl', getwinvar(a:winid, '&winhl'))
|
||||||
endif
|
endif
|
||||||
call setwinvar(winid, 'kind', 'loading')
|
call setwinvar(winid, 'kind', 'loading')
|
||||||
call setbufvar(bufnr, 'target', a:winid)
|
call setbufvar(bufnr, 'target_winid', a:winid)
|
||||||
call setbufvar(bufnr, 'popup', winid)
|
call setbufvar(bufnr, 'popup', winid)
|
||||||
call coc#float#add_related(winid, a:winid)
|
call coc#float#add_related(winid, a:winid)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Update list with new lines and highlights
|
||||||
|
function! coc#dialog#update_list(winid, bufnr, lines, highlights) abort
|
||||||
|
if coc#window#tabnr(a:winid) == tabpagenr()
|
||||||
|
if getwinvar(a:winid, 'auto_height', 0)
|
||||||
|
let row = coc#float#get_row(a:winid)
|
||||||
|
" core height
|
||||||
|
let height = max([1, len(copy(a:lines))])
|
||||||
|
let height = min([getwinvar(a:winid, 'max_height', 10), height, &lines - &cmdheight - 1 - row])
|
||||||
|
let curr = s:is_vim ? popup_getpos(a:winid)['core_height'] : nvim_win_get_height(a:winid)
|
||||||
|
let delta = height - curr
|
||||||
|
if delta != 0
|
||||||
|
call coc#float#change_height(a:winid, delta)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
call coc#compat#buf_set_lines(a:bufnr, 0, -1, a:lines)
|
||||||
|
call coc#highlight#add_highlights(a:winid, [], a:highlights)
|
||||||
|
if s:is_vim
|
||||||
|
let target = getwinvar(a:winid, 'target_winid', -1)
|
||||||
|
if target != -1
|
||||||
|
call coc#dialog#check_scroll_vim(target)
|
||||||
|
endif
|
||||||
|
call win_execute(a:winid, 'exe 1')
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Fix width of prompt window same as list window on scrollbar change
|
||||||
|
function! coc#dialog#check_scroll_vim(winid) abort
|
||||||
|
if s:is_vim && coc#float#valid(a:winid)
|
||||||
|
let winid = coc#float#get_related(a:winid, 'list')
|
||||||
|
if winid
|
||||||
|
redraw
|
||||||
|
let pos = popup_getpos(winid)
|
||||||
|
let width = pos['width'] + (pos['scrollbar'] ? 1 : 0)
|
||||||
|
if width != popup_getpos(a:winid)['width']
|
||||||
|
call popup_move(a:winid, {
|
||||||
|
\ 'minwidth': width - 2,
|
||||||
|
\ 'maxwidth': width - 2,
|
||||||
|
\ })
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! coc#dialog#set_cursor(winid, bufnr, line) abort
|
||||||
|
if s:is_vim
|
||||||
|
call coc#compat#execute(a:winid, 'exe '.a:line, 'silent!')
|
||||||
|
call popup_setoptions(a:winid, {'cursorline' : 1})
|
||||||
|
call popup_setoptions(a:winid, {'cursorline' : 0})
|
||||||
|
else
|
||||||
|
call nvim_win_set_cursor(a:winid, [a:line, 0])
|
||||||
|
endif
|
||||||
|
call s:place_sign(a:bufnr, a:line)
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Could be center(with optional marginTop) or cursor
|
" Could be center(with optional marginTop) or cursor
|
||||||
function! s:get_prompt_dimension(title, default, opts) abort
|
function! s:get_prompt_dimension(title, default, opts) abort
|
||||||
let relative = get(a:opts, 'position', 'cursor') ==# 'cursor' ? 'cursor' : 'editor'
|
let relative = get(a:opts, 'position', 'cursor') ==# 'cursor' ? 'cursor' : 'editor'
|
||||||
|
@ -510,29 +602,12 @@ function! s:get_prompt_dimension(title, default, opts) abort
|
||||||
endif
|
endif
|
||||||
let config = {
|
let config = {
|
||||||
\ 'col': float2nr((&columns - width) / 2),
|
\ 'col': float2nr((&columns - width) / 2),
|
||||||
\ 'row': row,
|
\ 'row': row - s:is_vim,
|
||||||
\ }
|
\ }
|
||||||
endif
|
endif
|
||||||
return extend(config, {'relative': relative, 'width': width, 'height': 1})
|
return extend(config, {'relative': relative, 'width': width, 'height': 1})
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:check_term_buffer(current, bufnr) abort
|
|
||||||
if bufloaded(a:bufnr)
|
|
||||||
let text = term_getline(a:bufnr, '.')
|
|
||||||
if text !=# a:current
|
|
||||||
let cursor = term_getcursor(a:bufnr)
|
|
||||||
let info = {
|
|
||||||
\ 'lnum': cursor[0],
|
|
||||||
\ 'col': cursor[1],
|
|
||||||
\ 'line': text ==# ' ' && cursor[1] == 1 ? '' : text,
|
|
||||||
\ 'changedtick': 0
|
|
||||||
\ }
|
|
||||||
call coc#rpc#notify('CocAutocmd', ['TextChangedI', a:bufnr, info])
|
|
||||||
endif
|
|
||||||
call timer_start(50, { -> s:check_term_buffer(text, a:bufnr)})
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:min_btns_width(buttons) abort
|
function! s:min_btns_width(buttons) abort
|
||||||
if empty(a:buttons)
|
if empty(a:buttons)
|
||||||
return 0
|
return 0
|
||||||
|
@ -566,7 +641,7 @@ endfunction
|
||||||
|
|
||||||
function! s:change_loading_buf(bufnr, idx) abort
|
function! s:change_loading_buf(bufnr, idx) abort
|
||||||
if bufloaded(a:bufnr)
|
if bufloaded(a:bufnr)
|
||||||
let target = getbufvar(a:bufnr, 'target', v:null)
|
let target = getbufvar(a:bufnr, 'target_winid', v:null)
|
||||||
if !empty(target) && !coc#float#valid(target)
|
if !empty(target) && !coc#float#valid(target)
|
||||||
call coc#float#close(getbufvar(a:bufnr, 'popup'))
|
call coc#float#close(getbufvar(a:bufnr, 'popup'))
|
||||||
return
|
return
|
||||||
|
@ -578,3 +653,8 @@ function! s:change_loading_buf(bufnr, idx) abort
|
||||||
call timer_start(100, { -> s:change_loading_buf(a:bufnr, idx)})
|
call timer_start(100, { -> s:change_loading_buf(a:bufnr, idx)})
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:place_sign(bufnr, line) abort
|
||||||
|
call sign_unplace(s:sign_group, { 'buffer': a:bufnr })
|
||||||
|
call sign_place(6, s:sign_group, 'CocCurrentLine', a:bufnr, {'lnum': a:line})
|
||||||
|
endfunction
|
||||||
|
|
|
@ -72,8 +72,8 @@ function! coc#float#change_height(winid, delta) abort
|
||||||
\ })
|
\ })
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let winids = coc#window#get_var(a:winid, 'related', [])
|
let winids = copy(coc#window#get_var(a:winid, 'related', []))
|
||||||
call filter(copy(winids), 'index(["border","pad","scrollbar"],coc#window#get_var(v:val,"kind","")) >= 0')
|
call filter(winids, 'index(["border","pad","scrollbar"],coc#window#get_var(v:val,"kind","")) >= 0')
|
||||||
call add(winids, a:winid)
|
call add(winids, a:winid)
|
||||||
for winid in winids
|
for winid in winids
|
||||||
if coc#window#get_var(winid, 'kind', '') ==# 'border'
|
if coc#window#get_var(winid, 'kind', '') ==# 'border'
|
||||||
|
@ -111,6 +111,9 @@ endfunction
|
||||||
" - winblend: (optional) winblend option for float window, neovim only.
|
" - winblend: (optional) winblend option for float window, neovim only.
|
||||||
" - shadow: (optional) use shadow as border style, neovim only.
|
" - shadow: (optional) use shadow as border style, neovim only.
|
||||||
" - focusable: (optional) neovim only, default to true.
|
" - focusable: (optional) neovim only, default to true.
|
||||||
|
" - scrollinside: (optional) neovim only, create scrollbar inside window.
|
||||||
|
" - rounded: (optional) use rounded borderchars, ignored when borderchars exists.
|
||||||
|
" - borderchars: (optional) borderchars, should be length of 8
|
||||||
function! coc#float#create_float_win(winid, bufnr, config) abort
|
function! coc#float#create_float_win(winid, bufnr, config) abort
|
||||||
let lines = get(a:config, 'lines', v:null)
|
let lines = get(a:config, 'lines', v:null)
|
||||||
let bufnr = coc#float#create_buf(a:bufnr, lines, 'hide')
|
let bufnr = coc#float#create_buf(a:bufnr, lines, 'hide')
|
||||||
|
@ -152,13 +155,14 @@ function! coc#float#create_float_win(winid, bufnr, config) abort
|
||||||
let title = get(a:config, 'title', '')
|
let title = get(a:config, 'title', '')
|
||||||
let buttons = get(a:config, 'buttons', [])
|
let buttons = get(a:config, 'buttons', [])
|
||||||
let hlgroup = get(a:config, 'highlight', 'CocFloating')
|
let hlgroup = get(a:config, 'highlight', 'CocFloating')
|
||||||
|
let border = s:empty_border(get(a:config, 'border', [])) ? [0, 0, 0, 0] : a:config['border']
|
||||||
let opts = {
|
let opts = {
|
||||||
\ 'title': title,
|
\ 'title': title,
|
||||||
\ 'line': line,
|
\ 'line': line,
|
||||||
\ 'col': col,
|
\ 'col': col,
|
||||||
\ 'fixed': 1,
|
\ 'fixed': 1,
|
||||||
\ 'padding': empty(title) ? [0, 1, 0, 1] : [0, 0, 0, 0],
|
\ 'padding': [0, !border[1], 0, !border[3]],
|
||||||
\ 'borderchars': get(a:config, 'rounded', 0) ? s:rounded_borderchars : s:borderchars,
|
\ 'borderchars': s:get_borderchars(a:config),
|
||||||
\ 'highlight': hlgroup,
|
\ 'highlight': hlgroup,
|
||||||
\ 'cursorline': get(a:config, 'cursorline', 0),
|
\ 'cursorline': get(a:config, 'cursorline', 0),
|
||||||
\ 'minwidth': a:config['width'],
|
\ 'minwidth': a:config['width'],
|
||||||
|
@ -166,7 +170,8 @@ function! coc#float#create_float_win(winid, bufnr, config) abort
|
||||||
\ 'maxwidth': a:config['width'],
|
\ 'maxwidth': a:config['width'],
|
||||||
\ 'maxheight': a:config['height'],
|
\ 'maxheight': a:config['height'],
|
||||||
\ 'close': get(a:config, 'close', 0) ? 'button' : 'none',
|
\ 'close': get(a:config, 'close', 0) ? 'button' : 'none',
|
||||||
\ 'border': s:empty_border(get(a:config, 'border', [])) ? [0, 0, 0, 0] : a:config['border']
|
\ 'border': border,
|
||||||
|
\ 'callback': { -> coc#float#on_close(winid)}
|
||||||
\ }
|
\ }
|
||||||
if !empty(get(a:config, 'borderhighlight', v:null))
|
if !empty(get(a:config, 'borderhighlight', v:null))
|
||||||
let borderhighlight = a:config['borderhighlight']
|
let borderhighlight = a:config['borderhighlight']
|
||||||
|
@ -192,7 +197,9 @@ function! coc#float#create_float_win(winid, bufnr, config) abort
|
||||||
let hlgroup = get(a:config, 'highlight', 'CocFloating')
|
let hlgroup = get(a:config, 'highlight', 'CocFloating')
|
||||||
call setwinvar(winid, '&winhl', 'Normal:'.hlgroup.',NormalNC:'.hlgroup.',FoldColumn:'.hlgroup)
|
call setwinvar(winid, '&winhl', 'Normal:'.hlgroup.',NormalNC:'.hlgroup.',FoldColumn:'.hlgroup)
|
||||||
call setwinvar(winid, 'border', get(a:config, 'border', []))
|
call setwinvar(winid, 'border', get(a:config, 'border', []))
|
||||||
|
call setwinvar(winid, 'scrollinside', get(a:config, 'scrollinside', 0))
|
||||||
call setwinvar(winid, '&foldcolumn', s:nvim_enable_foldcolumn(get(a:config, 'border', v:null)))
|
call setwinvar(winid, '&foldcolumn', s:nvim_enable_foldcolumn(get(a:config, 'border', v:null)))
|
||||||
|
call setwinvar(winid, '&cursorline', get(a:config, 'cursorline', 0))
|
||||||
" cursorline highlight not work on old neovim
|
" cursorline highlight not work on old neovim
|
||||||
call s:nvim_set_defaults(winid)
|
call s:nvim_set_defaults(winid)
|
||||||
call nvim_win_set_cursor(winid, [1, 0])
|
call nvim_win_set_cursor(winid, [1, 0])
|
||||||
|
@ -209,7 +216,7 @@ function! coc#float#create_float_win(winid, bufnr, config) abort
|
||||||
call setwinvar(winid, '&showbreak', 'NONE')
|
call setwinvar(winid, '&showbreak', 'NONE')
|
||||||
endif
|
endif
|
||||||
call setwinvar(winid, 'float', 1)
|
call setwinvar(winid, 'float', 1)
|
||||||
call setwinvar(winid, '&wrap', 1)
|
call setwinvar(winid, '&wrap', !get(a:config, 'cursorline', 0))
|
||||||
call setwinvar(winid, '&linebreak', 1)
|
call setwinvar(winid, '&linebreak', 1)
|
||||||
call setwinvar(winid, '&conceallevel', 0)
|
call setwinvar(winid, '&conceallevel', 0)
|
||||||
call s:add_highlights(winid, a:config, 1)
|
call s:add_highlights(winid, a:config, 1)
|
||||||
|
@ -239,7 +246,8 @@ function! coc#float#nvim_create_related(winid, config, opts) abort
|
||||||
call coc#float#close_related(a:winid, 'buttons')
|
call coc#float#close_related(a:winid, 'buttons')
|
||||||
endif
|
endif
|
||||||
if !s:empty_border(border)
|
if !s:empty_border(border)
|
||||||
call coc#float#nvim_border_win(a:config, get(a:opts, 'rounded', 0), a:winid, border, get(a:opts, 'title', ''), !empty(buttons), borderhighlight, shadow, related)
|
let borderchars = s:get_borderchars(a:opts)
|
||||||
|
call coc#float#nvim_border_win(a:config, borderchars, a:winid, border, get(a:opts, 'title', ''), !empty(buttons), borderhighlight, shadow, related)
|
||||||
elseif exists
|
elseif exists
|
||||||
call coc#float#close_related(a:winid, 'border')
|
call coc#float#close_related(a:winid, 'border')
|
||||||
endif
|
endif
|
||||||
|
@ -253,13 +261,13 @@ function! coc#float#nvim_create_related(winid, config, opts) abort
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" border window for neovim, content config with border
|
" border window for neovim, content config with border
|
||||||
function! coc#float#nvim_border_win(config, rounded, winid, border, title, hasbtn, hlgroup, shadow, related) abort
|
function! coc#float#nvim_border_win(config, borderchars, winid, border, title, hasbtn, hlgroup, shadow, related) abort
|
||||||
let winid = coc#float#get_related(a:winid, 'border')
|
let winid = coc#float#get_related(a:winid, 'border')
|
||||||
let row = a:border[0] ? a:config['row'] - 1 : a:config['row']
|
let row = a:border[0] ? a:config['row'] - 1 : a:config['row']
|
||||||
let col = a:border[3] ? a:config['col'] - 1 : a:config['col']
|
let col = a:border[3] ? a:config['col'] - 1 : a:config['col']
|
||||||
let width = a:config['width'] + a:border[1] + a:border[3]
|
let width = a:config['width'] + a:border[1] + a:border[3]
|
||||||
let height = a:config['height'] + a:border[0] + a:border[2] + (a:hasbtn ? 2 : 0)
|
let height = a:config['height'] + a:border[0] + a:border[2] + (a:hasbtn ? 2 : 0)
|
||||||
let lines = coc#float#create_border_lines(a:border, a:rounded, a:title, a:config['width'], a:config['height'], a:hasbtn)
|
let lines = coc#float#create_border_lines(a:border, a:borderchars, a:title, a:config['width'], a:config['height'], a:hasbtn)
|
||||||
let bufnr = winid ? winbufnr(winid) : 0
|
let bufnr = winid ? winbufnr(winid) : 0
|
||||||
let bufnr = coc#float#create_buf(bufnr, lines)
|
let bufnr = coc#float#create_buf(bufnr, lines)
|
||||||
let opt = {
|
let opt = {
|
||||||
|
@ -424,7 +432,7 @@ endfunction
|
||||||
" Create or refresh scrollbar for winid
|
" Create or refresh scrollbar for winid
|
||||||
" Need called on create, config, buffer change, scrolled
|
" Need called on create, config, buffer change, scrolled
|
||||||
function! coc#float#nvim_scrollbar(winid) abort
|
function! coc#float#nvim_scrollbar(winid) abort
|
||||||
if !has('nvim-0.4.0') || coc#window#get_var(a:winid, 'target_winid', 0)
|
if !has('nvim-0.4.0')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let winids = nvim_tabpage_list_wins(nvim_get_current_tabpage())
|
let winids = nvim_tabpage_list_wins(nvim_get_current_tabpage())
|
||||||
|
@ -446,6 +454,7 @@ function! coc#float#nvim_scrollbar(winid) abort
|
||||||
let ch = coc#float#content_height(bufnr, cw, getwinvar(a:winid, '&wrap'))
|
let ch = coc#float#content_height(bufnr, cw, getwinvar(a:winid, '&wrap'))
|
||||||
let closewin = coc#float#get_related(a:winid, 'close')
|
let closewin = coc#float#get_related(a:winid, 'close')
|
||||||
let border = getwinvar(a:winid, 'border', [])
|
let border = getwinvar(a:winid, 'border', [])
|
||||||
|
let scrollinside = getwinvar(a:winid, 'scrollinside', 0) && get(border, 1, 0)
|
||||||
let winblend = getwinvar(a:winid, '&winblend', 0)
|
let winblend = getwinvar(a:winid, '&winblend', 0)
|
||||||
let move_down = closewin && !get(border, 0, 0)
|
let move_down = closewin && !get(border, 0, 0)
|
||||||
let id = coc#float#get_related(a:winid, 'scrollbar')
|
let id = coc#float#get_related(a:winid, 'scrollbar')
|
||||||
|
@ -464,7 +473,7 @@ function! coc#float#nvim_scrollbar(winid) abort
|
||||||
let sbuf = coc#float#create_buf(sbuf, repeat([' '], height))
|
let sbuf = coc#float#create_buf(sbuf, repeat([' '], height))
|
||||||
let opts = {
|
let opts = {
|
||||||
\ 'row': move_down ? row + 1 : row,
|
\ 'row': move_down ? row + 1 : row,
|
||||||
\ 'col': column + width,
|
\ 'col': column + width - scrollinside,
|
||||||
\ 'relative': relative,
|
\ 'relative': relative,
|
||||||
\ 'width': 1,
|
\ 'width': 1,
|
||||||
\ 'height': height,
|
\ 'height': height,
|
||||||
|
@ -488,7 +497,9 @@ function! coc#float#nvim_scrollbar(winid) abort
|
||||||
call setwinvar(id, 'target_winid', a:winid)
|
call setwinvar(id, 'target_winid', a:winid)
|
||||||
call coc#float#add_related(id, a:winid)
|
call coc#float#add_related(id, a:winid)
|
||||||
endif
|
endif
|
||||||
call coc#float#nvim_scroll_adjust(a:winid)
|
if !scrollinside
|
||||||
|
call coc#float#nvim_scroll_adjust(a:winid)
|
||||||
|
endif
|
||||||
let thumb_height = max([1, float2nr(floor(height * (height + 0.0)/ch))])
|
let thumb_height = max([1, float2nr(floor(height * (height + 0.0)/ch))])
|
||||||
let wininfo = getwininfo(a:winid)[0]
|
let wininfo = getwininfo(a:winid)[0]
|
||||||
let start = 0
|
let start = 0
|
||||||
|
@ -514,8 +525,8 @@ function! coc#float#nvim_scrollbar(winid) abort
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! coc#float#create_border_lines(border, rounded, title, width, height, hasbtn) abort
|
function! coc#float#create_border_lines(border, borderchars, title, width, height, hasbtn) abort
|
||||||
let borderchars = a:rounded ? s:rounded_borderchars : s:borderchars
|
let borderchars = a:borderchars
|
||||||
let list = []
|
let list = []
|
||||||
if a:border[0]
|
if a:border[0]
|
||||||
let top = (a:border[3] ? borderchars[4]: '')
|
let top = (a:border[3] ? borderchars[4]: '')
|
||||||
|
@ -684,6 +695,16 @@ function! coc#float#nvim_refresh_scrollbar(winid) abort
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! coc#float#on_close(winid) abort
|
||||||
|
let winids = coc#float#get_float_win_list()
|
||||||
|
for winid in winids
|
||||||
|
let target = getwinvar(winid, 'target_winid', -1)
|
||||||
|
if target == a:winid
|
||||||
|
call coc#float#close(winid)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Close related windows, or specific kind
|
" Close related windows, or specific kind
|
||||||
function! coc#float#close_related(winid, ...) abort
|
function! coc#float#close_related(winid, ...) abort
|
||||||
if !coc#float#valid(a:winid)
|
if !coc#float#valid(a:winid)
|
||||||
|
@ -696,11 +717,14 @@ function! coc#float#close_related(winid, ...) abort
|
||||||
let kind = get(a:, 1, '')
|
let kind = get(a:, 1, '')
|
||||||
let winids = coc#window#get_var(a:winid, 'related', [])
|
let winids = coc#window#get_var(a:winid, 'related', [])
|
||||||
for id in winids
|
for id in winids
|
||||||
if s:is_vim
|
let curr = coc#window#get_var(id, 'kind', '')
|
||||||
" vim doesn't throw
|
if empty(kind) || curr ==# kind
|
||||||
noa call popup_close(id)
|
if curr == 'list'
|
||||||
else
|
call coc#float#close(id)
|
||||||
if empty(kind) || coc#window#get_var(id, 'kind', '') ==# kind
|
elseif s:is_vim
|
||||||
|
" vim doesn't throw
|
||||||
|
noa call popup_close(id)
|
||||||
|
else
|
||||||
silent! noa call nvim_win_close(id, 1)
|
silent! noa call nvim_win_close(id, 1)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
@ -863,7 +887,7 @@ function! coc#float#vim_filter(winid, key, keys) abort
|
||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! coc#float#get_related(winid, kind) abort
|
function! coc#float#get_related(winid, kind, ...) abort
|
||||||
if coc#float#valid(a:winid)
|
if coc#float#valid(a:winid)
|
||||||
for winid in coc#window#get_var(a:winid, 'related', [])
|
for winid in coc#window#get_var(a:winid, 'related', [])
|
||||||
if coc#window#get_var(winid, 'kind', '') ==# a:kind
|
if coc#window#get_var(winid, 'kind', '') ==# a:kind
|
||||||
|
@ -871,7 +895,19 @@ function! coc#float#get_related(winid, kind) abort
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
return 0
|
return get(a:, 1, 0)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! coc#float#get_row(winid) abort
|
||||||
|
let winid = s:is_vim ? a:winid : coc#float#get_related(a:winid, 'border', a:winid)
|
||||||
|
if coc#float#valid(winid)
|
||||||
|
if s:is_vim
|
||||||
|
let pos = popup_getpos(winid)
|
||||||
|
return pos['line'] - 1
|
||||||
|
endif
|
||||||
|
let pos = nvim_win_get_position(winid)
|
||||||
|
return pos[0]
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Create temporarily buffer with optional lines and &bufhidden
|
" Create temporarily buffer with optional lines and &bufhidden
|
||||||
|
@ -1265,13 +1301,15 @@ function! s:win_setview(winid, topline, lnum) abort
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:nvim_set_defaults(winid) abort
|
function! s:nvim_set_defaults(winid) abort
|
||||||
call setwinvar(a:winid, '&cursorline', 0)
|
|
||||||
call setwinvar(a:winid, '&signcolumn', 'auto')
|
call setwinvar(a:winid, '&signcolumn', 'auto')
|
||||||
call setwinvar(a:winid, '&list', 0)
|
call setwinvar(a:winid, '&list', 0)
|
||||||
call setwinvar(a:winid, '&number', 0)
|
call setwinvar(a:winid, '&number', 0)
|
||||||
call setwinvar(a:winid, '&relativenumber', 0)
|
call setwinvar(a:winid, '&relativenumber', 0)
|
||||||
call setwinvar(a:winid, '&cursorcolumn', 0)
|
call setwinvar(a:winid, '&cursorcolumn', 0)
|
||||||
call setwinvar(a:winid, '&colorcolumn', 0)
|
call setwinvar(a:winid, '&colorcolumn', 0)
|
||||||
|
if exists('*win_execute')
|
||||||
|
call win_execute(a:winid, 'setl fillchars+=eob:\ ')
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:nvim_add_related(winid, target, kind, winhl, related) abort
|
function! s:nvim_add_related(winid, target, kind, winhl, related) abort
|
||||||
|
@ -1321,11 +1359,16 @@ function! s:add_highlights(winid, config, create) abort
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:empty_border(border) abort
|
function! s:empty_border(border) abort
|
||||||
if empty(a:border)
|
if empty(a:border) || empty(filter(copy(a:border), 'v:val != 0'))
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
if a:border[0] == 0 && a:border[1] == 0 && a:border[2] == 0 && a:border[3] == 0
|
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:get_borderchars(config) abort
|
||||||
|
let borderchars = get(a:config, 'borderchars', [])
|
||||||
|
if !empty(borderchars)
|
||||||
|
return borderchars
|
||||||
|
endif
|
||||||
|
return get(a:config, 'rounded', 0) ? s:rounded_borderchars : s:borderchars
|
||||||
|
endfunction
|
||||||
|
|
|
@ -5,7 +5,8 @@ const readline = require("readline")
|
||||||
const rl = readline.createInterface({
|
const rl = readline.createInterface({
|
||||||
input: process.stdin,
|
input: process.stdin,
|
||||||
output: process.stdout,
|
output: process.stdout,
|
||||||
escapeCodeTimeout: 0
|
escapeCodeTimeout: 0,
|
||||||
|
prompt: ''
|
||||||
})
|
})
|
||||||
rl.setPrompt('')
|
rl.setPrompt('')
|
||||||
let value = process.argv[2]
|
let value = process.argv[2]
|
||||||
|
@ -13,37 +14,70 @@ if (value) {
|
||||||
rl.write(value)
|
rl.write(value)
|
||||||
}
|
}
|
||||||
rl.on('line', input => {
|
rl.on('line', input => {
|
||||||
let text = input.replace(/"/g, '\\"')
|
send(['confirm', input])
|
||||||
console.log(createSequences(JSON.stringify(['call', 'CocPopupCallback', ['confirm', text]])))
|
|
||||||
process.exit()
|
process.exit()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let original_ttyWrite = rl._ttyWrite
|
||||||
|
rl._ttyWrite = function (code, key) {
|
||||||
|
if (key.name === 'enter') {
|
||||||
|
send(['send', '<C-j>'])
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
original_ttyWrite.apply(rl, arguments)
|
||||||
|
send(['change', rl.line])
|
||||||
|
}
|
||||||
|
|
||||||
function createSequences(str) {
|
function createSequences(str) {
|
||||||
return '\033]51;' + str + '\x07'
|
return '\033]51;' + str + '\x07'
|
||||||
}
|
}
|
||||||
|
|
||||||
process.stdin.on('keypress', (_, key) => {
|
function send(args) {
|
||||||
|
process.stdout.write(createSequences(JSON.stringify(['call', 'CocPopupCallback', args])))
|
||||||
|
}
|
||||||
|
|
||||||
|
process.stdin.on('keypress', (e, key) => {
|
||||||
if (key) {
|
if (key) {
|
||||||
let k = getKey(key)
|
let k = getKey(key)
|
||||||
if (k == '<bs>') {
|
if (k == '<bs>') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (k == '<cr>') {
|
|
||||||
process.exit()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (k == '<esc>') {
|
if (k == '<esc>') {
|
||||||
console.log(createSequences(JSON.stringify(['call', 'CocPopupCallback', ['exit', '']])))
|
send(['exit', ''])
|
||||||
process.exit()
|
process.exit()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (k) {
|
if (k) {
|
||||||
console.log(createSequences(JSON.stringify(['call', 'CocPopupCallback', ['send', k]])))
|
send(['send', k])
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function getKey(key) {
|
function getKey(key) {
|
||||||
|
if (key.ctrl === true) {
|
||||||
|
if (key.name == 'n') {
|
||||||
|
return '<C-n>'
|
||||||
|
}
|
||||||
|
if (key.name == 'p') {
|
||||||
|
return '<C-p>'
|
||||||
|
}
|
||||||
|
if (key.name == 'j') {
|
||||||
|
return '<C-j>'
|
||||||
|
}
|
||||||
|
if (key.name == 'k') {
|
||||||
|
return '<C-k>'
|
||||||
|
}
|
||||||
|
if (key.name == 'f') {
|
||||||
|
return '<C-f>'
|
||||||
|
}
|
||||||
|
if (key.name == 'b') {
|
||||||
|
return '<C-b>'
|
||||||
|
}
|
||||||
|
if (key.sequence == '\x00') {
|
||||||
|
return '<C-@>'
|
||||||
|
}
|
||||||
|
}
|
||||||
if (key.sequence == '\u001b') {
|
if (key.sequence == '\u001b') {
|
||||||
return '<esc>'
|
return '<esc>'
|
||||||
}
|
}
|
||||||
|
@ -53,16 +87,6 @@ function getKey(key) {
|
||||||
if (key.sequence == '\t') {
|
if (key.sequence == '\t') {
|
||||||
return key.shift ? '<s-tab>' : '<tab>'
|
return key.shift ? '<s-tab>' : '<tab>'
|
||||||
}
|
}
|
||||||
// handle them can cause bug with terminal
|
|
||||||
// if (key.name == 'backspace') {
|
|
||||||
// return '<bs>'
|
|
||||||
// }
|
|
||||||
// if (key.name == 'left') {
|
|
||||||
// return '<left>'
|
|
||||||
// }
|
|
||||||
// if (key.name == 'right') {
|
|
||||||
// return '<right>'
|
|
||||||
// }
|
|
||||||
if (key.name == 'up') {
|
if (key.name == 'up') {
|
||||||
return '<up>'
|
return '<up>'
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1983,7 +1983,7 @@ g:coc_process_pid *g:coc_process_pid*
|
||||||
<
|
<
|
||||||
in your vimrc.
|
in your vimrc.
|
||||||
|
|
||||||
g:coc_service_initialized *g:coc_service_initialized*
|
g:coc_service_initialized *g:coc_service_initialized*
|
||||||
|
|
||||||
Is `1` when coc.nvim initialized, used with autocmd |CocNvimInit|.
|
Is `1` when coc.nvim initialized, used with autocmd |CocNvimInit|.
|
||||||
|
|
||||||
|
@ -3196,13 +3196,13 @@ characters.
|
||||||
|
|
||||||
Others~
|
Others~
|
||||||
|
|
||||||
|
*CocSearch* highlight group for matched characters in list.
|
||||||
*CocDisabled* highlight for disabled items, eg: menu item.
|
*CocDisabled* highlight for disabled items, eg: menu item.
|
||||||
*CocCodeLens* for virtual text of codeLens.
|
*CocCodeLens* for virtual text of codeLens.
|
||||||
*CocCursorRange* for highlight of activated cursors ranges.
|
*CocCursorRange* for highlight of activated cursors ranges.
|
||||||
*CocLinkedEditing* for highlight of activated linked editing ranges.
|
*CocLinkedEditing* for highlight of activated linked editing ranges.
|
||||||
*CocHoverRange* for range of current hovered symbol.
|
*CocHoverRange* for range of current hovered symbol.
|
||||||
*CocMenuSel* for current menu item in menu dialog, works on neovim only since
|
*CocMenuSel* for current menu item in menu dialog.
|
||||||
vim doesn't support change highlight group of cursorline inside popup.
|
|
||||||
*CocSelectedRange* for highlight ranges of outgoing calls.
|
*CocSelectedRange* for highlight ranges of outgoing calls.
|
||||||
*CocSnippetVisual* for highlight snippet placeholders.
|
*CocSnippetVisual* for highlight snippet placeholders.
|
||||||
*CocInlayHint* for highlight inlay hint virtual text block, default linked to
|
*CocInlayHint* for highlight inlay hint virtual text block, default linked to
|
||||||
|
@ -3814,15 +3814,41 @@ A input dialog request user input with optional default value, normally
|
||||||
created by `window.requestInput`, when `"coc.preferences.promptInput"` is
|
created by `window.requestInput`, when `"coc.preferences.promptInput"` is
|
||||||
false, vim's commandline input prompt is used instead.
|
false, vim's commandline input prompt is used instead.
|
||||||
|
|
||||||
|
On neovim, it uses float window, on vim8, it opens terminal in popup.
|
||||||
|
|
||||||
Supported key-mappings:
|
Supported key-mappings:
|
||||||
|
|
||||||
<C-a> - move cursor to first col.
|
<C-a> - move cursor to first col.
|
||||||
<C-e> - move cursor to last col.
|
<C-e> - move cursor to last col.
|
||||||
<esc> - cancel input, an empty string is received by callback.
|
<esc> - cancel input, null is received by callback.
|
||||||
<cr> - confirm selection of current item, use
|
<cr> - accept current input selection of current item.
|
||||||
|dialog.confirmKey| to override.
|
|
||||||
|
|
||||||
And other insert mode key-mappings that your neovim provided.
|
QuickPick related (available when created by |coc-dialog-quickpick|).
|
||||||
|
|
||||||
|
<C-f> - scroll forward quickpick list.
|
||||||
|
<C-b> - scroll backward quickpick list.
|
||||||
|
<C-j> <C-n> <down> - move to next item in quickpick list.
|
||||||
|
<C-k> <C-p> <up> - move to previous item in quickpick list.
|
||||||
|
<C-space> - toggle selection of current item in quickpick list when
|
||||||
|
canSelectMany is supported.
|
||||||
|
|
||||||
|
Note on neovim, other insert mode key-mappings could work.
|
||||||
|
|
||||||
|
Note not possible to configure key-mappings on vim8, to customize key-mappings
|
||||||
|
on neovim, use |CocOpenFloatPrompt| with current buffer.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
*coc-dialog-quickpick*
|
||||||
|
|
||||||
|
A quickpick is a input dialog in the middle with a float window/popup contains
|
||||||
|
filtred list items.
|
||||||
|
|
||||||
|
A simple fuzzy filter is used by default.
|
||||||
|
|
||||||
|
See |coc-config-dialog| for available configurations.
|
||||||
|
|
||||||
|
See |coc-dialog-input| for available key-mappings.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
# 2022-05-17
|
||||||
|
|
||||||
|
- Add `QuickPick` module.
|
||||||
|
- Add API `window.showQuickPick()` and `window.createQuickPick()`.
|
||||||
|
|
||||||
# 2022-05-16
|
# 2022-05-16
|
||||||
|
|
||||||
- Add properties `title`, `loading` & `borderhighlight` to `InputBox`
|
- Add properties `title`, `loading` & `borderhighlight` to `InputBox`
|
||||||
|
|
|
@ -64,6 +64,24 @@ function! CocPopupCallback(bufnr, arglist) abort
|
||||||
elseif a:arglist[0] == 'exit'
|
elseif a:arglist[0] == 'exit'
|
||||||
execute 'silent! bd! '.a:bufnr
|
execute 'silent! bd! '.a:bufnr
|
||||||
"call coc#rpc#notify('PromptUpdate', [a:arglist[1]])
|
"call coc#rpc#notify('PromptUpdate', [a:arglist[1]])
|
||||||
|
elseif a:arglist[0] == 'change'
|
||||||
|
let text = a:arglist[1]
|
||||||
|
let current = getbufvar(a:bufnr, 'current', '')
|
||||||
|
if text !=# current
|
||||||
|
call setbufvar(a:bufnr, 'current', text)
|
||||||
|
let cursor = term_getcursor(a:bufnr)
|
||||||
|
let info = {
|
||||||
|
\ 'lnum': cursor[0],
|
||||||
|
\ 'col': cursor[1],
|
||||||
|
\ 'line': text,
|
||||||
|
\ 'changedtick': 0
|
||||||
|
\ }
|
||||||
|
call coc#rpc#notify('CocAutocmd', ['TextChangedI', a:bufnr, info])
|
||||||
|
endif
|
||||||
|
elseif a:arglist[0] == 'send'
|
||||||
|
let key = a:arglist[1]
|
||||||
|
let escaped = strcharpart(key, 1, strchars(key) - 2)
|
||||||
|
call coc#rpc#notify('PromptKeyPress', [a:bufnr, escaped])
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -321,7 +339,7 @@ function! s:Enable(initialize)
|
||||||
autocmd WinEnter * call coc#float#nvim_win_enter(win_getid())
|
autocmd WinEnter * call coc#float#nvim_win_enter(win_getid())
|
||||||
endif
|
endif
|
||||||
if exists('##WinClosed')
|
if exists('##WinClosed')
|
||||||
autocmd WinClosed * call coc#float#close_related(+expand('<amatch>'))
|
autocmd WinClosed * call coc#float#on_close(+expand('<amatch>'))
|
||||||
autocmd WinClosed * call coc#notify#on_close(+expand('<amatch>'))
|
autocmd WinClosed * call coc#notify#on_close(+expand('<amatch>'))
|
||||||
elseif exists('##TabEnter')
|
elseif exists('##TabEnter')
|
||||||
autocmd TabEnter * call coc#notify#reflow()
|
autocmd TabEnter * call coc#notify#reflow()
|
||||||
|
|
Loading…
Reference in a new issue