From 9bdcc7f11e5c9932941b88bcb21adbf84d537ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20Say=C4=B1n?= <25414028+ssayin@users.noreply.github.com> Date: Fri, 5 May 2023 16:17:35 +0300 Subject: [PATCH 1/2] fix: vim.pretty_print is deprecated (^neovim-0.9.0) see: https://github.com/neovim/neovim/blob/040f1459849ab05b04f6bb1e77b3def16b4c2f2b/runtime/doc/news.txt#LL321C3-L321C3 vim.pretty_print is removed in development (prerelease) build: https://github.com/neovim/neovim/releases/tag/nightly --- doc/luasnip.txt | 2 +- plugin/luasnip.lua | 13 ++++- tests/integration/snippet_basics_spec.lua | 67 +++++++++++++++++++++++ 3 files changed, 80 insertions(+), 2 deletions(-) diff --git a/doc/luasnip.txt b/doc/luasnip.txt index ddd3c16b6..571ef214a 100644 --- a/doc/luasnip.txt +++ b/doc/luasnip.txt @@ -1,4 +1,4 @@ -*luasnip.txt* For NVIM v0.8.0 Last change: 2023 May 01 +*luasnip.txt* For NVIM v0.8.0 Last change: 2023 May 05 ============================================================================== Table of Contents *luasnip-table-of-contents* diff --git a/plugin/luasnip.lua b/plugin/luasnip.lua index d3e9ad611..e1e35d43c 100644 --- a/plugin/luasnip.lua +++ b/plugin/luasnip.lua @@ -61,8 +61,19 @@ end) vim.api.nvim_create_user_command("LuaSnipUnlinkCurrent", function() require("luasnip").unlink_current() end, { force = true }) + +--stylua: ignore vim.api.nvim_create_user_command("LuaSnipListAvailable", function() - vim.pretty_print(require("luasnip").available()) + ( + ( + vim.version + and type(vim.version) == "table" + and ( + ((vim.version().major == 0) and (vim.version().minor >= 9)) + or (vim.version().major > 0) ) + ) and vim.print + or vim.pretty_print + )(require("luasnip").available()) end, { force = true }) require("luasnip.config")._setup() diff --git a/tests/integration/snippet_basics_spec.lua b/tests/integration/snippet_basics_spec.lua index 69a0bffde..e166bbf59 100644 --- a/tests/integration/snippet_basics_spec.lua +++ b/tests/integration/snippet_basics_spec.lua @@ -768,4 +768,71 @@ describe("snippets_basic", function() end end ) + + it("LuaSnipListAvailable works", function() + helpers.clear() + ls_helpers.session_setup_luasnip() + + screen = Screen.new(50, 40) + screen:attach() + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue1}; + [1] = {bold = true, foreground = Screen.colors.Brown}; + [2] = {bold = true}; + [3] = {background = Screen.colors.LightGrey}; + [4] = {bold = true, reverse = true}; + [5] = {bold = true, foreground = Screen.colors.SeaGreen4}; + [6] = {foreground = Screen.colors.Red1}; + }) + exec_lua([[ + ls.add_snippets("all", { + s({trig="a"}, { t"justsometexta" }), + s({trig="b"}, { t"justsometextb" }), + s({trig="c"}, { t"justsometextc" }), + }) + ]]) + feed(":LuaSnipListAvailable") + screen:expect{grid=[[ + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {4: }| + { | + [""] = {}, | + all = { { | + description = { "a" }, | + name = "a", | + regTrig = false, | + trigger = "a", | + wordTrig = true | + }, { | + description = { "b" }, | + name = "b", | + regTrig = false, | + trigger = "b", | + wordTrig = true | + }, { | + description = { "c" }, | + name = "c", | + regTrig = false, | + trigger = "c", | + wordTrig = true | + } } | + } | + {5:Press ENTER or type command to continue}^ |]]} + feed("") + end) end) From ab3476643a5efec05f3c3f18340a20f8951d9935 Mon Sep 17 00:00:00 2001 From: L3MON4D3 Date: Fri, 5 May 2023 19:30:08 +0000 Subject: [PATCH 2/2] Format with stylua --- tests/integration/snippet_basics_spec.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/integration/snippet_basics_spec.lua b/tests/integration/snippet_basics_spec.lua index e166bbf59..b9973f93c 100644 --- a/tests/integration/snippet_basics_spec.lua +++ b/tests/integration/snippet_basics_spec.lua @@ -776,13 +776,13 @@ describe("snippets_basic", function() screen = Screen.new(50, 40) screen:attach() screen:set_default_attr_ids({ - [0] = {bold = true, foreground = Screen.colors.Blue1}; - [1] = {bold = true, foreground = Screen.colors.Brown}; - [2] = {bold = true}; - [3] = {background = Screen.colors.LightGrey}; - [4] = {bold = true, reverse = true}; - [5] = {bold = true, foreground = Screen.colors.SeaGreen4}; - [6] = {foreground = Screen.colors.Red1}; + [0] = { bold = true, foreground = Screen.colors.Blue1 }, + [1] = { bold = true, foreground = Screen.colors.Brown }, + [2] = { bold = true }, + [3] = { background = Screen.colors.LightGrey }, + [4] = { bold = true, reverse = true }, + [5] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [6] = { foreground = Screen.colors.Red1 }, }) exec_lua([[ ls.add_snippets("all", { @@ -792,7 +792,8 @@ describe("snippets_basic", function() }) ]]) feed(":LuaSnipListAvailable") - screen:expect{grid=[[ + screen:expect({ + grid = [[ | {0:~ }| {0:~ }| @@ -832,7 +833,8 @@ describe("snippets_basic", function() wordTrig = true | } } | } | - {5:Press ENTER or type command to continue}^ |]]} + {5:Press ENTER or type command to continue}^ |]], + }) feed("") end) end)