-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto rename file by note title on save #27
Comments
You can use vim.bo.filetype == "markdown" and require("zk.util").notebook_root(vim.api.nvim_buf_get_name(0)) ~= nil to check if the current buffer is a ZK note. Instead of checking |
Can't you use https://github.com/mickael-menu/zk-nvim/blob/main/lua/zk/util.lua#L7 and the function below it as well? |
Right now there's no built-in way to synchronously get the title of a note. But you can use the async api: function get_buf_zk_title()
local filename = vim.api.nvim_buf_get_name(0)
require("zk.api").list(filename, { select = { "title" }, hrefs = { filename } }, function(notes)
local title = notes[1].title
-- do something with the title here
end)
end |
@kabouzeid @eric-hansen Thanks for the help. I didn't think about the |
For the original feature request, I think this would best be served with a "rename" refactoring code action in the |
This would be a code action that renames the current file to match the note title? Btw, renaming files is possible via LSP ( |
No I thought of two different refactorings:
Both of these would update the links in other notes if possible. This would be a I don't think we need a command dedicated to update the file to match the current note title. If there's a refactoring code action, you should use it to retitle and propagate the changes. |
I don't think
|
And yes the idea for changing the title is also to update the filename and also all the links. |
Ah yes, I confused
|
Yes that's right. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 5 days. |
This issue was closed because it has been stalled for 5 days with no activity. |
Any updates on this? Thx guys!🙏 |
@piotryordanov It's currently not supported. Given I don't have much time for |
@mickael-menu no worries at all. |
I created a new issue to track this feature: zk-org/zk#200 |
I wrote a quick spec for the rename/move features here: zk-org/zk#200 (comment) Feel free to review and comment if you're interested in this! |
Hi, I want to auto rename the file based on note title on saving buffer, if title changed. And only rename if current buffer is a note.
Is there any buffer local flag which can tell if current buffer is a ZK note buffer?
The text was updated successfully, but these errors were encountered: