nvimdev / dashboard-nvim

vim dashboard
MIT License
2.3k stars 187 forks source link

feat(hyper): footer support function type #322

Closed Coien-rr closed 1 year ago

Coien-rr commented 1 year ago

make hyper footer support function type
additionally tiny change to #289

glepnir commented 1 year ago

this might be not work with dashboard command you should dump it in cache.

Coien-rr commented 1 year ago

I try to fix it and use os.time() to test it, it seems work fine. and i have an additional question that if set footer as

footer = {
        "test",
        "123",
        "test",
      },

this first item will not been set highlight like that

image

Is this for more customization freedom, or just set for blank line

glepnir commented 1 year ago

it fixed just now. did you try run it from dashboard comand ? you don't cache it in cache_opts function . so this might be broken on command.

Coien-rr commented 1 year ago

i use Dashboard to return dashboard from file window no error and the change in the result of the os.time() proves that the function was called again

you don't cache it in cache_opts function .

yep ... i just try to call function again...(maybe it is not great enough for unchange result :(

glepnir commented 1 year ago

you can take a look at the cache_opts function . do like what i do in this function. when it's a function dump it to a byte code then dashboard can cache it to file. otherwise it will report an error.

Coien-rr commented 1 year ago
if self.opts.config.footer and type(self.opts.config.footer) == 'function' then
    ---@diagnostic disable-next-line: param-type-mismatch
    local dump = assert(string.dump(self.opts.config.footer))
    self.opts.config.footer = dump
end

i found this snippet in cache_opts function, so you have finished serializing the function, I just need to reload the function and execute it by loadstring() :)

glepnir commented 1 year ago

you found it :) then do it.

Coien-rr commented 1 year ago

sorry :(, i don't understand your idea In my understanding, a function dump it to a byte code as first enter, When using Dashboard to retrieve it from the cache again, it has become a string, so it can be executed as long as it is converted to func by loadstring() And you've already done the transcode storage task, I don't think I'll have to do it again 😵‍💫

glepnir commented 1 year ago

hmm i forget i already dump it…