Make optional file opener callback function
sunjon opened this issue · 4 comments
sunjon commented
I'm thinking that if the user can supply a callback that's triggered on selection, what you do with it could be much more versatile, eg. Handing out certain filetypes to external programs.
tamago324 commented
Thanks for the suggestion.
Sorry. Due to my lack of understanding, could you please tell me what specific program you are going to pass it to?
I could not visualize how to use it.
sunjon commented
xdg-open, or something similar that would do something based on the file/mimetype.
tamago324 commented
I think it is possible to use a function to get the information of the target file.
Please let me know if I'm wrong, as I may have missed something.
require 'lir'.setup {
-- ['l'] = actions.edit,
['l'] = function()
local ctx = lir.get_context()
local current = ctx:current()
if string.match(current.value, '[^.]+$') == 'mp4' then
vim.fn.system('xdg-open ' .. current.fullpath)
return
end
actions.edit()
end,
--...
}
sunjon commented
yep, that's great.
Thanks!