-
-
Notifications
You must be signed in to change notification settings - Fork 618
fix(#2395): marks.bulk.move defaults to directory at cursor #2688
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
Conversation
Apologies for the delay in review. This works nicely: bulk_move_get_default_path = function()
return string.format("%s/foo", vim.fn.getcwd())
end, |
Rather than adding another option can we please add this to the API instead - it will be non-breaking. marks.bulk.move({opts}) *nvim-tree-api.marks.bulk.move()*
Prompts for a directory to move all marked nodes into.
Options: ~
• {prompt} (fun(absolute_path: string): string) takes the absolute path of the node under the cursor, returns the absolute path for the prompt This change will be complete and releasable. We can add further functionality to default the prompt to the node under the cursor in a later PR, or this PR if you are motivated. |
@alex-courtis I didn't like appending the options of the whole plugin either, i agree with you that adding the options to the bulk_move function would be a better move. I guess I'm just a little confused on how would user use the updated feature. Would they have to remap |
2bb8091
to
e7dcecb
Compare
@alex-courtis i removed global option and added the option to the bulk move function, could you please take a look. Hope I got your idea correctly |
This works nicely. local function my_bulk_move()
api.marks.bulk.move({
prompt = function(path)
return string.format("%s", path)
end,
})
end
---
vim.keymap.set('n', 'bmv', my_bulk_move, opts('Move Bookmarked')) |
lua/nvim-tree/marks/bulk-move.lua
Outdated
local defaultPrompt = core.get_cwd() | ||
|
||
if type(opts) == "table" and opts.prompt and type(opts.prompt) == "function" then | ||
defaultPrompt = opts.prompt(lib.get_node_at_cursor().absolute_path) |
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.
get_node_at_cursor
must be nil checked
Yes, as per the trivial case above. I am also confused: what is the use case for this? Do you have one? If we can't find one we can simplify this. I'm happy to class the default prompt change as a bug fix. |
@alex-courtis well, my use case is moving the files to the place where the cursor is as default and that's it. As far as simplification goes i would say it would be simpler to have an option that would be a boolean that would enable the bulk_move default prompt to be a node under the cursor and that's it. I don't really see any other use cases for it so maybe a whole custom callback might be an overkill. I honestly don't know if people are used to the default prompt being a cwd, so i would not take it upon myself to introduce a breaking change making node_under_cursor a default, but maybe you have some insight, if you think making node_under_cursor default is a good idea i would agree with you i will make it boolean with default being the way it is in the prod (no breaking changes), but please let me know if you think we should actually change default to being node_under_cursor |
That is completely reasonable. I don't imagine anyone is particularly happy with cwd. Let's just default it and release as Having an optional path and not breaking sounded reasonable in the issue discussion, however not so now, once we've actually built and played with it. |
Enhancement, no use case:
Enhancement, paste parity but YAGNI:
Let's just fix the default; we can add more functionality only if requested. |
sounds great! did that, please take a look |
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.
@alex-courtis you're totally right, I missed it. Now it should work as expected |
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.
Looking good... one more little one:
bmv to root:
E5108: Error executing lua: ...packer/start/fastndead/lua/nvim-tree/marks/bulk-move.lua:22: attempt to index field 'parent' (a nil value)
stack traceback:
...packer/start/fastndead/lua/nvim-tree/marks/bulk-move.lua:22: in function <...packer/start/fastndead/lua/nvim-tree/marks/bulk-move.lua:12>
@alex-courtis oh! this doesn't seem to be reproducible on Mac, that's why i didn't notice that, thanks for pointing it out! i added a check for node_at_cursor.parent before indexing it so the issues should disappear now |
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.
Love your work @fastndead
fixes #2395
Hey! In this PR I attempt to implement #2395 feature request.
The logic for bulk move is rendered unusable for me for the most part because every time I want to perform a bulk move I need to write the whole path from the cwd to the destination. when working with files nested deep inside the file structure this can be frustrating and I almost always retreat to opening the files in the Finder and moving them via system UI. This PR is my attempt to solve this problem.
This is not a breaking change. I add a new option to the configuration, leaving the default behaviour untouched, so the new functionality can be accessed on an opt in basis.