Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: vim.pretty_print is deprecated (^neovim-0.9.0) #880

Merged
merged 2 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/luasnip.txt
Original file line number Diff line number Diff line change
@@ -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*
Expand Down
13 changes: 12 additions & 1 deletion plugin/luasnip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
69 changes: 69 additions & 0 deletions tests/integration/snippet_basics_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -768,4 +768,73 @@ 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<Cr>")
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("<Cr>")
end)
end)