From 425dadef72e2af17eb45faf7bf45f7d74276ad72 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 28 May 2024 19:31:22 +0200 Subject: [PATCH] fix(snippets): show actual error for failed snippet --- lua/lazyvim/util/cmp.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/util/cmp.lua b/lua/lazyvim/util/cmp.lua index 0603b20d..1c9ad419 100644 --- a/lua/lazyvim/util/cmp.lua +++ b/lua/lazyvim/util/cmp.lua @@ -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