feat(snippets): load snippets
This commit is contained in:
+32
-10
@@ -3,13 +3,29 @@ local augroup = vim.api.nvim_create_augroup("Vitruvio", { clear = true })
|
|||||||
local post = function(url, file_path)
|
local post = function(url, file_path)
|
||||||
vim.fn.system({
|
vim.fn.system({
|
||||||
"curl",
|
"curl",
|
||||||
"-X", "POST",
|
"-X",
|
||||||
"-H", "Content-Type: application/xml",
|
"POST",
|
||||||
"--data-binary", "@" .. file_path,
|
"-H",
|
||||||
url
|
"Content-Type: application/xml",
|
||||||
|
"--data-binary",
|
||||||
|
"@" .. file_path,
|
||||||
|
url,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function get_snippet_path()
|
||||||
|
-- Look for the specific file or folder within the runtimepath
|
||||||
|
-- 'vscode' is the folder name in your snippet repo
|
||||||
|
local paths = vim.api.nvim_get_runtime_file("vscode/", true)
|
||||||
|
|
||||||
|
if #paths > 0 then
|
||||||
|
return paths[1] -- Returns the full path to the first match found
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
print(get_snippet_path())
|
||||||
|
|
||||||
local function main()
|
local function main()
|
||||||
vim.api.nvim_create_user_command("VitruvioURL", function(opts)
|
vim.api.nvim_create_user_command("VitruvioURL", function(opts)
|
||||||
vim.b.vitruvio_url = opts.fargs[1]
|
vim.b.vitruvio_url = opts.fargs[1]
|
||||||
@@ -32,18 +48,24 @@ local function main()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function setup()
|
local function setup()
|
||||||
vim.api.nvim_create_autocmd("BufEnter",
|
vim.api.nvim_create_autocmd("BufEnter", {
|
||||||
{
|
group = augroup,
|
||||||
group = augroup,
|
desc = "Utilidades para o desenvolvedor do Vitruvio",
|
||||||
desc = "Utilidades para o desenvolvedor do Vitruvio",
|
callback = main,
|
||||||
callback = main
|
})
|
||||||
|
|
||||||
|
local snippet_dir = get_snippet_path()
|
||||||
|
if snippet_dir then
|
||||||
|
require("luasnip.loaders.from_vscode").lazy_load({
|
||||||
|
paths = { snippet_dir },
|
||||||
})
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return { setup = setup }
|
return { setup = setup }
|
||||||
|
|||||||
Reference in New Issue
Block a user