This repository was archived by the owner on Sep 20, 2023. It is now read-only.
This repository was archived by the owner on Sep 20, 2023. It is now read-only.
Closed
Description
Currently custom providers allow us to execute arbitrary logic inside a provider function.
For 'heavy' providers there is no control on when the provider function is executed.
For example, given this provider:
trailing_whitespace = function()
-- Check for trailing whitespace
-- Must not have space after the last non-whitespace character
local trailing = fn.search('\\s$', 'nw')
local trailing_component = trailing ~= 0 and '[' .. trailing .. ']' .. 'trailing' or ''
-- Check for mixed indent
-- Must be all spaces or all tabs before the first non-whitespace character
local mixed_indent = fn.search('\v(^\t+ +)|(^ +\t+)', 'nw')
local mixed_component = mixed_indent ~= 0 and '[' .. mixed_indent .. ']' .. 'mixed indent' or ''
-- Pick first non empty
local components = {mixed_component, trailing_component}
for _, c in pairs(components) do
if c ~= '' then
return c
end
end
return ''
end
I would like to run this provider function only on CursorHold,BufWritePost autocmds.
Is there any better way than returning a global lua variable that gets updated on these events?