close #510: update DOC#515
Conversation
Oh yes, please 👍👍
Wow, That's awesome! Thank you for your effort ❤️
Oh that's a great idea, should help with understanding the snippets. Would adding them as mp4 be much trouble? I feel like being able to pause the playback is really helpful for understanding what's going on, and that's not possible with gifs :/ We're using panvimdoc to convert the markdown to vimdoc, so the gifs/mp4s should probably put inside an ignore-block so they don't show up in |
Like this? luasnip.mp4 |
|
Yup 👍 |
Github accepts a plain video link to show the video, so I'm not sure whether the plain link will be displayed in vimdoc.
Correct. The main purpose I make GIFs is to know the result of expansion, and all actions in GIFs are simple:
I think GIFs is simple and doesn't occupy much visual space, which looks neat. |
Of course, I will add it in this PR after I finish the translation. It won't take too long hopefully (2/3 already done). Thank you for reminding me of that. |
I think it might be shown as-is, you can push a version of
Oh I agree. Also, in this case the playback/pause-ui covers a good amount of the content, so that's another downside. Gifs it is 👍 |
|
docstring is confusing in DOC. All the examples from there yield the same result without any error, which is hard to understand why the arguments ls.add_snippets("all", {
s({ trig = "doc_simple(%d)", regTrig = true, }, {
f(function(args, snip)
return string.rep("repeatme ", tonumber(snip.captures[1]))
end, {})
}),
s({ trig = "doc_trig(%d)", regTrig = true, docTrig = "2" }, {
f(function(args, snip)
return string.rep("repeatme ", tonumber(snip.captures[1]))
end, {})
}),
s({ trig = "docstring(%d)", regTrig = true, docstring = "repeatmerepeatmerepeatme" }, {
f(function(args, snip)
return string.rep("repeatme ", tonumber(snip.captures[1]))
end, {})
}),
})2022-08-11_23-41-11.mp4The only explanation I found lies in the start of DOC:
And no example that must/should use |
|
One thing I'm suprised at is the table returned in lua file which is loaded by LuaSnip: return {
parse("trig", "loaded!!")
}
With this sentence in mind, I thought something like return {
parse("trig", { t"loaded!!", i(1, "") })
}Now, after several trials, I find it really means the lsp-snippets: |
Ahh, that isn't explained at all :/ -- has regTrig, (%d) is stored in `snip.captures[1]`
s({ trig = "doc_simple(%d)", regTrig = true, }, {
f(function(args, snip)
return string.rep("repeatme ", tonumber(snip.captures[1]))
end, {})
}),) I guess this is, again, a bit in-depth for someone just starting out, so a link |
It should, in files loaded by the lua-loader a call to |
|
Well, I find this example enlighten me much: Given the three snippets local doc1 = s({ trig = "doc(%d)", regTrig = true, }, f(
function(_args, snip)
return string.rep("repeatme ", tonumber(snip.captures[1]))
end, {}
))
local doc2 = s({ trig = "doc(%d)", regTrig = true, docTrig = "doc2" }, f(
function(_args, snip)
return string.rep("repeatme ", tonumber(snip.captures[1]))
end, {}
))
local doc3 = s({ trig = "doc(%d)", regTrig = true, docstring = "repeatmerepeatmerepeatme" }, f(
function(_args, snip)
return string.rep("repeatme ", tonumber(snip.captures[1]))
end, {}
))add_snippets / directly return-- in some lua file
ls.add_snippets("all", { doc1, doc2, doc3 })
-- or equivelently via loader, in `all.lua` or `all/*.lua`
return { doc1, doc2, doc3 }In this case, they generate the same result. The expansion of docstringlocal function gen(snip)
return table.concat(snip:get_docstring())
endreturn {
-- parse("doc_one", gen(doc1)),
parse("doc_two", gen(doc2)),
parse("doc_three", gen(doc3)),
doc1,
}For Now here comes the For |
|
Nice, yes that's exactly it 👍 |
This comment was marked as spam.
This comment was marked as spam.
|
It seems all images in md should be manually marked as to prevent appearance in vimdoc. |
|
Woah, that's a lot of gifs, amazing work👍👍👍 |
|
All I want to add is done. This PR can be merged after you review. |
|
LGTM, Thank you very much 👍👍 |

Since I'm reading the DOC and haven't finished it yet, I will fix more minor mistakes in this PR if I find them.
Plus, I'm translating the documentation here, and it's WIP.
Each example code is tried and the usage is recorded as GIF like this.
I can add them to the DOC if you want them to appear in the DOC.