Skip to content

Do LspAttached autocmd in the buffer its actually called for#558

Open
64-bitman wants to merge 2 commits intoyegappan:mainfrom
64-bitman:patch-1
Open

Do LspAttached autocmd in the buffer its actually called for#558
64-bitman wants to merge 2 commits intoyegappan:mainfrom
64-bitman:patch-1

Conversation

@64-bitman
Copy link

Issue: opening a session file with multiple buffers open would only set bufnr for the buffer that is focused from the start. This prevents buffer local mappings and autocmds from working properly.

Opening a session file with multiple buffers open would only set bufnr for the buffer that is focused from the start.
win_execute doesn't require switching buffers, and LspAttached is called on buffers with windows (from what I can tell)

if exists('#User#LspAttached')
doautocmd <nomodeline> User LspAttached
win_execute(bufwinnr(bnr), 'doautocmd <nomodeline> User LspAttached', silent)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems incorrect, winnr maybe changed or not existed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any other ideas?

Copy link

@mao-yining mao-yining Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's more, if users have set some opt's like 'setl keywordprg', can it be set in the correct buffer?

@GreenCourt
Copy link
Contributor

Thanks for the patch.

I tried it, but it does not trigger the LspAttached (even if the window exists).
And I had to fix the code where the variable silent wasn’t defined in the patch.

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

Successfully merging this pull request may close these issues.

4 participants