fix(snippets): show actual error for failed snippet

This commit is contained in:
Folke Lemaitre 2024-05-28 19:31:22 +02:00
parent 91493588a8
commit 425dadef72
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -95,12 +95,13 @@ function M.expand(snippet)
-- See: https://github.com/LazyVim/LazyVim/issues/3199
local session = vim.snippet.active() and vim.snippet._session or nil
local ok = pcall(vim.snippet.expand, snippet)
local ok, err = pcall(vim.snippet.expand, snippet)
if not ok then
local fixed = M.snippet_fix(snippet)
ok = pcall(vim.snippet.expand, fixed)
local msg = ok and "Failed to parse snippet,\nbut was able to fix it automatically." or "Failed to parse snippet."
local msg = ok and "Failed to parse snippet,\nbut was able to fix it automatically."
or ("Failed to parse snippet.\n" .. err)
LazyVim[ok and "warn" or "error"](
([[%s