mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-01 13:04:33 +02:00
fix(snippets): show actual error for failed snippet
This commit is contained in:
parent
91493588a8
commit
425dadef72
1 changed files with 3 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue