tamago324 / lir.nvim

Neovim file explorer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make optional file opener callback function

sunjon opened this issue · comments

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.

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.

xdg-open, or something similar that would do something based on the file/mimetype.

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,

    --...
}

yep, that's great.
Thanks!