mirror of
https://github.com/amix/vimrc
synced 2025-07-27 15:04:59 +08:00
Change Rainbow-parenthese plugin into Rainbow plugin.
This commit is contained in:
@ -14,38 +14,22 @@
|
||||
|
||||
---
|
||||
|
||||
<img alt="Gif" src="https://user-images.githubusercontent.com/251450/55285193-400a9000-53b9-11e9-8cff-ffe4983c5947.gif" width="60%" />
|
||||
<img alt="Gif" src="https://alfs.chigua.cn/dianyou/data/platform/default/20220801/2022-08-01%2002-14-03.2022-08-01%2002_15_16.gif" width="60%" />
|
||||
|
||||
_True snippet and additional text editing support_
|
||||
_Custom popup menu with snippet support_
|
||||
|
||||
## Why?
|
||||
|
||||
- 🚀 **Fast**: [instant increment completion](https://github.com/neoclide/coc.nvim/wiki/Completion-with-sources), increment buffer sync using buffer update events.
|
||||
- 🚀 **Fast**: separated NodeJS process that not block your vim most of the time.
|
||||
- 💎 **Reliable**: typed language, tested with CI.
|
||||
- 🌟 **Featured**: [full LSP support](https://github.com/neoclide/coc.nvim/wiki/Language-servers#supported-features)
|
||||
- 🌟 **Featured**: all LSP 3.16 features are supported, see `:h coc-lsp`.
|
||||
- ❤️ **Flexible**: [configured like VSCode](https://github.com/neoclide/coc.nvim/wiki/Using-the-configuration-file), [extensions work like in VSCode](https://github.com/neoclide/coc.nvim/wiki/Using-coc-extensions)
|
||||
|
||||
**Gold Sponsors**
|
||||
|
||||
<a href="https://opencollective.com/cocnvim#platinum-sponsors">
|
||||
<img src="https://opencollective.com/cocnvim/tiers/gold-sponsors.svg?avatarHeight=36&width=600">
|
||||
</a>
|
||||
|
||||
**Silver Sponsors**
|
||||
|
||||
<a href="https://opencollective.com/cocnvim#platinum-sponsors">
|
||||
<img src="https://opencollective.com/cocnvim/tiers/silver-sponsors.svg?avatarHeight=36&width=600">
|
||||
</a>
|
||||
|
||||
**Bronze Sponsors**
|
||||
|
||||
<a href="https://opencollective.com/cocnvim#platinum-sponsors">
|
||||
<img src="https://opencollective.com/cocnvim/tiers/bronze-sponsors.svg?avatarHeight=36&width=600">
|
||||
</a>
|
||||
|
||||
## Quick Start
|
||||
|
||||
Install [nodejs](https://nodejs.org/en/download/) >= 12.12:
|
||||
Make sure use vim >= 8.1.1719 or neovim >= 0.4.0.
|
||||
|
||||
Install [nodejs](https://nodejs.org/en/download/) >= 14.14:
|
||||
|
||||
```bash
|
||||
curl -sL install-node.vercel.app/lts | bash
|
||||
@ -110,44 +94,31 @@ possible to avoid conflict with your other plugins.
|
||||
command like`:verbose imap <tab>` to make sure that your keymap has taken effect.
|
||||
|
||||
```vim
|
||||
" Set internal encoding of vim, not needed on neovim, since coc.nvim using some
|
||||
" unicode characters in the file autoload/float.vim
|
||||
set encoding=utf-8
|
||||
|
||||
" TextEdit might fail if hidden is not set.
|
||||
set hidden
|
||||
|
||||
" Some servers have issues with backup files, see #649.
|
||||
set nobackup
|
||||
set nowritebackup
|
||||
|
||||
" Give more space for displaying messages.
|
||||
set cmdheight=2
|
||||
|
||||
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
|
||||
" delays and poor user experience.
|
||||
set updatetime=300
|
||||
|
||||
" Don't pass messages to |ins-completion-menu|.
|
||||
set shortmess+=c
|
||||
|
||||
" Always show the signcolumn, otherwise it would shift the text each time
|
||||
" diagnostics appear/become resolved.
|
||||
if has("nvim-0.5.0") || has("patch-8.1.1564")
|
||||
" Recently vim can merge signcolumn and number column into one
|
||||
set signcolumn=number
|
||||
else
|
||||
set signcolumn=yes
|
||||
endif
|
||||
set signcolumn=yes
|
||||
|
||||
" Use tab for trigger completion with characters ahead and navigate.
|
||||
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
|
||||
" other plugin before putting this into your config.
|
||||
inoremap <silent><expr> <TAB>
|
||||
\ pumvisible() ? "\<C-n>" :
|
||||
\ CheckBackspace() ? "\<TAB>" :
|
||||
\ coc#pum#visible() ? coc#pum#next(1):
|
||||
\ CheckBackspace() ? "\<Tab>" :
|
||||
\ coc#refresh()
|
||||
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
||||
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
|
||||
|
||||
" Make <CR> to accept selected completion item or notify coc.nvim to format
|
||||
" <C-g>u breaks current undo, please make your own choice.
|
||||
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
|
||||
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
||||
|
||||
function! CheckBackspace() abort
|
||||
let col = col('.') - 1
|
||||
@ -161,11 +132,6 @@ else
|
||||
inoremap <silent><expr> <c-@> coc#refresh()
|
||||
endif
|
||||
|
||||
" Make <CR> auto-select the first completion item and notify coc.nvim to
|
||||
" format on enter, <cr> could be remapped by other vim plugin
|
||||
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
|
||||
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
||||
|
||||
" Use `[g` and `]g` to navigate diagnostics
|
||||
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
|
||||
nmap <silent> [g <Plug>(coc-diagnostic-prev)
|
||||
@ -625,6 +591,10 @@ Try these steps when you have problem with coc.nvim.
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://github.com/rammiah"><img src="https://avatars.githubusercontent.com/u/26727562?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Rammiah</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/issues?q=author%3Arammiah" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://keybase.io/lambdalisue"><img src="https://avatars.githubusercontent.com/u/546312?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Alisue</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/issues?q=author%3Alambdalisue" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="http://bigshans.github.io"><img src="https://avatars.githubusercontent.com/u/26884666?v=4?s=50" width="50px;" alt=""/><br /><sub><b>bigshans</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/commits?author=bigshans" title="Documentation">📖</a></td>
|
||||
<td align="center"><a href="https://github.com/rob-3"><img src="https://avatars.githubusercontent.com/u/24816247?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Robert Boyd III</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/issues?q=author%3Arob-3" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://creasty.com"><img src="https://avatars.githubusercontent.com/u/1695538?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Yuki Iwanaga</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/commits?author=creasty" title="Code">💻</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
@ -9,7 +9,6 @@ let s:is_vim = !has('nvim')
|
||||
let s:error_sign = get(g:, 'coc_status_error_sign', has('mac') ? '❌ ' : 'E')
|
||||
let s:warning_sign = get(g:, 'coc_status_warning_sign', has('mac') ? '⚠️ ' : 'W')
|
||||
let s:select_api = exists('*nvim_select_popupmenu_item')
|
||||
let s:complete_info_api = exists('*complete_info')
|
||||
let s:callbacks = {}
|
||||
let s:hide_pum = has('nvim-0.6.1') || has('patch-8.2.3389')
|
||||
|
||||
@ -33,10 +32,6 @@ function! coc#add_command(id, cmd, ...)
|
||||
call coc#rpc#notify('addCommand', [config])
|
||||
endfunction
|
||||
|
||||
function! coc#refresh() abort
|
||||
return "\<c-r>=coc#start()\<CR>"
|
||||
endfunction
|
||||
|
||||
function! coc#on_enter()
|
||||
call coc#rpc#notify('CocAutocmd', ['Enter', bufnr('%')])
|
||||
return ''
|
||||
@ -46,7 +41,6 @@ function! coc#_insert_key(method, key, ...) abort
|
||||
let prefix = ''
|
||||
if get(a:, 1, 1)
|
||||
if pumvisible()
|
||||
let g:coc_hide_pum = 1
|
||||
if s:hide_pum
|
||||
let prefix = "\<C-x>\<C-z>"
|
||||
else
|
||||
@ -86,77 +80,12 @@ function! coc#_do_complete(start, items, preselect, changedtick)
|
||||
\ 'preselect': a:preselect
|
||||
\}
|
||||
if mode() =~# 'i'
|
||||
if s:is_vim
|
||||
" when the completeopt has longest, the input would be removed sometimes when not use feedkeys!
|
||||
call feedkeys("\<Plug>CocRefresh", 'i')
|
||||
else
|
||||
call coc#_complete()
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#_select_confirm() abort
|
||||
if !exists('*complete_info')
|
||||
throw 'coc#_select_confirm requires complete_info function to work'
|
||||
endif
|
||||
let selected = complete_info()['selected']
|
||||
if selected != -1
|
||||
return "\<C-y>"
|
||||
elseif pumvisible()
|
||||
return "\<down>\<C-y>"
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! coc#_selected()
|
||||
if !pumvisible() | return 0 | endif
|
||||
return coc#rpc#request('hasSelected', [])
|
||||
endfunction
|
||||
|
||||
" Deprecated
|
||||
function! coc#_hide() abort
|
||||
if pumvisible()
|
||||
call feedkeys("\<C-e>", 'in')
|
||||
call coc#_complete()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#_cancel(...)
|
||||
" hack for close pum
|
||||
" Use of <C-e> could cause bad insert when cursor just moved.
|
||||
let g:coc#_context = {'start': 0, 'preselect': -1,'candidates': []}
|
||||
if pumvisible()
|
||||
let g:coc_hide_pum = 1
|
||||
if get(a:, 1, 0)
|
||||
" Avoid delayed CompleteDone cancel new completion
|
||||
let g:coc_disable_complete_done = 1
|
||||
endif
|
||||
if s:hide_pum
|
||||
call feedkeys("\<C-x>\<C-z>", 'in')
|
||||
else
|
||||
let g:coc_disable_space_report = 1
|
||||
call feedkeys("\<space>\<bs>", 'in')
|
||||
endif
|
||||
endif
|
||||
for winid in coc#float#get_float_win_list()
|
||||
if getwinvar(winid, 'kind', '') ==# 'pum'
|
||||
call coc#float#close(winid)
|
||||
endif
|
||||
endfor
|
||||
let opt = get(a:, 2, '')
|
||||
if !empty(opt)
|
||||
execute 'noa set completeopt='.opt
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#_select() abort
|
||||
if !pumvisible() | return | endif
|
||||
call feedkeys("\<C-y>", 'in')
|
||||
endfunction
|
||||
|
||||
function! coc#start(...)
|
||||
let opt = coc#util#get_complete_option()
|
||||
call CocActionAsync('startCompletion', extend(opt, get(a:, 1, {})))
|
||||
return ''
|
||||
call coc#pum#close()
|
||||
endfunction
|
||||
|
||||
" used for statusline
|
||||
@ -217,10 +146,22 @@ function! coc#do_notify(id, method, result)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#start(...)
|
||||
let opt = coc#util#get_complete_option()
|
||||
call CocActionAsync('startCompletion', extend(opt, get(a:, 1, {})))
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! coc#refresh() abort
|
||||
return "\<c-r>=coc#start()\<CR>"
|
||||
endfunction
|
||||
|
||||
function! coc#_select_confirm() abort
|
||||
call timer_start(10, { -> coc#pum#select_confirm()})
|
||||
return s:is_vim || has('nvim-0.5.0') ? "\<Ignore>" : "\<space>\<bs>"
|
||||
endfunction
|
||||
|
||||
function! coc#complete_indent() abort
|
||||
if has('patch-8.2.3100')
|
||||
return 0
|
||||
endif
|
||||
let curpos = getcurpos()
|
||||
let indent_len = len(matchstr(getline('.'), '^\s*'))
|
||||
let startofline = &startofline
|
||||
@ -234,11 +175,9 @@ function! coc#complete_indent() abort
|
||||
let curpos[2] += shift
|
||||
let curpos[4] += shift
|
||||
call cursor(curpos[1:])
|
||||
if shift != 0
|
||||
if shift != 0
|
||||
if s:is_vim
|
||||
doautocmd TextChangedP
|
||||
call timer_start(0, { -> execute('redraw')})
|
||||
endif
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
endfunction
|
||||
|
@ -98,13 +98,7 @@ function! coc#compat#matchaddpos(group, pos, priority, winid) abort
|
||||
call matchaddpos(a:group, a:pos, a:priority, -1, {'window': a:winid})
|
||||
endif
|
||||
else
|
||||
if has('nvim-0.4.0')
|
||||
call matchaddpos(a:group, a:pos, a:priority, -1, {'window': a:winid})
|
||||
elseif exists('*nvim_set_current_win')
|
||||
noa call nvim_set_current_win(a:winid)
|
||||
call matchaddpos(a:group, a:pos, a:priority, -1)
|
||||
noa call nvim_set_current_win(curr)
|
||||
endif
|
||||
call matchaddpos(a:group, a:pos, a:priority, -1, {'window': a:winid})
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
@ -129,25 +123,9 @@ endfunction
|
||||
|
||||
" hlGroup, pos, priority
|
||||
function! coc#compat#matchaddgroups(winid, groups) abort
|
||||
" add by winid
|
||||
if has('patch-8.1.0218') || has('nvim-0.4.0')
|
||||
for group in a:groups
|
||||
call matchaddpos(group['hlGroup'], [group['pos']], group['priority'], -1, {'window': a:winid})
|
||||
endfor
|
||||
return
|
||||
endif
|
||||
let curr = win_getid()
|
||||
if curr == a:winid
|
||||
for group in a:groups
|
||||
call matchaddpos(group['hlGroup'], [group['pos']], group['priority'], -1)
|
||||
endfor
|
||||
elseif exists('*nvim_set_current_win')
|
||||
noa call nvim_set_current_win(a:winid)
|
||||
for group in a:groups
|
||||
call matchaddpos(group['hlGroup'], [group['pos']], group['priority'], -1)
|
||||
endfor
|
||||
noa call nvim_set_current_win(curr)
|
||||
endif
|
||||
for group in a:groups
|
||||
call matchaddpos(group['hlGroup'], [group['pos']], group['priority'], -1, {'window': a:winid})
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! coc#compat#del_var(name) abort
|
||||
|
@ -4,66 +4,70 @@ let s:root = expand('<sfile>:h:h:h')
|
||||
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:float_supported = exists('*nvim_open_win') || has('patch-8.1.1719')
|
||||
let s:frames = ['· ', '·· ', '···', ' ··', ' ·', ' ']
|
||||
let s:sign_group = 'PopUpCocDialog'
|
||||
let s:detail_bufnr = 0
|
||||
|
||||
" Float window aside pum
|
||||
function! coc#dialog#create_pum_float(winid, bufnr, lines, config) abort
|
||||
if !pumvisible() || !s:float_supported
|
||||
return v:null
|
||||
function! coc#dialog#create_pum_float(lines, config) abort
|
||||
let winid = coc#float#get_float_by_kind('pumdetail')
|
||||
if empty(a:lines) || !coc#pum#visible()
|
||||
if winid
|
||||
call coc#float#close(winid)
|
||||
endif
|
||||
return
|
||||
endif
|
||||
let pumbounding = a:config['pumbounding']
|
||||
let pw = pumbounding['width'] + get(pumbounding, 'scrollbar', 0)
|
||||
let pumbounding = coc#pum#info()
|
||||
let border = get(a:config, 'border', [])
|
||||
let pw = pumbounding['width'] + (pumbounding['border'] ? 0 : get(pumbounding, 'scrollbar', 0))
|
||||
let rp = &columns - pumbounding['col'] - pw
|
||||
let showRight = pumbounding['col'] > rp ? 0 : 1
|
||||
let maxWidth = showRight ? coc#math#min(rp - 1, a:config['maxWidth']) : coc#math#min(pumbounding['col'] - 1, a:config['maxWidth'])
|
||||
let border = get(a:config, 'border', [])
|
||||
let bh = get(border, 0 ,0) + get(border, 2, 0)
|
||||
let maxHeight = &lines - pumbounding['row'] - &cmdheight - 1 - bh
|
||||
if maxWidth <= 2 || maxHeight < 1
|
||||
return v:null
|
||||
endif
|
||||
let ch = 0
|
||||
let width = 0
|
||||
for line in a:lines
|
||||
let dw = max([1, strdisplaywidth(line)])
|
||||
let width = max([width, dw + 2])
|
||||
let ch += float2nr(ceil(str2float(string(dw))/(maxWidth - 2)))
|
||||
endfor
|
||||
let width = float2nr(coc#math#min(maxWidth, width))
|
||||
let ch = coc#string#content_height(a:lines, width - 2)
|
||||
let height = float2nr(coc#math#min(maxHeight, ch))
|
||||
let lines = map(a:lines, {_, s -> s =~# '^─' ? repeat('─', width - 2 + (s:is_vim && ch > height ? -1 : 0)) : s})
|
||||
let opts = {
|
||||
\ 'lines': lines,
|
||||
\ 'highlights': get(a:config, 'highlights', []),
|
||||
\ 'relative': 'editor',
|
||||
\ 'col': showRight ? pumbounding['col'] + pw : pumbounding['col'] - width - 1,
|
||||
\ 'col': showRight ? pumbounding['col'] + pw : pumbounding['col'] - width,
|
||||
\ 'row': pumbounding['row'],
|
||||
\ 'height': height,
|
||||
\ 'width': width - 2 + (s:is_vim && ch > height ? -1 : 0),
|
||||
\ 'scrollinside': showRight ? 0 : 1,
|
||||
\ 'codes': get(a:config, 'codes', []),
|
||||
\ }
|
||||
for key in ['border', 'highlight', 'borderhighlight', 'winblend', 'focusable', 'shadow']
|
||||
for key in ['border', 'highlight', 'borderhighlight', 'winblend', 'focusable', 'shadow', 'rounded']
|
||||
if has_key(a:config, key)
|
||||
let opts[key] = a:config[key]
|
||||
endif
|
||||
endfor
|
||||
call s:close_auto_hide_wins(a:winid)
|
||||
let res = coc#float#create_float_win(a:winid, a:bufnr, opts)
|
||||
if empty(res)
|
||||
return v:null
|
||||
call s:close_auto_hide_wins(winid)
|
||||
let result = coc#float#create_float_win(winid, s:detail_bufnr, opts)
|
||||
if empty(result)
|
||||
return
|
||||
endif
|
||||
call setwinvar(res[0], 'kind', 'pum')
|
||||
if has('nvim')
|
||||
call coc#float#nvim_scrollbar(res[0])
|
||||
let s:detail_bufnr = result[1]
|
||||
call setwinvar(result[0], 'kind', 'pumdetail')
|
||||
if !s:is_vim
|
||||
call coc#float#nvim_scrollbar(result[0])
|
||||
endif
|
||||
return res
|
||||
endfunction
|
||||
|
||||
" Float window below/above cursor
|
||||
function! coc#dialog#create_cursor_float(winid, bufnr, lines, config) abort
|
||||
if !s:float_supported || coc#prompt#activated()
|
||||
if coc#prompt#activated()
|
||||
return v:null
|
||||
endif
|
||||
let pumAlignTop = get(a:config, 'pumAlignTop', 0)
|
||||
@ -86,7 +90,7 @@ function! coc#dialog#create_cursor_float(winid, bufnr, lines, config) abort
|
||||
if empty(dimension)
|
||||
return v:null
|
||||
endif
|
||||
if pumvisible() && ((pumAlignTop && dimension['row'] <0)|| (!pumAlignTop && dimension['row'] > 0))
|
||||
if coc#pum#visible() && ((pumAlignTop && dimension['row'] <0)|| (!pumAlignTop && dimension['row'] > 0))
|
||||
return v:null
|
||||
endif
|
||||
let width = dimension['width']
|
||||
@ -248,7 +252,6 @@ function! coc#dialog#create_menu(lines, config) abort
|
||||
return
|
||||
endif
|
||||
let s:prompt_win_bufnr = ids[1]
|
||||
call s:place_sign(s:prompt_win_bufnr, 1)
|
||||
call coc#dialog#set_cursor(ids[0], ids[1], contentCount + 1)
|
||||
redraw
|
||||
if has('nvim')
|
||||
@ -284,7 +287,7 @@ function! coc#dialog#create_dialog(lines, config) abort
|
||||
return
|
||||
endif
|
||||
if get(a:config, 'cursorline', 0)
|
||||
call s:place_sign(bufnr, 1)
|
||||
call coc#dialog#place_sign(bufnr, 1)
|
||||
endif
|
||||
if has('nvim')
|
||||
redraw
|
||||
@ -324,7 +327,7 @@ function! coc#dialog#prompt_confirm(title, cb) abort
|
||||
\ 'focusable': v:false,
|
||||
\ 'relative': 'editor',
|
||||
\ 'highlight': 'Normal',
|
||||
\ 'borderhighlight': ['MoreMsg'],
|
||||
\ 'borderhighlight': 'MoreMsg',
|
||||
\ 'style': 'minimal',
|
||||
\ 'lines': [text],
|
||||
\ })
|
||||
@ -425,14 +428,13 @@ function! coc#dialog#get_config_cursor(lines, config) abort
|
||||
return v:null
|
||||
endif
|
||||
let maxHeight = coc#math#min(get(a:config, 'maxHeight', vh), vh)
|
||||
let ch = 0
|
||||
let width = coc#math#min(40, strdisplaywidth(title)) + 3
|
||||
for line in a:lines
|
||||
let dw = max([1, strdisplaywidth(line)])
|
||||
let width = max([width, dw + 2])
|
||||
let ch += float2nr(ceil(str2float(string(dw))/(maxWidth - 2)))
|
||||
endfor
|
||||
let width = coc#math#min(maxWidth, width)
|
||||
let ch = coc#string#content_height(a:lines, width - 2)
|
||||
let [lineIdx, colIdx] = coc#cursor#screen_pos()
|
||||
" How much we should move left
|
||||
let offsetX = coc#math#min(get(a:config, 'offsetX', 0), colIdx)
|
||||
@ -590,7 +592,14 @@ function! coc#dialog#set_cursor(winid, bufnr, line) abort
|
||||
else
|
||||
call nvim_win_set_cursor(a:winid, [a:line, 0])
|
||||
endif
|
||||
call s:place_sign(a:bufnr, a:line)
|
||||
call coc#dialog#place_sign(a:bufnr, a:line)
|
||||
endfunction
|
||||
|
||||
function! coc#dialog#place_sign(bufnr, line) abort
|
||||
call sign_unplace(s:sign_group, { 'buffer': a:bufnr })
|
||||
if a:line > 0
|
||||
call sign_place(6, s:sign_group, 'CocCurrentLine', a:bufnr, {'lnum': a:line})
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Could be center(with optional marginTop) or cursor
|
||||
@ -673,10 +682,3 @@ function! s:change_loading_buf(bufnr, idx) abort
|
||||
call timer_start(100, { -> s:change_loading_buf(a:bufnr, idx)})
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:place_sign(bufnr, line) abort
|
||||
call sign_unplace(s:sign_group, { 'buffer': a:bufnr })
|
||||
if a:line > 0
|
||||
call sign_place(6, s:sign_group, 'CocCurrentLine', a:bufnr, {'lnum': a:line})
|
||||
endif
|
||||
endfunction
|
||||
|
@ -102,7 +102,7 @@ endfunction
|
||||
" - cursorline: (optional) enable cursorline when is 1.
|
||||
" - autohide: (optional) window should be closed on CursorMoved when is 1.
|
||||
" - highlight: (optional) highlight of window, default to 'CocFloating'
|
||||
" - borderhighlight: (optional) should be array for border highlights,
|
||||
" - borderhighlight: (optional) should be array or string for border highlights,
|
||||
" highlight all borders with first value.
|
||||
" - close: (optional) show close button when is 1.
|
||||
" - highlights: (optional) highlight items.
|
||||
@ -114,9 +114,18 @@ endfunction
|
||||
" - 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
|
||||
" - nopad: (optional) not add pad when 1
|
||||
" - index: (optional) line index
|
||||
function! coc#float#create_float_win(winid, bufnr, config) abort
|
||||
let lines = get(a:config, 'lines', v:null)
|
||||
let bufnr = coc#float#create_buf(a:bufnr, lines, 'hide')
|
||||
let bufnr = a:bufnr
|
||||
try
|
||||
let bufnr = coc#float#create_buf(a:bufnr, lines, 'hide')
|
||||
catch /E523:/
|
||||
" happens when using getchar() #3921
|
||||
return []
|
||||
endtry
|
||||
let lnum = max([1, get(a:config, 'index', 0) + 1])
|
||||
" use exists
|
||||
if a:winid && coc#float#valid(a:winid)
|
||||
if s:is_vim
|
||||
@ -129,21 +138,29 @@ function! coc#float#create_float_win(winid, bufnr, config) abort
|
||||
\ 'minheight': a:config['height'],
|
||||
\ 'maxwidth': a:config['width'],
|
||||
\ 'maxheight': a:config['height'],
|
||||
\ 'cursorline': get(a:config, 'cursorline', 0),
|
||||
\ 'title': get(a:config, 'title', ''),
|
||||
\ 'highlight': get(a:config, 'highlight', 'CocFloating'),
|
||||
\ 'borderhighlight': [s:get_borderhighlight(a:config)],
|
||||
\ }
|
||||
if !s:empty_border(get(a:config, 'border', []))
|
||||
let opts['border'] = a:config['border']
|
||||
endif
|
||||
call popup_setoptions(a:winid, opts)
|
||||
call win_execute(a:winid, 'exe '.lnum)
|
||||
call coc#float#vim_buttons(a:winid, a:config)
|
||||
call s:add_highlights(a:winid, a:config, 0)
|
||||
return [a:winid, winbufnr(a:winid)]
|
||||
else
|
||||
let config = s:convert_config_nvim(a:config, 0)
|
||||
let hlgroup = get(a:config, 'highlight', 'CocFloating')
|
||||
let current = getwinvar(a:winid, '&winhl', '')
|
||||
let winhl = coc#util#merge_winhl(current, [['Normal', hlgroup], ['NormalNC', hlgroup], ['FoldColumn', hlgroup]])
|
||||
if winhl !=# current
|
||||
call setwinvar(a:winid, '&winhl', winhl)
|
||||
endif
|
||||
call nvim_win_set_buf(a:winid, bufnr)
|
||||
call nvim_win_set_config(a:winid, config)
|
||||
call nvim_win_set_cursor(a:winid, [1, 0])
|
||||
call nvim_win_set_cursor(a:winid, [lnum, 0])
|
||||
call coc#float#nvim_create_related(a:winid, config, a:config)
|
||||
call s:add_highlights(a:winid, a:config, 0)
|
||||
return [a:winid, bufnr]
|
||||
@ -155,34 +172,31 @@ function! coc#float#create_float_win(winid, bufnr, config) abort
|
||||
let title = get(a:config, 'title', '')
|
||||
let buttons = get(a:config, 'buttons', [])
|
||||
let hlgroup = get(a:config, 'highlight', 'CocFloating')
|
||||
let nopad = get(a:config, 'nopad', 0)
|
||||
let border = s:empty_border(get(a:config, 'border', [])) ? [0, 0, 0, 0] : a:config['border']
|
||||
let opts = {
|
||||
\ 'title': title,
|
||||
\ 'line': line,
|
||||
\ 'col': col,
|
||||
\ 'fixed': 1,
|
||||
\ 'padding': [0, !border[1], 0, !border[3]],
|
||||
\ 'padding': [0, !nopad && !border[1], 0, !nopad && !border[3]],
|
||||
\ 'borderchars': s:get_borderchars(a:config),
|
||||
\ 'highlight': hlgroup,
|
||||
\ 'cursorline': get(a:config, 'cursorline', 0),
|
||||
\ 'minwidth': a:config['width'],
|
||||
\ 'minheight': a:config['height'],
|
||||
\ 'maxwidth': a:config['width'],
|
||||
\ 'maxheight': a:config['height'],
|
||||
\ 'close': get(a:config, 'close', 0) ? 'button' : 'none',
|
||||
\ 'border': border,
|
||||
\ 'callback': { -> coc#float#on_close(winid)}
|
||||
\ 'callback': { -> coc#float#on_close(winid)},
|
||||
\ 'borderhighlight': [s:get_borderhighlight(a:config)],
|
||||
\ }
|
||||
if !empty(get(a:config, 'borderhighlight', v:null))
|
||||
let borderhighlight = a:config['borderhighlight']
|
||||
let opts['borderhighlight'] = type(borderhighlight) == 3
|
||||
\ ? map(borderhighlight, 'coc#highlight#compose_hlgroup(v:val,"'.hlgroup.'")')
|
||||
\ : [coc#highlight#compose_hlgroup(borderhighlight, hlgroup)]
|
||||
endif
|
||||
let winid = popup_create(bufnr, opts)
|
||||
if !s:popup_list_api
|
||||
call add(s:popup_list, winid)
|
||||
endif
|
||||
call s:set_float_defaults(winid, a:config)
|
||||
call win_execute(winid, 'exe '.lnum)
|
||||
call coc#float#vim_buttons(winid, a:config)
|
||||
else
|
||||
let config = s:convert_config_nvim(a:config, 1)
|
||||
@ -194,31 +208,12 @@ function! coc#float#create_float_win(winid, bufnr, config) abort
|
||||
if winid is 0
|
||||
return []
|
||||
endif
|
||||
let hlgroup = get(a:config, 'highlight', 'CocFloating')
|
||||
call setwinvar(winid, '&winhl', 'Normal:'.hlgroup.',NormalNC:'.hlgroup.',FoldColumn:'.hlgroup)
|
||||
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, '&cursorline', get(a:config, 'cursorline', 0))
|
||||
" cursorline highlight not work on old neovim
|
||||
call s:nvim_set_defaults(winid)
|
||||
call nvim_win_set_cursor(winid, [1, 0])
|
||||
call s:set_float_defaults(winid, a:config)
|
||||
call nvim_win_set_cursor(winid, [lnum, 0])
|
||||
call coc#float#nvim_create_related(winid, config, a:config)
|
||||
call coc#float#nvim_set_winblend(winid, get(a:config, 'winblend', v:null))
|
||||
endif
|
||||
if get(a:config, 'autohide', 0)
|
||||
call setwinvar(winid, 'autohide', 1)
|
||||
endif
|
||||
if s:is_vim || has('nvim-0.5.0')
|
||||
call setwinvar(winid, '&scrolloff', 0)
|
||||
endif
|
||||
if has('nvim-0.6.0') || has("patch-8.1.2281")
|
||||
call setwinvar(winid, '&showbreak', 'NONE')
|
||||
endif
|
||||
call setwinvar(winid, 'float', 1)
|
||||
call setwinvar(winid, '&wrap', !get(a:config, 'cursorline', 0))
|
||||
call setwinvar(winid, '&linebreak', 1)
|
||||
call setwinvar(winid, '&conceallevel', 0)
|
||||
call s:add_highlights(winid, a:config, 1)
|
||||
let g:coc_last_float_win = winid
|
||||
call coc#util#do_autocmd('CocOpenFloat')
|
||||
@ -229,11 +224,9 @@ function! coc#float#nvim_create_related(winid, config, opts) abort
|
||||
let related = getwinvar(a:winid, 'related', [])
|
||||
let exists = !empty(related)
|
||||
let border = get(a:opts, 'border', [])
|
||||
let highlights = get(a:opts, 'borderhighlight', [])
|
||||
let borderhighlight = type(highlights) == 1 ? highlights : get(highlights, 0, 'CocFloating')
|
||||
let borderhighlight = coc#highlight#compose_hlgroup(borderhighlight, get(a:opts, 'highlight', 'CocFloating'))
|
||||
let borderhighlight = s:get_borderhighlight(a:opts)
|
||||
let buttons = get(a:opts, 'buttons', [])
|
||||
let pad = empty(border) || get(border, 1, 0) == 0
|
||||
let pad = !get(a:opts, 'nopad', 0) && (empty(border) || get(border, 1, 0) == 0)
|
||||
let shadow = get(a:opts, 'shadow', 0)
|
||||
if get(a:opts, 'close', 0)
|
||||
call coc#float#nvim_close_btn(a:config, a:winid, border, borderhighlight, related)
|
||||
@ -284,11 +277,11 @@ function! coc#float#nvim_border_win(config, borderchars, winid, border, title, h
|
||||
endif
|
||||
if winid
|
||||
call nvim_win_set_config(winid, opt)
|
||||
call setwinvar(winid, '&winhl', 'Normal:'.a:hlgroup.',NormalNC:'.a:hlgroup)
|
||||
call setwinvar(winid, '&winhl', 'Normal:'.a:hlgroup.',NormalNC:'.a:hlgroup.',Search:')
|
||||
else
|
||||
noa let winid = nvim_open_win(bufnr, 0, opt)
|
||||
call setwinvar(winid, 'delta', -1)
|
||||
let winhl = 'Normal:'.a:hlgroup.',NormalNC:'.a:hlgroup
|
||||
let winhl = 'Normal:'.a:hlgroup.',NormalNC:'.a:hlgroup.',Search:'
|
||||
call s:nvim_add_related(winid, a:winid, 'border', winhl, a:related)
|
||||
endif
|
||||
endfunction
|
||||
@ -432,7 +425,7 @@ endfunction
|
||||
" Create or refresh scrollbar for winid
|
||||
" Need called on create, config, buffer change, scrolled
|
||||
function! coc#float#nvim_scrollbar(winid) abort
|
||||
if !has('nvim-0.4.0')
|
||||
if s:is_vim
|
||||
return
|
||||
endif
|
||||
let winids = nvim_tabpage_list_wins(nvim_get_current_tabpage())
|
||||
@ -590,6 +583,25 @@ function! coc#float#get_float_win_list(...) abort
|
||||
return []
|
||||
endfunction
|
||||
|
||||
function! coc#float#get_float_by_kind(kind) abort
|
||||
if s:is_vim
|
||||
if s:popup_list_api
|
||||
return get(filter(popup_list(), 'popup_getpos(v:val)["visible"] && getwinvar(v:val, "kind", "") ==# "'.a:kind.'"'), 0, 0)
|
||||
endif
|
||||
return get(filter(s:popup_list, 's:popup_visible(v:val) && getwinvar(v:val, "kind", "") ==# "'.a:kind.'"'), 0, 0)
|
||||
else
|
||||
let res = []
|
||||
for i in range(1, winnr('$'))
|
||||
let winid = win_getid(i)
|
||||
let config = nvim_win_get_config(winid)
|
||||
if !empty(config['relative']) && getwinvar(winid, 'kind', '') ==# a:kind
|
||||
return winid
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" Check if a float window is scrollable
|
||||
function! coc#float#scrollable(winid) abort
|
||||
let bufnr = winbufnr(a:winid)
|
||||
@ -625,16 +637,12 @@ function! coc#float#scroll(forward, ...)
|
||||
throw 'coc#float#scroll() requires nvim >= 0.4.0 or vim >= 8.2.0750'
|
||||
endif
|
||||
let amount = get(a:, 1, 0)
|
||||
let winids = filter(coc#float#get_float_win_list(), 'coc#float#scrollable(v:val)')
|
||||
let winids = filter(coc#float#get_float_win_list(), 'coc#float#scrollable(v:val) && getwinvar(v:val,"kind","") !=# "pum"')
|
||||
if empty(winids)
|
||||
return ''
|
||||
return mode() =~ '^i' || mode() ==# 'v' ? "" : "\<Ignore>"
|
||||
endif
|
||||
for winid in winids
|
||||
if s:is_vim
|
||||
call coc#float#scroll_win(winid, a:forward, amount)
|
||||
else
|
||||
call timer_start(0, { -> coc#float#scroll_win(winid, a:forward, amount)})
|
||||
endif
|
||||
call s:scroll_win(winid, a:forward, amount)
|
||||
endfor
|
||||
return mode() =~ '^i' || mode() ==# 'v' ? "" : "\<Ignore>"
|
||||
endfunction
|
||||
@ -737,11 +745,11 @@ function! coc#float#check_related() abort
|
||||
let ids = coc#float#get_float_win_list(1)
|
||||
for id in ids
|
||||
let target = getwinvar(id, 'target_winid', 0)
|
||||
if (target && index(ids, target) == -1) || getwinvar(id, 'kind', '') == 'pum'
|
||||
if target && index(ids, target) == -1
|
||||
call add(invalids, id)
|
||||
endif
|
||||
endfor
|
||||
if !s:popup_list_api
|
||||
if s:is_vim && !s:popup_list_api
|
||||
let s:popup_list = filter(ids, "index(invalids, v:val) == -1")
|
||||
endif
|
||||
for id in invalids
|
||||
@ -988,7 +996,8 @@ function! coc#float#nvim_scroll_adjust(winid) abort
|
||||
for winid in winids
|
||||
if nvim_win_is_valid(winid)
|
||||
if coc#window#get_var(winid, 'kind', '') != 'close'
|
||||
let [row, column] = nvim_win_get_position(winid)
|
||||
let config = nvim_win_get_config(winid)
|
||||
let [row, column] = [config.row, config.col]
|
||||
call nvim_win_set_config(winid, {
|
||||
\ 'row': row,
|
||||
\ 'col': column - 1,
|
||||
@ -1041,7 +1050,7 @@ function! s:convert_config_nvim(config, create) abort
|
||||
endif
|
||||
let result['width'] = float2nr(result['width'] + 1 - get(border,3, 0))
|
||||
else
|
||||
let result['width'] = float2nr(result['width'] + 1)
|
||||
let result['width'] = float2nr(result['width'] + (get(a:config, 'nopad', 0) ? 0 : 1))
|
||||
endif
|
||||
if has('nvim-0.5.1') && a:create
|
||||
let result['noautocmd'] = v:true
|
||||
@ -1300,16 +1309,45 @@ function! s:win_setview(winid, topline, lnum) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:nvim_set_defaults(winid) abort
|
||||
call setwinvar(a:winid, '&signcolumn', 'auto')
|
||||
function! s:set_float_defaults(winid, config) abort
|
||||
if !s:is_vim
|
||||
let hlgroup = get(a:config, 'highlight', 'CocFloating')
|
||||
call setwinvar(a:winid, '&winhl', 'Normal:'.hlgroup.',NormalNC:'.hlgroup.',FoldColumn:'.hlgroup.',Search:')
|
||||
call setwinvar(a:winid, 'border', get(a:config, 'border', []))
|
||||
call setwinvar(a:winid, 'scrollinside', get(a:config, 'scrollinside', 0))
|
||||
if !get(a:config, 'nopad', 0)
|
||||
call setwinvar(a:winid, '&foldcolumn', s:nvim_enable_foldcolumn(get(a:config, 'border', v:null)))
|
||||
endif
|
||||
call setwinvar(a:winid, '&signcolumn', 'no')
|
||||
call setwinvar(a:winid, '&cursorcolumn', 0)
|
||||
else
|
||||
call setwinvar(a:winid, '&foldcolumn', 0)
|
||||
endif
|
||||
if !s:is_vim || !has("patch-8.2.3100")
|
||||
call setwinvar(a:winid, '&number', 0)
|
||||
call setwinvar(a:winid, '&relativenumber', 0)
|
||||
call setwinvar(a:winid, '&cursorline', 0)
|
||||
endif
|
||||
call setwinvar(a:winid, '&foldenable', 0)
|
||||
call setwinvar(a:winid, '&colorcolumn', '')
|
||||
call setwinvar(a:winid, '&spell', 0)
|
||||
call setwinvar(a:winid, '&linebreak', 1)
|
||||
call setwinvar(a:winid, '&conceallevel', 0)
|
||||
call setwinvar(a:winid, '&list', 0)
|
||||
call setwinvar(a:winid, '&number', 0)
|
||||
call setwinvar(a:winid, '&relativenumber', 0)
|
||||
call setwinvar(a:winid, '&cursorcolumn', 0)
|
||||
call setwinvar(a:winid, '&colorcolumn', 0)
|
||||
call setwinvar(a:winid, '&wrap', !get(a:config, 'cursorline', 0))
|
||||
if s:is_vim || has('nvim-0.5.0')
|
||||
call setwinvar(a:winid, '&scrolloff', 0)
|
||||
endif
|
||||
if has('nvim-0.6.0') || has("patch-8.1.2281")
|
||||
call setwinvar(a:winid, '&showbreak', 'NONE')
|
||||
endif
|
||||
if exists('*win_execute')
|
||||
call win_execute(a:winid, 'setl fillchars+=eob:\ ')
|
||||
endif
|
||||
if get(a:config, 'autohide', 0)
|
||||
call setwinvar(a:winid, 'autohide', 1)
|
||||
endif
|
||||
call setwinvar(a:winid, 'float', 1)
|
||||
endfunction
|
||||
|
||||
function! s:nvim_add_related(winid, target, kind, winhl, related) abort
|
||||
@ -1372,3 +1410,21 @@ function! s:get_borderchars(config) abort
|
||||
endif
|
||||
return get(a:config, 'rounded', 0) ? s:rounded_borderchars : s:borderchars
|
||||
endfunction
|
||||
|
||||
function! s:scroll_win(winid, forward, amount) abort
|
||||
if s:is_vim
|
||||
call coc#float#scroll_win(a:winid, a:forward, a:amount)
|
||||
else
|
||||
call timer_start(0, { -> coc#float#scroll_win(a:winid, a:forward, a:amount)})
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:get_borderhighlight(config) abort
|
||||
let hlgroup = get(a:config, 'highlight', 'CocFloating')
|
||||
let borderhighlight = get(a:config, 'borderhighlight', v:null)
|
||||
if empty(borderhighlight)
|
||||
return hlgroup
|
||||
endif
|
||||
let highlight = type(borderhighlight) == 3 ? borderhighlight[0] : borderhighlight
|
||||
return coc#highlight#compose_hlgroup(highlight, hlgroup)
|
||||
endfunction
|
||||
|
@ -307,7 +307,7 @@ endfunction
|
||||
function! coc#highlight#add_highlight(bufnr, src_id, hl_group, line, col_start, col_end, ...) abort
|
||||
let opts = get(a:, 1, {})
|
||||
let priority = get(opts, 'priority', v:null)
|
||||
if has('nvim')
|
||||
if !s:is_vim
|
||||
if s:set_extmark && a:src_id != -1
|
||||
" get(opts, 'start_incl', 0) ? v:true : v:false,
|
||||
try
|
||||
@ -369,7 +369,9 @@ function! coc#highlight#add_highlights(winid, codes, highlights) abort
|
||||
endif
|
||||
if !empty(a:highlights)
|
||||
for item in a:highlights
|
||||
call coc#highlight#add_highlight(bufnr, -1, item['hlGroup'], item['lnum'], item['colStart'], item['colEnd'])
|
||||
let hlGroup = item['hlGroup']
|
||||
let opts = hlGroup =~# 'Search$' ? {'priority': 999, 'combine': 1} : {}
|
||||
call coc#highlight#add_highlight(bufnr, -1, hlGroup, item['lnum'], item['colStart'], item['colEnd'])
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
@ -421,7 +423,7 @@ function! coc#highlight#compose_hlgroup(fgGroup, bgGroup) abort
|
||||
if a:fgGroup ==# a:bgGroup
|
||||
return a:fgGroup
|
||||
endif
|
||||
if hlexists(hlGroup)
|
||||
if hlexists(hlGroup) && match(execute('hi '.hlGroup, 'silent!'), 'cleared') == -1
|
||||
return hlGroup
|
||||
endif
|
||||
let fgId = synIDtrans(hlID(a:fgGroup))
|
||||
|
@ -294,6 +294,7 @@ function! s:get_topline(config, lnum, winid) abort
|
||||
endfunction
|
||||
|
||||
function! s:set_preview_options(winid) abort
|
||||
call setwinvar(a:winid, '&foldmethod', 'manual')
|
||||
call setwinvar(a:winid, '&signcolumn', 'no')
|
||||
call setwinvar(a:winid, '&number', 1)
|
||||
call setwinvar(a:winid, '&cursorline', 0)
|
||||
|
@ -166,7 +166,7 @@ function! coc#notify#create(lines, config) abort
|
||||
let height = height + 1
|
||||
endif
|
||||
if !empty(actions)
|
||||
let before = width - strwidth(actionText)
|
||||
let before = max([width - strwidth(actionText), 0])
|
||||
let lines = lines + [repeat(' ', before).actionText]
|
||||
let height = height + 1
|
||||
call s:add_action_highlights(before, height - 1, highlights, actions)
|
||||
|
495
sources_non_forked/coc.nvim/autoload/coc/pum.vim
Normal file
495
sources_non_forked/coc.nvim/autoload/coc/pum.vim
Normal file
@ -0,0 +1,495 @@
|
||||
scriptencoding utf-8
|
||||
let s:is_vim = !has('nvim')
|
||||
let s:pum_bufnr = 0
|
||||
let s:pum_winid = 0
|
||||
let s:pum_index = -1
|
||||
let s:inserted = 0
|
||||
let s:virtual_text = 0
|
||||
let s:virtual_text_ns = 0
|
||||
let s:ignore = s:is_vim || has('nvim-0.5.0') ? "\<Ignore>" : "\<space>\<bs>"
|
||||
let s:hide_pum = has('nvim-0.6.1') || has('patch-8.2.3389')
|
||||
|
||||
function! coc#pum#visible() abort
|
||||
if !s:pum_winid
|
||||
return 0
|
||||
endif
|
||||
return getwinvar(s:pum_winid, 'float', 0) == 1
|
||||
endfunction
|
||||
|
||||
function! coc#pum#winid() abort
|
||||
return s:pum_winid
|
||||
endfunction
|
||||
|
||||
function! coc#pum#close_detail() abort
|
||||
let winid = coc#float#get_float_by_kind('pumdetail')
|
||||
if winid
|
||||
call coc#float#close(winid)
|
||||
if s:is_vim
|
||||
call timer_start(0, { -> execute('redraw')})
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#pum#close(...) abort
|
||||
if coc#float#valid(s:pum_winid)
|
||||
if get(a:, 1, '') ==# 'cancel'
|
||||
let input = getwinvar(s:pum_winid, 'input', '')
|
||||
let s:pum_index = -1
|
||||
call s:insert_word(input)
|
||||
call s:on_pum_change(0)
|
||||
doautocmd <nomodeline> TextChangedI
|
||||
elseif get(a:, 1, '') ==# 'confirm'
|
||||
let words = getwinvar(s:pum_winid, 'words', [])
|
||||
if s:pum_index >= 0
|
||||
let word = get(words, s:pum_index, '')
|
||||
call s:insert_word(word)
|
||||
endif
|
||||
doautocmd <nomodeline> TextChangedI
|
||||
endif
|
||||
call s:close_pum()
|
||||
if !get(a:, 2, 0)
|
||||
let pretext = strpart(getline('.'), 0, col('.') - 1)
|
||||
call coc#rpc#notify('CompleteStop', [get(a:, 1, ''), pretext])
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#pum#select_confirm() abort
|
||||
if s:pum_index < 0
|
||||
let s:pum_index = 0
|
||||
call s:on_pum_change(0)
|
||||
endif
|
||||
call coc#pum#close('confirm')
|
||||
endfunction
|
||||
|
||||
function! coc#pum#insert() abort
|
||||
call timer_start(10, { -> s:insert_current()})
|
||||
return s:ignore
|
||||
endfunction
|
||||
|
||||
function! coc#pum#_close() abort
|
||||
if coc#float#valid(s:pum_winid)
|
||||
call s:close_pum()
|
||||
if s:is_vim
|
||||
call timer_start(0, { -> execute('redraw')})
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:insert_current() abort
|
||||
if coc#float#valid(s:pum_winid)
|
||||
if s:pum_index >= 0
|
||||
let words = getwinvar(s:pum_winid, 'words', [])
|
||||
let word = get(words, s:pum_index, '')
|
||||
call s:insert_word(word)
|
||||
endif
|
||||
doautocmd <nomodeline> TextChangedI
|
||||
call s:close_pum()
|
||||
let pretext = strpart(getline('.'), 0, col('.') - 1)
|
||||
call coc#rpc#notify('CompleteStop', ['', pretext])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:close_pum() abort
|
||||
call s:clear_virtual_text()
|
||||
call coc#float#close(s:pum_winid)
|
||||
let s:pum_winid = 0
|
||||
let winid = coc#float#get_float_by_kind('pumdetail')
|
||||
if winid
|
||||
call coc#float#close(winid)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#pum#next(insert) abort
|
||||
call timer_start(10, { -> s:navigate(1, a:insert)})
|
||||
return s:ignore
|
||||
endfunction
|
||||
|
||||
function! coc#pum#prev(insert) abort
|
||||
call timer_start(10, { -> s:navigate(0, a:insert)})
|
||||
return s:ignore
|
||||
endfunction
|
||||
|
||||
function! coc#pum#stop() abort
|
||||
call timer_start(10, { -> coc#pum#close()})
|
||||
return s:ignore
|
||||
endfunction
|
||||
|
||||
function! coc#pum#cancel() abort
|
||||
call timer_start(10, { -> coc#pum#close('cancel')})
|
||||
return s:ignore
|
||||
endfunction
|
||||
|
||||
function! coc#pum#confirm() abort
|
||||
call timer_start(10, { -> coc#pum#close('confirm')})
|
||||
return s:ignore
|
||||
endfunction
|
||||
|
||||
function! coc#pum#select(index, insert, confirm) abort
|
||||
if !coc#float#valid(s:pum_winid)
|
||||
return ''
|
||||
endif
|
||||
if a:index == -1
|
||||
call coc#pum#close('cancel')
|
||||
return ''
|
||||
endif
|
||||
let total = coc#compat#buf_line_count(s:pum_bufnr)
|
||||
if a:index < 0 || a:index >= total
|
||||
throw 'index out of range ' . a:index
|
||||
endif
|
||||
call s:select_by_index(a:index, a:insert)
|
||||
if a:confirm
|
||||
call coc#pum#close('confirm')
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! coc#pum#info() abort
|
||||
let bufnr = winbufnr(s:pum_winid)
|
||||
let size = coc#compat#buf_line_count(bufnr)
|
||||
let words = getwinvar(s:pum_winid, 'words', [])
|
||||
let word = s:pum_index < 0 ? '' : get(words, s:pum_index, '')
|
||||
if s:is_vim
|
||||
let pos = popup_getpos(s:pum_winid)
|
||||
let border = has_key(popup_getoptions(s:pum_winid), 'border')
|
||||
let add = pos['scrollbar'] && border ? 1 : 0
|
||||
return {
|
||||
\ 'word': word,
|
||||
\ 'index': s:pum_index,
|
||||
\ 'scrollbar': pos['scrollbar'],
|
||||
\ 'row': pos['line'] - 1,
|
||||
\ 'col': pos['col'] - 1,
|
||||
\ 'width': pos['width'] + add,
|
||||
\ 'height': pos['height'],
|
||||
\ 'size': size,
|
||||
\ 'border': border,
|
||||
\ 'inserted': s:inserted ? v:true : v:false,
|
||||
\ }
|
||||
else
|
||||
let scrollbar = coc#float#get_related(s:pum_winid, 'scrollbar')
|
||||
let winid = coc#float#get_related(s:pum_winid, 'border', s:pum_winid)
|
||||
let pos = nvim_win_get_position(winid)
|
||||
return {
|
||||
\ 'word': word,
|
||||
\ 'index': s:pum_index,
|
||||
\ 'scrollbar': scrollbar && nvim_win_is_valid(scrollbar) ? 1 : 0,
|
||||
\ 'row': pos[0],
|
||||
\ 'col': pos[1],
|
||||
\ 'width': nvim_win_get_width(winid),
|
||||
\ 'height': nvim_win_get_height(winid),
|
||||
\ 'size': size,
|
||||
\ 'border': winid != s:pum_winid,
|
||||
\ 'inserted': s:inserted ? v:true : v:false,
|
||||
\ }
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#pum#scroll(forward) abort
|
||||
if coc#pum#visible()
|
||||
let size = coc#compat#buf_line_count(s:pum_bufnr)
|
||||
let height = s:get_height(s:pum_winid)
|
||||
if size > height
|
||||
call timer_start(10, { -> s:scroll_pum(a:forward, height, size)})
|
||||
endif
|
||||
endif
|
||||
return s:ignore
|
||||
endfunction
|
||||
|
||||
function! s:get_height(winid) abort
|
||||
if has('nvim')
|
||||
return nvim_win_get_height(a:winid)
|
||||
endif
|
||||
return get(popup_getpos(a:winid), 'core_height', 0)
|
||||
endfunction
|
||||
|
||||
function! s:scroll_pum(forward, height, size) abort
|
||||
let topline = s:get_topline(s:pum_winid)
|
||||
if !a:forward && topline == 1
|
||||
if s:pum_index >= 0
|
||||
call s:select_line(s:pum_winid, 1)
|
||||
call s:on_pum_change(1)
|
||||
endif
|
||||
return
|
||||
endif
|
||||
if a:forward && topline + a:height - 1 >= a:size
|
||||
if s:pum_index >= 0
|
||||
call s:select_line(s:pum_winid, a:size)
|
||||
call s:on_pum_change(1)
|
||||
endif
|
||||
return
|
||||
endif
|
||||
call coc#float#scroll_win(s:pum_winid, a:forward, a:height)
|
||||
if s:pum_index >= 0
|
||||
let lnum = s:pum_index + 1
|
||||
let topline = s:get_topline(s:pum_winid)
|
||||
if lnum >= topline && lnum <= topline + a:height - 1
|
||||
return
|
||||
endif
|
||||
call s:select_line(s:pum_winid, topline)
|
||||
call s:on_pum_change(1)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:get_topline(winid) abort
|
||||
if has('nvim')
|
||||
let info = getwininfo(a:winid)[0]
|
||||
return info['topline']
|
||||
else
|
||||
let pos = popup_getpos(a:winid)
|
||||
return pos['firstline']
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:navigate(next, insert) abort
|
||||
if !coc#float#valid(s:pum_winid)
|
||||
return
|
||||
endif
|
||||
let index = s:get_index(a:next)
|
||||
call s:select_by_index(index, a:insert)
|
||||
endfunction
|
||||
|
||||
function! s:select_by_index(index, insert) abort
|
||||
call s:set_cursor(s:pum_winid, a:index + 1)
|
||||
if !s:is_vim
|
||||
call coc#float#nvim_scrollbar(s:pum_winid)
|
||||
endif
|
||||
if a:insert
|
||||
let s:inserted = 1
|
||||
if a:index < 0
|
||||
let input = getwinvar(s:pum_winid, 'input', '')
|
||||
call s:insert_word(input)
|
||||
call coc#pum#close_detail()
|
||||
else
|
||||
let words = getwinvar(s:pum_winid, 'words', [])
|
||||
let word = get(words, a:index, '')
|
||||
call s:insert_word(word)
|
||||
endif
|
||||
doautocmd <nomodeline> TextChangedP
|
||||
endif
|
||||
call s:on_pum_change(1)
|
||||
endfunction
|
||||
|
||||
function! s:get_index(next) abort
|
||||
let size = coc#compat#buf_line_count(s:pum_bufnr)
|
||||
if a:next
|
||||
let index = s:pum_index + 1 == size ? -1 : s:pum_index + 1
|
||||
else
|
||||
let index = s:pum_index == -1 ? size - 1 : s:pum_index - 1
|
||||
endif
|
||||
return index
|
||||
endfunction
|
||||
|
||||
function! s:insert_word(word) abort
|
||||
let parts = getwinvar(s:pum_winid, 'parts', [])
|
||||
if !empty(parts) && mode() ==# 'i'
|
||||
let curr = getline('.')
|
||||
if curr ==# parts[0].a:word.parts[1]
|
||||
return
|
||||
endif
|
||||
let saved_completeopt = &completeopt
|
||||
if saved_completeopt =~ 'menuone'
|
||||
noa set completeopt=menu
|
||||
endif
|
||||
noa call complete(strlen(parts[0]) + 1, [a:word])
|
||||
if s:hide_pum
|
||||
" exit complete state
|
||||
call feedkeys("\<C-x>\<C-z>", 'in')
|
||||
else
|
||||
let g:coc_disable_space_report = 1
|
||||
call feedkeys("\<space>\<bs>", 'in')
|
||||
endif
|
||||
execute 'noa set completeopt='.saved_completeopt
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" create or update pum with lines, CompleteOption and config.
|
||||
" return winid & dimension
|
||||
function! coc#pum#create(lines, opt, config) abort
|
||||
if mode() !=# 'i' || a:opt['line'] != line('.')
|
||||
return
|
||||
endif
|
||||
let len = col('.') - a:opt['col'] - 1
|
||||
if len < 0
|
||||
return
|
||||
endif
|
||||
let input = len == 0 ? '' : strpart(getline('.'), a:opt['col'], len)
|
||||
if input !=# a:opt['input']
|
||||
return
|
||||
endif
|
||||
let config = s:get_pum_dimension(a:lines, a:opt['col'], a:config)
|
||||
if empty(config)
|
||||
return
|
||||
endif
|
||||
let s:virtual_text = has('nvim-0.5.0') && a:opt['virtualText']
|
||||
if s:virtual_text && !s:virtual_text_ns
|
||||
let s:virtual_text_ns = coc#highlight#create_namespace('pum-virtual')
|
||||
endif
|
||||
let selected = a:opt['index'] + 1
|
||||
call extend(config, {
|
||||
\ 'lines': a:lines,
|
||||
\ 'relative': 'cursor',
|
||||
\ 'nopad': 1,
|
||||
\ 'cursorline': 1,
|
||||
\ 'index': a:opt['index'],
|
||||
\ 'focusable': v:false
|
||||
\ })
|
||||
call extend(config, coc#dict#pick(a:config, ['highlight', 'rounded', 'highlights', 'winblend', 'shadow', 'border', 'borderhighlight']))
|
||||
if empty(get(config, 'winblend', 0)) && exists('&pumblend')
|
||||
let config['winblend'] = &pumblend
|
||||
endif
|
||||
let result = coc#float#create_float_win(s:pum_winid, s:pum_bufnr, config)
|
||||
if empty(result)
|
||||
return
|
||||
endif
|
||||
let s:inserted = 0
|
||||
let s:pum_winid = result[0]
|
||||
let s:pum_bufnr = result[1]
|
||||
call setwinvar(s:pum_winid, 'above', config['row'] < 0)
|
||||
let lnum = max([1, a:opt['index'] + 1])
|
||||
if s:is_vim
|
||||
call popup_setoptions(s:pum_winid, {
|
||||
\ 'firstline': s:get_firstline(lnum, len(a:lines), config['height'])
|
||||
\ })
|
||||
else
|
||||
let firstline = s:get_firstline(lnum, len(a:lines), config['height'])
|
||||
call coc#compat#execute(s:pum_winid, 'call winrestview({"lnum":'.lnum.',"topline":'.firstline.'})')
|
||||
endif
|
||||
let s:pum_index = get(config, 'index', -1)
|
||||
call coc#dialog#place_sign(s:pum_bufnr, s:pum_index + 1)
|
||||
call setwinvar(s:pum_winid, 'kind', 'pum')
|
||||
" content before col and content after cursor
|
||||
let linetext = getline('.')
|
||||
let parts = [strpart(linetext, 0, a:opt['col']), strpart(linetext, col('.') - 1)]
|
||||
call setwinvar(s:pum_winid, 'input', input)
|
||||
call setwinvar(s:pum_winid, 'parts', parts)
|
||||
call setwinvar(s:pum_winid, 'words', a:opt['words'])
|
||||
if !s:is_vim
|
||||
if len(a:lines) > config['height']
|
||||
redraw
|
||||
call coc#float#nvim_scrollbar(s:pum_winid)
|
||||
else
|
||||
call coc#float#close_related(s:pum_winid, 'scrollbar')
|
||||
endif
|
||||
endif
|
||||
call timer_start(10, { -> s:on_pum_change(0)})
|
||||
endfunction
|
||||
|
||||
function! s:get_firstline(lnum, total, height) abort
|
||||
if a:lnum <= a:height
|
||||
return 1
|
||||
endif
|
||||
return min([a:total - a:height + 1, a:lnum - (a:height*2/3)])
|
||||
endfunction
|
||||
|
||||
function! s:on_pum_change(move) abort
|
||||
if coc#float#valid(s:pum_winid)
|
||||
if s:virtual_text_ns
|
||||
call s:insert_virtual_text()
|
||||
endif
|
||||
let ev = extend(coc#pum#info(), {'move': a:move ? v:true : v:false})
|
||||
call coc#rpc#notify('CocAutocmd', ['MenuPopupChanged', ev, win_screenpos(winnr())[0] + winline() - 2])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:get_pum_dimension(lines, col, config) abort
|
||||
let linecount = len(a:lines)
|
||||
let [lineIdx, colIdx] = coc#cursor#screen_pos()
|
||||
let bh = empty(get(a:config, 'border', [])) ? 0 : 2
|
||||
let width = min([&columns, max([exists('&pumwidth') ? &pumwidth : 15, a:config['width']])])
|
||||
let vh = &lines - &cmdheight - 1 - !empty(&tabline)
|
||||
if vh <= 0
|
||||
return v:null
|
||||
endif
|
||||
let pumheight = empty(&pumheight) ? vh : &pumheight
|
||||
let showTop = getwinvar(s:pum_winid, 'above', v:null)
|
||||
if type(showTop) != v:t_number
|
||||
if vh - lineIdx - bh - 1 < min([pumheight, linecount]) && lineIdx > vh - lineIdx
|
||||
let showTop = 1
|
||||
else
|
||||
let showTop = 0
|
||||
endif
|
||||
endif
|
||||
let height = showTop ? min([lineIdx - bh - !empty(&tabline), linecount, pumheight]) : min([vh - lineIdx - bh - 1, linecount, pumheight])
|
||||
if height <= 0
|
||||
return v:null
|
||||
endif
|
||||
let col = - (col('.') - a:col - 1) - 1
|
||||
let row = showTop ? - height : 1
|
||||
let delta = colIdx + col
|
||||
if delta < 0
|
||||
let col = col - delta
|
||||
elseif delta + width > &columns
|
||||
let col = max([-colIdx, col - (delta + width - &columns)])
|
||||
endif
|
||||
return {
|
||||
\ 'row': row,
|
||||
\ 'col': col,
|
||||
\ 'width': width,
|
||||
\ 'height': height
|
||||
\ }
|
||||
endfunction
|
||||
|
||||
" can't use coc#dialog#set_cursor on vim8, don't know why
|
||||
function! s:set_cursor(winid, line) abort
|
||||
if s:is_vim
|
||||
let pos = popup_getpos(a:winid)
|
||||
let lastline = pos['firstline'] + pos['core_height'] - 1
|
||||
if a:line > lastline
|
||||
call popup_setoptions(a:winid, {
|
||||
\ 'firstline': pos['firstline'] + a:line - lastline,
|
||||
\ })
|
||||
elseif a:line < pos['firstline']
|
||||
call popup_setoptions(a:winid, {
|
||||
\ 'firstline': max([1, a:line]),
|
||||
\ })
|
||||
endif
|
||||
endif
|
||||
call s:select_line(a:winid, a:line)
|
||||
endfunction
|
||||
|
||||
function! s:select_line(winid, line) abort
|
||||
let s:pum_index = a:line - 1
|
||||
let lnum = max([1, a:line])
|
||||
if s:is_vim
|
||||
call coc#compat#execute(a:winid, 'exe '.lnum)
|
||||
else
|
||||
call nvim_win_set_cursor(a:winid, [lnum, 0])
|
||||
endif
|
||||
call coc#dialog#place_sign(winbufnr(a:winid), a:line)
|
||||
endfunction
|
||||
|
||||
function! s:insert_virtual_text() abort
|
||||
if !s:virtual_text_ns
|
||||
return
|
||||
endif
|
||||
let bufnr = bufnr('%')
|
||||
if !s:virtual_text || !coc#pum#visible() || s:pum_index < 0
|
||||
call nvim_buf_clear_namespace(bufnr, s:virtual_text_ns, 0, -1)
|
||||
else
|
||||
" Check if could create
|
||||
let insert = ''
|
||||
let words = getwinvar(s:pum_winid, 'words', [])
|
||||
let word = get(words, s:pum_index, '')
|
||||
let parts = getwinvar(s:pum_winid, 'parts', [])
|
||||
let input = strpart(getline('.'), strlen(parts[0]), col('.') - 1)
|
||||
if strchars(word) > strchars(input) && strcharpart(word, 0, strchars(input)) ==# input
|
||||
let insert = strcharpart(word, strchars(input))
|
||||
endif
|
||||
call nvim_buf_clear_namespace(bufnr, s:virtual_text_ns, 0, -1)
|
||||
if !empty(insert)
|
||||
let opts = {
|
||||
\ 'hl_mode': 'combine',
|
||||
\ 'virt_text': [[insert, 'CocPumVirtualText']],
|
||||
\ 'virt_text_pos': 'overlay',
|
||||
\ 'virt_text_win_col': virtcol('.') - 1,
|
||||
\ }
|
||||
call nvim_buf_set_extmark(bufnr, s:virtual_text_ns, line('.') - 1, col('.') - 1, opts)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:clear_virtual_text() abort
|
||||
if s:virtual_text_ns
|
||||
call nvim_buf_clear_namespace(bufnr('%'), s:virtual_text_ns, 0, -1)
|
||||
endif
|
||||
endfunction
|
@ -105,8 +105,8 @@ function! coc#snippet#disable()
|
||||
endfunction
|
||||
|
||||
function! coc#snippet#select(start, end, text) abort
|
||||
if pumvisible()
|
||||
call coc#_cancel()
|
||||
if coc#pum#visible()
|
||||
call coc#pum#close()
|
||||
endif
|
||||
if mode() == 's'
|
||||
call feedkeys("\<Esc>", 'in')
|
||||
@ -134,8 +134,8 @@ function! coc#snippet#move(position) abort
|
||||
let m = mode()
|
||||
if m == 's'
|
||||
call feedkeys("\<Esc>", 'in')
|
||||
elseif pumvisible()
|
||||
call coc#_cancel()
|
||||
elseif coc#pum#visible()
|
||||
call coc#pum#close()
|
||||
endif
|
||||
let pos = coc#snippet#to_cursor(a:position)
|
||||
call cursor(pos)
|
||||
|
@ -39,6 +39,35 @@ function! coc#string#reflow(lines, width) abort
|
||||
return empty(lines) ? [''] : lines
|
||||
endfunction
|
||||
|
||||
function! coc#string#content_height(lines, width) abort
|
||||
let len = 0
|
||||
for line in a:lines
|
||||
if strwidth(line) <= a:width
|
||||
let len = len + 1
|
||||
else
|
||||
let currlen = 0
|
||||
for part in split(line, '\<\|\>\|\ze\s')
|
||||
let w = strwidth(part)
|
||||
if currlen + w >= a:width
|
||||
if currlen + w == a:width
|
||||
let len = len + 1
|
||||
let currlen = 0
|
||||
else
|
||||
let len = len + (a:width + w)/a:width
|
||||
let currlen = w%a:width
|
||||
endif
|
||||
else
|
||||
let currlen = currlen + w
|
||||
endif
|
||||
endfor
|
||||
if currlen > 0
|
||||
let len = len + 1
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
return len == 0 ? 1 : len
|
||||
endfunction
|
||||
|
||||
" get change between two lines
|
||||
function! coc#string#diff(curr, previous, col) abort
|
||||
let end = strpart(a:curr, a:col - 1)
|
||||
|
@ -4,6 +4,25 @@ let s:is_mac = has('mac')
|
||||
let s:sign_api = exists('*sign_getplaced') && exists('*sign_place')
|
||||
let s:sign_groups = []
|
||||
|
||||
" Check <Tab> and <CR>
|
||||
function! coc#ui#check_pum_keymappings() abort
|
||||
for key in ['<cr>', '<tab>', '<c-y>']
|
||||
let lhs = maparg(key, 'i')
|
||||
if lhs =~# '\<pumvisible()' && lhs !~# '\<coc#pum#visible()'
|
||||
let lines = [
|
||||
\ 'coc.nvim switched to custom popup menu from 0.0.82',
|
||||
\ 'you have to change key-mapping of '.key.' to make it work.',
|
||||
\ 'checkout current key-mapping by ":verbose imap '.key.'"',
|
||||
\ 'checkout documentation by ":h coc-completion"']
|
||||
call coc#notify#create(lines, {
|
||||
\ 'borderhighlight': 'CocInfoSign',
|
||||
\ 'timeout': 30000,
|
||||
\ 'kind': 'warning',
|
||||
\ })
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! coc#ui#quickpick(title, items, cb) abort
|
||||
if exists('*popup_menu')
|
||||
function! s:QuickpickHandler(id, result) closure
|
||||
@ -249,22 +268,25 @@ function! coc#ui#set_lines(bufnr, changedtick, original, replacement, start, end
|
||||
if !empty(a:col)
|
||||
let delta = col('.') - a:col
|
||||
endif
|
||||
if getbufvar(a:bufnr, 'changedtick') != a:changedtick && bufnr('%') == a:bufnr
|
||||
if getbufvar(a:bufnr, 'changedtick') > a:changedtick && bufnr('%') == a:bufnr
|
||||
" try apply current line change
|
||||
let lnum = line('.')
|
||||
let idx = a:start - lnum + 1
|
||||
let previous = get(a:original, idx, 0)
|
||||
if type(previous) == 1
|
||||
let content = getline('.')
|
||||
if previous !=# content
|
||||
let diff = coc#string#diff(content, previous, col('.'))
|
||||
let changed = get(a:replacement, idx, 0)
|
||||
if type(changed) == 1 && strcharpart(previous, 0, diff['end']) ==# strcharpart(changed, 0, diff['end'])
|
||||
let applied = coc#string#apply(changed, diff)
|
||||
let replacement = copy(a:replacement)
|
||||
let replacement[idx] = applied
|
||||
call coc#compat#buf_set_lines(a:bufnr, a:start, a:end, replacement)
|
||||
return
|
||||
" change for current line
|
||||
if a:end - a:start == 1 && a:end == lnum && len(a:replacement) == 1
|
||||
let idx = a:start - lnum + 1
|
||||
let previous = get(a:original, idx, 0)
|
||||
if type(previous) == 1
|
||||
let content = getline('.')
|
||||
if previous !=# content
|
||||
let diff = coc#string#diff(content, previous, col('.'))
|
||||
let changed = get(a:replacement, idx, 0)
|
||||
if type(changed) == 1 && strcharpart(previous, 0, diff['end']) ==# strcharpart(changed, 0, diff['end'])
|
||||
let applied = coc#string#apply(changed, diff)
|
||||
let replacement = copy(a:replacement)
|
||||
let replacement[idx] = applied
|
||||
call coc#compat#buf_set_lines(a:bufnr, a:start, a:end, replacement)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
@ -340,11 +362,7 @@ function! coc#ui#rename_file(oldPath, newPath, write) abort
|
||||
execute 'keepalt tab drop '.fnameescape(bufname(bufnr))
|
||||
let winid = win_getid()
|
||||
endif
|
||||
if exists('*nvim_buf_set_name')
|
||||
call nvim_buf_set_name(bufnr, bufname)
|
||||
else
|
||||
call coc#compat#execute(winid, 'file '.fnameescape(bufname), 'silent')
|
||||
endif
|
||||
call coc#compat#execute(winid, 'keepalt file '.fnameescape(bufname), 'silent')
|
||||
call coc#compat#execute(winid, 'doautocmd BufEnter')
|
||||
if a:write
|
||||
call coc#compat#execute(winid, 'noa write!', 'silent')
|
||||
|
@ -2,7 +2,7 @@ scriptencoding utf-8
|
||||
let s:root = expand('<sfile>:h:h:h')
|
||||
let s:is_win = has('win32') || has('win64')
|
||||
let s:is_vim = !has('nvim')
|
||||
let s:vim_api_version = 30
|
||||
let s:vim_api_version = 31
|
||||
|
||||
function! coc#util#remote_fns(name)
|
||||
let fns = ['init', 'complete', 'should_complete', 'refresh', 'get_startcol', 'on_complete', 'on_enter']
|
||||
@ -15,6 +15,19 @@ function! coc#util#remote_fns(name)
|
||||
return res
|
||||
endfunction
|
||||
|
||||
function! coc#util#merge_winhl(curr, hls) abort
|
||||
let highlightMap = {}
|
||||
for parts in map(split(a:curr, ','), 'split(v:val, ":")')
|
||||
if len(parts) == 2
|
||||
let highlightMap[parts[0]] = parts[1]
|
||||
endif
|
||||
endfor
|
||||
for item in a:hls
|
||||
let highlightMap[item[0]] = item[1]
|
||||
endfor
|
||||
return join(map(items(highlightMap), 'v:val[0].":".v:val[1]'), ',')
|
||||
endfunction
|
||||
|
||||
function! coc#util#do_complete(name, opt, cb) abort
|
||||
let handler = 'coc#source#'.a:name.'#complete'
|
||||
let l:Cb = {res -> a:cb(v:null, res)}
|
||||
@ -24,9 +37,9 @@ endfunction
|
||||
|
||||
function! coc#util#suggest_variables(bufnr) abort
|
||||
return {
|
||||
\ 'coc_suggest_disable': getbufvar(a:bufnr, 'coc_suggest_disable', 0),
|
||||
\ 'coc_disabled_sources': getbufvar(a:bufnr, 'coc_disabled_sources', []),
|
||||
\ 'coc_suggest_blacklist': getbufvar(a:bufnr, 'coc_suggest_blacklist', []),
|
||||
\ 'disable': getbufvar(a:bufnr, 'coc_suggest_disable', 0),
|
||||
\ 'disabled_sources': getbufvar(a:bufnr, 'coc_disabled_sources', []),
|
||||
\ 'blacklist': getbufvar(a:bufnr, 'coc_suggest_blacklist', []),
|
||||
\ }
|
||||
endfunction
|
||||
|
||||
@ -282,7 +295,7 @@ function! coc#util#vim_info()
|
||||
\ 'filetypeMap': get(g:, 'coc_filetype_map', {}),
|
||||
\ 'version': coc#util#version(),
|
||||
\ 'completeOpt': &completeopt,
|
||||
\ 'pumevent': exists('##MenuPopupChanged') || exists('##CompleteChanged'),
|
||||
\ 'pumevent': 1,
|
||||
\ 'isVim': has('nvim') ? v:false : v:true,
|
||||
\ 'isCygwin': has('win32unix') ? v:true : v:false,
|
||||
\ 'isMacvim': has('gui_macvim') ? v:true : v:false,
|
||||
@ -294,10 +307,12 @@ function! coc#util#vim_info()
|
||||
\ 'locationlist': get(g:,'coc_enable_locationlist', 1),
|
||||
\ 'progpath': v:progpath,
|
||||
\ 'guicursor': &guicursor,
|
||||
\ 'pumwidth': exists('&pumwidth') ? &pumwidth : 15,
|
||||
\ 'tabCount': tabpagenr('$'),
|
||||
\ 'updateHighlight': has('nvim-0.5.0') || has('patch-8.1.1719') ? v:true : v:false,
|
||||
\ 'vimCommands': get(g:, 'coc_vim_commands', []),
|
||||
\ 'sign': exists('*sign_place') && exists('*sign_unplace'),
|
||||
\ 'ambiguousIsNarrow': &ambiwidth ==# 'single' ? v:true : v:false,
|
||||
\ 'textprop': has('textprop') && has('patch-8.1.1719') && !has('nvim') ? v:true : v:false,
|
||||
\ 'dialog': has('nvim-0.4.0') || has('patch-8.2.0750') ? v:true : v:false,
|
||||
\ 'semanticHighlights': coc#util#semantic_hlgroups()
|
||||
|
@ -22,6 +22,13 @@ function! coc#window#tabnr(winid) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#window#get_cursor(winid) abort
|
||||
if exists('*nvim_win_get_cursor')
|
||||
return nvim_win_get_cursor(a:winid)
|
||||
endif
|
||||
return coc#api#exec('win_get_cursor', [a:winid])
|
||||
endfunction
|
||||
|
||||
" Check if winid visible on current tabpage
|
||||
function! coc#window#visible(winid) abort
|
||||
if s:is_vim
|
||||
|
@ -16,8 +16,8 @@ endfunction
|
||||
|
||||
function! s:checkEnvironment() abort
|
||||
let valid
|
||||
\ = s:checkVim(has('nvim'), 'nvim', 'nvim-0.3.2')
|
||||
\ + s:checkVim(!has('nvim'), 'vim', 'patch-0.8.1453')
|
||||
\ = s:checkVim(has('nvim'), 'nvim', 'nvim-0.4.0')
|
||||
\ + s:checkVim(!has('nvim'), 'vim', 'patch-8.1.1719')
|
||||
let node = get(g:, 'coc_node_path', $COC_NODE_PATH == '' ? 'node' : $COC_NODE_PATH)
|
||||
if !executable(node)
|
||||
let valid = 0
|
||||
@ -32,9 +32,9 @@ function! s:checkEnvironment() abort
|
||||
if empty(ms)
|
||||
let valid = 0
|
||||
call health#report_error('Unable to detect version of node, make sure your node executable is http://nodejs.org/')
|
||||
elseif str2nr(ms[1]) < 12 || (str2nr(ms[1]) == 12 && str2nr(ms[2]) < 12)
|
||||
elseif str2nr(ms[1]) < 14 || (str2nr(ms[1]) == 14 && str2nr(ms[2]) < 14)
|
||||
let valid = 0
|
||||
call health#report_warn('Node.js version '.trim(output).' < 12.12.0, please upgrade node.js')
|
||||
call health#report_warn('Node.js version '.trim(output).' < 14.14.0, please upgrade node.js')
|
||||
endif
|
||||
if valid
|
||||
call health#report_ok('Environment check passed')
|
||||
|
File diff suppressed because one or more lines are too long
@ -127,6 +127,10 @@
|
||||
"progress",
|
||||
"callHierarchy",
|
||||
"linkedEditing",
|
||||
"inlayHint",
|
||||
"inlineValue",
|
||||
"typeHierarchy",
|
||||
"pullDiagnostic",
|
||||
"fileEvents",
|
||||
"semanticTokens"
|
||||
]
|
||||
@ -385,39 +389,62 @@
|
||||
"default": "npm",
|
||||
"description": "Command or absolute path to npm or yarn."
|
||||
},
|
||||
"suggest.noselect": {
|
||||
"type": "boolean",
|
||||
"description": "Not make vim select first item on completion start",
|
||||
"default": false
|
||||
},
|
||||
"suggest.formatItems": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"enum": ["abbr", "menu", "kind", "shortcut"]
|
||||
},
|
||||
"contains": {
|
||||
"enum": ["abbr"]
|
||||
},
|
||||
"uniqueItems": true,
|
||||
"description": "Items shown in popup menu in order.",
|
||||
"default": ["abbr", "menu", "kind", "shortcut"]
|
||||
},
|
||||
"suggest.selection": {
|
||||
"type": "string",
|
||||
"default": "none",
|
||||
"default": "first",
|
||||
"description": "Controls how suggestions are pre-selected when showing the suggest list.",
|
||||
"enum": ["none", "recentlyUsed", "recentlyUsedByPrefix"]
|
||||
"enum": ["first", "recentlyUsed", "recentlyUsedByPrefix"]
|
||||
},
|
||||
"suggest.enablePreselect": {
|
||||
"type": "boolean",
|
||||
"description": "Enable preselect feature of LSP, only works on neovim, required for suggest.selection config.",
|
||||
"default": false
|
||||
},
|
||||
"suggest.enablePreview": {
|
||||
"type": "boolean",
|
||||
"description": "Add preview option to completeopt, default: false.",
|
||||
"default": false
|
||||
},
|
||||
"suggest.floatEnable": {
|
||||
"type": "boolean",
|
||||
"description": "Enable floating window for documentation when possible.",
|
||||
"description": "Enable preselect feature of LSP, works when suggest.noselect is false.",
|
||||
"default": true
|
||||
},
|
||||
"suggest.floatConfig": {
|
||||
"type": "object",
|
||||
"description": "Configure style of documentation window for complete item.",
|
||||
"description": "Configure style of popup menu and documentation window of completion.",
|
||||
"allOf": [{ "$ref": "#/definitions/float" }],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"border": {},
|
||||
"rounded": {},
|
||||
"highlight": {},
|
||||
"borderhighlight": {},
|
||||
"maxWidth": {},
|
||||
"winblend": {},
|
||||
"shadow": {}
|
||||
}
|
||||
},
|
||||
"suggest.pumFloatConfig": {
|
||||
"type": ["object", "null"],
|
||||
"description": "Configure style of popup menu, suggest.floatConfig is used when not specified.",
|
||||
"allOf": [{ "$ref": "#/definitions/float" }],
|
||||
"additionalProperties": false,
|
||||
"default": null,
|
||||
"properties": {
|
||||
"border": {},
|
||||
"rounded": {},
|
||||
"highlight": {},
|
||||
"borderhighlight": {},
|
||||
"maxWidth": {},
|
||||
"winblend": {},
|
||||
"focusable": {},
|
||||
"shadow": {}
|
||||
}
|
||||
},
|
||||
@ -435,7 +462,7 @@
|
||||
"type": "string",
|
||||
"default": "preview",
|
||||
"description": "Where to show the detail text of CompleteItem from LS.",
|
||||
"enum": ["abbr", "menu", "preview"]
|
||||
"enum": ["abbr", "preview"]
|
||||
},
|
||||
"suggest.autoTrigger": {
|
||||
"type": "string",
|
||||
@ -448,21 +475,6 @@
|
||||
"default": 99,
|
||||
"description": "Priority of language sources."
|
||||
},
|
||||
"suggest.disableKind": {
|
||||
"type": "boolean",
|
||||
"description": "Remove kind field from vim complete item.",
|
||||
"default": false
|
||||
},
|
||||
"suggest.disableMenu": {
|
||||
"type": "boolean",
|
||||
"description": "Remove menu field from vim complete item.",
|
||||
"default": false
|
||||
},
|
||||
"suggest.disableMenuShortcut": {
|
||||
"type": "boolean",
|
||||
"description": "Disable shortcut of completion source in menu.",
|
||||
"default": false
|
||||
},
|
||||
"suggest.snippetIndicator": {
|
||||
"type": "string",
|
||||
"default": "~",
|
||||
@ -517,16 +529,6 @@
|
||||
"default": false,
|
||||
"description": "Controls whether suggestions should be accepted on commit characters. For example, in JavaScript, the semi-colon (`;`) can be a commit character that accepts a suggestion and types that character. Requires CompleteChanged event to work."
|
||||
},
|
||||
"suggest.noselect": {
|
||||
"type": "boolean",
|
||||
"description": "Not make vim select first item on completion start",
|
||||
"default": true
|
||||
},
|
||||
"suggest.keepCompleteopt": {
|
||||
"type": "boolean",
|
||||
"description": "When enabled, completeopt is not overridden, auto completion will be disabled if completeopt doesn't have noinsert and noselect.",
|
||||
"default": false
|
||||
},
|
||||
"suggest.lowPrioritySourceLimit": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
@ -610,6 +612,11 @@
|
||||
"description": "Regexps to ignore when trigger suggest",
|
||||
"default": []
|
||||
},
|
||||
"suggest.virtualText": {
|
||||
"type": "boolean",
|
||||
"description": "Show virtual text for insert word of selected item, works on neovim >= 0.5.0",
|
||||
"default": false
|
||||
},
|
||||
"documentHighlight.priority": {
|
||||
"type": "number",
|
||||
"default": -1,
|
||||
@ -1041,11 +1048,6 @@
|
||||
"default": 10,
|
||||
"description": "Maximum content height of notification dialog."
|
||||
},
|
||||
"notification.preferMenuPicker": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Use menu picker for message notification with actions."
|
||||
},
|
||||
"notification.disabledProgressSources": {
|
||||
"type": "array",
|
||||
"default": [],
|
||||
|
@ -56,36 +56,50 @@ Http request~
|
||||
------------------------------------------------------------------------------
|
||||
Completion related~
|
||||
*coc-config-suggest*
|
||||
"suggest.noselect" *coc-config-suggest-noselect*
|
||||
|
||||
Avoid select complete item on completion start, default: `false`.
|
||||
|
||||
Note: default changed to `false` on coc.nvim 0.0.82 to provide preselect
|
||||
item.
|
||||
|
||||
"suggest.selection" *coc-config-suggest-selection*
|
||||
|
||||
Controls how suggestions are pre-selected when showing the suggest
|
||||
list. Default: "none".
|
||||
list. Default: "recentlyUsed".
|
||||
|
||||
Could be "none", "recentlyUsed" and "recentlyUsedByPrefix".
|
||||
Could be "first", "recentlyUsed" and "recentlyUsedByPrefix".
|
||||
|
||||
Note: the selected item would be moved to first place when
|
||||
"suggest.enablePreselect" is not enabled.
|
||||
"suggest.formatItems" *coc-config-suggest-formatItems*
|
||||
|
||||
"suggest.enablePreselect" *coc-config-suggest-enablePreselect*
|
||||
Items shown in popup menu in order.
|
||||
Default to : `["abbr", "menu", "kind", "shortcut"]`
|
||||
|
||||
Enable preselect feature on Neovim, default: `false`
|
||||
"suggest.enablePreselect" *coc-config-suggest-enablePreselect*
|
||||
|
||||
Enable preselect feature of LSP, works when "suggest.noselect" is false.
|
||||
Default: `true`.
|
||||
|
||||
"suggest.labelMaxLength" *coc-config-suggest-labelMaxLength*
|
||||
|
||||
Maximum length of label shown in 'pum', default: `200`
|
||||
|
||||
"suggest.enablePreview" *coc-config-suggest-enablePreview*
|
||||
|
||||
Add preview option to 'completeopt', default: `false`
|
||||
|
||||
"suggest.floatEnable" *coc-config-suggest-floatEnable*
|
||||
|
||||
Enable floating window for documentation when possible, default: `true`
|
||||
Maximum length of label shown in popup menu, default: `200`
|
||||
|
||||
"suggest.floatConfig" *coc-config-suggest-floatConfig*
|
||||
|
||||
Configuration of floating window/popup, see |coc-config-float|.
|
||||
Excludes properties: "title", "close" and "maxHeight".
|
||||
Configure style of popup menu and documentation window for completion,
|
||||
see |coc-config-float|.
|
||||
|
||||
Note: some properties not work, including: "title", "focusable",
|
||||
"close" and "maxHeight" (use 'pumheight' option for maximum height of
|
||||
popup menu).
|
||||
|
||||
Note: "maxWidth" not works for popup menu, use
|
||||
|coc-config-suggest-detailMaxLength| instead.
|
||||
|
||||
"suggest.pumFloatConfig" *coc-config-suggest-pumFloatConfig*
|
||||
|
||||
Configure style of popup menu, suggest.floatConfig is used when not
|
||||
specified. Default: `null`.
|
||||
|
||||
"suggest.detailMaxLength" *coc-config-suggest-detailMaxLength*
|
||||
|
||||
@ -113,18 +127,10 @@ Completion related~
|
||||
|
||||
Priority of language sources, default: `99`
|
||||
|
||||
"suggest.disableKind" *coc-config-suggest-disableKind*
|
||||
|
||||
Remove kind field from Vim complete item, default: `false`
|
||||
|
||||
"suggest.disableMenu" *coc-config-suggest-disableMenu*
|
||||
|
||||
Remove menu field from Vim complete item, default: `false`
|
||||
|
||||
"suggest.snippetIndicator" *coc-config-suggest-snippetIndicator*
|
||||
|
||||
The character used in completion item abbreviation to indicate it
|
||||
expands as code snippet, default: `"~"`
|
||||
expands as code snippet, default: `~`.
|
||||
|
||||
"suggest.maxCompleteItemCount" *coc-config-suggest-maxCompleteItemCount*
|
||||
|
||||
@ -180,17 +186,6 @@ Completion related~
|
||||
after the completion item text. Requires `CompleteChanged` event to work,
|
||||
default: `false`
|
||||
|
||||
"suggest.noselect" *coc-config-suggest-noselect*
|
||||
|
||||
Prevent Vim from selecting the first item on completion start,
|
||||
default: `true`
|
||||
|
||||
"suggest.keepCompleteopt" *coc-config-suggest-keepCompleteopt*
|
||||
|
||||
When enabled, 'completeopt' is not overridden during completion. Won't
|
||||
work if 'completeopt' doesn't includes 'noinsert' and 'noselect' which
|
||||
are required by auto completion, default: `false`
|
||||
|
||||
"suggest.lowPrioritySourceLimit" *coc-config-suggest-lowPrioritySourceLimit*
|
||||
|
||||
Max items count for source priority lower than `90`.
|
||||
@ -199,10 +194,6 @@ Completion related~
|
||||
|
||||
Max items count for source priority bigger than or equal to `90`.
|
||||
|
||||
"suggest.disableMenuShortcut" *coc-config-suggest-disableMenuShortcut*
|
||||
|
||||
Disable shortcut of completion source in menu, default: `false`
|
||||
|
||||
"suggest.removeDuplicateItems" *coc-config-suggest-removeDuplicateItems*
|
||||
|
||||
Remove completion items with duplicated word for all sources, snippet
|
||||
@ -222,6 +213,16 @@ Completion related~
|
||||
|
||||
Trigger suggest with ASCII characters only, default: `false`
|
||||
|
||||
"suggest.ignoreRegexps" *coc-config-suggest-ignoreRegexps*
|
||||
|
||||
Array of regexps, when input matched one of them, not trigger
|
||||
completion, default: `[]`
|
||||
|
||||
"suggest.virtualText" *coc-config-suggest-virtualText*
|
||||
|
||||
Show virtual text for insert word of selected item, works on neovim >=
|
||||
0.5.0, default: `false`
|
||||
|
||||
"suggest.completionItemKindLabels" *coc-config-suggest-completionItemKindLabels*
|
||||
|
||||
Set custom labels to completion item kinds, default: `{}`.
|
||||
@ -610,11 +611,6 @@ Dialog~
|
||||
Notification~
|
||||
*coc-config-notification*
|
||||
|
||||
"notification.preferMenuPicker" *coc-config-notification-preferMenuPicker*
|
||||
|
||||
Use menu picker for message notifications with actions, default
|
||||
`false`.
|
||||
|
||||
"notification.maxWidth" *coc-config-notification-maxWidth*
|
||||
|
||||
Maximum content width of notification dialog, default to `60`.
|
||||
@ -743,7 +739,7 @@ List~
|
||||
|
||||
"list.height" *coc-config-list-height*
|
||||
|
||||
Height of split list window, default: `10`
|
||||
Height of list window (when splited), default: `10`
|
||||
|
||||
"list.signOffset" *coc-config-list-signOffset*
|
||||
|
||||
@ -1170,7 +1166,8 @@ Languageserver~
|
||||
initialization.
|
||||
|
||||
- "trace.server": Trace level of communication between server and
|
||||
client that showed with output channel.
|
||||
client that showed with output channel, open output channel by
|
||||
command `:CocCommand workspace.showOutput`
|
||||
|
||||
- "stdioEncoding": Encoding used for stdio of child process.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
*coc-nvim.txt* NodeJS client for Vim & Neovim.
|
||||
|
||||
Version: 0.0.81
|
||||
Version: 0.0.82
|
||||
Author: Qiming Zhao <chemzqm at gmail.com>
|
||||
License: Anti 996 license
|
||||
|
||||
@ -9,11 +9,13 @@ CONTENTS *coc-contents*
|
||||
Introduction |coc-introduction|
|
||||
Requirements |coc-requirements|
|
||||
Installation |coc-installation|
|
||||
Extensions |coc-extensions|
|
||||
Configuration |coc-configuration|
|
||||
LSP features |coc-lsp|
|
||||
Document |coc-document|
|
||||
Completion |coc-completion|
|
||||
Diagnostics |coc-diagnostics|
|
||||
Locations |coc-locations|
|
||||
Signature help |coc-signature|
|
||||
Format |coc-format|
|
||||
Code action |coc-code-actions|
|
||||
@ -79,8 +81,8 @@ Note: This plugin doesn't come with support for any specific language. You
|
||||
will need to install a coc.nvim extension or set up the language server by
|
||||
configuration.
|
||||
|
||||
Note: This plugin doesn't change any of your existing key-mappings. You will
|
||||
need to create key-mappings by yourself, see README.md for examples.
|
||||
Note: multiple language servers for same document is allowed, but you should
|
||||
avoid configure same language server that already used by coc.nvim extension.
|
||||
|
||||
Note: Automatic completion plugins can't play nicely together, you can disable
|
||||
automatic completion of coc.nvim through `"suggest.autoTrigger": "none"` (or
|
||||
@ -89,10 +91,9 @@ automatic completion of coc.nvim through `"suggest.autoTrigger": "none"` (or
|
||||
==============================================================================
|
||||
REQUIREMENTS *coc-requirements*
|
||||
|
||||
Neovim >= 0.3.2 or Vim >= 8.0.1453, for best experience, use neovim >= 0.4.0
|
||||
or vim >= 8.2.0750.
|
||||
Neovim >= 0.4.0 or Vim >= 8.1.1719.
|
||||
|
||||
NodeJS https://nodejs.org/ >= 12.12.0.
|
||||
NodeJS https://nodejs.org/ >= 14.14.0.
|
||||
|
||||
Yarn https://yarnpkg.com/ required to build coc.nvim from typescript source
|
||||
code.
|
||||
@ -111,26 +112,96 @@ And run: >
|
||||
|
||||
For other plugin managers, make sure to use code from the release branch.
|
||||
|
||||
You can also use Vim's native package management like: >
|
||||
To use Vim's native |packages| on Linux or MaxOS, use script like: >
|
||||
|
||||
#!/bin/sh
|
||||
# for vim8
|
||||
mkdir -p ~/.vim/pack/coc/start
|
||||
cd ~/.vim/pack/coc/start
|
||||
curl --fail -L https://github.com/neoclide/coc.nvim/archive/release.tar.gz|tar xzfv -
|
||||
vim -c 'helptags ~/.vim/pack/coc/start/doc|q'
|
||||
|
||||
# for neovim
|
||||
mkdir -p ~/.local/share/nvim/site/pack/coc/start
|
||||
cd ~/.local/share/nvim/site/pack/coc/start
|
||||
curl --fail -L https://github.com/neoclide/coc.nvim/archive/release.tar.gz|tar xzfv -
|
||||
nvim -c 'helptags ~/.local/share/nvim/site/pack/coc/start|q'
|
||||
|
||||
when using source code of coc.nvim, you'll have to install
|
||||
https://yarnpkg.com/ and run `yarn install` in project root of coc.nvim.
|
||||
|
||||
==============================================================================
|
||||
EXTENSIONS *coc-extensions*
|
||||
|
||||
To provide LSP features for buffers, the user have to config
|
||||
|coc-config-languageserver| or install coc extensions.
|
||||
|
||||
Coc extensions are more powerful since they could contribute json schemes,
|
||||
commands, and use middleware methods of languageserver to provide better
|
||||
results. It's also possible to provide features that not part of LSP.
|
||||
|
||||
Install extensions from git (not recommended):~
|
||||
|
||||
- Download to code by `git clone` command.
|
||||
- In project root, install dependencies and compile the code by `yarn install`
|
||||
(needed by most coc extensions).
|
||||
- Add the project root to vim's runtimepath by `set runtimepath^=/path/to/project`
|
||||
|
||||
Plugin manager like [vim-plug] can be used as well.
|
||||
|
||||
Note: use coc extensions from source code requires install dependencies which
|
||||
may take buge disk usage.
|
||||
|
||||
Install global extensions from npm (recommended):~
|
||||
|
||||
Use |:CocInstall| to install coc extensions from vim's command line.
|
||||
|
||||
To make coc.nvim install extensions on startup, use |g:coc_global_extensions|.
|
||||
|
||||
To use package manager other than npm (like `yarn` or `pnpm`), use
|
||||
|coc-config-npm-binPath|.
|
||||
|
||||
To customize npm registry for coc.nvim add `coc.nvim:registry` in your
|
||||
`~/.npmrc`, like:
|
||||
>
|
||||
coc.nvim:registry=https://registry.mycompany.org/
|
||||
<
|
||||
To customize extensions folder, user |g:coc_data_home|.
|
||||
|
||||
Uninstall global extensions:~
|
||||
|
||||
Use |:CocUninstall|.
|
||||
|
||||
Update global extensions:~
|
||||
|
||||
Use |:CocUpdate| or |:CocUpdateSync|.
|
||||
|
||||
To update extensions automatically, config |coc-preferences-extensionUpdateCheck|.
|
||||
|
||||
Manage extensions list:~
|
||||
|
||||
Use |coc-list-extensions| or other list plugin that request extensions list by
|
||||
|CocAction('extensionStats')|.
|
||||
|
||||
Single file extensions:~
|
||||
|
||||
All javascript files that ends with `.js` inside the folder
|
||||
|g:coc_config_home| + '/coc-extensions' are considered as coc extensions, for
|
||||
example:
|
||||
>
|
||||
const {window} = require('coc.nvim')
|
||||
|
||||
exports.activate = context => {
|
||||
window.showInformationMessage("message from extension")
|
||||
}
|
||||
<
|
||||
==============================================================================
|
||||
CONFIGURATION *coc-configuration*
|
||||
|
||||
The configuration of coc.nvim is stored in file `coc-settings.json`.
|
||||
|
||||
Command |:CocConfig| will open (create when necessary) a user settings
|
||||
file in the folder returned by |coc#util#get_config_home()|
|
||||
file in the folder returned by |coc#util#get_config_home()|.
|
||||
|
||||
To create a local configuration file for a specific workspace, use
|
||||
|:CocLocalConfig|.
|
||||
@ -140,8 +211,9 @@ The global configuration file can be created in another directory by setting
|
||||
|
||||
let g:coc_config_home = '/path/to/folder'
|
||||
|
||||
The configuration files are all in JSON format, it's recommended to
|
||||
enable JSON completion and validation by install the `coc-json` extension: >
|
||||
The configuration files are all in JSON format (with comment supported), it's
|
||||
recommended to enable JSON completion and validation by install the `coc-json`
|
||||
extension: >
|
||||
|
||||
:CocInstall coc-json
|
||||
<
|
||||
@ -157,8 +229,10 @@ All features (except for telemetry) of LSP 3.16 are supported, checkout
|
||||
the specification at
|
||||
https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/
|
||||
|
||||
Use `:CocCommand document.checkBuffer` to check exists providers used by
|
||||
current buffer. Or use API |CocHasProvider()|.
|
||||
LSP features only works with attached document, see |coc-document-attached|.
|
||||
|
||||
To check exists providers of current buffer, use command
|
||||
`:CocCommand document.checkBuffer` or |CocHasProvider()|.
|
||||
|
||||
For historic reason, some features just works, but some are not.
|
||||
|
||||
@ -170,8 +244,8 @@ Features automatically work by default:~
|
||||
- Inlay hints (only works with some coc extensions, but not
|
||||
|coc-config-languageserver| yet).
|
||||
|
||||
Note the features could be disabled by |coc-configuration| and some vim
|
||||
variables.
|
||||
Note all features could be disabled/enabled by |coc-configuration| and some
|
||||
vim variables.
|
||||
|
||||
Features require enabled by configuration:~
|
||||
|
||||
@ -184,23 +258,20 @@ Features require enabled by configuration:~
|
||||
|
||||
Features requested by user:~
|
||||
|
||||
- Locations related (including definitions, references etc.) |coc-locations|
|
||||
- Invoke code action |coc-code-actions|.
|
||||
- Show call hierarchy tree |coc-callHierarchy|.
|
||||
- Format, range format and on type format |coc-format|.
|
||||
- Highlight same symbol ranges |coc-document-highlights|.
|
||||
- Outline of document symbols |coc-outline| and |coc-list-symbols|.
|
||||
- Show hover message |CocAction('doHover')| and |CocAction('definitionHover')|.
|
||||
- Rename current symbol |CocAction('rename')|.
|
||||
- Jump to definition locations |CocAction('jumpDefinition')|.
|
||||
- Jump to declaration locations |CocAction('jumpDeclaration')|.
|
||||
- Jump to implementation locations |CocAction('jumpImplementation')|.
|
||||
- Jump to type definition locations |CocAction('jumpTypeDefinition')|.
|
||||
- Jump to references |CocAction('jumpReferences')| and |CocAction('jumpUsed')|.
|
||||
- Show hover information |CocAction('doHover')| and |CocAction('definitionHover')|.
|
||||
- Rename symbol under cursor |CocAction('rename')|.
|
||||
- Open link under cursor |CocAction('openlink')|.
|
||||
- Range selection |CocAction('rangeSelect').|
|
||||
- Create folds |CocAction('fold')|.
|
||||
|
||||
For convenient, some actions have associated |coc-key-mappings| provided.
|
||||
Prefer |CocAction()| for more options.
|
||||
|
||||
Features triggered by languageserver or extension:~
|
||||
|
||||
@ -220,7 +291,8 @@ https://github.com/neoclide/coc.nvim/wiki/Debug-language-server
|
||||
|
||||
DOCUMENT *coc-document*
|
||||
|
||||
A document is created on buffer create, and disposed on buffer unload.
|
||||
An associated document is created on buffer create, and disposed on buffer
|
||||
unload.
|
||||
|
||||
Attached document:~
|
||||
*coc-document-attached*
|
||||
@ -234,7 +306,7 @@ LSP features could be provided for the attached buffer.
|
||||
The buffer may not be attached by following reasons:
|
||||
|
||||
- The 'buftype' is neither <empty> nor 'acwrite'.
|
||||
- Buffer variable |b:coc_enabled| should is `1`.
|
||||
- Buffer variable |b:coc_enabled| is `0`.
|
||||
- Byte length of buffer exceed |coc-preferences-maxFileSize|.
|
||||
- Buffer is used for command line window.
|
||||
|
||||
@ -262,82 +334,133 @@ Note make sure use mapped filetypes for configurations that expect filetypes.
|
||||
==============================================================================
|
||||
COMPLETION *coc-completion*
|
||||
|
||||
Default behavior of coc.nvim's completion:
|
||||
The builtin completion of vim is no longer used, the default completion
|
||||
behavior works like VSCode:
|
||||
|
||||
- Completion is automatically triggered.
|
||||
- 'completeopt' is temporarily changed to `noinsert,menuone`.
|
||||
- Snippet complete item would only be expanded after confirm completion.
|
||||
- Completion is automatically triggered by default.
|
||||
- Item selection is enabled by default, use |coc-config-suggest-noselect| to
|
||||
disable default selection.
|
||||
- When selection enabled and no preselect item exists, recent used item that
|
||||
matched will be selected by default.
|
||||
- Snippet and additional edits only work after confirm completion.
|
||||
- 'completeopt' is not used and APIs of builtin popupmenu not work.
|
||||
|
||||
Use configurations |coc-config-suggest| to change behavior of completion.
|
||||
Default Key-mappings:~
|
||||
|
||||
To make the completion work like builtin completion without configuration,
|
||||
following key-mappings are used when the {lhs} is not mapped:
|
||||
|
||||
Use <C-n>, <C-p>, <up> and <down> to navigate completion list: >
|
||||
|
||||
inoremap <silent><expr> <C-n> coc#pum#visible() ? coc#pum#next(1) : "\<C-n>"
|
||||
inoremap <silent><expr> <C-p> coc#pum#visible() ? coc#pum#prev(1) : "\<C-p>"
|
||||
inoremap <silent><expr> <down> coc#pum#visible() ? coc#pum#next(0) : "\<down>"
|
||||
inoremap <silent><expr> <up> coc#pum#visible() ? coc#pum#prev(0) : "\<up>"
|
||||
<
|
||||
Use <PageDown> and <PageUp> to scroll: >
|
||||
|
||||
inoremap <silent><expr> <PageDown> coc#pum#visible() ? coc#pum#scroll(1) : "\<PageDown>"
|
||||
inoremap <silent><expr> <PageUp> coc#pum#visible() ? coc#pum#scroll(0) : "\<PageUp>"
|
||||
<
|
||||
Use <C-e> and <C-y> to cancel and confirm completion: >
|
||||
|
||||
inoremap <silent><expr> <C-e> coc#pum#visible() ? coc#pum#cancel() : "\<C-e>"
|
||||
inoremap <silent><expr> <C-y> coc#pum#visible() ? coc#pum#confirm() : "\<C-y>"
|
||||
|
||||
Note: <CR> and <Tab> are not remapped by coc.nvim.
|
||||
>
|
||||
Related variables:~
|
||||
|
||||
- |b:coc_suggest_disable|
|
||||
- |b:coc_disabled_sources|
|
||||
- |b:coc_suggest_blacklist|
|
||||
- |b:coc_additional_keywords|
|
||||
- Disable completion for buffer: |b:coc_suggest_disable|
|
||||
- Disable specific sources for buffer: |b:coc_disabled_sources|
|
||||
- Disable words for trigger completion: |b:coc_suggest_blacklist|
|
||||
- Add additional keyword characters: |b:coc_additional_keywords|
|
||||
|
||||
Related APIs:~
|
||||
Related functions:~
|
||||
|
||||
- |coc#start()|
|
||||
- |coc#refresh()|
|
||||
- |coc#_select_confirm()|
|
||||
- Trigger completion with options: |coc#start()|.
|
||||
- Trigger completion refresh: |coc#refresh()|.
|
||||
- Select and confirm completion: |coc#_select_confirm()|.
|
||||
- Check if customized popupmenu is visible: |coc#pum#visible()|.
|
||||
- Select next complete item: |coc#pum#next()|.
|
||||
- Select previous complete item: |coc#pum#prev()|.
|
||||
- Cancel completion and reset trigger text: |coc#pum#cancel()|.
|
||||
- Confirm completion: |coc#pum#confirm()|.
|
||||
- Close the popupmenu only: |coc#pum#stop()|.
|
||||
- Get information of the popupmenu: |coc#pum#info()|.
|
||||
- Select specific complete item: |coc#pum#select()|.
|
||||
- Insert word of selected item and finish completion: |coc#pum#insert()|.
|
||||
- Scroll popupmenu: |coc#pum#scroll()|.
|
||||
|
||||
Tips:~
|
||||
Customize completion:~
|
||||
|
||||
- 'completeopt' used by coc.nvim default to `noselect,menuone`.
|
||||
- Your 'completeopt' option would be changed and restored during completion,
|
||||
so you can still use `menu,preview` for Vim's built in completion.
|
||||
- Snippet expand and additional edit feature of LSP requires confirm
|
||||
completion by <C-y> to work.
|
||||
Use |coc-config-suggest| to change behavior of completion.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
Use 'pumwidth' for configure minimal width of popupmenu and 'pumheight'
|
||||
for maximum height.
|
||||
|
||||
Example completion key-mappings:~
|
||||
Related Highlight groups:
|
||||
|CocPum| for highlight groups of customized pum.
|
||||
|CocSymbol| for kind icons.
|
||||
|CocMenuSel| for background highlight of selected item.
|
||||
|
||||
Map <tab> to trigger completion and navigate to the next item: >
|
||||
Note: background, border and winblend are configured by
|
||||
|coc-config-suggest-floatConfig|.
|
||||
|
||||
function! s:check_back_space() abort
|
||||
let col = col('.') - 1
|
||||
return !col || getline('.')[col - 1] =~ '\s'
|
||||
endfunction
|
||||
Example user key-mappings:~
|
||||
*coc-completion-example*
|
||||
|
||||
inoremap <silent><expr> <TAB>
|
||||
\ pumvisible() ? "\<C-n>" :
|
||||
\ <SID>check_back_space() ? "\<TAB>" :
|
||||
\ coc#refresh()
|
||||
Note: use command `:verbose imap` to check current insert
|
||||
key-mappings when your key-mappings not work.
|
||||
|
||||
Use <tab> and <S-tab> to navigate completion list: >
|
||||
|
||||
Map <c-space> to trigger completion: >
|
||||
function! s:check_back_space() abort
|
||||
let col = col('.') - 1
|
||||
return !col || getline('.')[col - 1] =~ '\s'
|
||||
endfunction
|
||||
|
||||
inoremap <silent><expr> <c-space> coc#refresh()
|
||||
" Insert <tab> when previous text is space, refresh completion if not.
|
||||
inoremap <silent><expr> <TAB>
|
||||
\ coc#pum#visible() ? coc#pum#next(1):
|
||||
\ <SID>check_back_space() ? "\<Tab>" :
|
||||
\ coc#refresh()
|
||||
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
|
||||
|
||||
Use <c-space> to trigger completion: >
|
||||
|
||||
if has('nvim')
|
||||
inoremap <silent><expr> <c-space> coc#refresh()
|
||||
else
|
||||
inoremap <silent><expr> <c-@> coc#refresh()
|
||||
endif
|
||||
<
|
||||
<CR> to confirm completion, use: >
|
||||
Use <CR> to confirm completion, use: >
|
||||
|
||||
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<CR>"
|
||||
inoremap <expr> <cr> coc#pum#visible() ? coc#_select_confirm() : "\<CR>"
|
||||
<
|
||||
To make <CR> auto-select the first completion item and notify coc.nvim to
|
||||
format on enter, use: >
|
||||
To make <CR> to confirm selection of selected complete item or notify coc.nvim
|
||||
to format on enter, use: >
|
||||
|
||||
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
|
||||
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#_select_confirm()
|
||||
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
||||
|
||||
Map <tab> for trigger completion, completion confirm, snippet expand and jump
|
||||
like VSCode. >
|
||||
like VSCode: >
|
||||
|
||||
inoremap <silent><expr> <TAB>
|
||||
\ pumvisible() ? coc#_select_confirm() :
|
||||
\ coc#expandableOrJumpable() ?
|
||||
\ "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
|
||||
\ <SID>check_back_space() ? "\<TAB>" :
|
||||
\ coc#refresh()
|
||||
inoremap <silent><expr> <TAB>
|
||||
\ coc#pum#visible() ? coc#_select_confirm() :
|
||||
\ coc#expandableOrJumpable() ?
|
||||
\ "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
|
||||
\ <SID>check_back_space() ? "\<TAB>" :
|
||||
\ coc#refresh()
|
||||
|
||||
function! s:check_back_space() abort
|
||||
let col = col('.') - 1
|
||||
return !col || getline('.')[col - 1] =~# '\s'
|
||||
endfunction
|
||||
function! s:check_back_space() abort
|
||||
let col = col('.') - 1
|
||||
return !col || getline('.')[col - 1] =~# '\s'
|
||||
endfunction
|
||||
|
||||
let g:coc_snippet_next = '<tab>'
|
||||
let g:coc_snippet_next = '<tab>'
|
||||
<
|
||||
Note: the `coc-snippets` extension is required for this to work.
|
||||
|
||||
@ -397,10 +520,72 @@ Use key-mappings:
|
||||
|
||||
Check all diagnostics~
|
||||
|
||||
Use |coc-list-diagnostics| to open |CocList| with all diagnostics.
|
||||
Use |coc-list-diagnostics| to open |coc-list| with all available diagnostics.
|
||||
|
||||
Use API |CocAction('diagnosticList')| to get list of all diagnostics.
|
||||
|
||||
==============================================================================
|
||||
LOCATIONS SUPPORT *coc-locations*
|
||||
|
||||
There're different kinds of locations, including "definitions", "declarations",
|
||||
"implementations", "typeDefinitions" and "references", the languageserver used
|
||||
by current document may support some of them.
|
||||
|
||||
Key-mappings for invoke locations request~
|
||||
|
||||
- |<plug>(coc-definition)|
|
||||
- |<plug>(coc-declaration)|
|
||||
- |<plug>(coc-implementation)|
|
||||
- |<plug>(coc-type-definition)|
|
||||
- |<plug>(coc-references)|
|
||||
- |<plug>(coc-references-used)|
|
||||
|
||||
Error will be shown when the buffer not attached |coc-document-attached|.
|
||||
|
||||
Location jump behavior~
|
||||
|
||||
When there's only one location returned, the location is opened by command
|
||||
specified by |coc-preferences-jumpCommand| ("edit" by default), context mark
|
||||
is added by |m'|, so you can jump back previous location by <C-o>.
|
||||
|
||||
When multiple locations returned, |coc-list-location| is opened for preview
|
||||
and other further actions.
|
||||
|
||||
To use |coc-list-location| for single location as well, use
|
||||
|coc-locations-api| (instead key-mappings provided by coc.nvim).
|
||||
|
||||
To change default options of |coc-list-location| or use other plugin for
|
||||
list of locations, see |g:coc_enable_locationlist|.
|
||||
|
||||
To use vim's quickfix for locations, use configuration
|
||||
|coc-preferences-useQuickfixForLocations|.
|
||||
|
||||
To use vim's tag list for definitions, use |CocTagFunc()|.
|
||||
|
||||
*coc-locations-api*
|
||||
Related APIs~
|
||||
|
||||
APIs for jump locations:
|
||||
|
||||
- Jump to definition locations |CocAction('jumpDefinition')|.
|
||||
- Jump to declaration locations |CocAction('jumpDeclaration')|.
|
||||
- Jump to implementation locations |CocAction('jumpImplementation')|.
|
||||
- Jump to type definition locations |CocAction('jumpTypeDefinition')|.
|
||||
- Jump to references |CocAction('jumpReferences')| and |CocAction('jumpUsed')|.
|
||||
|
||||
APIs for get location list:
|
||||
|
||||
- |CocAction('definitions')|
|
||||
- |CocAction('declarations')|
|
||||
- |CocAction('implementations')|
|
||||
- |CocAction('typeDefinitions')|
|
||||
- |CocAction('references')|
|
||||
|
||||
Send custom locations request to languageserver:
|
||||
|
||||
- |CocLocations()|
|
||||
- |CocLocationsAsync()|
|
||||
|
||||
==============================================================================
|
||||
SIGNATURE HELP *coc-signature*
|
||||
|
||||
@ -461,6 +646,12 @@ Or create |BufWritePre| autocmd like: >
|
||||
<
|
||||
Note avoid use |CocActionAsync| with |BufWritePre|.
|
||||
|
||||
Format on enter:~
|
||||
|
||||
Use |coc#on_enter()| is required to notify coc.nvim the press on enter key.
|
||||
|
||||
Configure |coc-preferences-bracketEnterImprove|
|
||||
|
||||
==============================================================================
|
||||
CODE ACTION *coc-code-actions*
|
||||
|
||||
@ -547,8 +738,8 @@ Snippets engine of coc.nvim support both VSCode snippets and ultisnips
|
||||
snippets format.
|
||||
|
||||
The complete item with snippet format has label ends with `~` by default.
|
||||
Select the complete item and confirm the completion by <C-y> to expand the
|
||||
snippet.
|
||||
Select the complete item and confirm the completion by |coc#pum#confirm()| to
|
||||
expand the snippet.
|
||||
|
||||
A snippet session would be deactivated under the following conditions:
|
||||
|
||||
@ -561,7 +752,7 @@ A snippet session would be deactivated under the following conditions:
|
||||
To load and expand custom snippets, install `coc-snippets` extension is
|
||||
recommended.
|
||||
|
||||
Related configurations:
|
||||
Related configurations:~
|
||||
|
||||
- |g:coc_snippet_prev|
|
||||
- |g:coc_snippet_next|
|
||||
@ -570,7 +761,7 @@ Related configurations:
|
||||
- |coc-preferences-snippetStatusText|
|
||||
- |coc-preferences-snippetHighlight|
|
||||
|
||||
Related functions:
|
||||
Related functions:~
|
||||
|
||||
- |coc#snippet#next()|
|
||||
- |coc#snippet#prev()|
|
||||
@ -578,16 +769,19 @@ Related functions:
|
||||
- |coc#jumpable()|
|
||||
- |coc#expandableOrJumpable()|
|
||||
|
||||
Related variables: |b:coc_snippet_active|
|
||||
Related highlights: |CocSnippetVisual|
|
||||
Related autocmds: |CocJumpPlaceholder|
|
||||
Related variables, highlights and autocmds:~
|
||||
|
||||
- |b:coc_snippet_active|
|
||||
- |CocSnippetVisual|
|
||||
- |CocJumpPlaceholder|
|
||||
|
||||
==============================================================================
|
||||
WROKSPACE SUPPORT *coc-workspace*
|
||||
|
||||
Workspace folders~
|
||||
|
||||
Unlike VSCode, workspace folders are resolved from filepath after buffer load.
|
||||
Unlike VSCode, workspace folders are resolved from filepath after buffer
|
||||
creation.
|
||||
|
||||
A list of file/folder names is used for resolve workspace folder, the patterns
|
||||
could comes from:
|
||||
@ -1379,10 +1573,22 @@ coc#start([{option}]) *coc#start()*
|
||||
<
|
||||
Use `:CocList sources` to get available sources.
|
||||
|
||||
coc#refresh() *coc#refresh()*
|
||||
|
||||
Start or refresh completion at current cursor position, bind this to
|
||||
'imap' to trigger completion, example: >
|
||||
|
||||
inoremap <silent><expr> <c-space> coc#refresh()
|
||||
|
||||
coc#_select_confirm() *coc#_select_confirm()*
|
||||
|
||||
Select first completion item if no completion item is selected, then
|
||||
confirm the completion.
|
||||
|
||||
coc#config({section}, {value}) *coc#config()*
|
||||
|
||||
Change user configuration by Vim script, no changes would be made to
|
||||
user configuration file. Example: >
|
||||
Change user configuration, overwrite configurations from
|
||||
user config file and default values. Example: >
|
||||
|
||||
call coc#config('coc.preferences', {
|
||||
\ 'timeout': 1000,
|
||||
@ -1397,10 +1603,7 @@ coc#config({section}, {value}) *coc#config()*
|
||||
<
|
||||
|
||||
Note: this function can be called multiple times.
|
||||
|
||||
Note: this function can be called before the service has been
|
||||
initialized.
|
||||
|
||||
Note: this function can be called before coc.nvim started.
|
||||
Note: this function can work alongside the user configuration file,
|
||||
but it's not recommended to use both.
|
||||
|
||||
@ -1426,13 +1629,6 @@ coc#add_command({id}, {command}, [{title}]) *coc#add_command()*
|
||||
call coc#add_command('mundoToggle', 'MundoToggle',
|
||||
\ 'toggle mundo window')
|
||||
<
|
||||
coc#refresh() *coc#refresh()*
|
||||
|
||||
Start or refresh completion at current cursor position, bind this to
|
||||
'imap' to trigger completion, example: >
|
||||
|
||||
inoremap <silent><expr> <c-space> coc#refresh()
|
||||
<
|
||||
coc#expandable() *coc#expandable()*
|
||||
|
||||
Check if a snippet is expandable at the current position.
|
||||
@ -1453,10 +1649,12 @@ coc#on_enter() *coc#on_enter()*
|
||||
|
||||
Used for the format on type and improvement of brackets, example: >
|
||||
|
||||
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
|
||||
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
||||
" Confirm the completion when popupmenu is visible, insert <CR> and
|
||||
" notify coc.nvim otherwise.
|
||||
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
|
||||
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
||||
<
|
||||
Note:to enable formatOnType, add ` "coc.preferences.formatOnType": true`
|
||||
Note:to enable format on type, add ` "coc.preferences.formatOnType": true`
|
||||
in your settings file.
|
||||
|
||||
coc#status() *coc#status()*
|
||||
@ -1466,15 +1664,6 @@ coc#status() *coc#status()*
|
||||
extension contributed statuses from `g:coc_status`. For statusline
|
||||
integration, see |coc-status|
|
||||
|
||||
coc#_select_confirm() *coc#_select_confirm()*
|
||||
|
||||
Select first completion item if no completion item is selected, then
|
||||
confirm the completion.
|
||||
|
||||
Note: for this function to work as expected, either |CompleteChanged|
|
||||
autocmd should exist or only <C-n> and <C-p> should be used to select
|
||||
a completion item.
|
||||
|
||||
coc#util#api_version() *coc#util#api_version()*
|
||||
|
||||
Get coc.nvim's vim api version number, start from `1`.
|
||||
@ -1522,6 +1711,99 @@ coc#snippet#prev() *coc#snippet#prev()*
|
||||
|
||||
Jump to previous placeholder, does nothing when |coc#jumpable| is 0.
|
||||
|
||||
*coc#pum*
|
||||
coc#pum#visible() *coc#pum#visible()*
|
||||
|
||||
Check if customized popupmenu is visible.
|
||||
|
||||
coc#pum#next({insert}) *coc#pum#next()*
|
||||
|
||||
Select next item of customized popupmenu, insert word when {insert} is
|
||||
truth value.
|
||||
|
||||
coc#pum#prev({insert}) *coc#pum#prev()*
|
||||
|
||||
Select previous item of customized popupmenu, insert word when {insert}
|
||||
is truth value.
|
||||
|
||||
coc#pum#stop() *coc#pum#stop()*
|
||||
|
||||
Close the customized popupmenu, works like <C-x><C-z> of vim.
|
||||
Return <Ignore>
|
||||
|
||||
coc#pum#cancel() *coc#pum#cancel()*
|
||||
|
||||
Cancel the customized popupmenu and revert trigger input, like <C-e>
|
||||
of vim. Return empty string.
|
||||
|
||||
coc#pum#confirm() *coc#pum#confirm()*
|
||||
|
||||
Confirm completion and close the customized pum, like <C-y> of vim.
|
||||
Return empty string.
|
||||
|
||||
coc#pum#info() *coc#pum#info()*
|
||||
|
||||
Return information of the customized popupmenu, should only be used
|
||||
when |coc#pum#visible()| is 1.
|
||||
|
||||
Result contains:
|
||||
index Current select item index, 0 based.
|
||||
scrollbar Non-zero if a scrollbar is displayed.
|
||||
row Screen row count, 0 based.
|
||||
col Screen column count, 0 based.
|
||||
width Width of pum, including padding and border.
|
||||
height Height of pum, including padding and border.
|
||||
size Count of displayed complete items.
|
||||
inserted Is |v:true| when there is item inserted.
|
||||
|
||||
coc#pum#select({index}, {insert}, {confirm}) *coc#pum#select()*
|
||||
|
||||
Selects an item in the completion popupmenu.
|
||||
Return empty string.
|
||||
|
||||
Parameters:~
|
||||
{index} Index (zero-based) of the item to select.
|
||||
{insert} Whether the selection should be inserted
|
||||
in the buffer.
|
||||
{confirm} Confirm the completion and dismis the
|
||||
popupmenu, implies `insert`.
|
||||
|
||||
coc#pum#insert() *coc#pum#insert()*
|
||||
|
||||
Insert word of current selected item and finish completion.
|
||||
Timer is used to make it works as rhs of key-mappings.
|
||||
|
||||
coc#pum#scroll({forward}) *coc#pum#scroll()*
|
||||
|
||||
Scroll the popupmenu forward or backward by page.
|
||||
Timer is used to make it works as rhs of key-mappings.
|
||||
Return empty string.
|
||||
|
||||
Parameters:~
|
||||
{forward} Scroll forward when none zero.
|
||||
|
||||
*coc#notify*
|
||||
coc#notify#close_all() *coc#notify#close_all()*
|
||||
|
||||
Close all notification windows.
|
||||
|
||||
coc#notify#do_action([{winid}]) *coc#notify#do_action()*
|
||||
|
||||
Invoke action for all notification windows, or particular window with
|
||||
winid.
|
||||
|
||||
coc#notify#copy() *coc#notify#copy()*
|
||||
|
||||
Copy all content from notifications to system clipboard.
|
||||
|
||||
coc#notify#show_sources() *coc#notify#show_sources()*
|
||||
|
||||
Show source name (extension name) in notification windows.
|
||||
|
||||
coc#notify#keep() *coc#notify#keep()*
|
||||
|
||||
Stop auto hide timer of notification windows.
|
||||
|
||||
coc#float#has_float([{all}]) *coc#float#has_float()*
|
||||
|
||||
Check if float window/popup exists, check coc.nvim's float
|
||||
@ -1663,36 +1945,11 @@ CocTagFunc({pattern}, {flags}, {info}) *CocTagFunc()*
|
||||
>
|
||||
:echo exists('&tagfunc')
|
||||
<
|
||||
*coc#notify*
|
||||
coc#notify#close_all() *coc#notify#close_all()*
|
||||
|
||||
Close all notification windows.
|
||||
|
||||
coc#notify#do_action([{winid}]) *coc#notify#do_action()*
|
||||
|
||||
Invoke action for all notification windows, or particular window with
|
||||
winid.
|
||||
|
||||
Use `"notification.preferMenuPicker": true` if you would like to
|
||||
choose action on notification shown.
|
||||
|
||||
coc#notify#copy() *coc#notify#copy()*
|
||||
|
||||
Copy all content from notifications to system clipboard.
|
||||
|
||||
coc#notify#show_sources() *coc#notify#show_sources()*
|
||||
|
||||
Show source name (extension name) in notification windows.
|
||||
|
||||
coc#notify#keep() *coc#notify#keep()*
|
||||
|
||||
Stop auto hide timer of notification windows.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*coc-actions*
|
||||
Available Actions ~
|
||||
|
||||
Acceptable {action} names for |CocAction()| and |CocActionAsync|.
|
||||
Acceptable {action} names for |CocAction()| and |CocActionAsync()|.
|
||||
|
||||
"ensureDocument" *CocAction('ensureDocument')*
|
||||
|
||||
@ -1740,6 +1997,34 @@ Acceptable {action} names for |CocAction()| and |CocActionAsync|.
|
||||
|
||||
enable/disable {source}.
|
||||
|
||||
"definitions" *CocAction('definitions')*
|
||||
|
||||
Get definition locations of symbol under cursor.
|
||||
Return LSP `Location[]`
|
||||
|
||||
"declarations" *CocAction('declarations')*
|
||||
|
||||
Get declaration location(s) of symbol under cursor.
|
||||
Return LSP `Location | Location[] | LocationLink[]`
|
||||
|
||||
"implementations" *CocAction('implementations')*
|
||||
|
||||
Get implementation locations of symbol under cursor.
|
||||
Return LSP `Location[]`
|
||||
|
||||
"typeDefinitions" *CocAction('typeDefinitions')*
|
||||
|
||||
Get type definition locations of symbol under cursor.
|
||||
Return LSP `Location[]`
|
||||
|
||||
"references" [{excludeDeclaration}] *CocAction('references')*
|
||||
|
||||
Get references location list of symbol under cursor.
|
||||
|
||||
{excludeDeclaration}: exclude declaration locations when not zero.
|
||||
|
||||
Return LSP `Location[]`
|
||||
|
||||
"jumpDefinition" [{openCommand}] *CocAction('jumpDefinition')*
|
||||
|
||||
jump to definition locations of the current symbol.
|
||||
@ -1811,11 +2096,6 @@ Acceptable {action} names for |CocAction()| and |CocActionAsync|.
|
||||
Same as |CocAction('doHover')|, but includes definition contents from
|
||||
definition provider when possible.
|
||||
|
||||
"references" [{excludeDeclaration}] *CocAction('references')*
|
||||
|
||||
Get references location list, declaration locations are included by
|
||||
default.
|
||||
|
||||
"showSignatureHelp" *CocAction('showSignatureHelp')*
|
||||
|
||||
Echo signature help of current function, return `v:false` when
|
||||
@ -1887,10 +2167,10 @@ Acceptable {action} names for |CocAction()| and |CocActionAsync|.
|
||||
|
||||
Run code action for range.
|
||||
|
||||
{start} start line number of range.
|
||||
{end} end line number of range.
|
||||
{kind} code action kind, see |CocAction('codeActions')| for available
|
||||
action kind.
|
||||
{start} Start line number of range.
|
||||
{end} End line number of range.
|
||||
{kind} Code action kind, see |CocAction('codeActions')| for available
|
||||
action kind.
|
||||
|
||||
Can be used to create commands like: >
|
||||
|
||||
@ -2406,7 +2686,8 @@ cursor position.
|
||||
Float window/popup related~
|
||||
|
||||
*CocFloating* default highlight group of floating windows/popups.
|
||||
Default link to |NormalFloat| on neovim and|`Pmenu| on vim.
|
||||
Default links to |NormalFloat| on neovim and|`Pmenu| on vim.
|
||||
*CocFloatDividingLine* for dividing lines, links to |NonText| by default.
|
||||
*CocErrorFloat* for errors in floating windows/popups.
|
||||
*CocWarningFloat* for warnings in floating windows/popups.
|
||||
*CocInfoFloat* for infos in floating windows/popups.
|
||||
@ -2441,12 +2722,32 @@ CocTree *CocTree*
|
||||
*CocTreeOpenClose* for open and close icon in tree view.
|
||||
*CocTreeSelected* for highlight lines contains selected node.
|
||||
|
||||
Popup menu related~
|
||||
*CocPum*
|
||||
*CocPumSearch* for matched input characters, linked to |CocSearch| by default.
|
||||
*CocPumMenu* for menu of complete item.
|
||||
*CocPumShortcut* for shortcut text of source.
|
||||
*CocPumDeprecated* for deprecated label.
|
||||
*CocPumVirtualText* for virtual text which enabled by
|
||||
|coc-config-suggest-virtualText|
|
||||
|
||||
Symbol icons~
|
||||
|
||||
CocSymbol *CocSymbol*
|
||||
|
||||
Highlight groups for symbol icons, including:
|
||||
Highlight groups for symbol icons, including `CompletionItemKind` and
|
||||
`SymbolKind` of LSP. The highlight groups link to related |nvim-treesitter|
|
||||
highlight groups when possible and fallback to builtin highlight groups.
|
||||
|
||||
*CocSymbolDefault* linked to |hl-MoreMsg| by default.
|
||||
*CocSymbolText*
|
||||
*CocSymbolUnit*
|
||||
*CocSymbolValue*
|
||||
*CocSymbolKeyword*
|
||||
*CocSymbolSnippet*
|
||||
*CocSymbolColor*
|
||||
*CocSymbolReference*
|
||||
*CocSymbolFolder*
|
||||
*CocSymbolFile*
|
||||
*CocSymbolModule*
|
||||
*CocSymbolNamespace*
|
||||
@ -2473,15 +2774,14 @@ Highlight groups for symbol icons, including:
|
||||
*CocSymbolEvent*
|
||||
*CocSymbolOperator*
|
||||
*CocSymbolTypeParameter*
|
||||
*CocSymbolDefault*
|
||||
|
||||
Note: Use configuration `suggest.completionItemKindLabels` for customized icon
|
||||
Note: Use configuration |coc-config-suggest-completionItemKindLabels| for customized icon
|
||||
characters.
|
||||
|
||||
Semantic token highlight groups~
|
||||
*CocSem*
|
||||
|
||||
Semantic highlight groups are starts with `CocSem` which links to related
|
||||
Semantic highlight groups are starts with `CocSem` which link to related
|
||||
|nvim-treesitter| highlight groups when possible and fallback to builtin
|
||||
highlight groups, use variable |g:coc_default_semantic_highlight_groups| to
|
||||
disable creation of these highlight groups.
|
||||
@ -2518,7 +2818,8 @@ Others~
|
||||
*CocCursorRange* for highlight of activated cursors ranges.
|
||||
*CocLinkedEditing* for highlight of activated linked editing ranges.
|
||||
*CocHoverRange* for range of current hovered symbol.
|
||||
*CocMenuSel* for current menu item in menu dialog.
|
||||
*CocMenuSel* for current menu item in menu dialog (should only provide
|
||||
background color).
|
||||
*CocSelectedRange* for highlight ranges of outgoing calls.
|
||||
*CocSnippetVisual* for highlight snippet placeholders.
|
||||
*CocInlayHint* for highlight inlay hint virtual text block, default linked to
|
||||
@ -2704,13 +3005,12 @@ Options of CocList command~
|
||||
Use interactive mode, list items would be reloaded on input
|
||||
change, filter and sort would be done by list implementation.
|
||||
|
||||
Note: only works when the list support interactive mode.
|
||||
|
||||
Note: filtering and sorting would be done by underlying task, which
|
||||
means options including `--strict`, `--no-sort`, `--regex`,
|
||||
`--ignore-case` would not work at all.
|
||||
|
||||
Note: it requires list implementation have support for interactive
|
||||
mode.
|
||||
|
||||
--auto-preview
|
||||
-A
|
||||
|
||||
@ -2737,9 +3037,9 @@ LIST CONFIGURATION *coc-list-configuration*
|
||||
|
||||
Use `coc-settings.json` for configuration of lists.
|
||||
|
||||
The general configuration of list starts with 'list.'.
|
||||
Configuration of list starts with 'list.'.
|
||||
|
||||
Checkout |coc-config-list| or type `list.` in your settings file to get completion
|
||||
See |coc-config-list| or type `list.` in your settings file to get completion
|
||||
list (requires coc-json installed).
|
||||
|
||||
For configuration of a specified list, use section that starts with:
|
||||
@ -2822,7 +3122,7 @@ Default mappings on normal mode:
|
||||
<Tab> - Select action.
|
||||
<C-e> - Scroll preview window down.
|
||||
<C-y> - Scroll preview window up.
|
||||
<Space> - Toggle select of current item.
|
||||
<Space> - Toggle selection of current item.
|
||||
i,I,o,O,a,A - Change to insert mode.
|
||||
p - Preview action.
|
||||
: - Cancel list session without closing window.
|
||||
@ -3166,8 +3466,7 @@ result (same as <esc>).
|
||||
|
||||
NOTIFICATION SUPPORT *coc-notification*
|
||||
|
||||
Notification windows are shown from bottom right of the screen. Notifications
|
||||
behavior like notifications on VSCode.
|
||||
Notification windows are created at the bottom right of the screen.
|
||||
|
||||
Notifications are created by javascript APIs: `window.showErrorMessage()`,
|
||||
`window.showWarningMessage()`, `window.showInformationMessage()`,
|
||||
@ -3176,26 +3475,24 @@ Notifications are created by javascript APIs: `window.showErrorMessage()`,
|
||||
Possible kind of notifications: 'error', 'warning', 'info' and 'progress'.
|
||||
|
||||
Message notifications (not progress) requires
|
||||
|coc-preferences-enableMessageDialog| to be `true`. Message notifications
|
||||
without actions would be automatically closed after milliseconds specified by
|
||||
|coc-config-notification-timeout|.
|
||||
|coc-preferences-enableMessageDialog| to be `true`.
|
||||
|
||||
Features:
|
||||
Message notifications without actions would be automatically closed after
|
||||
milliseconds specified by |coc-config-notification-timeout|.
|
||||
|
||||
- Animated position and 'winblend' on show and hide.
|
||||
- Reposition current tab notification windows when notification dismissed.
|
||||
- Notification with same options will be replaced to avoid duplicated windows.
|
||||
- Percent and message update for progress notification.
|
||||
- Click the button (neovim only) or use |coc#notify#do_action()| to invoke
|
||||
actions.
|
||||
- Click the window would cancel auto close (on neovim and focusable is true).
|
||||
- For customize icons, see |g:coc_notify|.
|
||||
- For customize highlights, see |CocNotification|.
|
||||
- For customize other behaviors, see |coc-config-notification|.
|
||||
- For available user actions (ex: "close_all", "do_action" "show_sources"), see
|
||||
|coc#notify|.
|
||||
Customize notifications:~
|
||||
|
||||
Note notification feature requires neovim >= 0.4.0 or vim >= 8.2.0750 to work.
|
||||
- Customize icons: |g:coc_notify|
|
||||
- Customize highlights: |CocNotification|
|
||||
- Customize configurations: |coc-config-notification|
|
||||
|
||||
Related functions:~
|
||||
|
||||
- |coc#notify#close_all()|
|
||||
- |coc#notify#do_action()|
|
||||
- |coc#notify#copy()|
|
||||
- |coc#notify#show_sources()|
|
||||
- |coc#notify#keep()|
|
||||
|
||||
==============================================================================
|
||||
|
||||
|
@ -1,3 +1,22 @@
|
||||
# 2022-08-07
|
||||
|
||||
- Add configuration 'suggest.pumFloatConfig'.
|
||||
|
||||
# 2022-08-04
|
||||
|
||||
- Make diagnostic float window with the same background as CocFloating.
|
||||
|
||||
# 2022-08-03
|
||||
|
||||
- Add highlight group 'CocFloatingDividingLine'.
|
||||
|
||||
# 2022-08-01
|
||||
|
||||
- Use custom popup menu, #3862.
|
||||
- Use "first" instead of "none" for configuration `suggest.selection`.
|
||||
- Make "first" default for `suggest.selection`, like VSCode.
|
||||
- Add default blue color for hlgroup `CocMenuSel`.
|
||||
|
||||
# 2022-06-14
|
||||
|
||||
- Add highlight groups `CocListLine` and `CocListSearch`.
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "coc.nvim-release",
|
||||
"version": "0.0.81",
|
||||
"version": "0.0.82",
|
||||
"description": "LSP based intellisense engine for neovim & vim8.",
|
||||
"engines": {
|
||||
"node": ">=12.12.0"
|
||||
|
@ -7,25 +7,25 @@ function! s:checkVersion() abort
|
||||
let l:unsupported = 0
|
||||
if get(g:, 'coc_disable_startup_warning', 0) != 1
|
||||
if has('nvim')
|
||||
let l:unsupported = !has('nvim-0.3.2')
|
||||
let l:unsupported = !has('nvim-0.4.0')
|
||||
else
|
||||
let l:unsupported = !has('patch-8.0.1453')
|
||||
let l:unsupported = !has('patch-8.1.1719')
|
||||
endif
|
||||
|
||||
if l:unsupported == 1
|
||||
echohl Error
|
||||
echom "coc.nvim requires at least Vim 8.0.1453 or Neovim 0.3.2, but you're using an older version."
|
||||
echom "coc.nvim requires at least Vim 8.1.1719 or Neovim 0.4.0, but you're using an older version."
|
||||
echom "Please upgrade your (neo)vim."
|
||||
echom "You can add this to your vimrc to avoid this message:"
|
||||
echom " let g:coc_disable_startup_warning = 1"
|
||||
echom "Note that some features may error out or behave incorrectly."
|
||||
echom "Please do not report bugs unless you're using at least Vim 8.0.1453 or Neovim 0.3.2."
|
||||
echom "Please do not report bugs unless you're using at least Vim 8.1.1719 or Neovim 0.4.0."
|
||||
echohl None
|
||||
sleep 2
|
||||
else
|
||||
if !has('nvim-0.4.0') && !has('patch-8.1.1719')
|
||||
if !has('nvim-0.5.0') && !has('patch-8.2.0750')
|
||||
echohl WarningMsg
|
||||
echom "coc.nvim works best on vim >= 8.1.1719 and neovim >= 0.4.0, consider upgrade your vim."
|
||||
echom "coc.nvim works best on vim >= 8.2.0750 and neovim >= 0.5.0, consider upgrade your vim."
|
||||
echom "You can add this to your vimrc to avoid this message:"
|
||||
echom " let g:coc_disable_startup_warning = 1"
|
||||
echom "Note that some features may behave incorrectly."
|
||||
@ -277,19 +277,6 @@ function! s:HandleCharInsert(char, bufnr) abort
|
||||
call s:Autocmd('InsertCharPre', a:char, a:bufnr)
|
||||
endfunction
|
||||
|
||||
function! s:HandleCompleteDone(complete_item) abort
|
||||
let item = copy(a:complete_item)
|
||||
if get(g:, 'coc_hide_pum', 0)
|
||||
let item['close'] = v:true
|
||||
let g:coc_hide_pum = 0
|
||||
endif
|
||||
if get(g:, 'coc_disable_complete_done', 0)
|
||||
let g:coc_disable_complete_done = 0
|
||||
let item['closed'] = v:true
|
||||
endif
|
||||
call s:Autocmd('CompleteDone', item)
|
||||
endfunction
|
||||
|
||||
function! s:HandleWinScrolled(winid) abort
|
||||
if getwinvar(a:winid, 'float', 0)
|
||||
call coc#float#nvim_scrollbar(a:winid)
|
||||
@ -313,13 +300,6 @@ function! s:Enable(initialize)
|
||||
augroup coc_nvim
|
||||
autocmd!
|
||||
|
||||
if exists('##MenuPopupChanged') && exists('*nvim_open_win')
|
||||
autocmd MenuPopupChanged * call s:Autocmd('MenuPopupChanged', get(v:, 'event', {}), win_screenpos(winnr())[0] + winline() - 2)
|
||||
endif
|
||||
if exists('##CompleteChanged')
|
||||
autocmd CompleteChanged * call s:Autocmd('MenuPopupChanged', get(v:, 'event', {}), win_screenpos(winnr())[0] + winline() - 2)
|
||||
endif
|
||||
|
||||
if coc#rpc#started()
|
||||
autocmd VimEnter * call coc#rpc#notify('VimEnter', [])
|
||||
elseif get(g:, 'coc_start_at_startup', 1)
|
||||
@ -337,16 +317,17 @@ function! s:Enable(initialize)
|
||||
autocmd TermOpen * call s:Autocmd('TermOpen', +expand('<abuf>'))
|
||||
autocmd WinEnter * call coc#float#nvim_win_enter(win_getid())
|
||||
endif
|
||||
if exists('##CompleteChanged')
|
||||
autocmd CompleteChanged * call coc#pum#stop()
|
||||
endif
|
||||
autocmd CursorMoved list:///* call coc#list#select(bufnr('%'), line('.'))
|
||||
autocmd CursorHold * call coc#float#check_related()
|
||||
if exists('##WinClosed')
|
||||
autocmd WinClosed * call coc#float#on_close(+expand('<amatch>'))
|
||||
autocmd WinClosed * call coc#notify#on_close(+expand('<amatch>'))
|
||||
elseif exists('##TabEnter')
|
||||
autocmd TabEnter * call coc#notify#reflow()
|
||||
endif
|
||||
if has('nvim-0.4.0') || has('patch-8.1.1719')
|
||||
autocmd CursorHold * call coc#float#check_related()
|
||||
endif
|
||||
if exists('##WinScrolled')
|
||||
autocmd WinScrolled * call s:HandleWinScrolled(+expand('<amatch>'))
|
||||
endif
|
||||
@ -357,7 +338,6 @@ function! s:Enable(initialize)
|
||||
autocmd BufWinLeave * call s:Autocmd('BufWinLeave', +expand('<abuf>'), bufwinid(+expand('<abuf>')))
|
||||
autocmd BufWinEnter * call s:Autocmd('BufWinEnter', +expand('<abuf>'), win_getid())
|
||||
autocmd FileType * call s:Autocmd('FileType', expand('<amatch>'), +expand('<abuf>'))
|
||||
autocmd CompleteDone * call s:HandleCompleteDone(get(v:, 'completed_item', {}))
|
||||
autocmd InsertCharPre * call s:HandleCharInsert(v:char, bufnr('%'))
|
||||
if exists('##TextChangedP')
|
||||
autocmd TextChangedP * call s:Autocmd('TextChangedP', +expand('<abuf>'), coc#util#change_info())
|
||||
@ -371,7 +351,7 @@ function! s:Enable(initialize)
|
||||
autocmd BufWritePost * call s:Autocmd('BufWritePost', +expand('<abuf>'), getbufvar(+expand('<abuf>'), 'changedtick'))
|
||||
autocmd CursorMoved * call s:Autocmd('CursorMoved', +expand('<abuf>'), [line('.'), col('.')])
|
||||
autocmd CursorMovedI * call s:Autocmd('CursorMovedI', +expand('<abuf>'), [line('.'), col('.')])
|
||||
autocmd CursorHold * call s:Autocmd('CursorHold', +expand('<abuf>'), [line('.'), col('.')], coc#util#suggest_variables(bufnr('%')))
|
||||
autocmd CursorHold * call s:Autocmd('CursorHold', +expand('<abuf>'), [line('.'), col('.')])
|
||||
autocmd CursorHoldI * call s:Autocmd('CursorHoldI', +expand('<abuf>'), [line('.'), col('.')])
|
||||
autocmd BufNewFile,BufReadPost * call s:Autocmd('BufCreate', +expand('<abuf>'))
|
||||
autocmd BufUnload * call s:Autocmd('BufUnload', +expand('<abuf>'))
|
||||
@ -393,6 +373,15 @@ function! s:Enable(initialize)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:FgColor(hlGroup) abort
|
||||
let fgId = synIDtrans(hlID(a:hlGroup))
|
||||
let ctermfg = synIDattr(fgId, 'reverse', 'cterm') ==# '1' ? synIDattr(fgId, 'bg', 'cterm') : synIDattr(fgId, 'fg', 'cterm')
|
||||
let guifg = synIDattr(fgId, 'reverse', 'gui') ==# '1' ? synIDattr(fgId, 'bg', 'gui') : synIDattr(fgId, 'fg', 'gui')
|
||||
let cmd = ' ctermfg=' . (empty(ctermfg) ? '223' : ctermfg)
|
||||
let cmd .= ' guifg=' . (empty(guifg) ? '#ebdbb2' : guifg)
|
||||
return cmd
|
||||
endfunction
|
||||
|
||||
function! s:Hi() abort
|
||||
hi default CocErrorSign ctermfg=Red guifg=#ff0000 guibg=NONE
|
||||
hi default CocWarningSign ctermfg=Brown guifg=#ff922b guibg=NONE
|
||||
@ -403,22 +392,14 @@ function! s:Hi() abort
|
||||
hi default CocUnderline term=underline cterm=underline gui=underline
|
||||
hi default CocBold term=bold cterm=bold gui=bold
|
||||
hi default CocItalic term=italic cterm=italic gui=italic
|
||||
if s:is_vim || has('nvim-0.4.0')
|
||||
hi default CocStrikeThrough term=strikethrough cterm=strikethrough gui=strikethrough
|
||||
else
|
||||
hi default CocStrikeThrough guifg=#989898 ctermfg=gray
|
||||
endif
|
||||
hi default CocStrikeThrough term=strikethrough cterm=strikethrough gui=strikethrough
|
||||
hi default CocMarkdownLink ctermfg=Blue guifg=#15aabf guibg=NONE
|
||||
hi default CocDisabled guifg=#999999 ctermfg=gray
|
||||
hi default CocSearch ctermfg=Blue guifg=#15aabf guibg=NONE
|
||||
hi default CocMenuSel ctermbg=237 guibg=#13354A
|
||||
hi default link CocFadeOut Conceal
|
||||
hi default link CocMarkdownCode markdownCode
|
||||
hi default link CocMarkdownHeader markdownH1
|
||||
hi default link CocMenuSel PmenuSel
|
||||
hi default link CocErrorFloat CocErrorSign
|
||||
hi default link CocWarningFloat CocWarningSign
|
||||
hi default link CocInfoFloat CocInfoSign
|
||||
hi default link CocHintFloat CocHintSign
|
||||
hi default link CocErrorHighlight CocUnderline
|
||||
hi default link CocWarningHighlight CocUnderline
|
||||
hi default link CocInfoHighlight CocUnderline
|
||||
@ -452,38 +433,19 @@ function! s:Hi() abort
|
||||
hi default link CocSelectedRange CocHighlightText
|
||||
" Symbol highlights
|
||||
hi default link CocSymbolDefault MoreMsg
|
||||
hi default link CocSymbolFile Statement
|
||||
hi default link CocSymbolModule Statement
|
||||
hi default link CocSymbolNamespace Statement
|
||||
hi default link CocSymbolPackage Statement
|
||||
hi default link CocSymbolClass Statement
|
||||
hi default link CocSymbolMethod Function
|
||||
hi default link CocSymbolProperty Keyword
|
||||
hi default link CocSymbolField CocSymbolDefault
|
||||
hi default link CocSymbolConstructor Function
|
||||
hi default link CocSymbolEnum CocSymbolDefault
|
||||
hi default link CocSymbolInterface CocSymbolDefault
|
||||
hi default link CocSymbolFunction Function
|
||||
hi default link CocSymbolVariable CocSymbolDefault
|
||||
hi default link CocSymbolConstant Constant
|
||||
hi default link CocSymbolString String
|
||||
hi default link CocSymbolNumber Number
|
||||
hi default link CocSymbolBoolean Boolean
|
||||
hi default link CocSymbolArray CocSymbolDefault
|
||||
hi default link CocSymbolObject CocSymbolDefault
|
||||
hi default link CocSymbolKey Keyword
|
||||
hi default link CocSymbolNull Type
|
||||
hi default link CocSymbolEnumMember CocSymbolDefault
|
||||
hi default link CocSymbolStruct Keyword
|
||||
hi default link CocSymbolEvent Keyword
|
||||
hi default link CocSymbolOperator Operator
|
||||
hi default link CocSymbolTypeParameter Operator
|
||||
"Pum
|
||||
hi default link CocPumSearch CocSearch
|
||||
hi default link CocPumMenu CocFloating
|
||||
hi default link CocPumShortcut Comment
|
||||
hi default link CocPumDeprecated CocStrikeThrough
|
||||
hi default CocPumVirtualText ctermfg=239 guifg=#504945
|
||||
|
||||
if has('nvim')
|
||||
hi default link CocFloating NormalFloat
|
||||
else
|
||||
hi default link CocFloating Pmenu
|
||||
endif
|
||||
hi default link CocFloatDividingLine NonText
|
||||
if !exists('*sign_getdefined') || empty(sign_getdefined('CocCurrentLine'))
|
||||
sign define CocCurrentLine linehl=CocMenuSel
|
||||
endif
|
||||
@ -500,10 +462,23 @@ function! s:Hi() abort
|
||||
if has('nvim')
|
||||
let names = ['Error', 'Warning', 'Info', 'Hint']
|
||||
for name in names
|
||||
if !hlexists('Coc'.name.'VirtualText')
|
||||
let suffix = name ==# 'Warning' ? 'Warn' : name
|
||||
if hlexists('DiagnosticVirtualText'.suffix)
|
||||
exe 'hi default link Coc'.name.'VirtualText DiagnosticVirtualText'.suffix
|
||||
else
|
||||
exe 'hi default link Coc'.name.'VirtualText Coc'.name.'Sign'
|
||||
endif
|
||||
if hlexists('Diagnostic'.suffix)
|
||||
exe 'hi default link Coc'.name.'Float Diagnostic'.suffix
|
||||
else
|
||||
exe 'hi default link Coc'.name.'Float '.coc#highlight#compose_hlgroup('Coc'.name.'Sign', 'CocFloating')
|
||||
endif
|
||||
endfor
|
||||
else
|
||||
execute 'hi default link CocErrorFloat '.coc#highlight#compose_hlgroup('CocErrorSign', 'CocFloating')
|
||||
execute 'hi default link CocWarningFloat '.coc#highlight#compose_hlgroup('CocWarningSign', 'CocFloating')
|
||||
execute 'hi default link CocInfoFloat '.coc#highlight#compose_hlgroup('CocInfoSign', 'CocFloating')
|
||||
execute 'hi default link CocHintFloat '.coc#highlight#compose_hlgroup('CocHintSign', 'CocFloating')
|
||||
endif
|
||||
call s:AddAnsiGroups()
|
||||
|
||||
@ -541,6 +516,48 @@ function! s:Hi() abort
|
||||
execute 'hi default link CocSem'.key.' '.(hlexists(ts) ? ts : fallback)
|
||||
endfor
|
||||
endif
|
||||
let symbolMap = {
|
||||
\ 'Keyword': ['TSKeyword', 'Keyword'],
|
||||
\ 'Namespace': ['TSNamespace', 'Include'],
|
||||
\ 'Class': ['TSConstructor', 'Special'],
|
||||
\ 'Method': ['TSMethod', 'Function'],
|
||||
\ 'Property': ['TSProperty', 'Identifier'],
|
||||
\ 'Text': ['TSText', 'CocSymbolDefault'],
|
||||
\ 'Unit': ['TSUnit', 'CocSymbolDefault'],
|
||||
\ 'Value': ['TSValue', 'CocSymbolDefault'],
|
||||
\ 'Snippet': ['TSSnippet', 'CocSymbolDefault'],
|
||||
\ 'Color': ['TSColor', 'Float'],
|
||||
\ 'Reference': ['TSTextReference', 'Constant'],
|
||||
\ 'Folder': ['TSFolder', 'CocSymbolDefault'],
|
||||
\ 'File': ['TSFile', 'Statement'],
|
||||
\ 'Module': ['TSModule', 'Statement'],
|
||||
\ 'Package': ['TSPackage', 'Statement'],
|
||||
\ 'Field': ['TSField', 'Identifier'],
|
||||
\ 'Constructor': ['TSConstructor', 'Special'],
|
||||
\ 'Enum': ['TSEnum', 'CocSymbolDefault'],
|
||||
\ 'Interface': ['TSInterface', 'CocSymbolDefault'],
|
||||
\ 'Function': ['TSFunction', 'Function'],
|
||||
\ 'Variable': ['TSVariableBuiltin', 'Special'],
|
||||
\ 'Constant': ['TSConstant', 'Constant'],
|
||||
\ 'String': ['TSString', 'String'],
|
||||
\ 'Number': ['TSNumber', 'Number'],
|
||||
\ 'Boolean': ['TSBoolean', 'Boolean'],
|
||||
\ 'Array': ['TSArray', 'CocSymbolDefault'],
|
||||
\ 'Object': ['TSObject', 'CocSymbolDefault'],
|
||||
\ 'Key': ['TSKey', 'Identifier'],
|
||||
\ 'Null': ['TSNull', 'Type'],
|
||||
\ 'EnumMember': ['TSEnumMember', 'Identifier'],
|
||||
\ 'Struct': ['TSStruct', 'Keyword'],
|
||||
\ 'Event': ['TSEvent', 'Constant'],
|
||||
\ 'Operator': ['TSOperator', 'Operator'],
|
||||
\ 'TypeParameter': ['TSParameter', 'Identifier'],
|
||||
\ }
|
||||
for [key, value] in items(symbolMap)
|
||||
let hlGroup = hlexists(value[0]) ? value[0] : get(value, 1, 'CocSymbolDefault')
|
||||
if hlexists(hlGroup)
|
||||
execute 'hi default CocSymbol'.key.' '.s:FgColor(hlGroup)
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:FormatFromSelected(type)
|
||||
@ -563,8 +580,8 @@ function! s:ShowInfo()
|
||||
else
|
||||
let output = trim(system(node . ' --version'))
|
||||
let ms = matchlist(output, 'v\(\d\+\).\(\d\+\).\(\d\+\)')
|
||||
if empty(ms) || str2nr(ms[1]) < 12 || (str2nr(ms[1]) == 12 && str2nr(ms[2]) < 12)
|
||||
call add(lines, 'Error: Node version '.output.' < 12.12.0, please upgrade node.js')
|
||||
if empty(ms) || str2nr(ms[1]) < 14 || (str2nr(ms[1]) == 14 && str2nr(ms[2]) < 14)
|
||||
call add(lines, 'Error: Node version '.output.' < 14.14.0, please upgrade node.js')
|
||||
endif
|
||||
endif
|
||||
" check bundle
|
||||
@ -615,6 +632,32 @@ command! -nargs=* -bar -complete=custom,s:InstallOptions CocInstall :call coc#
|
||||
call s:Enable(1)
|
||||
call s:Hi()
|
||||
|
||||
" Default key-mappings for completion
|
||||
if empty(mapcheck('<C-n>', 'i'))
|
||||
inoremap <silent><expr> <C-n> coc#pum#visible() ? coc#pum#next(1) : "\<C-n>"
|
||||
endif
|
||||
if empty(mapcheck('<C-p>', 'i'))
|
||||
inoremap <silent><expr> <C-p> coc#pum#visible() ? coc#pum#prev(1) : "\<C-p>"
|
||||
endif
|
||||
if empty(mapcheck('<down>', 'i'))
|
||||
inoremap <silent><expr> <down> coc#pum#visible() ? coc#pum#next(0) : "\<down>"
|
||||
endif
|
||||
if empty(mapcheck('<up>', 'i'))
|
||||
inoremap <silent><expr> <up> coc#pum#visible() ? coc#pum#prev(0) : "\<up>"
|
||||
endif
|
||||
if empty(mapcheck('<C-e>', 'i'))
|
||||
inoremap <silent><expr> <C-e> coc#pum#visible() ? coc#pum#cancel() : "\<C-e>"
|
||||
endif
|
||||
if empty(mapcheck('<C-y>', 'i'))
|
||||
inoremap <silent><expr> <C-y> coc#pum#visible() ? coc#pum#confirm() : "\<C-y>"
|
||||
endif
|
||||
if empty(mapcheck('<PageDown>', 'i'))
|
||||
inoremap <silent><expr> <PageDown> coc#pum#visible() ? coc#pum#scroll(1) : "\<PageDown>"
|
||||
endif
|
||||
if empty(mapcheck('<PageUp>', 'i'))
|
||||
inoremap <silent><expr> <PageUp> coc#pum#visible() ? coc#pum#scroll(0) : "\<PageUp>"
|
||||
endif
|
||||
|
||||
vnoremap <silent> <Plug>(coc-range-select) :<C-u>call CocActionAsync('rangeSelect', visualmode(), v:true)<CR>
|
||||
vnoremap <silent> <Plug>(coc-range-select-backward) :<C-u>call CocActionAsync('rangeSelect', visualmode(), v:false)<CR>
|
||||
nnoremap <Plug>(coc-range-select) :<C-u>call CocActionAsync('rangeSelect', '', v:true)<CR>
|
||||
@ -645,7 +688,6 @@ nnoremap <silent> <Plug>(coc-float-hide) :<C-u>call coc#float#c
|
||||
nnoremap <silent> <Plug>(coc-float-jump) :<c-u>call coc#float#jump()<cr>
|
||||
nnoremap <silent> <Plug>(coc-command-repeat) :<C-u>call CocAction('repeatCommand')<CR>
|
||||
nnoremap <silent> <Plug>(coc-refactor) :<C-u>call CocActionAsync('refactor')<CR>
|
||||
inoremap <silent> <Plug>CocRefresh <C-r>=coc#_complete()<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(coc-cursors-operator) :<C-u>set operatorfunc=<SID>CursorRangeFromSelected<CR>g@
|
||||
vnoremap <silent> <Plug>(coc-cursors-range) :<C-u>call CocAction('cursorsSelect', bufnr('%'), 'range', visualmode())<CR>
|
||||
|
Reference in New Issue
Block a user