mirror of
1
0
Fork 0

Change Rainbow-parenthese plugin into Rainbow plugin.

This commit is contained in:
Kurtis Moxley 2022-08-11 11:57:20 +08:00
parent bbbedb5311
commit 1f4af09835
53 changed files with 2745 additions and 845 deletions

View File

@ -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>

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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))

View File

@ -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)

View File

@ -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)

View 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

View File

@ -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)

View File

@ -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)

View File

@ -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')

View File

@ -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()

View File

@ -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

View File

@ -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

View File

@ -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": [],

View File

@ -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.

View File

@ -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>"
<
Noteto enable formatOnType, add ` "coc.preferences.formatOnType": true`
Noteto 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()|
==============================================================================

View File

@ -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`.

View File

@ -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"

View File

@ -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>

View File

@ -0,0 +1,32 @@
---
name: Bug report
about: Create a report to help us improve
title: "[Bug] "
labels: ''
assignees: ''
---
### **Describe the bug**
A clear and concise description of what the bug is.
### **To Reproduce**
Steps to reproduce the behavior, **Please provide a minimal piece of code to produce this issue**, along with it's filename and it's filetype detected by vim (via `:set ft?`), a piece of text is better than a picture here. For example:
File: `bug.js`, filetype=javascript
```
var pair = {x: 1, y: 2}
```
Steps:
1. Open file via `vim bug.js`
2. See the color of `{` and `}` around text `{x: 1, y: 2}`
### **Expected behavior**
A clear and concise description of what you expected to happen.
### **Screenshots**
Provide a screenshot to describe what you got.
### **Additional context**
**Are you using some third-party syntax plugins?** Add any other context about the problem here.

View File

@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: feature request
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@ -0,0 +1,10 @@
---
name: Not Issue
about: Start a conversation which is not about bug report or feature request
title: ''
labels: ''
assignees: ''
---
This is not an Issue. You can type anything here except bug report and feature request.

1
sources_non_forked/rainbow/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
doc/tags

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,2 @@
Rainbow Parentheses Improved
Copyright 2013 LuoChen (luochen1990@gmail.com). Licensed under the Apache License 2.0.

View File

@ -0,0 +1,189 @@
Rainbow Parentheses Improved
===
> help you read complex code by showing diff level of parentheses in diff color !!
Description [(这里有中文版)](https://github.com/luochen1990/rainbow/blob/master/README_zh.md)
---------------------------------------------------------------------------------------------------
As everyone knows, the most complex codes were composed of a mass of different kinds of parentheses (typically: lisp).
This plugin will help you read these codes by showing different levels of parentheses in different colors.
You can also find this plugin in **[www.vim.org](http://www.vim.org/scripts/script.php?script_id=4176)**.
#### lisp
![lisp](https://raw.githubusercontent.com/luochen1990/rainbow/demo/lisp.png)
#### html
![html](https://raw.githubusercontent.com/luochen1990/rainbow/demo/html.png)
#### [more](https://github.com/luochen1990/rainbow/blob/demo/more.md)
### What is improved ?
- no limit of parentheses levels.
- separately edit guifgs and ctermfgs (the colors used for highlighting).
- now you can design your own parentheses such as 'begin' and 'end'.
- you can also configure anything separately for different types of files.
- now you can even decide to let some operators (like + - * / , ==) highlighted with the parentheses together.
- dot separated combined filetype support (`:h ft`).
- json style configuration used, more understandable and readable, easier for advanced configuration.
- the code is shorter and easier to read now.
- smoother and faster.
- the Chinese document is added.
### Referenced:
- http://www.vim.org/scripts/script.php?script_id=1561 (Martin Krischik)
- http://www.vim.org/scripts/script.php?script_id=3772 (kien)
Install
-------
#### install via Plug:
```vim
Plug 'luochen1990/rainbow'
let g:rainbow_active = 1 "set to 0 if you want to enable it later via :RainbowToggle
```
#### install manually:
- first, execute the following commands (for windows users, use `~/vimfiles` instead of `~/.vim`)
```sh
git clone https://github.com/luochen1990/rainbow.git
cd rainbow
mkdir -p ~/.vim/plugin ~/.vim/autoload
cp plugin/* ~/.vim/plugin
cp autoload/* ~/.vim/autoload
```
- second, add the follow sentences to your `.vimrc` or `_vimrc` :
```vim
let g:rainbow_active = 1 "set to 0 if you want to enable it later via :RainbowToggle
```
- third, restart your vim and enjoy coding.
Configure
---------
There is an example for advanced configuration, add it to your vimrc and edit it as you wish (just keep the format).
Note: you can remove these lines safely since they are all included by the [source code](https://github.com/luochen1990/rainbow/blob/master/autoload/rainbow_main.vim)).
```vim
let g:rainbow_conf = {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
\ 'guis': [''],
\ 'cterms': [''],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'markdown': {
\ 'parentheses_options': 'containedin=markdownCode contained', "enable rainbow for code blocks only
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'], "lisp needs more colors for parentheses :)
\ },
\ 'haskell': {
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\v\{\ze[^-]/ end=/}/ fold'], "the haskell lang pragmas should be excluded
\ },
\ 'vim': {
\ 'parentheses_options': 'containedin=vimFuncBody', "enable rainbow inside vim function body
\ },
\ 'perl': {
\ 'syn_name_prefix': 'perlBlockFoldRainbow', "solve the [perl indent-depending-on-syntax problem](https://github.com/luochen1990/rainbow/issues/20)
\ },
\ 'stylus': {
\ 'parentheses': ['start=/{/ end=/}/ fold contains=@colorableGroup'], "[vim css color](https://github.com/ap/vim-css-color) compatibility
\ },
\ 'css': 0, "disable this plugin for css files
\ }
\}
```
- 'guifgs': a list of `guifg` (`:h highlight-guifg`), i.e. colors for gui interface, will be used in order
- 'guis': a list of `gui` (`:h highlight-gui`), will be used in order
- 'ctermfgs': a list of `ctermfg` (`:h highlight-ctermfg`)
- 'cterms': a list of `cterm` (`:h highlight-cterm`)
- 'operators': describe the operators you want to highlight (note: be careful about special characters which needs escaping, you can find more examples [here](https://github.com/luochen1990/rainbow/issues/3), and you can also read the [vim help about syn-pattern](http://vimdoc.sourceforge.net/htmldoc/syntax.html#:syn-pattern)). note that this option will be overwritten by the `step` part of `parentheses`.
- 'parentheses': a list of parentheses definitions, a parentheses definition contains parts like `start=/(/`, `step=/,/`, `stop=/)/`, `fold`, `contained`, `containedin=someSynNames`, `contains=@Spell`, see `:h syntax` for more details. notice that the `step` part is defined by this plugin so it is not described by the official vim doc.
- 'parentheses_options': parentheses options shared between different parentheses, things like `containedin=xxxFuncBody`, `contains=@Spell` (or 'contains=@NoSpell') often appears here. this option is often used to solve [3rd-party-plugin-compatibility]() problems.
- 'separately': configure for specific filetypes (decided by &ft), key `*` for filetypes without separate configuration, value `0` means disable rainbow only for this type of files, value `"default"` means keep the default shim for this filetype (notice: the default shim config will change between plugin version).
- 'syn_name_prefix': add a prefix to name of the syntax definition, this option is often used to solve [3rd-party-plugin-compatibility]() problems.
- 'after': execute some vim commands after the rainbow syntax rules is defined. it is often used like `['syn clear xxx']` to solve [3rd-party-plugin-compatibility]() problems.
- keep a field empty to use the default setting.
To get more advanced config examples, try to search throught this [tag](https://github.com/luochen1990/rainbow/issues?utf8=%E2%9C%93&q=label%3A%22config+reference%22+).
User Command
------------
- **:RainbowToggle** --you can use it to toggle this plugin.
3rd Party Plugin Compatibility
------------------------------
You should notice that this plugin is very special, Vim plugins is expected to provide syntax definitions vertically, i.e. one filetype, one syntax definition set:
```
----------------------------------------------------
| cpp | java | python |
| | | |
| syn cppKeyword | syn javaKeyword | syn pyKeyword |
| syn cppFunc | syn javaFunc | syn pyLambda |
| syn cppParen | syn javaParen | syn pyParen |
| ... | ... | ... |
----------------------------------------------------
```
But this plugin provide syntax definitions horizontally, i.e. parentheses syntax for all filetypes:
```
----------------------------------------------------
| cpp | java | python |
| | | |
| syn cppKeyword | syn javaKeyword | syn pyKeyword |
| syn cppFunc | syn javaFunc | syn pyLambda |
| ... | ... | ... |
----------------------------------------------------
| rainbow |
| |
| syn cppRainbow syn javaRainbow syn pyRainbow |
----------------------------------------------------
```
You can notice that, to provide rainbow parentheses, this plugin have to define it's own syntax rules, and these rules will overwrite the parentheses syntax provided by the filetype plugin.
It works well at most of the time, but in some special cases, when the parentheses syntax rule is depended somewhere else (e.g. indent, spell checking, nested syntax rules), the things depend on the original syntax rules will be broken.
This plugin has provide some mechanisms to solve the compatibility problems, and have provided default configurations to solve compatibility problems with the default vim syntax files.
But if this plugin is conflicted with some other plugins, you will probably have to solve them by yourself. First, you can search on [this issue tag](https://github.com/luochen1990/rainbow/issues?utf8=%E2%9C%93&q=label%3A%22confliction+with+other+third-party+syntax+plugins%22+) to find whether there is somebody else had the same problem and solved it. Second, you can read the following content about troubleshooting.
Troubleshooting
---------------
- rainbow doesn't work at all: find out the current parentheses syntax name, and use the `after` mechanism to clear these syntax.
- rainbow doesn't work inside some structure: find out the syntax region name, and use the `parentheses_options` mechanism like `'containedin=xxx'`.
- spell checking doesn't work inside parentheses: use the `parentheses_options` mechanism like `'contains=@Spell'`.
- spell checking works inside parentheses but you don't want it: use the `parentheses_options` mechanism like `'contains=@NoSpell'`.
- indent not works correctly: check the indent script you are using and search `synID` inside it to find which syntax name prefix it depends on, and use the `syn_name_prefix` mechanism to solve it.
The following keymappings will help you to check the syntax name and definitions under the cursor, add them to your vimrc and restart vim:
```vim
nnoremap <f1> :echo synIDattr(synID(line('.'), col('.'), 0), 'name')<cr>
nnoremap <f2> :echo ("hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">")<cr>
nnoremap <f3> :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')<cr>
nnoremap <f4> :exec 'syn list '.synIDattr(synID(line('.'), col('.'), 0), 'name')<cr>
```
Move your cursor to a parentheses and press the keys to use them.
------------------------------------------------------------------
**Rate this script if you like it, and I'll appreciate it and improve this plugin for you because of your support!
Just go to [this page](http://www.vim.org/scripts/script.php?script_id=4176) and choose `Life Changing` and click `rate`**

View File

@ -0,0 +1,103 @@
彩虹括号增强版 (Rainbow Parentheses Improved)
=============================================
> 通过将不同层次的括号高亮为不同的颜色, 帮助你阅读世界上最复杂的代码
插件简介:
---------
众所周知,最复杂的代码都是由一堆乱七八糟的括号组成。这款插件通过以不同的颜色展示不同层次的括号,致力于帮助你阅读这样的复杂代码。 你同样可以在[Vim官网](http://www.vim.org/scripts/script.php?script_id=4176)里看到这款插件
#### lisp
![lisp](https://raw.githubusercontent.com/luochen1990/rainbow/demo/lisp.png)
#### html
![html](https://raw.githubusercontent.com/luochen1990/rainbow/demo/html.png)
#### [more](https://github.com/luochen1990/rainbow/blob/demo/more.md)
### 有哪些改进?
- 更快速和流畅的体验。
- 简短,高质量,并且易读的源代码。
- 现在的版本将不再限制括号的嵌套层数。
- 现在你可以分别自定义图形界面下和终端上所使用的各种括号颜色。
- 现在你可以自定义括号的形式不过在这之前你最好了解vim脚本的正则表达式。
- 现在你甚至可以为不同类型的文件设定不同的配置。
- 现在你甚至可以决定是否让某些符号跟着它们所在的括号一起高亮,你也可以对不同类型的文件分别设置。
- 支持点分隔的复合文件类型 (`:h ft`)
- 现在采用json风格的配置文件,更加可读,更易于进行高级配置。
- 最后但并非不重要的一点是,如你所见,现在增加了中文说明。
### 以下是本插件所参考的旧版本:
- http://www.vim.org/scripts/script.php?script_id=1561 (Martin Krischik)
- http://www.vim.org/scripts/script.php?script_id=3772 (kien)
安装说明:
---------
### 使用Vundle安装:
```vim
Bundle 'luochen1990/rainbow'
let g:rainbow_active = 1 "0 if you want to enable it later via :RainbowToggle
```
### 手动安装:
- 首先,执行以下命令 (Windows用户需要使用 `~/vimfiles` 替代 `~/.vim`) 。
```sh
git clone https://github.com/luochen1990/rainbow.git
cd rainbow
cp plugin/* ~/.vim/plugin
cp autoload/* ~/.vim/autoload
```
- 然后将以下句子加入到你的vim配置文件中windows下配置文件是`_vimrc`而linux下是`.vimrc`
```vim
let g:rainbow_active = 1 "0 if you want to enable it later via :RainbowToggle
```
- 最后重新启动你的vim你就可以享受coding了。
高级配置:
---------
以下是一个配置的样例也是我在用的配置将它加入到你的vimrc并按照你喜欢的方式修改它但是保持格式你就可以精确地控制插件的行为了。
```vim
let g:rainbow_conf = {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'tex': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
\ },
\ 'vim': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
\ },
\ 'html': {
\ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
\ },
\ 'css': 0,
\ }
\}
```
- 'guifgs': 一个`guifg`的列表 (`:h highlight-guifg`), 即GUI界面的括号颜色, 将按顺序循环使用
- 'guis': 一个`gui`的列表 (`:h highlight-gui`), 将按顺序循环使用
- 'ctermfgs': 一个`ctermfg`的列表 (`:h highlight-ctermfg`), 即终端下的括号颜色
- 'cterms': 一个`cterm`的列表 (`:h highlight-cterm`)
- 'operators': 描述你希望哪些运算符跟着与它同级的括号一起高亮(注意:留意需要转义的特殊字符,更多样例见[这里](https://github.com/luochen1990/rainbow/issues/3), 你也可以读[vim帮助 :syn-pattern](http://vimdoc.sourceforge.net/htmldoc/syntax.html#:syn-pattern))
- 'parentheses': 一个关于括号定义的列表, 每一个括号的定义包含形如以下的部分: `start=/(/`, `step=/,/`, `stop=/)/`, `fold`, `contained`, `containedin=someSynNames`, `contains=@Spell`. 各个部分具体含义可参考 `:h syntax`, 其中 `step` 为本插件的扩展定义, 表示括号中间需要高亮的运算符.
- 'separately': 针对文件类型(由&ft决定)作不同的配置,未被单独设置的文件类型使用`*`下的配置,值为`0`表示仅对该类型禁用插件,值为`"default"`表示使用针对该类型的默认兼容配置 (注意, 默认兼容配置可能随着该插件版本的更新而改变, 如果你不希望它改变, 那么你应该将它拷贝一份放到你的vimrc文件里).
- 省略某个字段以使用默认设置
-------------------------------------------------------------------
**最后,如果你喜欢这个插件,给它一个评价,我会心存感激,并且因为你的肯定继续改进这个插件!(从[该页面](http://www.vim.org/scripts/script.php?script_id=4176)下方,选择`Life Changing`选项,然后点击`rate`**

View File

@ -0,0 +1,128 @@
" Copyright 2013 LuoChen (luochen1990@gmail.com). Licensed under the Apache License 2.0.
if exists('s:loaded') | finish | endif | let s:loaded = 1
fun s:trim(s)
return substitute(a:s, '\v^\s*(.{-})\s*$', '\1', '')
endfun
fun s:concat(strs)
return join(filter(a:strs, "v:val !~ '^[ ]*$'"), ',')
endfun
fun s:resolve_parenthesis_with(init_state, p)
let [paren, contained, containedin, contains_prefix, contains, op] = a:init_state
let p = (type(a:p) == type([])) ? ((len(a:p) == 3) ? printf('start=#%s# step=%s end=#%s#', a:p[0], op, a:p[-1]) : printf('start=#%s# end=#%s#', a:p[0], a:p[-1])) : a:p "NOTE: preprocess the old style parentheses config
let ls = split(p, '\v%(%(start|step|end)\=(.)%(\1@!.)*\1[^ ]*|\w+%(\=[^ ]*)?) ?\zs', 0)
for s in ls
let [k, v] = [matchstr(s, '^[^=]\+\ze\(=\|$\)'), matchstr(s, '^[^=]\+=\zs.*')]
if k == 'step'
let op = s:trim(v)
elseif k == 'contains_prefix'
let contains_prefix = s:trim(v)
elseif k == 'contains'
let contains = s:concat([contains, s:trim(v)])
elseif k == 'containedin'
let containedin = s:concat([containedin, s:trim(v)])
elseif k == 'contained'
let contained = 1
else
let paren .= s
endif
endfor
let rst = [paren, contained, containedin, contains_prefix, contains, op]
"echom json_encode(rst)
return rst
endfun
fun s:resolve_parenthesis_from_config(config)
return s:resolve_parenthesis_with(['', 0, '', a:config.contains_prefix, '', a:config.operators], a:config.parentheses_options)
endfun
fun s:synID(prefix, group, lv, id)
return a:prefix.'_lv'.a:lv.'_'.a:group.a:id
endfun
fun s:synGroupID(prefix, group, lv)
return a:prefix.a:group.'_lv'.a:lv
endfun
fun rainbow#syn(config)
let conf = a:config
let prefix = conf.syn_name_prefix
let cycle = conf.cycle
let glob_paran_opts = s:resolve_parenthesis_from_config(conf)
let b:rainbow_loaded = cycle
for id in range(len(conf.parentheses))
let [paren, contained, containedin, contains_prefix, contains, op] = s:resolve_parenthesis_with(glob_paran_opts, conf.parentheses[id])
for lv in range(cycle)
let lv2 = ((lv + cycle - 1) % cycle)
let [rid, pid, gid2] = [s:synID(prefix, 'r', lv, id), s:synID(prefix, 'p', lv, id), s:synGroupID(prefix, 'Regions', lv2)]
if len(op) > 2
exe 'syn match '.s:synID(prefix, 'o', lv, id).' '.op.' containedin='.s:synID(prefix, 'r', lv, id).' contained'
endif
let real_contained = (lv == 0)? (contained? 'contained ' : '') : 'contained '
let real_containedin = (lv == 0)? s:concat([containedin, '@'.gid2]) : '@'.gid2
let real_contains = s:concat([contains_prefix, contains])
exe 'syn region '.rid.' matchgroup='.pid.' '.real_contained.'containedin='.real_containedin.' contains='.real_contains.' '.paren
endfor
endfor
for lv in range(cycle)
exe 'syn cluster '.s:synGroupID(prefix, 'Regions', lv).' contains='.join(map(range(len(conf.parentheses)), 's:synID(prefix, "r", lv, v:val)'), ',')
exe 'syn cluster '.s:synGroupID(prefix, 'Parentheses', lv).' contains='.join(map(range(len(conf.parentheses)), 's:synID(prefix, "p", lv, v:val)'), ',')
exe 'syn cluster '.s:synGroupID(prefix, 'Operators', lv).' contains='.join(map(range(len(conf.parentheses)), 's:synID(prefix, "o", lv, v:val)'), ',')
endfor
exe 'syn cluster '.prefix.'Regions contains='.join(map(range(cycle), '"@".s:synGroupID(prefix, "Regions", v:val)'), ',')
exe 'syn cluster '.prefix.'Parentheses contains='.join(map(range(cycle), '"@".s:synGroupID(prefix, "Parentheses", v:val)'), ',')
exe 'syn cluster '.prefix.'Operators contains='.join(map(range(cycle), '"@".s:synGroupID(prefix, "Operators", v:val)'), ',')
if has_key(conf, 'after') | for cmd in conf.after | exe cmd | endfor | endif
endfun
fun rainbow#syn_clear(config)
let conf = a:config
let prefix = conf.syn_name_prefix
for id in range(len(conf.parentheses))
for lv in range(conf.cycle)
let [rid, oid] = [s:synID(prefix, 'r', lv, id), s:synID(prefix, 'o', lv, id)]
exe 'syn clear '.rid
exe 'syn clear '.oid
endfor
endfor
endfun
fun rainbow#hi(config)
let conf = a:config
let prefix = conf.syn_name_prefix
for id in range(len(conf.parentheses))
for lv in range(conf.cycle)
let [pid, oid] = [s:synID(prefix, 'p', lv, id), s:synID(prefix, 'o', lv, id)]
let ctermfg = conf.ctermfgs[lv % len(conf.ctermfgs)]
let guifg = conf.guifgs[lv % len(conf.guifgs)]
let cterm = conf.cterms[lv % len(conf.cterms)]
let gui = conf.guis[lv % len(conf.guis)]
let hi_style = 'ctermfg='.ctermfg.' guifg='.guifg.(len(cterm) > 0 ? ' cterm='.cterm : '').(len(gui) > 0 ? ' gui='.gui : '')
exe 'hi '.pid.' '.hi_style
exe 'hi '.oid.' '.hi_style
endfor
endfor
endfun
fun rainbow#hi_clear(config)
let conf = a:config
let prefix = conf.syn_name_prefix
for id in range(len(conf.parentheses))
for lv in range(conf.cycle)
let [pid, oid] = [s:synID(prefix, 'p', lv, id), s:synID(prefix, 'o', lv, id)]
exe 'hi clear '.pid
exe 'hi clear '.oid
endfor
endfor
endfun

View File

@ -0,0 +1,136 @@
" Copyright 2013 LuoChen (luochen1990@gmail.com). Licensed under the Apache License 2.0.
let s:rainbow_conf = {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
\ 'guis': [''],
\ 'cterms': [''],
\ 'operators': '_,_',
\ 'contains_prefix': 'TOP',
\ 'parentheses_options': '',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'markdown': {
\ 'parentheses_options': 'containedin=markdownCode contained',
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
\ },
\ 'haskell': {
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\v\{\ze[^-]/ end=/}/ fold'],
\ },
\ 'ocaml': {
\ 'parentheses': ['start=/(\ze[^*]/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\[|/ end=/|\]/ fold', 'start=/{/ end=/}/ fold'],
\ },
\ 'tex': {
\ 'parentheses_options': 'containedin=texDocZone',
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
\ },
\ 'vim': {
\ 'parentheses_options': 'containedin=vimFuncBody,vimExecute',
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold'],
\ },
\ 'xml': {
\ 'syn_name_prefix': 'xmlRainbow',
\ 'parentheses': ['start=/\v\<\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'))?)*\>/ end=#</\z1># fold'],
\ },
\ 'xhtml': {
\ 'parentheses': ['start=/\v\<\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'))?)*\>/ end=#</\z1># fold'],
\ },
\ 'html': {
\ 'parentheses': ['start=/\v\<((script|style|area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
\ },
\ 'lua': {
\ 'parentheses': ["start=/(/ end=/)/", "start=/{/ end=/}/", "start=/\\v\\[\\ze($|[^[])/ end=/\\]/"],
\ },
\ 'perl': {
\ 'syn_name_prefix': 'perlBlockFoldRainbow',
\ },
\ 'php': {
\ 'syn_name_prefix': 'phpBlockRainbow',
\ 'contains_prefix': '',
\ 'parentheses': ['start=/(/ end=/)/ containedin=@htmlPreproc contains=@phpClTop', 'start=/\[/ end=/\]/ containedin=@htmlPreproc contains=@phpClTop', 'start=/{/ end=/}/ containedin=@htmlPreproc contains=@phpClTop', 'start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold contains_prefix=TOP'],
\ },
\ 'stylus': {
\ 'parentheses': ['start=/{/ end=/}/ fold contains=@colorableGroup'],
\ },
\ 'css': 0,
\ 'sh': 0,
\ 'vimwiki': 0,
\ }
\}
fun s:eq(x, y)
return type(a:x) == type(a:y) && a:x == a:y
endfun
fun s:gcd(a, b)
let [a, b, t] = [a:a, a:b, 0]
while b != 0
let t = b
let b = a % b
let a = t
endwhile
return a
endfun
fun s:lcm(a, b)
return (a:a / s:gcd(a:a, a:b)) * a:b
endfun
fun rainbow_main#gen_config(ft)
let g = exists('g:rainbow_conf')? g:rainbow_conf : {}
"echom 'g:rainbow_conf:' string(g)
let s = get(g, 'separately', {})
"echom 'g:rainbow_conf.separately:' string(s)
let dft_conf = extend(copy(s:rainbow_conf), g) | unlet dft_conf.separately
"echom 'default config options:' string(dft_conf)
let dx_conf = s:rainbow_conf.separately['*']
"echom 'default star config:' string(dx_conf)
let ds_conf = get(s:rainbow_conf.separately, a:ft, dx_conf)
"echom 'default separately config:' string(ds_conf)
let ux_conf = get(s, '*', ds_conf)
"echom 'user star config:' string(ux_conf)
let us_conf = get(s, a:ft, ux_conf)
"echom 'user separately config:' string(us_conf)
let af_conf = (s:eq(us_conf, 'default') ? ds_conf : us_conf)
"echom 'almost finally config:' string(af_conf)
if s:eq(af_conf, 0)
return 0
else
let conf = extend(extend({'syn_name_prefix': substitute(a:ft, '\v\A+(\a)', '\u\1', 'g').'Rainbow'}, dft_conf), af_conf)
let conf.cycle = (has('gui_running') || (has('termguicolors') && &termguicolors)) ? s:lcm(len(conf.guifgs), len(conf.guis)) : s:lcm(len(conf.ctermfgs), len(conf.cterms))
return conf
endif
endfun
fun rainbow_main#gen_configs(ft)
return filter(map(split(a:ft, '\v\.'), 'rainbow_main#gen_config(v:val)'), 'type(v:val) == type({})')
endfun
fun rainbow_main#load()
let b:rainbow_confs = rainbow_main#gen_configs(&filetype)
for conf in b:rainbow_confs
call rainbow#syn(conf)
call rainbow#hi(conf)
endfor
endfun
fun rainbow_main#clear()
if !exists('b:rainbow_confs') | return | endif
for conf in b:rainbow_confs
call rainbow#hi_clear(conf)
call rainbow#syn_clear(conf)
endfor
unlet b:rainbow_confs
endfun
fun rainbow_main#toggle()
if exists('b:rainbow_confs')
call rainbow_main#clear()
else
call rainbow_main#load()
endif
endfun

View File

@ -0,0 +1,18 @@
Rainbow Parentheses Improved *rainbow*
==========================================================================
Commands: *rainbow-commands*
--------------------------------------------------------------------------
*RainbowToggle* --- toggle this plugin on/off
*RainbowToggleOn* --- toggle this plugin on
*RainbowToggleOff* --- toggle this plugin off
Configurations: *rainbow-config*
--------------------------------------------------------------------------
*g:rainbow_active* --- 1 to auto enable this plugin
0 to enable it later via :RainbowToggle
*g:rainbow_conf* --- https://github.com/luochen1990/rainbow#configure
vim:tw=78:ts=8:ft=help:norl:

View File

@ -0,0 +1,12 @@
" Copyright 2013 LuoChen (luochen1990@gmail.com). Licensed under the Apache License 2.0.
if exists('s:loaded') || !(exists('g:rainbow_active') || exists('g:rainbow_conf')) | finish | endif | let s:loaded = 1
command! RainbowToggle call rainbow_main#toggle()
command! RainbowToggleOn call rainbow_main#load()
command! RainbowToggleOff call rainbow_main#clear()
if (exists('g:rainbow_active') && g:rainbow_active)
auto syntax * call rainbow_main#load()
auto colorscheme * call rainbow_main#load()
endif

View File

@ -0,0 +1,11 @@
#ifdef __cplusplus
extern "C" {
#endif
typoo
(typoo)
int main() {
printf("hello, world");
return 0;
}

View File

@ -0,0 +1,3 @@
div {
color: red
}

View File

@ -0,0 +1,14 @@
a,b,c,d
1,2,3,4
1,,3,4
1,,,4
1 , , , 4
1,2,3,4,5
1, 2, 3, 4
1 ,2 ,3, 4, 5
1 , 2 , 3 , 4
1 , 2 , 3 , 4
1, 3
1,2,3
1,3,4,5
1 a,b,c,d
2 1,2,3,4
3 1,,3,4
4 1,,,4
5 1 , , , 4
6 1,2,3,4,5
7 1, 2, 3, 4
8 1 ,2 ,3, 4, 5
9 1 , 2 , 3 , 4
10 1 , 2 , 3 , 4
11 1, 3
12 1,2,3
13 1,3,4,5

View File

@ -0,0 +1,4 @@
typoo
(typoo)
client := &http.Client{}

View File

@ -0,0 +1,5 @@
{- this is a comment block -}
xs = [1, 2, 3]
ps = [(1, 2), (3, 1 / 4)]

View File

@ -0,0 +1,22 @@
<html>
<head>
<style>
h1 {color:red;}
p {color:blue;}
</style>
</head>
<body>
<div>
<img />
(1 + (2 + 3))
</div>
<script>
var foo = true;
if (foo) {
alert("hey");
}
</script>
</body>
</html>

View File

@ -0,0 +1,8 @@
<html>
<div>
<img />
(1 + (2 + 3))
</div>
</html>
<!-- vim: set ft=html.txt : -->

View File

@ -0,0 +1,5 @@
typoo
(typoo)
console.log({w: 200, h: 100, pos: [{x: 1, y: 2}, {x: 3, y: 4}]})

View File

@ -0,0 +1,12 @@
(function(args)
lst = { a=function(arg) print("hello") end,
b=(1+2)*3/4,
[3+5]={ ["hello"]=("hi") },
}
lst[
(function() return 0 end)()] = 1
end)("blah")
[[
Special lua string...
]]

View File

@ -0,0 +1,13 @@
<?php
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
}
?>
<html>
hello (world)
</html>

View File

@ -0,0 +1,10 @@
typoo
(typoo)
sub test {
correct indent;
}
if ($test) {
incorrect indent;
}

View File

@ -0,0 +1,15 @@
{{{}}}
((()))
[[[]]]
[[[[]]]]
def sample_function(a, b)
((()))
[[[]]]
end
class SampleClass
def sample_method(a, b)
[[[]]]
end
end

View File

@ -0,0 +1,52 @@
#!/bin/bash
typoo
(typoo)
if stuff
then
somestuff
test = (())
(())
a = (1 + (2 + 3))
if
then
elif
then
else
fi
else
otherstuff
fi
if stuff
then
somestuff
else
otherstuff
fi
function f() {
if
fi
}
# check if command exists
command_exists () {
type "${1}" > /dev/null 2>&1;
a = (1 + (2 + 3))
}
# Fetch the update
fetch() {
if type wget > /dev/null 2>&1 ; then
$debug && echo "fetching update via wget"
wget --no-check-certificate -O "${2}" "${1}" >/dev/null 2>&1
elif type curl > /dev/null 2>&1 ; then
$debug && echo "fetching update via curl"
curl --insecure --remote-name -o "${2}" "${1}" >/dev/null 2>&1
else
echo 'Warning: Neither wget nor curl is available. online updates unavailable' >&2
exit 1
fi
}

View File

@ -0,0 +1,5 @@
(((())))
[[[[]]]]
{{{{}}}}
# vim: set ft=this-is-a--very-SPECIAL-filetype :

View File

@ -0,0 +1,3 @@
div {
color: red
}

View File

@ -0,0 +1,11 @@
\documentclass[]{article}
{{{{}}}}
((((((()))))))
[[[[[[]]]]]]
\begin{document}
((((()))))
${{{{}}}}$
{{{{}}}}
[[[[[[]]]]]]
\end{document}

View File

@ -0,0 +1,6 @@
<html>
<div>
<img />
</div>
</html>

@ -1 +0,0 @@
Subproject commit eb8baa5428bde10ecc1cb14eed1d6e16f5f24695

View File

@ -121,23 +121,23 @@ au FileType mako vmap Si S"i${ _(<esc>2f"a) }<esc>
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ ['mode', 'paste'],
\ ['fugitive', 'readonly', 'filename', 'modified'] ],
\ 'right': [ [ 'lineinfo' ], ['percent'] ]
\ },
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"🔒":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}',
\ 'fugitive': '%{exists("*FugitiveHead")?FugitiveHead():""}'
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype!="help"&& &readonly)',
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
\ 'fugitive': '(exists("*FugitiveHead") && ""!=FugitiveHead())'
\ },
\ 'separator': { 'left': ' ', 'right': ' ' },
\ 'subseparator': { 'left': ' ', 'right': ' ' }
\ }
\ 'left': [ ['mode', 'paste'],
\ ['fugitive', 'readonly', 'filename', 'modified'] ],
\ 'right': [ [ 'lineinfo' ], ['percent'] ]
\ },
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"🔒":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}',
\ 'fugitive': '%{exists("*FugitiveHead")?FugitiveHead():""}'
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype!="help"&& &readonly)',
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
\ 'fugitive': '(exists("*FugitiveHead") && ""!=FugitiveHead())'
\ },
\ 'separator': { 'left': ' ', 'right': ' ' },
\ 'subseparator': { 'left': ' ', 'right': ' ' }
\ }
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vimroom
@ -213,26 +213,5 @@ autocmd BufWrite * :Autoformat
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Rainbow Parentheses
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['black', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\ ]
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
let g:rainbow_active = 1