feat: e opens a repo's SOPS or .env file, in nvim, sops edit or your editor #1

Merged
keb merged 3 commits from feat/edit-files into main 2026-10-11 09:34:05 +02:00
Showing only changes of commit 98f597ffae - Show all commits
+8 -2
View File
@@ -169,7 +169,9 @@ func (m *Model) handleEditDone(msg editDoneMsg) tea.Cmd {
// that terminal's own process (the nvim plugin, or :terminal lazysecrets), // that terminal's own process (the nvim plugin, or :terminal lazysecrets),
// it waits for the terminal to close, so the file opens in the window // it waits for the terminal to close, so the file opens in the window
// below rather than in one about to close. Otherwise (a shell in a // below rather than in one about to close. Otherwise (a shell in a
// terminal) it opens it in the previous window now. // terminal) it opens it in the previous window now. The autocmd isn't
// the buffer's own: snacks wipes the buffer when the terminal closes,
// which would delete it before it runs.
const nvimLua = `local path, line, pid = ... const nvimLua = `local path, line, pid = ...
local function open() local function open()
local ok, err = pcall(vim.cmd, "edit " .. vim.fn.fnameescape(path)) local ok, err = pcall(vim.cmd, "edit " .. vim.fn.fnameescape(path))
@@ -178,7 +180,11 @@ local function open()
end end
for _, b in ipairs(vim.api.nvim_list_bufs()) do for _, b in ipairs(vim.api.nvim_list_bufs()) do
if vim.bo[b].buftype == "terminal" and vim.b[b].terminal_job_pid == pid then if vim.bo[b].buftype == "terminal" and vim.b[b].terminal_job_pid == pid then
vim.api.nvim_create_autocmd("TermClose", { buffer = b, once = true, callback = function() vim.defer_fn(open, 50) end }) vim.api.nvim_create_autocmd("TermClose", { callback = function(ev)
if ev.buf ~= b then return end
vim.defer_fn(open, 50)
return true
end })
return return
end end
end end