mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
feat(rename): save all buffers if ft~=telekasten
This commit is contained in:
@@ -336,11 +336,17 @@ local function recursive_substitution(dir, old, new)
|
|||||||
os.execute(replace_cmd)
|
os.execute(replace_cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function save_all_tk_buffers()
|
local function save_all_mod_buffers()
|
||||||
for i = 1, vim.fn.bufnr("$") do
|
for i = 1, vim.fn.bufnr("$") do
|
||||||
if
|
if
|
||||||
vim.fn.getbufvar(i, "&filetype") == "telekasten"
|
vim.fn.getbufvar(i, "&mod") == 1
|
||||||
and vim.fn.getbufvar(i, "&mod") == 1
|
and (
|
||||||
|
(
|
||||||
|
M.Cfg.auto_set_filetype == true
|
||||||
|
and vim.fn.getbufvar(i, "&filetype") == "telekasten"
|
||||||
|
)
|
||||||
|
or M.Cfg.auto_set_filetype == false
|
||||||
|
)
|
||||||
then
|
then
|
||||||
vim.cmd(i .. "bufdo w")
|
vim.cmd(i .. "bufdo w")
|
||||||
end
|
end
|
||||||
@@ -1707,17 +1713,14 @@ local function RenameNote()
|
|||||||
local oldlink = "[[" .. oldfile.title
|
local oldlink = "[[" .. oldfile.title
|
||||||
local newlink = "[[" .. newname
|
local newlink = "[[" .. newname
|
||||||
|
|
||||||
-- Save open telekasten buffers before looking for links to replace
|
-- Save open buffers before looking for links to replace
|
||||||
if
|
if #(vim.fn.getbufinfo({ bufmodified = 1 })) > 1 then
|
||||||
#(vim.fn.getbufinfo({ bufmodified = 1 })) > 1
|
|
||||||
and M.Cfg.auto_set_filetype == true
|
|
||||||
then
|
|
||||||
vim.ui.select({ "Yes (default)", "No" }, {
|
vim.ui.select({ "Yes (default)", "No" }, {
|
||||||
prompt = "Telekasten.nvim: "
|
prompt = "Telekasten.nvim: "
|
||||||
.. "Save all telekasten buffers before updating links?",
|
.. "Save all modified buffers before updating links?",
|
||||||
}, function(answer)
|
}, function(answer)
|
||||||
if answer ~= "No" then
|
if answer ~= "No" then
|
||||||
save_all_tk_buffers()
|
save_all_mod_buffers()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user