From ab96133b471eae64f3e11d87c27505ec60269933 Mon Sep 17 00:00:00 2001 From: ray-x Date: Thu, 10 Mar 2022 12:25:31 +1100 Subject: [PATCH] support config from a lazy function --- lua/navigator/lspclient/attach.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lua/navigator/lspclient/attach.lua b/lua/navigator/lspclient/attach.lua index ec5d246..23c2ddc 100644 --- a/lua/navigator/lspclient/attach.lua +++ b/lua/navigator/lspclient/attach.lua @@ -46,9 +46,17 @@ M.on_attach = function(client, bufnr) log(client.name, 'customized attach for all clients') config.on_attach(client, bufnr) end - if config.lsp and config.lsp[client.name] and config.lsp[client.name].on_attach ~= nil then - log('lsp client specific attach for', client.name) - config.lsp[client.name].on_attach(client, bufnr) + if config.lsp and config.lsp[client.name] then + if type(config.lsp[client.name]) == 'function' then + local attach = config.lsp[client.name]().on_attach + if attach then + attach(client, bufnr) + end + elseif config.lsp[client.name].on_attach ~= nil then + log(client.name, 'customized attach for this client') + log('lsp client specific attach for', client.name) + config.lsp[client.name].on_attach(client, bufnr) + end end if _NgConfigValues.lsp.code_action.enable then