From 8c971a97f831d1c9112a211002dcdb1b9b5c0440 Mon Sep 17 00:00:00 2001 From: Heyward Fann Date: Wed, 29 May 2024 11:21:29 +0800 Subject: [PATCH] feat!: increase minimum vim/nvim versions - vim 9.0.0438 - nvim 0.8.0 --- README.md | 2 +- autoload/coc.vim | 3 +- autoload/coc/client.vim | 25 +--- autoload/coc/compat.vim | 14 +- autoload/coc/dialog.vim | 20 +-- autoload/coc/float.vim | 55 ++----- autoload/coc/highlight.vim | 149 ++++--------------- autoload/coc/list.vim | 4 +- autoload/coc/prompt.vim | 4 +- autoload/coc/pum.vim | 32 ++-- autoload/coc/snippet.vim | 1 - autoload/coc/task.vim | 21 +-- autoload/coc/util.vim | 2 - autoload/coc/vtext.vim | 55 +++---- autoload/coc/window.vim | 8 +- autoload/health/coc.vim | 4 +- doc/coc-example-config.vim | 14 +- doc/coc.txt | 2 +- history.md | 6 + plugin/coc.vim | 28 +--- src/__tests__/handler/inlayHint.test.ts | 14 -- src/__tests__/handler/semanticTokens.test.ts | 6 - src/completion/index.ts | 2 +- src/handler/colors/colorBuffer.ts | 2 +- src/handler/inlayHint/index.ts | 1 - src/handler/semanticTokens/buffer.ts | 3 +- src/types.ts | 2 - 27 files changed, 115 insertions(+), 364 deletions(-) diff --git a/README.md b/README.md index 5d24b414c2e..a9e0539c72b 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ _Custom popup menu with snippet support_ ## Quick Start -Make sure use Vim >= 8.1.1719 or Neovim >= 0.4.0. +Make sure use Vim >= 9.0.0438 or Neovim >= 0.8.0. Install [nodejs](https://nodejs.org/en/download/) >= 16.18.0: diff --git a/autoload/coc.vim b/autoload/coc.vim index 56fcc0c3361..86a3c98d941 100644 --- a/autoload/coc.vim +++ b/autoload/coc.vim @@ -10,7 +10,6 @@ let s:error_sign = get(g:, 'coc_status_error_sign', has('mac') && s:utf ? "\u274 let s:warning_sign = get(g:, 'coc_status_warning_sign', has('mac') && s:utf ? "\u26a0\ufe0f " : 'W ') let s:select_api = exists('*nvim_select_popupmenu_item') let s:callbacks = {} -let s:hide_pum = has('nvim-0.6.1') || has('patch-8.2.3389') function! coc#expandable() abort return coc#rpc#request('snippetCheck', [1, 0]) @@ -42,7 +41,7 @@ function! coc#_insert_key(method, key, ...) abort if get(a:, 1, 1) if coc#pum#visible() let prefix = "\=coc#pum#close()\" - elseif pumvisible() && s:hide_pum + elseif pumvisible() let prefix = "\\" endif endif diff --git a/autoload/coc/client.vim b/autoload/coc/client.vim index f2763fbc1af..d7290025266 100644 --- a/autoload/coc/client.vim +++ b/autoload/coc/client.vim @@ -50,6 +50,7 @@ function! s:start() dict echohl MoreMsg | echo '[coc.nvim] channel log to '.file | echohl None endif let options = { + \ 'noblock': 1, \ 'in_mode': 'json', \ 'out_mode': 'json', \ 'err_mode': 'nl', @@ -61,9 +62,6 @@ function! s:start() dict \ 'TMPDIR': tmpdir, \ } \} - if has("patch-8.1.350") - let options['noblock'] = 1 - endif let job = job_start(self.command, options) let status = job_status(job) if status !=# 'run' @@ -74,32 +72,13 @@ function! s:start() dict let self['running'] = 1 let self['channel'] = job_getchannel(job) else - let original = {} let opts = { \ 'rpc': 1, \ 'on_stderr': {channel, msgs -> s:on_stderr(self.name, msgs)}, \ 'on_exit': {channel, code -> s:on_exit(self.name, code)}, + \ 'env': { 'NODE_NO_WARNINGS': '1', 'TMPDIR': tmpdir } \ } - if has('nvim-0.5.0') - " could use env option - let opts['env'] = { - \ 'NODE_NO_WARNINGS': '1', - \ 'TMPDIR': tmpdir - \ } - else - let original = { - \ 'NODE_NO_WARNINGS': getenv('NODE_NO_WARNINGS'), - \ 'TMPDIR': getenv('TMPDIR'), - \ } - call setenv('NODE_NO_WARNINGS', '1') - call setenv('TMPDIR', tmpdir) - endif let chan_id = jobstart(self.command, opts) - if !empty(original) - for key in keys(original) - call setenv(key, original[key]) - endfor - endif if chan_id <= 0 echohl Error | echom 'Failed to start '.self.name.' service' | echohl None return diff --git a/autoload/coc/compat.vim b/autoload/coc/compat.vim index 21bab01c784..0ef7eec5140 100644 --- a/autoload/coc/compat.vim +++ b/autoload/coc/compat.vim @@ -64,8 +64,6 @@ function! coc#compat#win_is_valid(winid) abort return !empty(getwininfo(a:winid)) endfunction -" clear matches by window id, not throw on none exists window. -" may not work on vim < 8.1.1084 & neovim < 0.4.0 function! coc#compat#clear_matches(winid) abort if !coc#compat#win_is_valid(a:winid) return @@ -76,9 +74,7 @@ function! coc#compat#clear_matches(winid) abort return endif if s:is_vim - if has('patch-8.1.1084') - call clearmatches(a:winid) - endif + call clearmatches(a:winid) else if exists('*nvim_set_current_win') noa call nvim_set_current_win(a:winid) @@ -93,13 +89,7 @@ function! coc#compat#matchaddpos(group, pos, priority, winid) abort if curr == a:winid call matchaddpos(a:group, a:pos, a:priority, -1) else - if s:is_vim - if has('patch-8.1.0218') - call matchaddpos(a:group, a:pos, a:priority, -1, {'window': a:winid}) - endif - else - call matchaddpos(a:group, a:pos, a:priority, -1, {'window': a:winid}) - endif + call matchaddpos(a:group, a:pos, a:priority, -1, {'window': a:winid}) endif endfunction diff --git a/autoload/coc/dialog.vim b/autoload/coc/dialog.vim index 4569311b362..6ba0dadd3e9 100644 --- a/autoload/coc/dialog.vim +++ b/autoload/coc/dialog.vim @@ -78,14 +78,6 @@ function! coc#dialog#create_cursor_float(winid, bufnr, lines, config) abort if index(modes, mode) == -1 return v:null endif - if !s:is_vim && !has('nvim-0.5.0') && mode ==# 'i' - " helps to fix undo issue, don't know why. - call feedkeys("\u", 'n') - endif - if mode ==# 's' && has('patch-8.2.4969') && !has('patch-8.2.4996') - echohl WarningMsg | echon 'Popup not created to avoid issue #10466 on vim >= 8.2.4969' | echohl None - return v:null - endif let dimension = coc#dialog#get_config_cursor(a:lines, a:config) if empty(dimension) return v:null @@ -114,9 +106,6 @@ endfunction " Use terminal buffer function! coc#dialog#_create_prompt_vim(title, default, opts) abort - if !has('patch-8.2.0750') - throw 'Input box not supported on vim < 8.2.0750' - endif execute 'hi link CocPopupTerminal '.get(a:opts, 'highlight', 'CocFloating') let node = expand(get(g:, 'coc_node_path', 'node')) let placeHolder = get(a:opts, 'placeHolder', '') @@ -174,7 +163,7 @@ function! coc#dialog#_create_prompt_nvim(title, default, opts) abort call feedkeys("\A", 'int') endif let placeHolder = get(a:opts, 'placeHolder', '') - if empty(a:default) && !empty(placeHolder) && has('nvim-0.5.0') + if empty(a:default) && !empty(placeHolder) let src_id = coc#highlight#create_namespace('input-box') call nvim_buf_set_extmark(bufnr, src_id, 0, 0, { \ 'virt_text': [[placeHolder, 'CocInputBoxVirtualText']], @@ -182,9 +171,6 @@ function! coc#dialog#_create_prompt_nvim(title, default, opts) abort \ }) endif call coc#util#do_autocmd('CocOpenFloatPrompt') - if !has('nvim-0.6.0') - redraw - endif let id = coc#float#get_related(winid, 'border') let pos = nvim_win_get_position(id) let dimension = [nvim_win_get_width(id), nvim_win_get_height(id), pos[0], pos[1]] @@ -575,10 +561,8 @@ function! coc#dialog#change_loading(winid, loading) abort \ 'width': 3, \ 'height': 1, \ 'style': 'minimal', + \ 'zindex': 900, \ } - if has('nvim-0.5.1') - let opts['zindex'] = 900 - endif let winid = nvim_open_win(bufnr, v:false, opts) call setwinvar(winid, '&winhl', getwinvar(a:winid, '&winhl')) endif diff --git a/autoload/coc/float.vim b/autoload/coc/float.vim index 5d8b2bee5db..83687ea13c3 100644 --- a/autoload/coc/float.vim +++ b/autoload/coc/float.vim @@ -277,7 +277,7 @@ function! coc#float#nvim_border_win(config, borderchars, winid, border, title, h if has_key(a:config, 'zindex') let opt['zindex'] = a:config['zindex'] endif - if has('nvim-0.5.0') && a:shadow && !a:hasbtn && a:border[2] + if a:shadow && !a:hasbtn && a:border[2] let opt['border'] = 'shadow' endif if winid @@ -332,16 +332,13 @@ function! coc#float#nvim_right_pad(config, winid, shadow, related) abort if has_key(a:config, 'zindex') let config['zindex'] = a:config['zindex'] + 1 endif - if has('nvim-0.5.0') && a:shadow + if a:shadow let config['border'] = 'shadow' endif if winid && nvim_win_is_valid(winid) - if has('nvim-0.5.0') - call nvim_win_set_config(winid, coc#dict#pick(config, ['relative', 'row', 'col'])) - call nvim_win_set_height(winid, config['height']) - return - endif - noa call nvim_win_close(winid, 1) + call nvim_win_set_config(winid, coc#dict#pick(config, ['relative', 'row', 'col'])) + call nvim_win_set_height(winid, config['height']) + return endif let s:pad_bufnr = bufloaded(s:pad_bufnr) ? s:pad_bufnr : coc#float#create_buf(0, repeat([''], &lines), 'hide') noa let winid = nvim_open_win(s:pad_bufnr, 0, config) @@ -360,12 +357,10 @@ function! coc#float#nvim_buttons(config, winid, buttons, getchar, borderbottom, \ 'relative': a:config['relative'], \ 'focusable': 1, \ 'style': 'minimal', + \ 'zindex': 300, \ } - if has('nvim-0.5.1') - let config['zindex'] = 300 - if a:shadow - let config['border'] = 'shadow' - endif + if a:shadow + let config['border'] = 'shadow' endif if winid let bufnr = winbufnr(winid) @@ -485,7 +480,7 @@ function! coc#float#nvim_scrollbar(winid) abort if has_key(config, 'zindex') let opts['zindex'] = config['zindex'] + 2 endif - if has('nvim-0.5.0') && s:has_shadow(config) + if s:has_shadow(config) let opts['border'] = 'shadow' endif if id @@ -768,9 +763,6 @@ endfunction " Show float window/popup for user confirm. " Create buttons popup on vim function! coc#float#vim_buttons(winid, config) abort - if !has('patch-8.2.0750') - return - endif let related = getwinvar(a:winid, 'related', []) let winid = coc#float#get_related(a:winid, 'buttons') let btns = get(a:config, 'buttons', []) @@ -1061,14 +1053,12 @@ function! s:convert_config_nvim(config, create) abort else let result['width'] = float2nr(result['width'] + (get(a:config, 'nopad', 0) ? 0 : 1)) endif - if has('nvim-0.5.0') && get(a:config, 'shadow', 0) && a:create + if get(a:config, 'shadow', 0) && a:create if empty(get(a:config, 'buttons', v:null)) && empty(get(border, 2, 0)) let result['border'] = 'shadow' endif endif - if has('nvim-0.5.1') - let result['zindex'] = get(a:config, 'zindex', 50) - endif + let result['zindex'] = get(a:config, 'zindex', 50) let result['height'] = float2nr(result['height']) return result endfunction @@ -1341,7 +1331,7 @@ function! s:set_float_defaults(winid, config) abort if exists('&statuscolumn') call setwinvar(a:winid, '&statuscolumn', '') endif - if !s:is_vim || !has("patch-8.2.3100") + if has('nvim') call setwinvar(a:winid, '&number', 0) call setwinvar(a:winid, '&relativenumber', 0) call setwinvar(a:winid, '&cursorline', 0) @@ -1353,15 +1343,9 @@ function! s:set_float_defaults(winid, config) abort call setwinvar(a:winid, '&conceallevel', 0) call setwinvar(a:winid, '&list', 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 + call setwinvar(a:winid, '&scrolloff', 0) + call setwinvar(a:winid, '&showbreak', 'NONE') + call win_execute(a:winid, 'setl fillchars+=eob:\ ') if get(a:config, 'autohide', 0) call setwinvar(a:winid, 'autohide', 1) endif @@ -1372,15 +1356,6 @@ function! s:nvim_add_related(winid, target, kind, winhl, related) abort if a:winid <= 0 return endif - " minimal not work - if !has('nvim-0.4.3') - call setwinvar(a:winid, '&colorcolumn', '') - call setwinvar(a:winid, '&number', 0) - call setwinvar(a:winid, '&relativenumber', 0) - call setwinvar(a:winid, '&foldcolumn', 0) - call setwinvar(a:winid, '&signcolumn', 0) - call setwinvar(a:winid, '&list', 0) - endif if exists('&statuscolumn') call setwinvar(a:winid, '&statuscolumn', '') endif diff --git a/autoload/coc/highlight.vim b/autoload/coc/highlight.vim index ab0c91bef1f..948eb29cf90 100644 --- a/autoload/coc/highlight.vim +++ b/autoload/coc/highlight.vim @@ -1,8 +1,5 @@ scriptencoding utf-8 let s:is_vim = !has('nvim') -let s:nvim_50 = has('nvim-0.5.0') -let s:nvim_60 = has('nvim-0.6.0') -let s:clear_match_by_window = s:nvim_60 || s:is_vim let s:set_extmark = has('nvim') && exists('*nvim_buf_set_extmark') let s:namespace_map = {} let s:ns_id = 1 @@ -11,15 +8,6 @@ let s:diagnostic_hlgroups = ['CocErrorHighlight', 'CocWarningHighlight', 'CocInf let g:coc_highlight_maximum_count = get(g:, 'coc_highlight_maximum_count', 200) let s:term = &termguicolors == 0 && !has('gui_running') -if has('nvim-0.5.0') && s:clear_match_by_window == 0 - try - call getmatches(0) - let s:clear_match_by_window = 1 - catch /^Vim\%((\a\+)\)\=:E118/ - " ignored - endtry -endif - " Update buffer region by region. function! coc#highlight#buffer_update(bufnr, key, highlights, ...) abort if !bufloaded(a:bufnr) @@ -69,7 +57,7 @@ function! coc#highlight#update_highlights(bufnr, key, highlights, ...) abort " index list that exists with current highlights let exists = [] let ns = coc#highlight#create_namespace(a:key) - if has('nvim-0.5.0') || exists('*prop_list') + if has('nvim') || exists('*prop_list') let endLnum = end < 0 ? linecount - 1 : end - 1 let firstLnum = a:highlights[0]['lnum'] if firstLnum > start @@ -153,54 +141,28 @@ function! coc#highlight#get_highlights(bufnr, key, ...) abort endif let start = get(a:, 1, 0) let end = get(a:, 2, -1) - if s:nvim_60 + if has('nvim') return v:lua.require('coc.highlight').getHighlights(a:bufnr, a:key, start, end) - elseif s:nvim_50 - return luaeval( - \ 'require("coc.highlight").getHighlights(_A[1],_A[2],_A[3],_A[4])', - \ [a:bufnr, a:key, start, end] - \ ) endif + let res = [] let ns = s:namespace_map[a:key] - if exists('*prop_list') - 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') - let endLnum = end == -1 ? -1 : end + 1 - for prop in prop_list(start + 1, {'bufnr': a:bufnr, 'types': types, 'end_lnum': endLnum}) - if prop['start'] == 0 || prop['end'] == 0 - " multi line textprop are not supported, simply ignore it - continue - endif - let startCol = prop['col'] - 1 - let endCol = startCol + prop['length'] - call add(res, [s:prop_type_hlgroup(prop['type']), prop['lnum'] - 1, startCol, endCol, prop['id']]) - endfor - else - if end == -1 - let end = coc#compat#buf_line_count(a:bufnr) - else - let end = end + 1 - endif - for line in range(start + 1, end) - for prop in prop_list(line, {'bufnr': a:bufnr}) - if index(types, prop['type']) == -1 || prop['start'] == 0 || prop['end'] == 0 - " multi line textprop are not supported, simply ignore it - continue - endif - let startCol = prop['col'] - 1 - let endCol = startCol + prop['length'] - call add(res, [s:prop_type_hlgroup(prop['type']), line - 1, startCol, endCol, prop['id']]) - endfor - endfor - endif - else - throw 'Get highlights requires neovim 0.5.0 or vim support prop_list' + let types = coc#api#get_types(ns) + if empty(types) + return res endif + + let endLnum = end == -1 ? -1 : end + 1 + for prop in prop_list(start + 1, {'bufnr': a:bufnr, 'types': types, 'end_lnum': endLnum}) + if prop['start'] == 0 || prop['end'] == 0 + " multi line textprop are not supported, simply ignore it + continue + endif + let startCol = prop['col'] - 1 + let endCol = startCol + prop['length'] + call add(res, [s:prop_type_hlgroup(prop['type']), prop['lnum'] - 1, startCol, endCol, prop['id']]) + endfor + return res endfunction @@ -212,13 +174,8 @@ function! coc#highlight#set(bufnr, key, highlights, priority) abort endif let ns = coc#highlight#create_namespace(a:key) let g:c = 1 - if s:nvim_60 + if has('nvim') call v:lua.require('coc.highlight').set(a:bufnr, ns, a:highlights, a:priority) - elseif s:nvim_50 - call luaeval( - \ 'require("coc.highlight").set(_A[1],_A[2],_A[3],_A[4])', - \ [a:bufnr, ns, a:highlights, a:priority] - \ ) else if len(a:highlights) > g:coc_highlight_maximum_count call s:add_highlights_timer(a:bufnr, ns, a:highlights, a:priority) @@ -560,10 +517,6 @@ function! coc#highlight#match_ranges(winid, bufnr, ranges, hlGroup, priority) ab " not valid return [] endif - if !s:clear_match_by_window - let curr = win_getid() - noa call win_gotoid(winid) - endif let ids = [] for range in a:ranges let pos = [] @@ -583,7 +536,7 @@ function! coc#highlight#match_ranges(winid, bufnr, ranges, hlGroup, priority) ab call add(pos, [lnum, colStart, colEnd - colStart]) endfor if !empty(pos) - let opts = s:clear_match_by_window ? {'window': a:winid} : {} + let opts = {'window': a:winid} let i = 1 let l = [] for p in pos @@ -601,9 +554,6 @@ function! coc#highlight#match_ranges(winid, bufnr, ranges, hlGroup, priority) ab endif endif endfor - if !s:clear_match_by_window - noa call win_gotoid(curr) - endif return ids endfunction @@ -614,27 +564,10 @@ function! coc#highlight#clear_match_group(winid, match) abort " not valid return endif - if s:clear_match_by_window - let arr = filter(getmatches(winid), 'v:val["group"] =~# "'.a:match.'"') - for item in arr - call matchdelete(item['id'], winid) - endfor - else - let curr = win_getid() - let switch = exists('*nvim_set_current_win') && curr != winid - if switch - noa call nvim_set_current_win(a:winid) - endif - if win_getid() == winid - let arr = filter(getmatches(), 'v:val["group"] =~# "'.a:match.'"') - for item in arr - call matchdelete(item['id']) - endfor - endif - if switch - noa call nvim_set_current_win(curr) - endif - endif + let arr = filter(getmatches(winid), 'v:val["group"] =~# "'.a:match.'"') + for item in arr + call matchdelete(item['id'], winid) + endfor endfunction " Clear matches by match ids, use 0 for current win. @@ -644,33 +577,13 @@ function! coc#highlight#clear_matches(winid, ids) " not valid return endif - if s:clear_match_by_window - for id in a:ids - try - call matchdelete(id, winid) - catch /^Vim\%((\a\+)\)\=:E803/ - " ignore - endtry - endfor - else - let curr = win_getid() - let switch = exists('*nvim_set_current_win') && curr != winid - if switch - noa call nvim_set_current_win(a:winid) - endif - if win_getid() == winid - for id in a:ids - try - call matchdelete(id) - catch /^Vim\%((\a\+)\)\=:E803/ - " ignore - endtry - endfor - endif - if switch - noa call nvim_set_current_win(curr) - endif - endif + for id in a:ids + try + call matchdelete(id, winid) + catch /^Vim\%((\a\+)\)\=:E803/ + " ignore + endtry + endfor endfunction function! coc#highlight#clear_all() abort diff --git a/autoload/coc/list.vim b/autoload/coc/list.vim index e13de701ffe..256de08a7e5 100644 --- a/autoload/coc/list.vim +++ b/autoload/coc/list.vim @@ -108,9 +108,7 @@ function! coc#list#setup(source) setl cursorline setl winhighlight=CursorLine:CocListLine endif - if has('nvim-0.5.0') || has('patch-8.1.0864') - setl scrolloff=0 - endif + setl scrolloff=0 setl filetype=list syntax case ignore let source = a:source[8:] diff --git a/autoload/coc/prompt.vim b/autoload/coc/prompt.vim index f2a7304527c..d743da739bf 100644 --- a/autoload/coc/prompt.vim +++ b/autoload/coc/prompt.vim @@ -139,7 +139,7 @@ function! s:start_prompt() if s:activated | return | endif if !get(g:, 'coc_disable_transparent_cursor', 0) if s:gui - if has('nvim-0.5.0') && !empty(s:saved_cursor) + if has('nvim') && !empty(s:saved_cursor) set guicursor+=a:ver1-CocCursorTransparent/lCursor endif elseif s:is_vim @@ -195,7 +195,7 @@ function! s:reset() abort if !get(g:, 'coc_disable_transparent_cursor',0) " neovim has bug with revert empty &guicursor if s:gui && !empty(s:saved_cursor) - if has('nvim-0.5.0') + if has('nvim') set guicursor+=a:ver1-Cursor/lCursor let &guicursor = s:saved_cursor endif diff --git a/autoload/coc/pum.vim b/autoload/coc/pum.vim index be0e052edb5..008cdceec2d 100644 --- a/autoload/coc/pum.vim +++ b/autoload/coc/pum.vim @@ -8,9 +8,6 @@ let s:pum_size = 0 let s:inserted = 0 let s:virtual_text = 0 let s:virtual_text_ns = coc#highlight#create_namespace('pum-virtual') -let s:ignore = s:is_vim || has('nvim-0.5.0') ? "\" : "\\" -let s:hide_pum = has('nvim-0.6.1') || has('patch-8.2.3389') -let s:virtual_text_support = has('nvim-0.5.0') || has('patch-9.0.0067') " bufnr, &indentkeys let s:saved_indenetkeys = [] let s:saved_textwidth = [] @@ -19,7 +16,7 @@ let s:reversed = 0 let s:check_hl_group = 0 let s:start_col = -1 -if s:is_vim && s:virtual_text_support +if s:is_vim if empty(prop_type_get('CocPumVirtualText')) call prop_type_add('CocPumVirtualText', {'highlight': 'CocPumVirtualText'}) endif @@ -214,7 +211,7 @@ function! coc#pum#scroll(forward) abort endif endif " Required on old version vim/neovim. - return s:ignore + return "\" endfunction function! s:get_height(winid) abort @@ -316,25 +313,20 @@ function! s:insert_word(word, finish) abort endif " should not be used on finish to have correct line. if s:is_vim && !a:finish - call coc#pum#repalce(s:start_col + 1, a:word, 1) + call coc#pum#replace(s:start_col + 1, a:word, 1) else let saved_completeopt = &completeopt noa set completeopt=menu noa call complete(s:start_col + 1, [{ 'empty': v:true, 'word': a:word }]) " exit complete state - if s:hide_pum - call feedkeys("\\", 'in') - else - let g:coc_disable_space_report = 1 - call feedkeys("\\", 'in') - endif + call feedkeys("\\", 'in') execute 'noa set completeopt='.saved_completeopt endif endif endfunction " Replace from col to cursor col with new characters -function! coc#pum#repalce(col, insert, ...) abort +function! coc#pum#replace(col, insert, ...) abort let insert = a:insert let curr = getline('.') let removed = strpart(curr, a:col - 1, col('.') - a:col) @@ -379,7 +371,7 @@ function! coc#pum#create(lines, opt, config) abort return endif let s:reversed = get(a:config, 'reverse', 0) && config['row'] < 0 - let s:virtual_text = s:virtual_text_support && a:opt['virtualText'] + let s:virtual_text = a:opt['virtualText'] let s:pum_size = len(a:lines) let s:pum_index = a:opt['index'] let lnum = s:index_to_lnum(s:pum_index) @@ -593,14 +585,12 @@ function! s:insert_virtual_text() abort endfunction function! s:clear_virtual_text() abort - if s:virtual_text_support - if s:is_vim - if s:prop_id != 0 - call prop_remove({'id': s:prop_id}) - endif - else - call nvim_buf_clear_namespace(bufnr('%'), s:virtual_text_ns, 0, -1) + if s:is_vim + if s:prop_id != 0 + call prop_remove({'id': s:prop_id}) endif + else + call nvim_buf_clear_namespace(bufnr('%'), s:virtual_text_ns, 0, -1) endif endfunction diff --git a/autoload/coc/snippet.vim b/autoload/coc/snippet.vim index d9375b21899..4f972b0dfe0 100644 --- a/autoload/coc/snippet.vim +++ b/autoload/coc/snippet.vim @@ -2,7 +2,6 @@ scriptencoding utf-8 let s:is_vim = !has('nvim') let s:map_next = 1 let s:map_prev = 1 -let s:cmd_mapping = has('nvim') || has('patch-8.2.1978') function! coc#snippet#_select_mappings() if !get(g:, 'coc_selectmode_mapping', 1) diff --git a/autoload/coc/task.vim b/autoload/coc/task.vim index 80ff02fea60..527534c8bc3 100644 --- a/autoload/coc/task.vim +++ b/autoload/coc/task.vim @@ -24,6 +24,7 @@ function! coc#task#start(id, opts) if s:is_vim let options = { \ 'cwd': cwd, + \ 'noblock' : 1, \ 'err_mode': 'nl', \ 'out_mode': 'nl', \ 'err_cb': {channel, message -> s:on_stderr(a:id, [message])}, @@ -31,9 +32,6 @@ function! coc#task#start(id, opts) \ 'exit_cb': {channel, code -> s:on_exit(a:id, code)}, \ 'env': env, \} - if has("patch-8.1.350") - let options['noblock'] = 1 - endif if get(a:opts, 'pty', 0) let options['pty'] = 1 endif @@ -51,27 +49,12 @@ function! coc#task#start(id, opts) \ 'on_stdout': {channel, msgs -> s:on_stdout(a:id, msgs)}, \ 'on_exit': {channel, code -> s:on_exit(a:id, code)}, \ 'detach': get(a:opts, 'detach', 0), + \ 'env': env, \} - let original = {} - if !empty(env) - if has('nvim-0.5.0') - let options['env'] = env - elseif exists('*setenv') && exists('*getenv') - for key in keys(env) - let original[key] = getenv(key) - call setenv(key, env[key]) - endfor - endif - endif if get(a:opts, 'pty', 0) let options['pty'] = 1 endif let chan_id = jobstart(cmd, options) - if !empty(original) - for key in keys(original) - call setenv(key, original[key]) - endfor - endif if chan_id <= 0 echohl Error | echom 'Failed to start '.a:id.' task' | echohl None return v:false diff --git a/autoload/coc/util.vim b/autoload/coc/util.vim index 0ebeeaa5f39..9aac9db48d0 100644 --- a/autoload/coc/util.vim +++ b/autoload/coc/util.vim @@ -286,12 +286,10 @@ function! coc#util#vim_info() \ 'guicursor': &guicursor, \ 'pumwidth': exists('&pumwidth') ? &pumwidth : 15, \ 'tabCount': tabpagenr('$'), - \ 'updateHighlight': has('nvim-0.5.0') || has('textprop') ? 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') ? v:true : v:false, - \ 'virtualText': has('nvim-0.5.0') || has('patch-9.0.0067') ? v:true : v:false, \ 'dialog': 1, \ 'semanticHighlights': coc#util#semantic_hlgroups() \} diff --git a/autoload/coc/vtext.vim b/autoload/coc/vtext.vim index 1bf0af92c4b..ddc54e3041c 100644 --- a/autoload/coc/vtext.vim +++ b/autoload/coc/vtext.vim @@ -1,7 +1,4 @@ let s:is_vim = !has('nvim') -let s:virtual_text_support = has('nvim-0.5.0') || has('patch-9.0.0067') -let s:text_options = has('patch-9.0.0121') || has('nvim-0.6.0') -let s:vim_above = has('patch-9.0.0438') let s:n10 = has('nvim-0.10.0') " This function is called by buffer.setVirtualText @@ -12,9 +9,6 @@ let s:n10 = has('nvim-0.10.0') " opts.text_wrap could be 'wrap' and 'truncate', vim9 only. " opts.indent add indent when using 'above' and 'below' as text_align function! coc#vtext#add(bufnr, src_id, line, blocks, opts) abort - if !s:virtual_text_support - return - endif let align = get(a:opts, 'text_align', 'after') let column = get(a:opts, 'col', 0) let indent = '' @@ -47,34 +41,27 @@ function! coc#vtext#add(bufnr, src_id, line, blocks, opts) abort endfor else let opts = { 'hl_mode': get(a:opts, 'hl_mode', 'combine') } - if s:text_options - if align ==# 'above' || align ==# 'below' - let blocks = empty(indent) ? a:blocks : [[indent, 'Normal']] + a:blocks - let opts['virt_lines'] = [blocks] - if align ==# 'above' - let opts['virt_lines_above'] = v:true - endif + if align ==# 'above' || align ==# 'below' + let blocks = empty(indent) ? a:blocks : [[indent, 'Normal']] + a:blocks + let opts['virt_lines'] = [blocks] + if align ==# 'above' + let opts['virt_lines_above'] = v:true + endif + else + let opts['virt_text'] = a:blocks + if s:n10 && column != 0 + let opts['virt_text_pos'] = 'inline' + elseif align ==# 'right' + let opts['virt_text_pos'] = 'right_align' else - let opts['virt_text'] = a:blocks - if s:n10 && column != 0 - let opts['virt_text_pos'] = 'inline' - elseif align ==# 'right' - let opts['virt_text_pos'] = 'right_align' + if type(get(a:opts, 'virt_text_win_col', v:null)) == 0 + let opts['virt_text_win_col'] = a:opts['virt_text_win_col'] + let opts['virt_text_pos'] = 'overlay' else - if type(get(a:opts, 'virt_text_win_col', v:null)) == 0 - let opts['virt_text_win_col'] = a:opts['virt_text_win_col'] - let opts['virt_text_pos'] = 'overlay' - else - " default to 'after' - let opts['virt_text_pos'] = 'eol' - endif + " default to 'after' + let opts['virt_text_pos'] = 'eol' endif endif - else - if has('nvim-0.5.1') && type(get(a:opts, 'virt_text_win_col', v:null)) == 0 - let opts['virt_text_win_col'] = a:opts['virt_text_win_col'] - let opts['virt_text_pos'] = 'overlay' - endif endif let col = s:n10 ? column - 1 : 0 call nvim_buf_set_extmark(a:bufnr, a:src_id, a:line, col, opts) @@ -83,12 +70,8 @@ endfunction function! s:get_option_vim(align, column, wrap) abort let opts = {} - if s:text_options && a:column == 0 - if a:align ==# 'top' && !s:vim_above - let opts['text_align'] = 'right' - else - let opts['text_align'] = a:align - endif + if a:column == 0 + let opts['text_align'] = a:align let opts['text_wrap'] = a:wrap endif return opts diff --git a/autoload/coc/window.vim b/autoload/coc/window.vim index 72879ca0587..0c0e4325f87 100644 --- a/autoload/coc/window.vim +++ b/autoload/coc/window.vim @@ -18,11 +18,9 @@ function! coc#window#get_cursor(winid) abort if exists('*nvim_win_get_cursor') return nvim_win_get_cursor(a:winid) endif - if has('patch-8.2.1727') - let pos = getcurpos(a:winid) - return [pos[1], pos[2] - 1] - endif - return coc#api#exec('win_get_cursor', [a:winid]) + + let pos = getcurpos(a:winid) + return [pos[1], pos[2] - 1] endfunction " Check if winid visible on current tabpage diff --git a/autoload/health/coc.vim b/autoload/health/coc.vim index f62dd512676..13d4586621b 100644 --- a/autoload/health/coc.vim +++ b/autoload/health/coc.vim @@ -40,8 +40,8 @@ endfunction function! s:checkEnvironment() abort let valid - \ = s:checkVim(has('nvim'), 'nvim', 'nvim-0.4.0') - \ + s:checkVim(!has('nvim'), 'vim', 'patch-8.1.1719') + \ = s:checkVim(has('nvim'), 'nvim', 'nvim-0.8.0') + \ + s:checkVim(!has('nvim'), 'vim', 'patch-9.0.0438') let node = get(g:, 'coc_node_path', $COC_NODE_PATH == '' ? 'node' : $COC_NODE_PATH) if !executable(node) let valid = 0 diff --git a/doc/coc-example-config.vim b/doc/coc-example-config.vim index 6d08727a336..eeb76c847f5 100644 --- a/doc/coc-example-config.vim +++ b/doc/coc-example-config.vim @@ -115,14 +115,12 @@ xmap ac (coc-classobj-a) omap ac (coc-classobj-a) " Remap and to scroll float windows/popups -if has('nvim-0.4.0') || has('patch-8.2.0750') - nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" - nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" - inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" - inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" - vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" - vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" -endif +nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" +nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" +inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" +inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" +vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" +vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" " Use CTRL-S for selections ranges " Requires 'textDocument/selectionRange' support of language server diff --git a/doc/coc.txt b/doc/coc.txt index 60d10d1d02c..662e2c7433d 100644 --- a/doc/coc.txt +++ b/doc/coc.txt @@ -1361,7 +1361,7 @@ Selection range function:~ CODE LENS *coc-code-lens* Code lens feature shows additional information above or after specific lines. -Works best on nvim >= 0.6.0 and vim >= 9.0.0438. On older vim, some +Works best on nvim >= 0.8.0 and vim >= 9.0.0438. On older vim, some configurations may not work. CodeLens are not shown by default, use |coc-config-codeLens-enable| to enable, diff --git a/history.md b/history.md index 23443f98363..bc7e193f44b 100644 --- a/history.md +++ b/history.md @@ -1,3 +1,9 @@ +# 2024-05-29 + +- Break change: increase minimum vim/nvim version requirement + - vim 9.0.0438 + - nvim 0.8.0 + # 2024-05-14 - Added `suggest.reTriggerAfterIndent` to control re-trigger or not after indent changes diff --git a/plugin/coc.vim b/plugin/coc.vim index 06496ca9ef5..59266b78c6b 100644 --- a/plugin/coc.vim +++ b/plugin/coc.vim @@ -7,39 +7,21 @@ 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.4.0') + let l:unsupported = !has('nvim-0.8.0') else - let l:unsupported = !has('patch-8.1.1719') + let l:unsupported = !has('patch-9.0.0438') endif if l:unsupported == 1 echohl Error - echom "coc.nvim requires at least Vim 8.1.1719 or Neovim 0.4.0, but you're using an older version." + echom "coc.nvim requires at least Vim 9.0.0438 or Neovim 0.8.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.1.1719 or Neovim 0.4.0." + echom "Please do not report bugs unless you're using at least Vim 9.0.0438 or Neovim 0.8.0." echohl None sleep 2 - else - if !has('nvim-0.5.0') && !has('patch-8.2.0750') - echohl WarningMsg - echom "coc.nvim works best on vim >= 8.2.0750 and neovim >= 0.5.0, consider upgrading 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." - echohl None - sleep 2 - elseif !has('nvim') && (!has('job') || !has('popupwin') || !has('textprop')) - echohl WarningMsg - echom "coc.nvim requires job, popupwin and textprop features of vim, consider recompile 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." - echohl None - sleep 2 - endif endif endif endfunction @@ -521,7 +503,7 @@ function! s:Highlight() abort hi default link CocListLine CursorLine endif - if has('nvim-0.5.0') + if has('nvim') hi default CocCursorTransparent gui=strikethrough blend=100 endif diff --git a/src/__tests__/handler/inlayHint.test.ts b/src/__tests__/handler/inlayHint.test.ts index 24c7b9227fc..846392c2b17 100644 --- a/src/__tests__/handler/inlayHint.test.ts +++ b/src/__tests__/handler/inlayHint.test.ts @@ -175,20 +175,6 @@ describe('InlayHint', () => { }) describe('env & options', () => { - it('should not create when virtualText not supported', async () => { - Object.assign(workspace.env, { - virtualText: false - }) - disposables.push(Disposable.create(() => { - Object.assign(workspace.env, { - virtualText: true - }) - })) - let doc = await helper.createDocument() - let item = handler.getItem(doc.bufnr) - expect(item).toBeUndefined() - }) - it('should not enabled when disabled by configuration', async () => { helper.updateConfiguration('inlayHint.filetypes', []) let doc = await workspace.document diff --git a/src/__tests__/handler/semanticTokens.test.ts b/src/__tests__/handler/semanticTokens.test.ts index d80f98404eb..e888ab6ed6a 100644 --- a/src/__tests__/handler/semanticTokens.test.ts +++ b/src/__tests__/handler/semanticTokens.test.ts @@ -750,15 +750,9 @@ describe('semanticTokens', () => { item.checkState() }) toThrow(() => { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - workspace._env.updateHighlight = false item.checkState() }) let enabled = item.enabled - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - workspace._env.updateHighlight = true expect(enabled).toBe(false) expect(() => { item.checkState() diff --git a/src/completion/index.ts b/src/completion/index.ts index f4d6b9df554..00d91f03339 100644 --- a/src/completion/index.ts +++ b/src/completion/index.ts @@ -289,7 +289,7 @@ export class Completion implements Disposable { logger.debug('commit by commit character.') let startcol = byteIndex(this.option.line, resolvedItem.character) + 1 this.stop(true) - this.nvim.call('coc#pum#repalce', [startcol, resolvedItem.word + info.insertChar], true) + this.nvim.call('coc#pum#replace', [startcol, resolvedItem.word + info.insertChar], true) return } } diff --git a/src/handler/colors/colorBuffer.ts b/src/handler/colors/colorBuffer.ts index a5a7099838f..b0a5c47979f 100644 --- a/src/handler/colors/colorBuffer.ts +++ b/src/handler/colors/colorBuffer.ts @@ -79,7 +79,7 @@ export default class ColorBuffer implements SyncItem { public get enabled(): boolean { let { filetypes } = this.config let { filetype } = this.doc - if (!workspace.env.updateHighlight || !this.hasProvider) return false + if (!this.hasProvider) return false if (Array.isArray(filetypes) && (filetypes.includes('*') || filetypes.includes(filetype))) return true return this.enable } diff --git a/src/handler/inlayHint/index.ts b/src/handler/inlayHint/index.ts index ca4bf108493..1922d779c9d 100644 --- a/src/handler/inlayHint/index.ts +++ b/src/handler/inlayHint/index.ts @@ -16,7 +16,6 @@ export default class InlayHintHandler { private disposables: Disposable[] = [] constructor(nvim: Neovim, handler: HandlerDelegate) { this.buffers = workspace.registerBufferSync(doc => { - if (!workspace.env.virtualText) return return new InlayHintBuffer(nvim, doc) }) this.disposables.push(this.buffers) diff --git a/src/handler/semanticTokens/buffer.ts b/src/handler/semanticTokens/buffer.ts index d53066a683c..87a63abcfb8 100644 --- a/src/handler/semanticTokens/buffer.ts +++ b/src/handler/semanticTokens/buffer.ts @@ -181,12 +181,11 @@ export default class SemanticTokensBuffer implements SyncItem { } public get enabled(): boolean { - if (!this.configEnabled || !workspace.env.updateHighlight || !this.hasLegend) return false + if (!this.configEnabled || !this.hasLegend) return false return this.hasProvider } public checkState(): void { - if (!workspace.env.updateHighlight) throw new Error(`Can't perform highlight update, highlight update requires vim >= 8.1.1719 or neovim >= 0.5.0`) if (!this.configEnabled) throw new Error(`Semantic tokens highlight not enabled for current filetype: ${this.doc.filetype}`) if (!this.hasProvider || !this.hasLegend) throw new Error(`SemanticTokens provider not found for ${this.doc.uri}`) } diff --git a/src/types.ts b/src/types.ts index 67b13cdae1c..42df099ff3c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -142,7 +142,6 @@ export interface HighlightItem extends HighlightItemOption { export interface Env { runtimepath: string - readonly virtualText: boolean readonly guicursor: string readonly tabCount: number readonly mode: string @@ -169,7 +168,6 @@ export interface Env { readonly progpath: string readonly dialog: boolean readonly textprop: boolean - readonly updateHighlight: boolean readonly vimCommands: CommandConfig[] readonly semanticHighlights: string[] }