feat: avoid global variable use (#1813)

This commit is contained in:
Josef Litoš 2024-03-21 18:56:07 +01:00 committed by GitHub
parent 04e0ca376d
commit a1b4ef08c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -24,7 +24,7 @@ feedkeys.call = setmetatable({
if callback then
local id = misc.id('cmp.utils.feedkeys.call')
self.callbacks[id] = callback
table.insert(queue, { keymap.t('<Cmd>call v:lua.cmp.utils.feedkeys.call.run(%s)<CR>'):format(id), 'n', true })
table.insert(queue, { keymap.t('<Cmd>lua require"cmp.utils.feedkeys".run(%s)<CR>'):format(id), 'n', true })
end
if is_insert then
@ -42,12 +42,12 @@ feedkeys.call = setmetatable({
end
end,
})
misc.set(_G, { 'cmp', 'utils', 'feedkeys', 'call', 'run' }, function(id)
feedkeys.run = function(id)
if feedkeys.call.callbacks[id] then
feedkeys.call.callbacks[id]()
feedkeys.call.callbacks[id] = nil
end
return ''
end)
end
return feedkeys