Skip to content

plugins.lsp: alias onAttach to new lsp.onAttach #3295

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 7, 2025

Conversation

MattSturgeon
Copy link
Member

Follow up to #3280

Simplify the impl by doing global on-attach logic in lsp.onAttach (i.e. a LspAttach autocmd) instead of adding lua lines to each server's individual on_attach callback function.

This is effectively a mkAliasOptionModule [ "plugins" "lsp" "onAttach" ] [ "lsp" "onAttach" ] alias, but it is only applied when plugins.lsp.enable is true.

@MattSturgeon MattSturgeon force-pushed the plugins/lsp-on-attach branch 3 times, most recently from 3d88184 to dbac55c Compare May 7, 2025 13:38
Comment on lines -85 to -93
# If nvim-lspconfig is enabled:
(mkIf config.plugins.lsp.enable {
# Use the same `on_attach` callback as for the other LSP servers
plugins.rustaceanvim.settings.server.on_attach = mkDefault ''
function(client, bufnr)
return _M.lspOnAttach(client, bufnr)
end
'';
})
Copy link
Member Author

@MattSturgeon MattSturgeon May 7, 2025

Choose a reason for hiding this comment

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

The actual change in this file is removing:

# If nvim-lspconfig is enabled:
(mkIf config.plugins.lsp.enable {
  # Use the same `on_attach` callback as for the other LSP servers
  plugins.rustaceanvim.settings.server.on_attach = mkDefault ''
    function(client, bufnr)
      return _M.lspOnAttach(client, bufnr)
    end
  '';
})

Otherwise, the large diff is just removing the now-redundent mkMerge, so it may be easier to read with whitespace changes hidden.

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.

Great !!!

This simplifies the impl by doing global on-attach logic in a
`LspAttach` autocmd instead of adding lua lines to each server's
individual `on_attach` callback.

This is effectively a `mkAliasOptionModule` alias, other than the alias
only being applied when `plugins.lsp.enable`.
@MattSturgeon MattSturgeon force-pushed the plugins/lsp-on-attach branch from dbac55c to 5c52e8f Compare May 7, 2025 13:52
@MattSturgeon

This comment was marked as resolved.

This comment has been minimized.

This comment has been minimized.

@MattSturgeon

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

mergify bot commented May 7, 2025

This pull request, with head sha 5c52e8f9e438b6850f2c7a6e4bf3f967a3a699fd, 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 5c52e8f9e438b6850f2c7a6e4bf3f967a3a699fd 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 plugins/lsp-on-attach, this means GitHub will fail to detect the merge.

@mergify mergify bot merged commit 5c52e8f into nix-community:main May 7, 2025
4 checks passed
@mergify mergify bot temporarily deployed to github-pages May 7, 2025 19:18 Inactive
@MattSturgeon MattSturgeon deleted the plugins/lsp-on-attach branch May 7, 2025 19:19
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.

2 participants