Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork635
feat(#1851): persist bookmarks#3033
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Conversation
alex-courtis left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This looks great! I'll give it a full review and test in the next few days.
Initial thoughts:
- Should we be using
vim.json.encodeinstead of the fn ? - Please don't move existing methods (constructor, toggle)
- This should be an optional feature in
nvim-tree-opts, disabled by default - This needs checking and safety
- Use a pcall or similar to prevent an error being raised
- Report failures to the user
This comment has been minimized.
This comment has been minimized.
alex-courtis commentedFeb 16, 2025
I'm happy with this providing the above is addressed. |
xiantang commentedFeb 16, 2025
@alex-courtis updated |
alex-courtis commentedFeb 16, 2025
Proposed help, please correct indexes and run ============================================================================== 5.19 OPTS: BOOKMARKS*nvim-tree-opts-bookmarks**nvim-tree.bookmarks.persist*Persist bookmarks to a json file containing a list of absolute paths.Type:`boolean` |`string`, Default:`false``true`: use default: `stdpath("data") .. "/nvim-tree-bookmarks.json"``string`: absolute path of your choice. |
alex-courtis left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is looking fantastic! It's very robust and works well.
Please
| end | ||
| file:write(vim.json.encode(data)) | ||
| file:close() | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| end | |
| end | |
| else | |
| notify.warn("Invalid marks.save_path, disabling persistence:"..errmsg) | |
| opts.marks.enable_persistence=false |
Printerrmsg and disable persistence on a bad path, permission etc.
[NvimTree] Invalid marks.save_path, disabling persistence: /home/alex/marks.json: Permission denied
[NvimTree] Invalid marks.save_path, disabling persistence: /home/alexxxxxxxxxxxxxxxxxxxx/mar ks.json: No such file or directory
| end | ||
| localstorepath=get_save_path(opts) | ||
| localfile=io.open(storepath,"w") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| localfile=io.open(storepath,"w") | |
| localfile,errmsg=io.open(storepath,"w") |
| ifexplorerthen | ||
| for_,nodeinpairs(explorer.marks:list())do | ||
| status.bookmarks[node.absolute_path]=node.type | ||
| forkey,nodeinpairs(explorer.marks.marks)do |
alex-courtisFeb 16, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is private and should not be accessed, seeCI failure
Please useMarks:list()
I know this is not your code, but we can clean this up by usingself.explorer (guaranteed not null) instead of calling core.
Edit: it appears thatself.explorer.marks:list() is now returning an array of booleans instead of an array of nodes.
| marks= { | ||
| enable_persistence=false, | ||
| save_path=nil,-- nil will default to stdpath("data") .. "/nvim-tree-bookmarks.json" | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| marks= { | |
| enable_persistence=false, | |
| save_path=nil,-- nil will default to stdpath("data") .. "/nvim-tree-bookmarks.json" | |
| }, | |
| bookmarks= { | |
| persist=false, | |
| }, |
Rather than a toggle and path, we can use just one option that is boolean or string. This is consistent with other options.
We then add the type explitictly so that it may be validated. Add toACCEPTED_TYPES:
bookmarks= {persist= {"boolean","string"}, },
alex-courtis commentedFeb 22, 2025
I've added you to this repository so that you may push branches and run CI in the future. |
alex-courtis commentedFeb 22, 2025
Apologies, I was not clear about my request tosimplify options andproposed help Attached is a patch with those changes gunzip simplify_options.diff.gzgit apply simplify_options.diff |
bburgess19 commentedMay 16, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@xiantang I was looking for this feature! Could you kindly add the patched changes so we can all benefit from your implementation? Thank you and@alex-courtis for working on this :) |
alex-courtis commentedMay 18, 2025
If we don't hear back from@xiantang I would be most grateful for a new PR from you@bburgess19 with all the changes. |
alex-courtis commentedJun 14, 2025
Would you like me to complete this and merge it? |
xiantang commentedJun 14, 2025 via email
ok i will continue it …On Sat, 14 Jun 2025 at 3:29 PM, Alexander Courtis ***@***.***> wrote: *alex-courtis* left a comment (nvim-tree/nvim-tree.lua#3033) <#3033 (comment)>@xiantang <https://github.com/xiantang> Would you like me to complete this and merge it? — Reply to this email directly, view it on GitHub <#3033 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AIHB3TZ3Y5GOG3S2QK5HYUT3DPFNZAVCNFSM6AAAAABUBK6ZJGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNZSGQZDGOBVGY> . You are receiving this because you were mentioned.Message ID: ***@***.***> |
xiantang commentedJun 14, 2025 via email
sorry for misunderstanding, u can complete this merge request. …On Sat, 14 Jun 2025 at 3:29 PM, Alexander Courtis ***@***.***> wrote: *alex-courtis* left a comment (nvim-tree/nvim-tree.lua#3033) <#3033 (comment)>@xiantang <https://github.com/xiantang> Would you like me to complete this and merge it? — Reply to this email directly, view it on GitHub <#3033 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AIHB3TZ3Y5GOG3S2QK5HYUT3DPFNZAVCNFSM6AAAAABUBK6ZJGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNZSGQZDGOBVGY> . You are receiving this because you were mentioned.Message ID: ***@***.***> |
alex-courtis commentedJun 15, 2025
I would be very grateful if you completed. You deserve all the credit for this great feature. |
Uh oh!
There was an error while loading.Please reload this page.
close#1851 (comment)