From 1e74f3deabefdbc2e5ebc4f49e08950f3c234c20 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Wed, 21 Aug 2024 09:16:50 -0500 Subject: [PATCH] plugins/lsp: make lspOnAttach available globally Allows plugins to utilize the global nixvim table to access the lsp on attach function and prevent needing to filter attribute set or manage the property explicitly in lua. --- plugins/lsp/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/lsp/default.nix b/plugins/lsp/default.nix index 65f9aa83..0efae272 100644 --- a/plugins/lsp/default.nix +++ b/plugins/lsp/default.nix @@ -225,7 +225,8 @@ in ${cfg.preConfig} local __lspServers = ${helpers.toLuaObject cfg.enabledServers} - local __lspOnAttach = function(client, bufnr) + -- Adding lspOnAttach function to nixvim module lua table so other plugins can hook into it. + _M.lspOnAttach = function(client, bufnr) ${updateCapabilities} ${cfg.onAttach} @@ -239,7 +240,7 @@ in end local __setup = ${runWrappers cfg.setupWrappers "{ - on_attach = __lspOnAttach, + on_attach = _M.lspOnAttach, capabilities = __lspCapabilities() }"}