feat(nvim): make req
work with dots
This commit is contained in:
parent
25c6a44a2a
commit
bc4e9b7952
|
@ -1,16 +1,27 @@
|
|||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local ls = require "luasnip"
|
||||
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local rep = require("luasnip.extras").rep
|
||||
|
||||
local i = ls.insert_node
|
||||
local f, i = ls.function_node, ls.insert_node
|
||||
|
||||
return {
|
||||
req = fmt("local {} = require('{}')", { i(1), rep(1) }),
|
||||
pcall = fmt(
|
||||
[[
|
||||
local status_ok, {} = pcall(require, "{}")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
]],
|
||||
{ i(1), rep(1) }
|
||||
),
|
||||
|
||||
pcall = fmt([[
|
||||
local status_ok, {} = pcall(require, "{}")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
]], { i(1), rep(1) })
|
||||
req = fmt([[local {} = require "{}"]], {
|
||||
f(function(import_name)
|
||||
local parts = vim.split(import_name[1][1], ".", true)
|
||||
|
||||
return parts[#parts] or ""
|
||||
end, { 1 }),
|
||||
i(1),
|
||||
}),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue