Skip to content

Git Actions #2474

Description

@hinell

function M.rename(node, to)
local notify_from = notify.render_path(node.absolute_path)
local notify_to = notify.render_path(to)
if utils.file_exists(to) then
notify.warn(err_fmt(notify_from, notify_to, "file already exists"))
return
end
events._dispatch_will_rename_node(node.absolute_path, to)
local success, err = vim.loop.fs_rename(node.absolute_path, to)
if not success then
return notify.warn(err_fmt(notify_from, notify_to, err))
end
notify.info(notify_from .. "" .. notify_to)
utils.rename_loaded_buffers(node.absolute_path, to)
events._dispatch_node_renamed(node.absolute_path, to)
end

Describe the solution you'd like

The e and r don't respect git repo: by renaming something we loose track of file path history. I would like to be able to rename filepath by using git mv (instead of system command) in order to keep track of file renames:

git mv <src_path> <dst_path>

Currently, nvim-tree doesn't provide this feature forcing me to rename file by using git manually.

Describe alternatives you've considered

Running !git mv % <path_no_new_name> is rather clunky...
Running !git -A <path_no_new_name> is rather clunky and not something I want...

Can this functionality be implemented utilising API?

NO.

Additional context

I'ts difficult to easily contribute API feature, cause:

  1. The runner is not a generic lua wrapper for git:
  • it's hard-wired to run only single git subcommand: status
  • quite intricate interally - it's hard to extend
  • no docs/comments
  1. This repo has no dedicated git wrapper for running & handling git output (there is a dedicated fast libgit2 lua bindings btw)
  2. Intent of nvim-tree.git is unclear

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions