move home configs to root

This commit is contained in:
Joakim Repomaa
2025-01-30 20:47:28 +02:00
parent ea7c4cbf31
commit 12647a2e77
27 changed files with 204 additions and 210 deletions

View File

@@ -0,0 +1,83 @@
local ls = require("luasnip")
local fmt = require("luasnip.extras.fmt").fmt
local s = ls.snippet
local sn = ls.snippet_node
local i = ls.insert_node
local f = ls.function_node
local d = ls.dynamic_node
return {
s(
{ trig = "fc", desc = "React.FC" },
fmt(
[[
import React from "react"
interface {props_name} {{
{prop_types}
}}
const {component_name}: React.FC<{props_name}> = ({props}) => {{
return (
{markup}
)
}}
export default {component_name}
]],
{
props_name = i(3, "Props"),
prop_types = i(2),
component_name = d(1, function()
local filename = vim.api.nvim_buf_get_name(0)
local component_name
if filename == "index.tsx" then
component_name = vim.fs.basename(vim.fs.dirname(filename))
else
component_name = vim.fs.basename(filename):match("(.+)%.tsx")
end
return sn(nil, i(1, component_name))
end),
props = f(function(prop_types)
local props = {}
for _, prop in ipairs(prop_types[1]) do
local parts = vim.split(prop, ":", { plain = true, trimempty = true })
local name = parts[1]
if name then
table.insert(props, vim.trim(name))
end
end
return "{ " .. table.concat(props, ", ") .. " }"
end, { 2 }),
markup = i(0),
},
{
repeat_duplicates = true,
}
)
),
s(
{ trig = "t", desc = "<tag>" },
fmt(
[[
<{tag}>
{children}
</{closing_tag}>
]],
{
tag = i(1, "div"),
closing_tag = f(function(tag)
return vim.split(tag[1][1], " ")[1]
end, { 1 }),
children = i(0),
},
{
repeat_duplicates = true,
}
)
),
}