diff options
| author | Micah Halter <micah@mehalter.com> | 2024-10-03 11:05:59 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-03 08:05:59 -0700 |
| commit | 09074a29315dfe1c1bd5081a43481bd9af97bd3c (patch) | |
| tree | 4122e6efd35ab6b780991b9a198cc387d7b67848 /lua | |
| parent | feat: assert minimum required Nvim version #3338 (diff) | |
| download | nvim-lspconfig-09074a29315dfe1c1bd5081a43481bd9af97bd3c.tar nvim-lspconfig-09074a29315dfe1c1bd5081a43481bd9af97bd3c.tar.gz nvim-lspconfig-09074a29315dfe1c1bd5081a43481bd9af97bd3c.tar.bz2 nvim-lspconfig-09074a29315dfe1c1bd5081a43481bd9af97bd3c.tar.lz nvim-lspconfig-09074a29315dfe1c1bd5081a43481bd9af97bd3c.tar.xz nvim-lspconfig-09074a29315dfe1c1bd5081a43481bd9af97bd3c.tar.zst nvim-lspconfig-09074a29315dfe1c1bd5081a43481bd9af97bd3c.zip | |
fix: malformed version message in older Nvim #3345
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig.lua | 18 |
1 files changed, 16 insertions, 2 deletions
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 |
