Skip to content

Structure snippets in multiple files #1236

Closed Answered by Felipe-9
Felipe-9 asked this question in Q&A
Discussion options

You must be logged in to vote

Hello! its been some time, i finnally found a solution for this.

the solutions i found whent on the path of adding sinppets using ls.add_snippets('tex',{...}) method.

The reason it wasnt working before is because we were inserting a table of tables instead of having a single table of snippets which was expected by the function.

so with the following loop we can join together tables and insert then into luasnip:

local snippet_tables = {
  require('snippets.latex.mysnipfile'),
  ...
}

local snippets = {}
for _,sniptable in ipairs(snippet_tables) do
  for _,snip in ipairs(sniptable) do
    table.insert(snippets,snip)
  end
end

ls.add_snippets('tex',snippets)

luasnip.lua

return {
  "L3MON…

Replies: 3 comments 15 replies

Comment options

You must be logged in to vote
2 replies
@Felipe-9
Comment options

@iMagUdspEllr
Comment options

Comment options

You must be logged in to vote
12 replies
@Felipe-9
Comment options

@L3MON4D3
Comment options

@Felipe-9
Comment options

@Felipe-9
Comment options

@L3MON4D3
Comment options

Comment options

You must be logged in to vote
1 reply
@L3MON4D3
Comment options

Answer selected by Felipe-9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants