Problem:
No way to add snippets in Lua.
Solution:
Add require("yasp").add with a signature like this:
---Add VS Code-style snippet
---@param trig string
---@param body string VS Code-style snippet string
---@param opts {ft: string, desc: string}
So it can be used like this:
require("yasp").add("au", [[
vim.api.nvim_create_autocmd("${1:Event}", {
callback = function(args)
$0
end
})
]], { ft = "lua", desc = "Neovim autocmd" })
Benefits:
It will allow users to organize their snippets however they want and will not require creating separate snippet files for this.
I am especially interested in this because I put all language-specific configurations in one separate file for each language. You can take a look here:
https://github.com/miroshQa/dotfiles/blob/main/nvim/lua/languages/lua.lua
Since I already have lua.lua, js.lua, I don’t want to create snippets/lua.json, snippets/js.json as well, because it will be hard to fuzzy-find them and will create too many files. Also it simply much more pleasant to write snippets using lua multistring literals.
Problem:
No way to add snippets in Lua.
Solution:
Add require("yasp").add with a signature like this:
So it can be used like this:
Benefits:
It will allow users to organize their snippets however they want and will not require creating separate snippet files for this.
I am especially interested in this because I put all language-specific configurations in one separate file for each language. You can take a look here:
https://github.com/miroshQa/dotfiles/blob/main/nvim/lua/languages/lua.lua
Since I already have lua.lua, js.lua, I don’t want to create snippets/lua.json, snippets/js.json as well, because it will be hard to fuzzy-find them and will create too many files. Also it simply much more pleasant to write snippets using lua multistring literals.