kitchen sink
This commit is contained in:
@ -9,8 +9,21 @@ local function c_func(func)
|
||||
local q = vim.treesitter.query.parse("c", "(function_definition) @f")
|
||||
local matches = q:iter_matches(tree, 0)
|
||||
|
||||
vim.treesitter.query.parse("c", "(identifier) @i")
|
||||
local m = q:iter_matches(matches, 0)
|
||||
print(vim.treesitter.get_node_text(m:child(), 0))
|
||||
|
||||
if true then
|
||||
return
|
||||
end
|
||||
|
||||
for _, match in matches do
|
||||
for _, node in pairs(match) do
|
||||
if not node or not node:child(1) or not node:child(1):child() then
|
||||
-- print(vim.treesitter.get_node_text(node:child(1):child(), 0))
|
||||
goto continue
|
||||
end
|
||||
|
||||
if vim.treesitter.get_node_text(node:child(1):child(), 0) == func then
|
||||
local def = ""
|
||||
for i = 0, node:child_count() - 2 do
|
||||
@ -22,6 +35,7 @@ local function c_func(func)
|
||||
-- Print the function name using node text
|
||||
return def:gsub("\n", "")
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
|
70
lua/snippets/tex.lua
Normal file
70
lua/snippets/tex.lua
Normal file
@ -0,0 +1,70 @@
|
||||
require('core.snippets.shorthands')
|
||||
require('core.snippets.functions')
|
||||
|
||||
return {
|
||||
-- document snippet
|
||||
s("doc",
|
||||
fmta(
|
||||
[[
|
||||
\documentclass{article}
|
||||
\title{<>}
|
||||
\author{<>}
|
||||
\begin{document}
|
||||
\maketitle
|
||||
<>
|
||||
\end{document}
|
||||
]],
|
||||
{
|
||||
c(1, {
|
||||
sn(nil, { f(file_name, {}), i(1) }),
|
||||
i(1, "my title")
|
||||
}),
|
||||
i(2, "my name"),
|
||||
i(0)
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
s({ trig = ";begin", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{<>}
|
||||
<>
|
||||
\end{<>}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(0),
|
||||
rep(1)
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
s({ trig = ";href", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[\href{<>}{<>}]],
|
||||
{
|
||||
i(1, "url"),
|
||||
i(2, "display name"),
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
postfix(".b", {
|
||||
f(function(_, parent)
|
||||
return [[\textbf{]]..parent.snippet.env.POSTFIX_MATCH.."}"
|
||||
end)
|
||||
}),
|
||||
|
||||
postfix(".i", {
|
||||
f(function(_, parent)
|
||||
return [[\textit{]]..parent.snippet.env.POSTFIX_MATCH.."}"
|
||||
end)
|
||||
}),
|
||||
|
||||
postfix(".ul", {
|
||||
f(function(_, parent)
|
||||
return [[\underline{]]..parent.snippet.env.POSTFIX_MATCH.."}"
|
||||
end)
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user