mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-14 18:10:28 +00:00
29 lines
588 B
Lua
29 lines
588 B
Lua
|
|
local M = {}
|
|
|
|
M.created_files = {}
|
|
|
|
function M.clean_files()
|
|
for _, bufnr in ipairs(M.created_files) do
|
|
vim.api.nvim_buf_delete(bufnr, {force = true})
|
|
end
|
|
|
|
M.created_files = {}
|
|
end
|
|
|
|
---@param name string
|
|
---@param contents string[]
|
|
function M.create_file(name, contents, row, col)
|
|
local bufnr = vim.fn.bufnr(name, true)
|
|
vim.api.nvim_set_current_buf(bufnr)
|
|
vim.api.nvim_buf_set_text(0, 0, 0, 0, 0, contents)
|
|
if row then
|
|
vim.api.nvim_win_set_cursor(0, {row, col})
|
|
end
|
|
|
|
table.insert(M.created_files, bufnr)
|
|
return bufnr
|
|
end
|
|
|
|
return M
|