1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

update version check

This commit is contained in:
jdhao 2022-08-14 22:54:19 +08:00
parent 2880d7bce3
commit a52a362b02
2 changed files with 10 additions and 19 deletions

View File

@ -8,11 +8,14 @@
-- Email: jdhao@hotmail.com -- Email: jdhao@hotmail.com
-- Blog: https://jdhao.github.io/ -- Blog: https://jdhao.github.io/
local utils = require "utils" -- check if we have the latest stable version of nvim
local match_res = utils.check_version_match() local expected_ver = "0.7.2"
if not match_res.match then local utils = require "utils"
local msg = string.format("Nvim version mistmatch: %s expected, but got %s instead!", match_res.expected, match_res.actual) local nvim_ver = utils.get_nvim_version()
if nvim_ver ~= expected_ver then
local msg = string.format("Unsupported nvim version: expect %s, but got %s instead!", expected_ver, nvim_ver)
vim.api.nvim_echo({ { msg, "ErrorMsg" } }, false, {}) vim.api.nvim_echo({ { msg, "ErrorMsg" } }, false, {})
return return
end end

View File

@ -25,23 +25,11 @@ function M.may_create_dir()
end end
end end
function M.check_version_match() function M.get_nvim_version()
-- check if we have the lastest stable version of nvim
local expected_ver = {major = 0, minor = 7, patch = 2}
local actual_ver = vim.version() local actual_ver = vim.version()
local ver_match = true local nvim_ver_str = string.format("%d.%d.%d", actual_ver.major, actual_ver.minor, actual_ver.patch)
for key, val in pairs(expected_ver) do return nvim_ver_str
if val ~= actual_ver[key] then
ver_match = false
break
end
end
local expect_ver_str = string.format("%s.%s.%s", expected_ver.major, expected_ver.minor, expected_ver.patch)
local nvim_ver_str = string.format("%s.%s.%s", actual_ver.major, actual_ver.minor, actual_ver.patch)
return {match=ver_match, expected=expect_ver_str, actual=nvim_ver_str}
end end
return M return M