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

Question about on_attach being called early #1147

Closed
tronikelis opened this issue Nov 17, 2024 · 2 comments
Closed

Question about on_attach being called early #1147

tronikelis opened this issue Nov 17, 2024 · 2 comments

Comments

@tronikelis
Copy link

Hello,

I see in the docs it states

Custom mappings can be defined in the on_attach callback

And in the readme I see examples of setting a lot of keymaps in the on_attach callback.

Problem

What does not make sense to me is that at the time of calling vim.keymap or any other keymap adding api, those keymaps wouldn't work, because on_attach is called before actually computing hunks

It's called here

if config.on_attach and config.on_attach(cbuf) == false then

But for keymaps to work this update needs to finish

-- Initial update
manager.update(cbuf)

As I understand it now the on_attach is meant to be used to skip attaching to some buffers, so moving it under update wouldn't make sense at this point, thus I propose adding a new config, which I tried to do in this PR #1146

@tronikelis tronikelis changed the title Question about on_attach being called too early Question about on_attach being called early Nov 17, 2024
@xzbdmw
Copy link
Contributor

xzbdmw commented Nov 17, 2024

I think GitSignsUpdate would be called after attaching first time (I forgot this autocommand before).

@tronikelis
Copy link
Author

Yep, GitSignsUpdate works thanks @xzbdmw , I am closing this then

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

No branches or pull requests

2 participants