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

Ability to disable per-buffer #56

Closed
andrewferrier opened this issue Feb 13, 2021 · 8 comments
Closed

Ability to disable per-buffer #56

andrewferrier opened this issue Feb 13, 2021 · 8 comments
Labels
enhancement New feature or request

Comments

@andrewferrier
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Thanks for making gitsigns.nvim! I used to use vim-gitgutter but gitsigns.nvim is almost a complete drop-in replacement and is much faster/more efficient.

One feature I've noticed that's missing though; sometimes I used to disable signs on a per-buffer basis using :GitGutterDisable. It would be really nice to have an equivalent of this in gitsigns.

Describe the solution you'd like
Either a command (like :GitSignsDisableBuffer, probably with a corresponding :GitSignsEnableBuffer) or a buffer-local variable (e.g. b:git_signs_disable=1) which can turn off the signs in a buffer.

Describe alternatives you've considered
One alternative is to go back to gitgutter, obviously don't want to do that. Not aware of any other alternatives.

Thanks for all your hard work on this plugin!

@andrewferrier andrewferrier added the enhancement New feature or request label Feb 13, 2021
@lewis6991
Copy link
Owner

Given gitsigns is a lua plugin, I'd like to implement this enhancement as an exposed lua function.

It would be used as:

:lua require('gitsigns').detach()

We could implement this via a command or buffer local variable, but up until now I've tried to avoid introducing these and have only had lua as the interface to the plugin.

Would this solution be acceptable or would you much prefer this wrapped in a command for convenience?

lewis6991 added a commit that referenced this issue Feb 13, 2021
Enhancement for #56
lewis6991 added a commit that referenced this issue Feb 13, 2021
Enhancement for #56
lewis6991 added a commit that referenced this issue Feb 13, 2021
Enhancement for #56
@andrewferrier
Copy link
Contributor Author

That definitely makes sense to me, and in principle certainly works for my purposes. I tested your latest version with the commits above, though (and thanks for doing that so quickly!), and it doesn't quite seem to work as expected. If I open a file that already has some changes (versus the git state), which gitsigns then of course highlights, and I invoke :lua require('gitsigns').detach, what seems to happen is that those existing changes continue to be marked in the signcolumn. New changes that I make from that point onwards are not highlighted, but I was expecting that all of the gitsigns signs would disappear from the signcolumn immediately.

@lewis6991
Copy link
Owner

Ah, thanks for testing. We just need to delete all the signs in that buffer.

Will update soon.

lewis6991 added a commit that referenced this issue Feb 14, 2021
@lewis6991
Copy link
Owner

I think this is resolved now. Please reopen otherwise.

@andrewferrier
Copy link
Contributor Author

Yes, this seems to work for me now. Thanks!

lewis6991 added a commit that referenced this issue Aug 7, 2021
Enhancement for #56
lewis6991 added a commit that referenced this issue Aug 7, 2021
@pwntester
Copy link

Im trying to disable gitsigns on markdown buffers by running a BufEnter autocommand that runs :lua require('gitsigns').detach(). This works, but as soon as I save the buffer, the signs are showed again. I tried to detach them again on BufWritePost but its not working. Is there a permanent way to prevent gitsigns to attach to a markdown buffer?

Ideally, I would like to be able to prevent attaching gitsigns to md buffers at all (buffer enter, write, etc) rather than having to detach it

Thanks!

@lewis6991
Copy link
Owner

Take a look at :help gitsigns-config-on_attach. You can use this to prevent attaching to a buffer.

@pwntester
Copy link

@lewis6991 oh, I missed that. Thank!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants