Skip to content

Commit

Permalink
vim: Move neovim version check and deprecation warning to init.lua (#36)
Browse files Browse the repository at this point in the history
init.lua would be a better place than vimrc because it's specific to
neovim. Also, allow users to suppress this startup deprecation warning
message by setting `DOTFILES_SUPPRESS_NEOVIM_VERSION_WARNING=1`.
  • Loading branch information
wookayin committed May 2, 2023
1 parent 32b6aa1 commit 2396d49
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
13 changes: 13 additions & 0 deletions nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ if vim.fn.has('nvim-0.7') == 0 then
echohl WarningMsg | echom 'This version of neovim is unsupported. Please upgrade to Neovim 0.7.0+ or higher.' | echohl None
]]
return

elseif vim.fn.has('nvim-0.8.0') == 0 then
vim.defer_fn(function()
local like_false = function(x) return x == nil or x == "0" or x == "" end
if not like_false(vim.env.DOTFILES_SUPPRESS_NEOVIM_VERSION_WARNING) then return end
local msg = 'Please upgrade to latest neovim (0.9.0+).\n'
msg = msg .. 'Support for neovim < 0.8 will be dropped soon.'
msg = msg .. '\n\n' .. string.format('Try: $ %s install neovim', vim.fn.has('mac') > 0 and 'brew' or 'dotfiles')
msg = msg .. '\n\n' .. ('If you cannot upgrade yet but want to suppress this warning,\n'
.. 'use `export DOTFILES_SUPPRESS_NEOVIM_VERSION_WARNING=1`.')
---@diagnostic disable-next-line: param-type-mismatch
vim.notify(msg, 'error', { title = 'Deprecation Warning', timeout = 5000 })
end, 100)
end

-- require a lua module, but force reload it (RC files can be re-sourced)
Expand Down
12 changes: 0 additions & 12 deletions vim/vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@ else " No timer support, this will run during VimEnter (before UI draws)
autocmd! VimEnter * call execute('doautocmd User LazyInit')
endif

" Check neovim version.
if has('nvim') && !has('nvim-0.8.0')
let s:warning_msg = 'Please upgrade to latest neovim (0.9.0+). Support for neovim < 0.8 will be dropped soon. '
let s:warning_msg .= printf('(Try: %s install neovim)', has('mac') ? 'brew' : 'dotfiles')
if exists('*luaeval')
autocmd VimEnter * call timer_start(100, { ->
\ luaeval("vim.notify(_A[1], _A[2], _A[3])", [s:warning_msg, 'error', {'title': 'Deprecation Warning'}])
\ })
else
autocmd VimEnter * echohl WarningMsg | echom s:warning_msg | echohl None
endif
endif

"""""""""""""""""""""""""""""""""""""""""
" 0. Load Plugin {{{
Expand Down

0 comments on commit 2396d49

Please sign in to comment.