telescope-bibtex.nvim
telescope-bibtex.nvim copied to clipboard
[wip] Open file
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}
~~
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.
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.