windwp/windline.nvim

[Defect] windline.nvim/lua/wlanimation/components/job.lua:122: attempt to index field 'buffer_auto_funcs' (a nil value)

ray-x opened this issue · 4 comments

ray-x commented

Code:

local job_utils = require('wlanimation.components.job')

basic.job_event = {
  hl_colors = { 'green', 'black_light' },
  text = job_utils.job_event('sleep 4', 'BufEnter', 'job_sleep', function(data)
    -- ....
  end),
}

error:

Error executing vim.schedule lua callback: ...im/lazy/windline.nvim/lua/wlanimation/components/job.lua:122: attempt to index field 'buffer_auto_funcs' (a nil value)
stack traceback:
        ...im/lazy/windline.nvim/lua/wlanimation/components/job.lua:122: in function 'job_event'

sorry i change the cache_utils so it will not work now.
if you don't want a spinner you can combine cache_utils and uv_utils similar to what i do with git_rev https://github.com/windwp/windline.nvim/blob/master/lua/windline/components/git_rev.lua

ray-x commented

Does this mean the wlanimation.components.job is deprecated as well?
I would love to keep the animations.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

I don't want to deal with job you should use another library to manage job.
i create a small component to display loading spinner.

local loading = require('wlanimation.components.loading').create_loading()
local is_loading = true

local windline = require('windline')
windline.add_component({
    name = "loading",
    hl_colors = { 'white', 'NormalBg' },
    text = function() return loading(is_loading) end
}, {
    name = 'loading',
    position = 'right',
    auto_remove = true
})

vim.api.nvim_create_user_command('ToggleLoading', function()
    is_loading = not is_loading
end, {})