1

I want to make my custom snippets in latex files. I am using luasnip and this is my config:

{
"hrsh7th/nvim-cmp",
config = function()
  require("luasnip.loaders.from_vscode").lazy_load({
    paths = { "C:/Users/lenovo/AppData/Local/nvim/snippets" },
  })

  require("luasnip").filetype_extend("tex", { "latex" })

  local cmp = require("cmp")
  local ls = require("luasnip")
  ls.add_snippets("latex", {
    ls.snippet("ttt", {
      ls.text_node("HELLO FROM LUA SNIPPET"),
    }),
  })

When I use this config it works without problems but i want to create a separate folder and get the snippets from there using:

require("luasnip.loaders.from_vscode").lazy_load({
paths = { "C:/Users/lenovo/AppData/Local/nvim/snippets" },})

but when i delete:

ls.add_snippets("latex", {
ls.snippet("ttt", {
  ls.text_node("HELLO FROM LUA SNIPPET"),
}),

the snippets don't work.

Inside the snippets folder I have a file latex.json where I put this snippet:

{"test-snippet": {
"prefix": "ttt",
"body": ["HELLO FROM SNIPPET"] }}

And when I enter the command :set filetype? in the .tex file it returns tex.

1 Answer 1

1

You using WIndows. Therefore i guess you have to use Backslashes.

Example using longstring (double brackets) and Backslashes:

paths = {[[C:\Users\lenovo\AppData\Local\nvim\snippets]]}

See > Escape sequences are not recognized when using double brackets, so:

Example using enquoted string and Backslashes:

paths = {"C:\\Users\\lenovo\\AppData\\Local\\nvim\\snippets"}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.