Skip to content

modules/lsp/onAttach: fix bufnr and document event arg #3321

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

Merged
merged 1 commit into from
May 13, 2025

Conversation

MattSturgeon
Copy link
Member

@MattSturgeon MattSturgeon commented May 13, 2025

Fixes #3319

See :h event-args and :h LspAttach

I'm unsure whether we should consider this advice from the docs:

Note: If the LSP server performs dynamic registration, capabilities may be registered any time after LspAttach. In that case you may want to handle the "registerCapability" event.

Example:

vim.lsp.handlers['client/registerCapability'] = (function(overridden)
  return function(err, res, ctx)
    local result = overridden(err, res, ctx)
    local client = vim.lsp.get_client_by_id(ctx.client_id)
    if not client then
      return
    end
    -- Call your custom on_attach logic...
    -- my_on_attach(client, vim.api.nvim_get_current_buf())
    return result
  end
end)(vim.lsp.handlers['client/registerCapability'])

But that's out of scope for this PR. See #3323

@MattSturgeon MattSturgeon requested a review from a team May 13, 2025 17:46
Copy link
Member

@GaetanLepage GaetanLepage left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@MattSturgeon

This comment was marked as resolved.

This comment was marked as resolved.

Copy link
Contributor

mergify bot commented May 13, 2025

This pull request, with head sha cbd5f7de5e93cf501526cb64e64b1d4936fe9c45, has been successfully merged with fast-forward by Mergify.

This pull request will be automatically closed by GitHub.

As soon as GitHub detects that the sha cbd5f7de5e93cf501526cb64e64b1d4936fe9c45 is part of the main branch, it will mark this pull request as merged.

It is possible for this pull request to remain open if this detection does not happen, this usually happens when a force-push is done on this branch lsp/fix-onAttach-bufnr, this means GitHub will fail to detect the merge.

@mergify mergify bot merged commit cbd5f7d into nix-community:main May 13, 2025
4 checks passed
@mergify mergify bot temporarily deployed to github-pages May 13, 2025 20:42 Inactive
@MattSturgeon MattSturgeon deleted the lsp/fix-onAttach-bufnr branch May 13, 2025 20:57
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.

[BUG] LSP module onAttach
2 participants