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.
This commit is contained in:
Austin Horstman 2024-08-21 09:16:50 -05:00
parent 8a272143ee
commit 1e74f3deab
No known key found for this signature in database

View file

@ -225,7 +225,8 @@ in
${cfg.preConfig} ${cfg.preConfig}
local __lspServers = ${helpers.toLuaObject cfg.enabledServers} 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} ${updateCapabilities}
${cfg.onAttach} ${cfg.onAttach}
@ -239,7 +240,7 @@ in
end end
local __setup = ${runWrappers cfg.setupWrappers "{ local __setup = ${runWrappers cfg.setupWrappers "{
on_attach = __lspOnAttach, on_attach = _M.lspOnAttach,
capabilities = __lspCapabilities() capabilities = __lspCapabilities()
}"} }"}