Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: increase minimum vim/nvim versions #5026

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
3 changes: 1 addition & 2 deletions autoload/coc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -42,7 +41,7 @@ function! coc#_insert_key(method, key, ...) abort
if get(a:, 1, 1)
if coc#pum#visible()
let prefix = "\<C-r>=coc#pum#close()\<CR>"
elseif pumvisible() && s:hide_pum
elseif pumvisible()
let prefix = "\<C-x>\<C-z>"
endif
endif
Expand Down
25 changes: 2 additions & 23 deletions autoload/coc/client.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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'
Expand All @@ -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
Expand Down
14 changes: 2 additions & 12 deletions autoload/coc/compat.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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

Expand Down
20 changes: 2 additions & 18 deletions autoload/coc/dialog.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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("\<C-g>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
Expand Down Expand Up @@ -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', '')
Expand Down Expand Up @@ -174,17 +163,14 @@ function! coc#dialog#_create_prompt_nvim(title, default, opts) abort
call feedkeys("\<esc>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']],
\ 'virt_text_pos': 'overlay',
\ })
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]]
Expand Down Expand Up @@ -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
Expand Down
55 changes: 15 additions & 40 deletions autoload/coc/float.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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', [])
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading