let s:activated = 0 let s:is_vim = !has('nvim') let s:saved_ve = &t_ve let s:saved_cursor = &guicursor let s:gui = has('gui_running') || has('nvim') function! coc#list#get_chars() return { \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '' : "\", \ '' : "\", \ '' : "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '<2-LeftMouse>': "\<2-LeftMouse>", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \ '': "\", \} endfunction function! coc#list#getc() abort let c = getchar() return type(c) == type(0) ? nr2char(c) : c endfunction function! coc#list#getchar() abort let input = coc#list#getc() if 1 != &iminsert return input endif "a language keymap is activated, so input must be resolved to the mapped values. let partial_keymap = mapcheck(input, "l") while partial_keymap !=# "" let full_keymap = maparg(input, "l") if full_keymap ==# "" && len(input) >= 3 "HACK: assume there are no keymaps longer than 3. return input elseif full_keymap ==# partial_keymap return full_keymap endif let c = coc#list#getc() if c ==# "\" || c ==# "\" "if the short sequence has a valid mapping, return that. if !empty(full_keymap) return full_keymap endif return input endif let input .= c let partial_keymap = mapcheck(input, "l") endwhile return input endfunction function! coc#list#start_prompt(...) abort let eventName = get(a:, 1, 'InputChar') if s:is_vim call s:start_prompt_vim(eventName) else call s:start_prompt(eventName) endif endfunction function! s:start_prompt_vim(eventName) abort call timer_start(10, {-> s:start_prompt(a:eventName)}) endfunction function! s:start_prompt(eventName) if s:activated | return | endif if !get(g:, 'coc_disable_transparent_cursor', 0) if s:gui if has('nvim-0.5.0') && !empty(s:saved_cursor) set guicursor+=a:ver1-CocCursorTransparent/lCursor endif elseif s:is_vim set t_ve= endif endif let s:activated = 1 try while s:activated let ch = coc#list#getchar() if ch ==# "\u26d4" break endif if ch ==# "\" || ch ==# "\" || ch ==# "\" continue else call coc#rpc#notify(a:eventName, [ch, getcharmod()]) endif endwhile catch /^Vim:Interrupt$/ let s:activated = 0 call coc#rpc#notify(a:eventName, ["\"]) return endtry let s:activated = 0 endfunction function! coc#list#setlines(lines, append) if a:append silent call append(line('$'), a:lines) else silent call append(0, a:lines) if exists('*deletebufline') call deletebufline('%', len(a:lines) + 1, '$') else let n = len(a:lines) + 1 let saved_reg = @" silent execute n.',$d' let @" = saved_reg endif endif endfunction function! coc#list#options(...) let list = ['--top', '--tab', '--normal', '--no-sort', '--input', '--strict', \ '--regex', '--interactive', '--number-select', '--auto-preview', \ '--ignore-case', '--no-quit', '--first'] if get(g:, 'coc_enabled', 0) let names = coc#rpc#request('listNames', []) call extend(list, names) endif return join(list, "\n") endfunction function! coc#list#names(...) abort let names = coc#rpc#request('listNames', []) return join(names, "\n") endfunction function! coc#list#stop_prompt(...) if s:activated let s:activated = 0 if get(a:, 1, 0) == 0 && !get(g:, 'coc_disable_transparent_cursor',0) " neovim has bug with revert empty &guicursor if s:gui && !empty(s:saved_cursor) if has('nvim-0.5.0') set guicursor+=a:ver1-Cursor/lCursor let &guicursor = s:saved_cursor endif elseif s:is_vim let &t_ve = s:saved_ve endif endif echo "" call feedkeys("\u26d4", 'int') endif endfunction function! coc#list#status(name) if !exists('b:list_status') | return '' | endif return get(b:list_status, a:name, '') endfunction function! coc#list#create(position, height, name, numberSelect) if a:position ==# 'tab' execute 'silent tabe list:///'.a:name else execute 'silent keepalt '.(a:position ==# 'top' ? '' : 'botright').a:height.'sp list:///'.a:name execute 'resize '.a:height endif if a:numberSelect setl norelativenumber setl number else setl nonumber setl norelativenumber setl signcolumn=yes endif return [bufnr('%'), win_getid()] endfunction " close list windows function! coc#list#clean_up() abort for i in range(1, winnr('$')) let bufname = bufname(winbufnr(i)) if bufname =~# 'list://' execute i.'close!' endif endfor endfunction function! coc#list#setup(source) let b:list_status = {} setl buftype=nofile nobuflisted nofen nowrap setl norelativenumber bufhidden=wipe cursorline winfixheight setl tabstop=1 nolist nocursorcolumn undolevels=-1 setl signcolumn=auto if has('nvim-0.5.0') || has('patch-8.1.0864') setl scrolloff=0 endif if exists('&cursorlineopt') setl cursorlineopt=both endif setl filetype=list syntax case ignore let source = a:source[8:] let name = toupper(source[0]).source[1:] execute 'syntax match Coc'.name.'Line /\v^.*$/' nnoremap c endfunction function! coc#list#has_preview() for i in range(1, winnr('$')) let preview = getwinvar(i, '&previewwindow') if preview return 1 endif endfor return 0 endfunction function! coc#list#restore(winid, height) let res = win_gotoid(a:winid) if res == 0 | return | endif if winnr('$') == 1 return endif execute 'resize '.a:height if s:is_vim redraw endif endfunction function! coc#list#set_height(height) abort if winnr('$') == 1| return | endif execute 'resize '.a:height endfunction