Skip to content
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

Show diff for current buffer compared to saved version #164

Closed
JoseConseco opened this issue Apr 22, 2021 · 8 comments · Fixed by #894 · May be fixed by #980
Closed

Show diff for current buffer compared to saved version #164

JoseConseco opened this issue Apr 22, 2021 · 8 comments · Fixed by #894 · May be fixed by #980
Labels
enhancement New feature or request

Comments

@JoseConseco
Copy link

Is your feature request related to a problem? Please describe.
Lets say we do not have tracked file. We we made dome changes to file, and we want to quickly see what lines were edited.

Describe the solution you'd like
Gitsign could higlight/mark somehow edited lines (comparing edited file to non edited version on HDD)

Describe alternatives you've considered
We could maybe run diff of current buffer to original version but signs could be nicer

Additional context
Cool implementation in kde Kate text editor:

KateDiff.mp4

Modified lines are marked yellow, on save they tun green, and then new additional lines are marked yellow again. We can repeat save and new changes turn gree.
I know this may be outside the scope of this plug but still it could be nice feature to have..

@JoseConseco JoseConseco added the enhancement New feature or request label Apr 22, 2021
@lewis6991
Copy link
Owner

This isn't outside the scope, I've been thinking about implementing something like this.

Something I'm a little more interested in is showing signs for changes that are staged which would be useful if you like staging individual hunks which I personally do all the time. So essentially a diff of HEAD against index.

This suggestion is more of the lines of diffing tree against index

@JoseConseco
Copy link
Author

Actually I found this plug:

  • https://github.com/chrisbra/changesPlugin - it does work but user has to enable it manually each time, and it does not have as rich customization as gitsigns but works ok (non lua though). Maybe it could be used for inspiration :)

@JoseConseco
Copy link
Author

I found this plugin: footprint which is good enough for my needs. I will close this then.

@lewis6991
Copy link
Owner

Using footprint is probably a better option since the requirement of signs for modified lines doesn't require git.

@lewis6991
Copy link
Owner

lewis6991 commented Oct 20, 2021

After some talk on Matrix, I'd like to reconsider this at some point.

@clason

@lewis6991 lewis6991 reopened this Oct 20, 2021
lewis6991 added a commit that referenced this issue Oct 2, 2023
The `base` can now be set to `FILE` to diff against the working version.

Resolves #164
lewis6991 added a commit that referenced this issue Oct 2, 2023
The `base` can now be set to `FILE` to diff against the working version.

Resolves #164
lewis6991 added a commit that referenced this issue Oct 2, 2023
The `base` can now be set to `FILE` to diff against the working version.

Resolves #164
@JoseConseco
Copy link
Author

JoseConseco commented Oct 2, 2023

Thx levis, somone figured out how to use it?
Something like:
autocmd IF_Buffer_Not_Tracked : attach(bnumb, ctx = {base='FILE'} ?

https://github.com/lewis6991/gitsigns.nvim/blob/61e0130d4bd255d4a447656ec6e6c11bfeeb20a4/doc/gitsigns.txt#L104C1-L104C1
317c98d

@JoseConseco
Copy link
Author

For now I get something like this :

local git_non_tracked = vim.api.nvim_create_augroup("GitSignTrackNonTracked", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter"}, {
  pattern = "*",
  callback = function()
    print('attaching gitsigngs')
    gitsigns.attach(0, {
      file = vim.fn.expand("%:p"),
      toplevel = vim.fn.expand("%:p"),
      base = 'FILE' })
  end,
  group = git_non_tracked,
})

But it does not seem to work. And I have to find way to detect non tracked buffer/files only. ..

@lewis6991
Copy link
Owner

The files still need to be within a git repo for this to work, otherwise gitsigns can't attach.

Supremist added a commit to Supremist/gitsigns.nvim that referenced this issue Apr 5, 2024
This will allow to highlight usaved changes in buffer, even if file is not in the git repo.
This behaviour needs to be enabled by `attach_to_out_of_repo` config option (false by default).

Resolves lewis6991#164
Supremist added a commit to Supremist/gitsigns.nvim that referenced this issue Apr 9, 2024
This will allow to highlight usaved changes in buffer, even if file is not in the git repo.
This behaviour needs to be enabled by `attach_to_out_of_repo` config option (false by default).

Resolves lewis6991#164
Supremist added a commit to Supremist/gitsigns.nvim that referenced this issue Apr 9, 2024
This will allow to highlight usaved changes in buffer, even if file is not in the git repo.
This behaviour needs to be enabled by `attach_to_out_of_repo` config option (false by default).

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