You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in file 20240820-old.md, the original id might be 20240820-old:
---id: 20240820-oldaliases: []tags: []---
if i run the command :ObsidianRename new, the filename of current file would be changed to new.md and all references from other notes will be replaced to [[new]], however, the id property of current file remains 20240820-old:
---id: 20240820-oldaliases: []tags: []---
And if then I would like to run :ObsidianRename 20240820-old for changing the name back to 20240820-old, plugin would not allow me to to that and reports: New note ID is the same, doing nothing, due to the id of current file never changes.
Even if I want to change to another name, e.g. :ObsidianRename another_new, the filename of current file would be changed to another_new.md, the id of current file still remains 20240820-old, and the references from all other files would be kept as [[new]] due to the id does not match, which means backlink of current file could not be resolved.
Config
return {
"epwalsh/obsidian.nvim",
-- version = "*",-- lazy = true,ft="markdown",
dependencies= {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
"hrsh7th/nvim-cmp",
},
keys= {
{"<leader>fnd", "<cmd>ObsidianDailies<cr>", desc="[Obsidian] Open daily notes"},
{"<leader>fnt", "<cmd>ObsidianTemplate<cr>", desc="[Obsidian] Insert template"},
{"<leader>fnT", "<cmd>ObsidianNewFromTemplate<cr>", desc="[Obsidian] Create note using template"},
{"<leader>fnn", "<cmd>ObsidianQuickSwitch<cr>", desc="[Obsidian] Open/Create new note"},
{"<leader>fnp", "<cmd>ObsidianPasteImg<cr>", desc="[Obsidian] Paste image into note"},
{"<leader>fnr", "<cmd>ObsidianRename<cr>", desc="[Obsidian] Rename note"},
{"<leader>fnf", "<cmd>ObsidianSearch<cr>", desc="[Obsidian] Global Search"},
{"<leader>fnb", "<cmd>ObsidianBacklinks<cr>", desc="[Obsidian] Search Backlink"},
{"<leader>fno", "<cmd>ObsidianOpen<cr>", desc="[Obsidian] Open note in Obsidian"},
},
opts= {
workspaces= {
{
name="Junk",
path="~/Obsidian/Junk/"
},
},
notes_subdir="notes",
new_notes_location="notes_subdir",
log_level=vim.log.levels.INFO,
daily_notes= {
folder="dailies",
date_format="%Y-%m-%d",
alias_format="%B %-d, %Y",
default_tags= { "daily-notes" },
-- Optional, if you want to automatically insert a template from your template directory like 'daily.md'template='[Daily].md'
},
completion= {
-- Set to false to disable completion.nvim_cmp=true,
-- Trigger completion at 2 chars.min_chars=2,
},
-- Optional, configure key mappings. These are the defaults. If you don't want to set any keymappings this-- way then set 'mappings = {}'.mappings= {
-- Overrides the 'gf' mapping to work on markdown/wiki links within your vault.
["<leader>fnf"] = {
action=function()
returnrequire("obsidian").util.gf_passthrough()
end,
opts= { noremap=false, expr=true, buffer=true },
},
-- Toggle check-boxes.
["<cr>"] = {
action=function()
returnrequire("obsidian").util.toggle_checkbox()
end,
opts= { buffer=true },
},
-- Smart action depending on context, either follow link or toggle checkbox.
["<Tab>"] = {
action=function()
returnrequire("obsidian").util.smart_action()
end,
opts= { buffer=true, expr=true },
}
},
templates= {
folder="../templates",
date_format="%Y-%m-%d",
time_format="%H:%M",
substitutions= {},
},
attachments= {
-- The default folder to place images in via `:ObsidianPasteImg`.-- If this is a relative path it will be interpreted as relative to the vault root.-- You can always override this per image by passing a full path to the command instead of just a filename.img_folder="assets/imgs" ..vim.fn.expand('%:t:r'), -- This is the default-- Optional, customize the default name or prefix when pasting images via `:ObsidianPasteImg`.---@returnstringimg_name_func=function()
-- Prefix image names with timestamp.returnstring.format("%s-", os.date("%y%m%d%H%M%S"))
end,
-- A function that determines the text to insert in the note when pasting an image.-- It takes two arguments, the `obsidian.Client` and an `obsidian.Path` to the image file.-- This is the default implementation.---@paramclientobsidian.Client---@parampathobsidian.Path the absolute path to the image file---@returnstringimg_text_func=function(client, path)
path=client:vault_relative_path(path) orpathreturnstring.format("", string.sub(path.name, 14), path)
end,
},
-- Optional, customize how note IDs are generated given an optional title.---@paramtitlestring|?---@returnstringnote_id_func=function(title)
-- Create note IDs in a Zettelkasten format with a timestamp and a suffix.-- In this case a note with the title 'My new note' will be given an ID that looks-- like '1657296016-my-new-note', and therefore the file name '1657296016-my-new-note.md'localsuffix=""iftitle~=nilthen-- If title is given, transform it into valid file name.suffix=title:gsub("", "-"):gsub("[^A-Za-z0-9-]", ""):lower()
else-- If title is nil, just add 4 random uppercase letters to the suffix.for_=1, 4dosuffix=suffix..string.char(math.random(65, 90))
endendreturntostring(os.time()) .."-" ..suffixend,
-- Optional, customize how note file names are generated given the ID, target directory, and title.---@paramspec{ id: string, dir: obsidian.Path, title: string|? }---@returnstring|obsidian.Path The full path to the new note.note_path_func=function(spec)
-- This is equivalent to the default behavior.localpath=spec.dir/tostring(spec.title)
returnpath:with_suffix(".md")
end,
}
}
Environment
NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info
monologconnor
changed the title
:ObsidianRename does not replace the id of renamed fileObsidianRename does not replace the id of renamed file
Aug 20, 2024
🐛 Describe the bug
in file
20240820-old.md
, the original id might be20240820-old
:if i run the command
:ObsidianRename new
, the filename of current file would be changed tonew.md
and all references from other notes will be replaced to[[new]]
, however, theid
property of current file remains20240820-old
:And if then I would like to run
:ObsidianRename 20240820-old
for changing the name back to20240820-old
, plugin would not allow me to to that and reports:New note ID is the same, doing nothing
, due to the id of current file never changes.Even if I want to change to another name, e.g.
:ObsidianRename another_new
, the filename of current file would be changed toanother_new.md
, the id of current file still remains20240820-old
, and the references from all other files would be kept as[[new]]
due to the id does not match, which means backlink of current file could not be resolved.Config
Environment
The text was updated successfully, but these errors were encountered: