File tree 2 files changed +30
-5
lines changed
2 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -4,10 +4,10 @@ local function fts_from_ts_lang(lang)
4
4
if vim .treesitter .language and vim .treesitter .language .get_filetypes then
5
5
fts = vim .treesitter .language .get_filetypes (lang )
6
6
end
7
- -- Keep lang as part of the result, for backward compatibility
8
- if not vim . list_contains ( fts , lang ) then
9
- table.insert ( fts , lang )
10
- end
7
+ -- Keep lang as part of the result, for backward compatibility.
8
+ -- If lang is already part of fts, one entry will be removed by deduplicate
9
+ -- in get_snippet_filetypes().
10
+ table.insert ( fts , lang )
11
11
return fts
12
12
end
13
13
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ describe("snippets_basic", function()
8
8
9
9
before_each (function ()
10
10
ls_helpers .clear ()
11
- ls_helpers .session_setup_luasnip ()
11
+ ls_helpers .session_setup_luasnip ({ setup_parsers = true } )
12
12
13
13
screen = Screen .new (50 , 3 )
14
14
screen :attach ()
@@ -1597,4 +1597,29 @@ describe("snippets_basic", function()
1597
1597
assert .are .same (true , exec_lua (" return enter_snode_m1" ))
1598
1598
assert .are .same (true , exec_lua (" return enter_snode_via_parent" ))
1599
1599
end )
1600
+
1601
+ it (" Correct filetype is recognized via treesitter." , function ()
1602
+ exec_lua ([=[
1603
+ ls.setup({
1604
+ ft_func = require("luasnip.extras.filetype_functions").from_cursor_pos
1605
+ })
1606
+ ls.add_snippets("lua", {
1607
+ s("asdf", t[[print("qwer")]])
1608
+ })
1609
+ ]=] )
1610
+ exec (" set ft=lua" )
1611
+ feed ([[ ilocal function a() end<Esc>hhhi]] )
1612
+ screen :expect ({
1613
+ grid = [[
1614
+ local function a() ^ end |
1615
+ {0:~ }|
1616
+ {2:-- INSERT --} |]] })
1617
+ feed ([[ asdf]] )
1618
+ exec_lua (" ls.expand()" )
1619
+ screen :expect ({
1620
+ grid = [[
1621
+ local function a() print("qwer")^ end |
1622
+ {0:~ }|
1623
+ {2:-- INSERT --} |]] })
1624
+ end )
1600
1625
end )
You can’t perform that action at this time.
0 commit comments