Closed devansh08 closed 11 months ago
I'm assuming what I'm doing should only stage the hunks I picked. Am I missing or misunderstanding anything here ?
Yes, you've understood the process correctly. But I can't reproduce this. Please use the minimal config from the report template properly. It's there to help both you and me figure out whether your problem is related to your setup or to the plugin. You use the minimal config by saving it anywhere on your disk and then calling nvim with:
$ nvim --clean -n -u path/to/diffview_mini.lua
Hey, seems like I misunderstood the purpose of the minimal config in the template :sweat_smile:
It does work perfectly with the minimal config. Adding the diffview
config I shared above also does work. Seems like some other plugin or my own config is breaking this.
I'll try and incrementally check what might be breaking this. But any pointers or better approach to check this are welcome :)
Thanks!
Aaaand I've found the issue in my config :)
I've an autocmd that runs jdtls.organize_imports()
on filetype java
that's triggered on BufWritePre
. So I guess that's interfering with diffview telling what to write to index.
I'll probably look for ways to check how to identify if I'm in a DiffView type of buffer. Pls let me know if you have any suggestions for that :)
Thanks!
Edit: In case anyone lands in this situation, you can use hooks like view_opened
, view_enter
, view_closed
and view_leave
to figure out when you are in diffview mode.
I'm glad you figured it out.
I'll probably look for ways to check how to identify if I'm in a DiffView type of buffer. Pls let me know if you have any suggestions for that :)
Thanks!
Edit: In case anyone lands in this situation, you can use hooks like
view_opened
,view_enter
,view_closed
andview_leave
to figure out when you are in diffview mode.
You don't need to use hooks for this. As far as I can tell, what you actually want to assert is that the file path you're writing to could be a real path on your file system. In that case I assume that in most cases it would be enough to check that the file's parent directory exists:
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.java",
callback = function(e)
-- Ensure that the parent dir is a real path
if vim.fn.isdirectory(vim.fn.fnamemodify(e.file, ":h")) == 1 then
jdtls.organize_imports()
end
end,
})
Description
I'm trying to stage specific hunks in a file by following the steps in this section. But on using![asciicast](https://asciinema.org/a/ZfJxCwsiLdl1m4k3GnzluX3t2.svg)
diffput
on some hunks in the unstaged changes buffer and then saving with:w
on the index buffer, the entire file's changes get staged. Recording of this behavior: https://asciinema.org/a/ZfJxCwsiLdl1m4k3GnzluX3t2I'm assuming what I'm doing should only stage the hunks I picked. Am I missing or misunderstanding anything here ?
For the config, I'm using the default example one given in the README. I'm still exploring this plugin and so I'm not fully sure yet if some part of the config is messing things for me. Do let me know if something needs to be checked there.
Thanks!
Expected behavior
Stage only the hunks picked using
diffput
Actual behavior
Stages the entire file
Steps to reproduce
:DiffviewOpen
:diffput
for some hunks from the right side buffer:w
in the left side bufferRecording of the behavior: https://asciinema.org/a/ZfJxCwsiLdl1m4k3GnzluX3t2
Health check
Output of
``` ============================================================================== diffview: require("diffview.health").check() Checking plugin dependencies ~ - OK nvim-web-devicons installed. Checking VCS tools ~ - The plugin requires at least one of the supported VCS tools to be valid. - OK Git found. - OK Git is up-to-date. (2.41.0) - WARNING Configured `hg_cmd` is not executable: 'hg' ```:checkhealth diffview
Log info
Relevant info from
``` [ERROR 2023-08-13 23:62:42.960 +0530] ...lazy/diffview.nvim/lua/diffview/vcs/adapters/hg/init.lua:50: [HgAdapter] Configured `hg_cmd` is not executable: 'hg' [INFO 2023-08-13 23:66:09.082 +0530] ...local/share/nvim/lazy/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen [INFO 2023-08-13 23:66:09.197 +0530] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 38 files successfully (72.390 ms) [INFO 2023-08-13 23:66:54.756 +0530] ...local/share/nvim/lazy/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen [INFO 2023-08-13 23:66:54.856 +0530] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 38 files successfully (63.150 ms) [INFO 2023-08-13 23:67:28.318 +0530] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 39 files successfully (55.339 ms) [INFO 2023-08-13 23:67:28.850 +0530] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 39 files successfully (48.407 ms) ```:DiffviewLog
Neovim version
Operating system and version
Linux 6.4.10-arch1-1 x86_64 GNU/Linux
Minimal config