mirror of
https://github.com/pnx/dotfiles
synced 2026-06-16 03:14:55 +02:00
nvim: add typescript snippets
This commit is contained in:
parent
f3e924742c
commit
05439d0859
1 changed files with 38 additions and 0 deletions
38
nvim/snippets/typescript.lua
Normal file
38
nvim/snippets/typescript.lua
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
local ls = require("luasnip")
|
||||||
|
local s = ls.snippet
|
||||||
|
local i = ls.insert_node
|
||||||
|
local f = ls.function_node
|
||||||
|
local fmt = require("luasnip.extras.fmt").fmt
|
||||||
|
local rep = require("luasnip.extras").rep
|
||||||
|
|
||||||
|
local function capitalize_first(args)
|
||||||
|
local str = args[1][1] or ""
|
||||||
|
return str:gsub("^%l", string.upper)
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
s(
|
||||||
|
"cvar",
|
||||||
|
fmt([[
|
||||||
|
export const {}Variants = cva(
|
||||||
|
'',
|
||||||
|
{{
|
||||||
|
variants: {{
|
||||||
|
variant: {{
|
||||||
|
default: "",
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
defaultVariants: {{
|
||||||
|
variant: 'default',
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
)
|
||||||
|
|
||||||
|
export type {}Variant = VariantProps<typeof {}Variants>
|
||||||
|
]], {
|
||||||
|
i(1, "my"),
|
||||||
|
f(capitalize_first, { 1 }),
|
||||||
|
rep(1),
|
||||||
|
})
|
||||||
|
),
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue