telescope-bibtex.nvim icon indicating copy to clipboard operation
telescope-bibtex.nvim copied to clipboard

[wip] Open file

Open erooke opened this issue 3 years ago • 2 comments

This pr aims to address #20. It is currently rather rough and not quite ready, this is just to track process on it / enable feedback.

Specifically it aims to provide a file opening action where if a bibtex entry has a file field following one of the following forms:

  • file = {/path/to/article.pdf}
  • file = {name:/path/to/article.pdf:PDF}
  • file={name:/path/to/article.pdf:PDF;name:/path/to/supplementary_materials.pdf:PDF}

we should be able to open it in a user specified reader.

Currently we only work with the second style of file fields. That is fields of the form name:/path/to/article:ext given a config entry called reader like so:

require('telescope').setup {
  extensions = {
    bibtex = {
      reader = {
        djvu = 'evince',
        pdf  = 'zathura'
      },
    }
  }
}

it will open djvu files in evince and pdf files in zathura. Currently it is rather bodged together and will not work if there is a : in the path anywhere.

Still left to todo:

  • [x] handle file specifications of the form {/path/to/article}
  • [ ] handle multiple files (should it spawn another picker to allow you to choose?)
  • [x] properly handle files with : in their paths
  • [x] handle the case where the user has not specified a reader for a filetype

~~maybe handle remote files? For instance something likefile = {:http\://arxiv.org/pdf/2003.05580v3:PDF}~~

erooke avatar Jan 26 '22 19:01 erooke

Maybe you can use xdg-open to find a default reader? I do not know whether Windows has something similar, but this would be good to have as a fallback. This would also address remote files which would be opened in the browser.

noahares avatar Jan 27 '22 09:01 noahares

Ah yeah, I totally forgot xdg-open existed. That's perfect. I'm thinking we shouldn't really handle remote files differently for the time being. As you pointed out xdg-open will handle them and some readers (evince in particular) will also handle remote files. It doesn't feel worth the extra complexity for now.

erooke avatar Jan 27 '22 15:01 erooke