stevearc / oil.nvim

Neovim file explorer: edit your filesystem like a buffer
MIT License
3.84k stars 110 forks source link

feature request: use `git mv` when renaming files so that git can reflect file name changes #290

Closed LeviticusNelson closed 5 months ago

LeviticusNelson commented 8 months ago

Did you check existing requests?

Describe the feature

Oil should file name changes to git if applicable.

Provide background

I was using Oil to capitalize some file names, and it never detected the change on git. I learned to use git mv file.js File.js to apply those changes on git.

What is the significance of this feature?

nice to have

Additional details

No response

stevearc commented 8 months ago

I've seen this request before, and I don't understand why it's needed. Maybe you could help me understand your workflow better. It would take a good bit of work, but I could make it so that every file operation has an accompanying git add, git mv, or git rm. That would ensure that all the modifications made in oil will be immediately staged in git. But if you want to stage all changes, why not just run git add --all .? I don't see how automatically staging these changes improves anything, so I must be missing something.

LeviticusNelson commented 8 months ago

@stevearc I use lazygit to stage, discard, and commit changes, but it does not detect a file name change for me to stage that specific change. I think a good option would be to have an additional popup that would confirm those changes to git by doing git mv.

bew commented 8 months ago

Are you on Windows? Or more generally do you use a filesystem that makes no distinction between lowercase and uppercase letters? That would be a reason why git doesn't detect changes, and why explicit git mv .. are necessary here

LeviticusNelson commented 8 months ago

@bew I'm on mac

DavidGamba commented 8 months ago

I have a number of files that I don't commit nor write ignore rules for because they don't belong to the current commit I am working on, having git add --all wouldn't work for my workflow. I would love to have oil use git mv when renaming files and folders.

Oil should file name changes to git if applicable.

When applicable should check if the file or folder is already tracked by git then use git mv, if not then use your normal mv command.

stevearc commented 7 months ago

I will do a bit of experimentation with this to see how it feels, and if it can be done without adding too much complexity. I am wary of doing anything with git because I'm worried it will become a slippery slope of requests to add a whole slew of git features, which I definitely don't want to have to do or maintain. Will report back once I try this out.

LunarLambda commented 7 months ago

I think a git status column would be really nice to have. I don't necessarily need it to track file changes automatically, as I tend to use mv and then manually git add things.

Everything else could be as simple as binding something like gga to :!git add <cWORD> or some equivalent.

edit: found https://github.com/refractalize/oil-git-status.nvim :)

Think git-oriented bindings are probably the way to go, and shouldn't be hard to do

stevearc commented 5 months ago

I have added experimental support for this. There may be bugs around the edge cases, and I don't guarantee that the feature will stay. You can enable it by changing the functions in the git config option.

https://github.com/stevearc/oil.nvim/blob/1f05774e1c2dbc1940104b5c950d5c7b65ec6e0b/lua/oil/config.lua#L103-L115