How can I add a value of placeholder as argument to function?
opened this issue · comments
Deleted user commented
I have this function to capitalize the first letter of a word:
function titleCase(first, rest)
return first:upper()..rest:lower()
end
And want to use this in my snippet:
Basically i want capitalize what I typed on first placeholder
typescriptreact = {
["ush"] = [[
const [${1}, ${=string.gsub($1, "(%a)([%w_']*)", titleCase)}] = useState(${3})
]]
};
I'm very noob on lua so apologies if it's a dumb question, but I'm really struggle with this
Deleted user commented
Already solved! It was just lack of reading the documentation haha.
Solution:
["ush"] = [[
const [${1}, ${1|string.format('set%s', S.v:sub(1, 1):upper()..S.v:sub(2))}] = useState(${3})$0
]],