mirror of
https://github.com/L3MON4D3/LuaSnip
synced 2024-09-16 13:44:04 +02:00
fix: stay compatible with old nvim-versions.
they don't have vim.list_contains.
This commit is contained in:
parent
03c607c2bd
commit
20448f4573
2 changed files with 30 additions and 5 deletions
|
@ -4,10 +4,10 @@ local function fts_from_ts_lang(lang)
|
|||
if vim.treesitter.language and vim.treesitter.language.get_filetypes then
|
||||
fts = vim.treesitter.language.get_filetypes(lang)
|
||||
end
|
||||
-- Keep lang as part of the result, for backward compatibility
|
||||
if not vim.list_contains(fts, lang) then
|
||||
table.insert(fts, lang)
|
||||
end
|
||||
-- Keep lang as part of the result, for backward compatibility.
|
||||
-- If lang is already part of fts, one entry will be removed by deduplicate
|
||||
-- in get_snippet_filetypes().
|
||||
table.insert(fts, lang)
|
||||
return fts
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ describe("snippets_basic", function()
|
|||
|
||||
before_each(function()
|
||||
ls_helpers.clear()
|
||||
ls_helpers.session_setup_luasnip()
|
||||
ls_helpers.session_setup_luasnip({setup_parsers=true})
|
||||
|
||||
screen = Screen.new(50, 3)
|
||||
screen:attach()
|
||||
|
@ -1597,4 +1597,29 @@ describe("snippets_basic", function()
|
|||
assert.are.same(true, exec_lua("return enter_snode_m1"))
|
||||
assert.are.same(true, exec_lua("return enter_snode_via_parent"))
|
||||
end)
|
||||
|
||||
it("Correct filetype is recognized via treesitter.", function()
|
||||
exec_lua([=[
|
||||
ls.setup({
|
||||
ft_func = require("luasnip.extras.filetype_functions").from_cursor_pos
|
||||
})
|
||||
ls.add_snippets("lua", {
|
||||
s("asdf", t[[print("qwer")]])
|
||||
})
|
||||
]=])
|
||||
exec("set ft=lua")
|
||||
feed([[ilocal function a() end<Esc>hhhi]])
|
||||
screen:expect({
|
||||
grid = [[
|
||||
local function a() ^ end |
|
||||
{0:~ }|
|
||||
{2:-- INSERT --} |]]})
|
||||
feed([[asdf]])
|
||||
exec_lua("ls.expand()")
|
||||
screen:expect({
|
||||
grid = [[
|
||||
local function a() print("qwer")^ end |
|
||||
{0:~ }|
|
||||
{2:-- INSERT --} |]]})
|
||||
end)
|
||||
end)
|
||||
|
|
Loading…
Reference in a new issue