mirror of
1
0
Fork 0

Update coc.nvim

This commit is contained in:
Kurtis Moxley 2022-06-17 14:39:48 +08:00
parent 27c01e54fa
commit 9c0283f83b
16 changed files with 1897 additions and 1615 deletions

View File

@ -285,7 +285,7 @@ nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
- [Create coc.nvim extension to improve Vim experience](https://medium.com/@chemzqm/create-coc-nvim-extension-to-improve-vim-experience-4461df269173) - [Create coc.nvim extension to improve Vim experience](https://medium.com/@chemzqm/create-coc-nvim-extension-to-improve-vim-experience-4461df269173)
- [How to write a coc.nvim extension (and why)](https://samroeca.com/coc-plugin.html) - [How to write a coc.nvim extension (and why)](https://samroeca.com/coc-plugin.html)
## Trouble shooting ## Troubleshooting
Try these steps when you have problem with coc.nvim. Try these steps when you have problem with coc.nvim.
@ -603,7 +603,7 @@ Try these steps when you have problem with coc.nvim.
<td align="center"><a href="https://github.com/minefuto"><img src="https://avatars.githubusercontent.com/u/46558834?v=4?s=50" width="50px;" alt=""/><br /><sub><b>minefuto</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/commits?author=minefuto" title="Code">💻</a></td> <td align="center"><a href="https://github.com/minefuto"><img src="https://avatars.githubusercontent.com/u/46558834?v=4?s=50" width="50px;" alt=""/><br /><sub><b>minefuto</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/commits?author=minefuto" title="Code">💻</a></td>
<td align="center"><a href="https://twitter.com/robokomy"><img src="https://avatars.githubusercontent.com/u/20733354?v=4?s=50" width="50px;" alt=""/><br /><sub><b>miyanokomiya</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/commits?author=miyanokomiya" title="Code">💻</a></td> <td align="center"><a href="https://twitter.com/robokomy"><img src="https://avatars.githubusercontent.com/u/20733354?v=4?s=50" width="50px;" alt=""/><br /><sub><b>miyanokomiya</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/commits?author=miyanokomiya" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/miyaviee"><img src="https://avatars.githubusercontent.com/u/15247561?v=4?s=50" width="50px;" alt=""/><br /><sub><b>miyaviee</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/commits?author=miyaviee" title="Code">💻</a></td> <td align="center"><a href="https://github.com/miyaviee"><img src="https://avatars.githubusercontent.com/u/15247561?v=4?s=50" width="50px;" alt=""/><br /><sub><b>miyaviee</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/commits?author=miyaviee" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/monkoose"><img src="https://avatars.githubusercontent.com/u/6261276?v=4?s=50" width="50px;" alt=""/><br /><sub><b>monkoose</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/commits?author=monkoose" title="Code">💻</a></td> <td align="center"><a href="https://github.com/monkoose"><img src="https://avatars.githubusercontent.com/u/6261276?v=4?s=50" width="50px;" alt=""/><br /><sub><b>monkoose</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/commits?author=monkoose" title="Code">💻</a> <a href="https://github.com/neoclide/coc.nvim/issues?q=author%3Amonkoose" title="Bug reports">🐛</a></td>
</tr> </tr>
<tr> <tr>
<td align="center"><a href="https://github.com/mujx"><img src="https://avatars.githubusercontent.com/u/6430350?v=4?s=50" width="50px;" alt=""/><br /><sub><b>mujx</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/commits?author=mujx" title="Code">💻</a></td> <td align="center"><a href="https://github.com/mujx"><img src="https://avatars.githubusercontent.com/u/6430350?v=4?s=50" width="50px;" alt=""/><br /><sub><b>mujx</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/commits?author=mujx" title="Code">💻</a></td>
@ -623,6 +623,9 @@ Try these steps when you have problem with coc.nvim.
<td align="center"><a href="https://limingfei56.github.io/"><img src="https://avatars.githubusercontent.com/u/8553407?v=4?s=50" width="50px;" alt=""/><br /><sub><b>李鸣飞</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/commits?author=LiMingFei56" title="Code">💻</a></td> <td align="center"><a href="https://limingfei56.github.io/"><img src="https://avatars.githubusercontent.com/u/8553407?v=4?s=50" width="50px;" alt=""/><br /><sub><b>李鸣飞</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/commits?author=LiMingFei56" title="Code">💻</a></td>
<td align="center"><a href="https://bandism.net/"><img src="https://avatars.githubusercontent.com/u/22633385?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Ikko Ashimine</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/commits?author=eltociear" title="Documentation">📖</a></td> <td align="center"><a href="https://bandism.net/"><img src="https://avatars.githubusercontent.com/u/22633385?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Ikko Ashimine</b></sub></a><br /><a href="https://github.com/neoclide/coc.nvim/commits?author=eltociear" title="Documentation">📖</a></td>
</tr> </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>
</tr>
</table> </table>
<!-- markdownlint-restore --> <!-- markdownlint-restore -->

View File

@ -218,6 +218,9 @@ function! coc#do_notify(id, method, result)
endfunction endfunction
function! coc#complete_indent() abort function! coc#complete_indent() abort
if has('patch-8.2.3100')
return 0
endif
let curpos = getcurpos() let curpos = getcurpos()
let indent_len = len(matchstr(getline('.'), '^\s*')) let indent_len = len(matchstr(getline('.'), '^\s*'))
let startofline = &startofline let startofline = &startofline

View File

@ -2,7 +2,7 @@
" Description: Client api used by vim8 " Description: Client api used by vim8
" Author: Qiming Zhao <chemzqm@gmail.com> " Author: Qiming Zhao <chemzqm@gmail.com>
" Licence: Anti 996 licence " Licence: Anti 996 licence
" Last Modified: Mar 08, 2022 " Last Modified: Jun 03, 2022
" ============================================================================ " ============================================================================
if has('nvim') | finish | endif if has('nvim') | finish | endif
scriptencoding utf-8 scriptencoding utf-8
@ -10,6 +10,11 @@ let s:funcs = {}
let s:prop_offset = get(g:, 'coc_text_prop_offset', 1000) let s:prop_offset = get(g:, 'coc_text_prop_offset', 1000)
let s:namespace_id = 1 let s:namespace_id = 1
let s:namespace_cache = {} let s:namespace_cache = {}
let s:max_src_id = 1000
" bufnr => max textprop id
let s:buffer_id = {}
" srcId => list of types
let s:id_types = {}
" helper {{ " helper {{
function! s:buf_line_count(bufnr) abort function! s:buf_line_count(bufnr) abort
@ -96,7 +101,7 @@ function! s:funcs.call_atomic(calls)
try try
call add(res, call(s:funcs[name], arglist)) call add(res, call(s:funcs[name], arglist))
catch /.*/ catch /.*/
return [res, [i, "VimException(".s:inspect_type(v:exception).")", v:exception]] return [res, [i, "VimException(".s:inspect_type(v:exception).")", v:exception . ' on '.v:throwpoint]]
endtry endtry
endfor endfor
return [res, v:null] return [res, v:null]
@ -270,42 +275,27 @@ function! s:funcs.buf_add_highlight(bufnr, srcId, hlGroup, line, colStart, colEn
if !has('patch-8.1.1719') if !has('patch-8.1.1719')
return return
endif endif
let bufnr = a:bufnr == 0 ? bufnr('%') : a:bufnr if a:srcId == 0
let type = 'CocHighlight'.a:hlGroup let srcId = s:max_src_id + 1
if empty(prop_type_get(type)) let s:max_src_id = srcId
let opts = get(a:, 1, 0)
let priority = get(opts, 'priority', 0)
call prop_type_add(type, {
\ 'highlight': a:hlGroup,
\ 'priority': type(priority) == 0 ? priority : 0,
\ 'combine': get(opts, 'combine', 1),
\ 'start_incl': get(opts, 'start_incl', 0),
\ 'end_incl': get(opts, 'end_incl', 0),
\ })
endif
let total = strlen(getbufline(bufnr, a:line + 1)[0])
let end = a:colEnd
if end == -1
let end = total
else else
let end = min([end, total]) let srcId = a:srcId
endif endif
if end <= a:colStart let bufnr = a:bufnr == 0 ? bufnr('%') : a:bufnr
let type = a:hlGroup.'_'.srcId
let types = get(s:id_types, srcId, [])
if index(types, type) == -1
call add(types, type)
let s:id_types[srcId] = types
call prop_type_add(type, extend({'highlight': a:hlGroup}, get(a:, 1, {})))
endif
let end = a:colEnd == -1 ? strlen(getbufline(bufnr, a:line + 1)[0]) + 1 : a:colEnd + 1
if end < a:colStart + 1
return return
endif endif
let srcId = a:srcId let id = s:generate_id(a:bufnr)
if srcId == 0
while v:true
let srcId = srcId + 1
if empty(prop_find({'id': s:prop_offset + srcId, 'lnum' : 1}))
break
endif
endwhile
" generate srcId
endif
let id = srcId == -1 ? 0 : s:prop_offset + srcId
try try
call prop_add(a:line + 1, a:colStart + 1, {'length': end - a:colStart, 'bufnr': bufnr, 'type': type, 'id': id}) call prop_add(a:line + 1, a:colStart + 1, {'bufnr': bufnr, 'type': type, 'id': id, 'end_col': end})
catch /^Vim\%((\a\+)\)\=:E967/ catch /^Vim\%((\a\+)\)\=:E967/
" ignore 967 " ignore 967
endtry endtry
@ -323,13 +313,18 @@ function! s:funcs.buf_clear_namespace(bufnr, srcId, startLine, endLine) abort
let start = a:startLine + 1 let start = a:startLine + 1
let end = a:endLine == -1 ? len(getbufline(bufnr, 1, '$')) : a:endLine let end = a:endLine == -1 ? len(getbufline(bufnr, 1, '$')) : a:endLine
if a:srcId == -1 if a:srcId == -1
if has_key(s:buffer_id, a:bufnr)
unlet s:buffer_id[a:bufnr]
endif
call prop_clear(start, end, {'bufnr' : bufnr}) call prop_clear(start, end, {'bufnr' : bufnr})
else else
try for type in get(s:id_types, a:srcId, [])
call prop_remove({'bufnr': bufnr, 'all': 1, 'id': s:prop_offset + a:srcId}, start, end) try
catch /^Vim\%((\a\+)\)\=:E968/ call prop_remove({'bufnr': bufnr, 'all': 1, 'type': type}, start, end)
" ignore 968 catch /^Vim\%((\a\+)\)\=:E968/
endtry " ignore 968
endtry
endfor
endif endif
endfunction endfunction
@ -640,8 +635,19 @@ function! s:funcs.tabpage_get_win(tabnr)
let wnr = tabpagewinnr(a:tabnr) let wnr = tabpagewinnr(a:tabnr)
return win_getid(wnr, a:tabnr) return win_getid(wnr, a:tabnr)
endfunction endfunction
function! s:generate_id(bufnr) abort
let max = get(s:buffer_id, a:bufnr, s:prop_offset)
let id = max + 1
let s:buffer_id[a:bufnr] = id
return id
endfunction
" }} " }}
function! coc#api#get_types(srcId) abort
return get(s:id_types, a:srcId, [])
endfunction
function! coc#api#func_names() abort function! coc#api#func_names() abort
return keys(s:funcs) return keys(s:funcs)
endfunction endfunction
@ -652,7 +658,7 @@ function! coc#api#call(method, args) abort
try try
let res = call(s:funcs[a:method], a:args) let res = call(s:funcs[a:method], a:args)
catch /.*/ catch /.*/
let err = v:exception let err = v:exception .' on api "'.a:method.'" '.json_encode(a:args)
endtry endtry
return [err, res] return [err, res]
endfunction endfunction
@ -662,6 +668,11 @@ function! coc#api#exec(method, args) abort
endfunction endfunction
function! coc#api#notify(method, args) abort function! coc#api#notify(method, args) abort
call call(s:funcs[a:method], a:args) try
call call(s:funcs[a:method], a:args)
catch /.*/
let g:b = v:exception
call coc#rpc#notify('nvim_error_event', [0, v:exception.' on api "'.a:method.'" '.json_encode(a:args)])
endtry
endfunction endfunction
" vim: set sw=2 ts=2 sts=2 et tw=78 foldmarker={{,}} foldmethod=marker foldlevel=0: " vim: set sw=2 ts=2 sts=2 et tw=78 foldmarker={{,}} foldmethod=marker foldlevel=0:

View File

@ -5,7 +5,7 @@ let s:is_win = has("win32") || has("win64")
let s:clients = {} let s:clients = {}
if get(g:, 'node_client_debug', 0) if get(g:, 'node_client_debug', 0)
echohl WarningMsg | echon '[coc.nvim] Enable g:node_client_debug could impact your vim experience' | echohl None echohl WarningMsg | echo '[coc.nvim] Enable g:node_client_debug could impact your vim experience' | echohl None
let $NODE_CLIENT_LOG_LEVEL = 'debug' let $NODE_CLIENT_LOG_LEVEL = 'debug'
if exists('$NODE_CLIENT_LOG_FILE') if exists('$NODE_CLIENT_LOG_FILE')
let s:logfile = resolve($NODE_CLIENT_LOG_FILE) let s:logfile = resolve($NODE_CLIENT_LOG_FILE)
@ -43,9 +43,13 @@ function! s:start() dict
return return
endif endif
let timeout = string(get(g:, 'coc_channel_timeout', 30)) let timeout = string(get(g:, 'coc_channel_timeout', 30))
let disable_warning = string(get(g:, 'coc_disable_startup_warning', 0))
let tmpdir = fnamemodify(tempname(), ':p:h') let tmpdir = fnamemodify(tempname(), ':p:h')
if s:is_vim if s:is_vim
if get(g:, 'node_client_debug', 0)
let file = tmpdir . '/coc.log'
call ch_logfile(file, 'w')
echohl MoreMsg | echo '[coc.nvim] channel log to '.file | echohl None
endif
let options = { let options = {
\ 'in_mode': 'json', \ 'in_mode': 'json',
\ 'out_mode': 'json', \ 'out_mode': 'json',

View File

@ -74,7 +74,7 @@ function! coc#dialog#create_cursor_float(winid, bufnr, lines, config) abort
if index(modes, mode) == -1 if index(modes, mode) == -1
return v:null return v:null
endif endif
if has('nvim') && mode ==# 'i' if !s:is_vim && !has('nvim-0.5.0') && mode ==# 'i'
" helps to fix undo issue, don't know why. " helps to fix undo issue, don't know why.
call feedkeys("\<C-g>u", 'n') call feedkeys("\<C-g>u", 'n')
endif endif
@ -676,5 +676,7 @@ endfunction
function! s:place_sign(bufnr, line) abort function! s:place_sign(bufnr, line) abort
call sign_unplace(s:sign_group, { 'buffer': a:bufnr }) call sign_unplace(s:sign_group, { 'buffer': a:bufnr })
call sign_place(6, s:sign_group, 'CocCurrentLine', a:bufnr, {'lnum': a:line}) if a:line > 0
call sign_place(6, s:sign_group, 'CocCurrentLine', a:bufnr, {'lnum': a:line})
endif
endfunction endfunction

View File

@ -2,7 +2,6 @@ scriptencoding utf-8
let s:is_vim = !has('nvim') let s:is_vim = !has('nvim')
let s:clear_match_by_window = has('nvim-0.6.0') || has('patch-8.1.1084') let s:clear_match_by_window = has('nvim-0.6.0') || has('patch-8.1.1084')
let s:set_extmark = has('nvim') && exists('*nvim_buf_set_extmark') let s:set_extmark = has('nvim') && exists('*nvim_buf_set_extmark')
let s:del_extmark = has('nvim') && exists('*nvim_buf_del_extmark')
let s:prop_offset = get(g:, 'coc_text_prop_offset', 1000) let s:prop_offset = get(g:, 'coc_text_prop_offset', 1000)
let s:namespace_map = {} let s:namespace_map = {}
let s:ns_id = 1 let s:ns_id = 1
@ -82,46 +81,43 @@ function! coc#highlight#update_highlights(bufnr, key, highlights, ...) abort
endif endif
let current = coc#highlight#get_highlights(bufnr, a:key, start, endLnum) let current = coc#highlight#get_highlights(bufnr, a:key, start, endLnum)
let currIndex = 0 let currIndex = 0
let clearLnums = []
if !empty(current) if !empty(current)
for [lnum, items] in s:to_group(current) for [lnum, items] in s:to_group(current)
let indexes = [] let indexes = []
let currIndexes = range(0, len(items) - 1) let currIndexes = range(0, len(items) - 1)
"call coc#rpc#notify('Log', ['items:', lnum, items]) let removeIndexes = []
while currIndex != total while currIndex != total
let hi = a:highlights[currIndex] let hi = a:highlights[currIndex]
if hi['lnum'] == lnum if hi['lnum'] == lnum
let findIndex = -1
for idx in currIndexes for idx in currIndexes
let item = items[idx] let item = items[idx]
if hi['hlGroup'] ==# item[0] && hi['colStart'] == item[2] && hi['colEnd'] == item[3] if hi['hlGroup'] ==# item[0] && hi['colStart'] == item[2] && hi['colEnd'] == item[3]
call add(indexes, currIndex) call add(indexes, currIndex)
call filter(currIndexes, 'v:val != '.idx) let findIndex = idx
break break
elseif item[2] > hi['colStart'] elseif item[2] > hi['colStart']
break break
endif endif
endfor endfor
if findIndex != -1
call filter(currIndexes, 'v:val != '.findIndex)
endif
elseif hi['lnum'] > lnum elseif hi['lnum'] > lnum
break break
endif endif
let currIndex = currIndex + 1 let currIndex = currIndex + 1
endwhile endwhile
if !empty(currIndexes) for idx in currIndexes
if s:del_extmark if s:is_vim
for idx in currIndexes call prop_remove({'bufnr': bufnr, 'id': items[idx][4]})
call nvim_buf_del_extmark(bufnr, ns, items[idx][4])
endfor
call extend(exists, indexes)
else else
call add(clearLnums, lnum) call nvim_buf_del_extmark(bufnr, ns, items[idx][4])
endif endif
else endfor
" all highlights of current line exists, not clear. call extend(exists, indexes)
call extend(exists, indexes)
endif
endfor endfor
endif endif
call coc#highlight#clear(bufnr, a:key, clearLnums)
else else
call coc#highlight#clear_highlight(bufnr, a:key, start, end) call coc#highlight#clear_highlight(bufnr, a:key, start, end)
endif endif
@ -131,19 +127,19 @@ function! coc#highlight#update_highlights(bufnr, key, highlights, ...) abort
endif endif
for idx in indexes for idx in indexes
let hi = a:highlights[idx] let hi = a:highlights[idx]
let opts = {} let opts = {
\ 'combine': get(hi, 'combine', 0),
\ 'start_incl': get(hi, 'start_incl', 0),
\ 'end_incl': get(hi, 'end_incl', 0),
\ }
if type(priority) == 0 if type(priority) == 0
let opts['priority'] = s:get_priority(a:key, hi['hlGroup'], priority) let opts['priority'] = s:get_priority(a:key, hi['hlGroup'], priority)
endif endif
for key in ['combine', 'start_incl', 'end_incl']
if has_key(hi, key)
let opts[key] = hi[key]
endif
endfor
call coc#highlight#add_highlight(bufnr, ns, hi['hlGroup'], hi['lnum'], hi['colStart'], hi['colEnd'], opts) call coc#highlight#add_highlight(bufnr, ns, hi['hlGroup'], hi['lnum'], hi['colStart'], hi['colEnd'], opts)
endfor endfor
endfunction endfunction
" Get list of highlights by range or all buffer.
" 0 based line, start_col and end_col " 0 based line, start_col and end_col
" 0 based start & end line, end inclusive. " 0 based start & end line, end inclusive.
function! coc#highlight#get_highlights(bufnr, key, ...) abort function! coc#highlight#get_highlights(bufnr, key, ...) abort
@ -158,17 +154,21 @@ function! coc#highlight#get_highlights(bufnr, key, ...) abort
let res = [] let res = []
let ns = s:namespace_map[a:key] let ns = s:namespace_map[a:key]
if exists('*prop_list') if exists('*prop_list')
" Could filter by end_lnum and ids let types = coc#api#get_types(ns)
if empty(types)
return res
endif
" Could filter by end_lnum and types
if has('patch-8.2.3652') if has('patch-8.2.3652')
let endLnum = end == -1 ? -1 : end + 1 let endLnum = end == -1 ? -1 : end + 1
for prop in prop_list(start + 1, {'bufnr': a:bufnr, 'ids': [s:prop_offset + ns], 'end_lnum': endLnum}) for prop in prop_list(start + 1, {'bufnr': a:bufnr, 'types': types, 'end_lnum': endLnum})
if prop['start'] == 0 || prop['end'] == 0 if prop['start'] == 0 || prop['end'] == 0
" multi line textprop are not supported, simply ignore it " multi line textprop are not supported, simply ignore it
continue continue
endif endif
let startCol = prop['col'] - 1 let startCol = prop['col'] - 1
let endCol = startCol + prop['length'] let endCol = startCol + prop['length']
call add(res, [s:prop_type_hlgroup(prop['type']), prop['lnum'] - 1, startCol, endCol]) call add(res, [s:prop_type_hlgroup(prop['type']), prop['lnum'] - 1, startCol, endCol, prop['id']])
endfor endfor
else else
if end == -1 if end == -1
@ -176,16 +176,15 @@ function! coc#highlight#get_highlights(bufnr, key, ...) abort
else else
let end = end + 1 let end = end + 1
endif endif
let id = s:prop_offset + ns
for line in range(start + 1, end) for line in range(start + 1, end)
for prop in prop_list(line, {'bufnr': a:bufnr}) for prop in prop_list(line, {'bufnr': a:bufnr})
if prop['id'] != id || prop['start'] == 0 || prop['end'] == 0 if index(types, prop['type']) == -1 || prop['start'] == 0 || prop['end'] == 0
" multi line textprop are not supported, simply ignore it " multi line textprop are not supported, simply ignore it
continue continue
endif endif
let startCol = prop['col'] - 1 let startCol = prop['col'] - 1
let endCol = startCol + prop['length'] let endCol = startCol + prop['length']
call add(res, [s:prop_type_hlgroup(prop['type']), line - 1, startCol, endCol]) call add(res, [s:prop_type_hlgroup(prop['type']), line - 1, startCol, endCol, prop['id']])
endfor endfor
endfor endfor
endif endif
@ -237,7 +236,7 @@ endfunction
" Clear highlights by 0 based line numbers. " Clear highlights by 0 based line numbers.
function! coc#highlight#clear(bufnr, key, lnums) abort function! coc#highlight#clear(bufnr, key, lnums) abort
if !bufloaded(a:bufnr) if !bufloaded(a:bufnr) || empty(a:lnums)
return return
endif endif
let ns = coc#highlight#create_namespace(a:key) let ns = coc#highlight#create_namespace(a:key)
@ -245,7 +244,7 @@ function! coc#highlight#clear(bufnr, key, lnums) abort
if has('nvim') if has('nvim')
call nvim_buf_clear_namespace(a:bufnr, ns, lnum, lnum + 1) call nvim_buf_clear_namespace(a:bufnr, ns, lnum, lnum + 1)
else else
call coc#api#call('buf_clear_namespace', [a:bufnr, ns, lnum, lnum + 1]) call coc#api#exec('buf_clear_namespace', [a:bufnr, ns, lnum, lnum + 1])
endif endif
endfor endfor
" clear highlights in invalid line. " clear highlights in invalid line.
@ -261,7 +260,11 @@ function! coc#highlight#del_markers(bufnr, key, ids) abort
endif endif
let ns = coc#highlight#create_namespace(a:key) let ns = coc#highlight#create_namespace(a:key)
for id in a:ids for id in a:ids
call nvim_buf_del_extmark(a:bufnr, ns, id) if s:is_vim
call prop_remove({'bufnr': a:bufnr, 'id': id})
else
call nvim_buf_del_extmark(a:bufnr, ns, id)
endif
endfor endfor
endfunction endfunction
@ -323,7 +326,7 @@ function! coc#highlight#add_highlight(bufnr, src_id, hl_group, line, col_start,
call nvim_buf_add_highlight(a:bufnr, a:src_id, a:hl_group, a:line, a:col_start, a:col_end) call nvim_buf_add_highlight(a:bufnr, a:src_id, a:hl_group, a:line, a:col_start, a:col_end)
endif endif
else else
call coc#api#call('buf_add_highlight', [a:bufnr, a:src_id, a:hl_group, a:line, a:col_start, a:col_end, opts]) call coc#api#exec('buf_add_highlight', [a:bufnr, a:src_id, a:hl_group, a:line, a:col_start, a:col_end, opts])
endif endif
endfunction endfunction
@ -336,7 +339,7 @@ function! coc#highlight#clear_highlight(bufnr, key, start_line, end_line) abort
if has('nvim') if has('nvim')
call nvim_buf_clear_namespace(a:bufnr, src_id, a:start_line, a:end_line) call nvim_buf_clear_namespace(a:bufnr, src_id, a:start_line, a:end_line)
else else
call coc#api#call('buf_clear_namespace', [a:bufnr, src_id, a:start_line, a:end_line]) call coc#api#exec('buf_clear_namespace', [a:bufnr, src_id, a:start_line, a:end_line])
endif endif
endfunction endfunction
@ -354,6 +357,9 @@ endfunction
" endLine: number " endLine: number
" } " }
function! coc#highlight#add_highlights(winid, codes, highlights) abort function! coc#highlight#add_highlights(winid, codes, highlights) abort
if get(g:, 'coc_node_env', '') ==# 'test'
call setwinvar(a:winid, 'highlights', a:highlights)
endif
" clear highlights " clear highlights
call coc#compat#execute(a:winid, 'syntax clear') call coc#compat#execute(a:winid, 'syntax clear')
let bufnr = winbufnr(a:winid) let bufnr = winbufnr(a:winid)
@ -595,7 +601,7 @@ function! coc#highlight#clear_all() abort
if has('nvim') if has('nvim')
call nvim_buf_clear_namespace(bufnr, src_id, 0, -1) call nvim_buf_clear_namespace(bufnr, src_id, 0, -1)
else else
call coc#api#call('buf_clear_namespace', [bufnr, src_id, 0, -1]) call coc#api#exec('buf_clear_namespace', [bufnr, src_id, 0, -1])
endif endif
endfor endfor
endfor endfor
@ -622,10 +628,7 @@ function! coc#highlight#get_syntax_name(lnum, col)
endfunction endfunction
function! s:prop_type_hlgroup(type) abort function! s:prop_type_hlgroup(type) abort
if strpart(a:type, 0, 12) ==# 'CocHighlight' return substitute(a:type, '_\d\+$', '', '')
return strpart(a:type, 12)
endif
return get(prop_type_get(a:type), 'highlight', '')
endfunction endfunction
function! s:update_highlights_timer(bufnr, changedtick, key, priority, groups, idx) abort function! s:update_highlights_timer(bufnr, changedtick, key, priority, groups, idx) abort

View File

@ -1,6 +1,7 @@
scriptencoding utf-8 scriptencoding utf-8
let s:is_vim = !has('nvim') let s:is_vim = !has('nvim')
let s:prefix = '[List Preview]' let s:prefix = '[List Preview]'
let s:sign_group = 'CocList'
" filetype detect could be slow. " filetype detect could be slow.
let s:filetype_map = { let s:filetype_map = {
\ 'c': 'c', \ 'c': 'c',
@ -66,7 +67,6 @@ function! coc#list#create(position, height, name, numberSelect)
else else
setl nonumber setl nonumber
setl norelativenumber setl norelativenumber
setl signcolumn=yes
endif endif
return [bufnr('%'), win_getid(), tabpagenr()] return [bufnr('%'), win_getid(), tabpagenr()]
endfunction endfunction
@ -84,15 +84,12 @@ endfunction
function! coc#list#setup(source) function! coc#list#setup(source)
let b:list_status = {} let b:list_status = {}
setl buftype=nofile nobuflisted nofen nowrap setl buftype=nofile nobuflisted nofen nowrap
setl norelativenumber bufhidden=wipe cursorline winfixheight setl norelativenumber bufhidden=wipe nocursorline winfixheight
setl tabstop=1 nolist nocursorcolumn undolevels=-1 setl tabstop=1 nolist nocursorcolumn undolevels=-1
setl signcolumn=auto setl signcolumn=auto
if has('nvim-0.5.0') || has('patch-8.1.0864') if has('nvim-0.5.0') || has('patch-8.1.0864')
setl scrolloff=0 setl scrolloff=0
endif endif
if exists('&cursorlineopt')
setl cursorlineopt=both
endif
setl filetype=list setl filetype=list
syntax case ignore syntax case ignore
let source = a:source[8:] let source = a:source[8:]
@ -104,6 +101,13 @@ function! coc#list#setup(source)
endif endif
endfunction endfunction
function! coc#list#select(bufnr, line) abort
call sign_unplace(s:sign_group, { 'buffer': a:bufnr })
if a:line > 0
call sign_place(6, s:sign_group, 'CocListCurrent', a:bufnr, {'lnum': a:line})
endif
endfunction
" Check if previewwindow exists on current tab. " Check if previewwindow exists on current tab.
function! coc#list#has_preview() function! coc#list#has_preview()
for i in range(1, winnr('$')) for i in range(1, winnr('$'))
@ -163,20 +167,12 @@ endfunction
" config.hlGroup - (optional) highlight group. " config.hlGroup - (optional) highlight group.
" config.maxHeight - (optional) max height of window, valid for 'below' & 'top' position. " config.maxHeight - (optional) max height of window, valid for 'below' & 'top' position.
function! coc#list#preview(lines, config) abort function! coc#list#preview(lines, config) abort
if s:is_vim && !exists('*win_execute')
throw 'win_execute function required for preview, please upgrade your vim.'
return
endif
let name = fnamemodify(get(a:config, 'name', ''), ':.') let name = fnamemodify(get(a:config, 'name', ''), ':.')
let lines = a:lines let lines = a:lines
if empty(lines) if empty(lines)
if get(a:config, 'scheme', 'file') != 'file' if get(a:config, 'scheme', 'file') != 'file'
let bufnr = s:load_buffer(name) let bufnr = s:load_buffer(name)
if bufnr != 0 let lines = bufnr == 0 ? [''] : getbufline(bufnr, 1, '$')
let lines = getbufline(bufnr, 1, '$')
else
let lines = ['']
endif
else else
" Show empty lines so not close window. " Show empty lines so not close window.
let lines = [''] let lines = ['']
@ -221,11 +217,7 @@ function! coc#list#preview(lines, config) abort
let winid = win_getid() let winid = win_getid()
endif endif
noa call winrestview({"lnum": lnum ,"topline":s:get_topline(a:config, lnum, winid)}) noa call winrestview({"lnum": lnum ,"topline":s:get_topline(a:config, lnum, winid)})
call setwinvar(winid, '&signcolumn', 'no') call s:set_preview_options(winid)
call setwinvar(winid, '&number', 1)
call setwinvar(winid, '&cursorline', 0)
call setwinvar(winid, '&relativenumber', 0)
call setwinvar(winid, 'previewwindow', 1)
noa call win_gotoid(curr) noa call win_gotoid(curr)
else else
let height = s:get_height(lines, a:config) let height = s:get_height(lines, a:config)
@ -262,17 +254,16 @@ function! coc#list#preview(lines, config) abort
let s:filetype_map[extname] = ft let s:filetype_map[extname] = ft
endif endif
endif endif
call sign_unplace('coc', {'buffer': bufnr}) call sign_unplace('CocCursorLine', {'buffer': bufnr})
call coc#compat#execute(winid, 'call clearmatches()') call coc#compat#execute(winid, 'call clearmatches()')
if !s:is_vim if !s:is_vim
" vim send <esc> to buffer on FocusLost, <C-w> and other cases " vim send <esc> to buffer on FocusLost, <C-w> and other cases
call coc#compat#execute(winid, 'nnoremap <silent><nowait><buffer> <esc> :call CocActionAsync("listCancel")<CR>') call coc#compat#execute(winid, 'nnoremap <silent><nowait><buffer> <esc> :call CocActionAsync("listCancel")<CR>')
endif endif
if !empty(range) if !empty(range)
call sign_place(1, 'coc', 'CocCurrentLine', bufnr, {'lnum': lnum}) call sign_place(1, 'CocCursorLine', 'CocCurrentLine', bufnr, {'lnum': lnum})
call coc#highlight#match_ranges(winid, bufnr, [range], hlGroup, 10) call coc#highlight#match_ranges(winid, bufnr, [range], hlGroup, 10)
endif endif
redraw
endfunction endfunction
function! s:get_height(lines, config) abort function! s:get_height(lines, config) abort
@ -301,3 +292,11 @@ function! s:get_topline(config, lnum, winid) abort
let toplineOffset = get(a:config, 'toplineOffset', 3) let toplineOffset = get(a:config, 'toplineOffset', 3)
return max([1, a:lnum - toplineOffset]) return max([1, a:lnum - toplineOffset])
endfunction endfunction
function! s:set_preview_options(winid) abort
call setwinvar(a:winid, '&signcolumn', 'no')
call setwinvar(a:winid, '&number', 1)
call setwinvar(a:winid, '&cursorline', 0)
call setwinvar(a:winid, '&relativenumber', 0)
call setwinvar(a:winid, 'previewwindow', 1)
endfunction

View File

@ -78,6 +78,7 @@ function! coc#rpc#restart()
call coc#rpc#start_server() call coc#rpc#start_server()
else else
call coc#highlight#clear_all() call coc#highlight#clear_all()
call coc#ui#sign_unplace()
call coc#float#close_all() call coc#float#close_all()
call coc#rpc#request('detach', []) call coc#rpc#request('detach', [])
sleep 100m sleep 100m

View File

@ -1,6 +1,8 @@
let s:is_vim = !has('nvim') let s:is_vim = !has('nvim')
let s:is_win = has('win32') || has('win64') let s:is_win = has('win32') || has('win64')
let s:is_mac = has('mac') let s:is_mac = has('mac')
let s:sign_api = exists('*sign_getplaced') && exists('*sign_place')
let s:sign_groups = []
function! coc#ui#quickpick(title, items, cb) abort function! coc#ui#quickpick(title, items, cb) abort
if exists('*popup_menu') if exists('*popup_menu')
@ -374,3 +376,51 @@ function! coc#ui#safe_rename(bufnr, oldPath, newPath, write) abort
call win_gotoid(winid) call win_gotoid(winid)
return bufnr return bufnr
endfunction endfunction
function! coc#ui#sign_unplace() abort
if exists('*sign_unplace')
for group in s:sign_groups
call sign_unplace(group)
endfor
endif
endfunction
function! coc#ui#update_signs(bufnr, group, signs) abort
if !s:sign_api || !bufloaded(a:bufnr)
return
endif
if len(a:signs)
call add(s:sign_groups, a:group)
endif
let current = get(get(sign_getplaced(a:bufnr, {'group': a:group}), 0, {}), 'signs', [])
let exists = []
let unplaceList = []
for item in current
let index = 0
let placed = 0
for def in a:signs
if def['name'] ==# item['name'] && def['lnum'] == item['lnum']
let placed = 1
call add(exists, index)
break
endif
let index = index + 1
endfor
if !placed
call add(unplaceList, item['id'])
endif
endfor
for idx in range(0, len(a:signs) - 1)
if index(exists, idx) == -1
let def = a:signs[idx]
let opts = {'lnum': def['lnum']}
if has_key(def, 'priority')
let opts['priority'] = def['priority']
endif
call sign_place(0, a:group, def['name'], a:bufnr, opts)
endif
endfor
for id in unplaceList
call sign_unplace(a:group, {'buffer': a:bufnr, 'id': id})
endfor
endfunction

File diff suppressed because one or more lines are too long

View File

@ -11,6 +11,11 @@
"default": false, "default": false,
"description": "Set to true to use borders." "description": "Set to true to use borders."
}, },
"rounded": {
"type": "boolean",
"default": false,
"description": "Use rounded borders when border is true."
},
"highlight": { "highlight": {
"type": "string", "type": "string",
"default": "CocFloating", "default": "CocFloating",
@ -187,7 +192,7 @@
}, },
"progressOnInitialization": { "progressOnInitialization": {
"type": "boolean", "type": "boolean",
"default": true, "default": false,
"description": "Enable progress report on languageserver initialize." "description": "Enable progress report on languageserver initialize."
}, },
"initializationOptions": { "initializationOptions": {
@ -797,6 +802,7 @@
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"border": {}, "border": {},
"rounded": {},
"highlight": {}, "highlight": {},
"borderhighlight": {}, "borderhighlight": {},
"title": {}, "title": {},
@ -858,6 +864,7 @@
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"border": {}, "border": {},
"rounded": {},
"highlight": {}, "highlight": {},
"borderhighlight": {}, "borderhighlight": {},
"title": {}, "title": {},
@ -942,6 +949,7 @@
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"border": {}, "border": {},
"rounded": {},
"highlight": {}, "highlight": {},
"borderhighlight": {}, "borderhighlight": {},
"title": {}, "title": {},
@ -1038,6 +1046,14 @@
"default": false, "default": false,
"description": "Use menu picker for message notification with actions." "description": "Use menu picker for message notification with actions."
}, },
"notification.disabledProgressSources": {
"type": "array",
"default": [],
"description": "Soureces that should be disabled for message progress, use * to disable all message only progresses",
"items": {
"type": "string"
}
},
"notification.minProgressWidth": { "notification.minProgressWidth": {
"type": "integer", "type": "integer",
"default": 30, "default": 30,
@ -1055,6 +1071,11 @@
"maximum": 100, "maximum": 100,
"description": "Winblend option of notification window, neovim only." "description": "Winblend option of notification window, neovim only."
}, },
"workspace.openOutputCommand": {
"type": "string",
"default": "vs",
"description": "Command used to open output channel."
},
"workspace.openResourceCommand": { "workspace.openResourceCommand": {
"type": "string", "type": "string",
"default": "tab drop", "default": "tab drop",
@ -1071,7 +1092,7 @@
"workspace.bottomUpFiletypes": { "workspace.bottomUpFiletypes": {
"type": "array", "type": "array",
"default": [], "default": [],
"description": "Filetypes that should have workspace folder should resolved from base directory of file.", "description": "Filetypes that should have workspace folder should resolved from base directory of file, or [\"*\"] for any filetype.",
"items": { "items": {
"type": "string" "type": "string"
} }
@ -1164,11 +1185,6 @@
"default": false, "default": false,
"description": "Use vsplit for preview window." "description": "Use vsplit for preview window."
}, },
"list.matchHighlightGroup": {
"type": "string",
"default": "CocSearch",
"description": "Highlight group used for matched texts in list window."
},
"list.previewHighlightGroup": { "list.previewHighlightGroup": {
"type": "string", "type": "string",
"default": "Search", "default": "Search",

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,21 @@
# 2022-06-11
- Add configuration "notification.disabledProgressSources"
- Add "rounded" property to "floatConfig"
# 2022-06-04
- Add configuration `workspace.openOutputCommand`.
- Log channel message of vim when `g:node_client_debug` enabled.
# 2022-05-30
- Disable `progressOnInitialization` for language client by default.
# 2022-05-28
- Support `repeat#set` for commands that make changes only.
# 2022-05-24 # 2022-05-24
- Add transition and annotation support for `workspace.applyEdits()`. - Add transition and annotation support for `workspace.applyEdits()`.

View File

@ -335,9 +335,9 @@ function! s:Enable(initialize)
else else
autocmd DirChanged * call s:Autocmd('DirChanged', get(v:event, 'cwd', '')) autocmd DirChanged * call s:Autocmd('DirChanged', get(v:event, 'cwd', ''))
autocmd TermOpen * call s:Autocmd('TermOpen', +expand('<abuf>')) autocmd TermOpen * call s:Autocmd('TermOpen', +expand('<abuf>'))
autocmd CursorMoved * call coc#float#nvim_refresh_scrollbar(win_getid())
autocmd WinEnter * call coc#float#nvim_win_enter(win_getid()) autocmd WinEnter * call coc#float#nvim_win_enter(win_getid())
endif endif
autocmd CursorMoved list:///* call coc#list#select(bufnr('%'), line('.'))
if exists('##WinClosed') if exists('##WinClosed')
autocmd WinClosed * call coc#float#on_close(+expand('<amatch>')) autocmd WinClosed * call coc#float#on_close(+expand('<amatch>'))
autocmd WinClosed * call coc#notify#on_close(+expand('<amatch>')) autocmd WinClosed * call coc#notify#on_close(+expand('<amatch>'))
@ -425,6 +425,8 @@ function! s:Hi() abort
hi default link CocHintHighlight CocUnderline hi default link CocHintHighlight CocUnderline
hi default link CocDeprecatedHighlight CocStrikeThrough hi default link CocDeprecatedHighlight CocStrikeThrough
hi default link CocUnusedHighlight CocFadeOut hi default link CocUnusedHighlight CocFadeOut
hi default link CocListLine CursorLine
hi default link CocListSearch CocSearch
hi default link CocListMode ModeMsg hi default link CocListMode ModeMsg
hi default link CocListPath Comment hi default link CocListPath Comment
hi default link CocHighlightText CursorColumn hi default link CocHighlightText CursorColumn
@ -485,6 +487,9 @@ function! s:Hi() abort
if !exists('*sign_getdefined') || empty(sign_getdefined('CocCurrentLine')) if !exists('*sign_getdefined') || empty(sign_getdefined('CocCurrentLine'))
sign define CocCurrentLine linehl=CocMenuSel sign define CocCurrentLine linehl=CocMenuSel
endif endif
if !exists('*sign_getdefined') || empty(sign_getdefined('CocListCurrent'))
sign define CocListCurrent linehl=CocListLine
endif
if !exists('*sign_getdefined') || empty(sign_getdefined('CocTreeSelected')) if !exists('*sign_getdefined') || empty(sign_getdefined('CocTreeSelected'))
sign define CocTreeSelected linehl=CocTreeSelected sign define CocTreeSelected linehl=CocTreeSelected
endif endif

View File

@ -208,7 +208,7 @@ inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
" => Vim-autoformat " => Vim-autoformat
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:python3_host_prog="/usr/bin/python3" let g:python3_host_prog="/usr/bin/python3"
"autocmd BufWrite * :Autoformat autocmd BufWrite * :Autoformat
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Rainbow Parentheses " => Rainbow Parentheses