From 09074a29315dfe1c1bd5081a43481bd9af97bd3c Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Thu, 3 Oct 2024 11:05:59 -0400 Subject: fix: malformed version message in older Nvim #3345 --- lua/lspconfig.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/lspconfig.lua b/lua/lspconfig.lua index eb5fa666..e1e6084d 100644 --- a/lua/lspconfig.lua +++ b/lua/lspconfig.lua @@ -48,6 +48,20 @@ M.server_aliases = function(name) return used_aliases end +-- Temporary port of Nvim 0.10 vim.version:tostring. +---@param version vim.Version +local function version_string(version) + assert(version.major and version.minor and version.patch, 'invalid vim.Version table') + local ret = table.concat({ version.major, version.minor, version.patch }, '.') + if version.prerelease then + ret = ret .. '-' .. version.prerelease + end + if version.build and version.build ~= vim.NIL then + ret = ret .. '+' .. version.build + end + return ret +end + local mt = {} function mt:__index(k) if configs[k] == nil then @@ -80,8 +94,8 @@ local minimum_neovim_version = '0.9' if vim.fn.has('nvim-' .. minimum_neovim_version) == 0 then local msg = string.format( 'nvim-lspconfig requires Nvim version %s, but you are running: %s', - vim.version.parse(minimum_neovim_version), - vim.version() + minimum_neovim_version, + vim.version and version_string(vim.version()) or 'older than v0.5.0' ) error(msg) end -- cgit v1.2.3-70-g09d2