fix(lsp): correctly parse LSP snippets #15579

Fixes #15522
This commit is contained in:
hrsh7th
2021-09-14 20:31:41 +09:00
committed by Justin M. Keyes
parent 5a813160ae
commit 64dc7a1b55
4 changed files with 565 additions and 6 deletions

View File

@@ -1,4 +1,5 @@
local protocol = require 'vim.lsp.protocol'
local snippet = require 'vim.lsp._snippet'
local vim = vim
local validate = vim.validate
local api = vim.api
@@ -579,9 +580,13 @@ end
--@param input (string) unparsed snippet
--@returns (string) parsed snippet
function M.parse_snippet(input)
local res, _ = parse_snippet_rec(input, false)
return res
local ok, parsed = pcall(function()
return tostring(snippet.parse(input))
end)
if not ok then
return input
end
return parsed
end
--@private