From 7a544f89a5581ab8ee26eb30c24e999d6c2d579c Mon Sep 17 00:00:00 2001 From: dcampos Date: Wed, 16 Jul 2025 21:31:36 -0300 Subject: [PATCH] fix(snippet): use backslash to escape dollar signs in snippet templates Some snippet engines, including the built-in one, don't recognize double dollar sign. Using backslash seems to be universally supported. --- lua/neogen/snippet.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/neogen/snippet.lua b/lua/neogen/snippet.lua index 1fed3fbc..e41b127f 100644 --- a/lua/neogen/snippet.lua +++ b/lua/neogen/snippet.lua @@ -49,10 +49,10 @@ snippet.engines = {} snippet.to_snippet = function(template, marks, pos) local offset, ph = {}, {} - -- Add double $ for template before creating the snippet so that text with $ (such as parameters in php) + -- Escape $ for template before creating the snippet so that text with $ (such as parameters in php) -- are not interpreted as snippet for i, str in ipairs(template) do - template[i] = str:gsub("%$", "$$") -- Escape $ + template[i] = str:gsub("%$", "\\$") -- Escape $ end for i, m in ipairs(marks) do