nvim-telescope / telescope-bibtex.nvim

A telescope.nvim extension to search and paste bibtex entries into your TeX files.
MIT License
112 stars 16 forks source link

Is it any opportunity to open attached pdf file from bibtex... #20

Open VolkovIlia opened 2 years ago

VolkovIlia commented 2 years ago

I have bibtex file that is generated with link to pdf document (jabref and papers-cli generate it). Is it any opportunity to bind key for opening it while I search it in telescope... ?

@article{amini_rezaei2015,
 author = {Amini, Ehsan and Rezaei, Mehran},
 doi = {10.1016/s1872-2067(15)60922-6},
 file = {:/home/volk/Library/PDFs/2015/amini_rezaei2015.pdf:pdf},
 journal = {Chinese Journal of Catalysis},
 month = {10},
 number = {10},
 pages = {1711-1718},
 publisher = {Elsevier BV},
 title = {Preparation of mesoporous Fe-Cu mixed metal oxide nanopowder as active and stable catalyst for low-temperature CO oxidation},
 url = {http://dx.doi.org/10.1016/s1872-2067(15)60922-6},
 volume = {36},
 year = {2015}
}
noahares commented 2 years ago

If telescope supports specifying result-sensitive actions this should be possible. However this is not a feature I have in mind for this plugin (at least right now, as I am busy doing other stuff and development of new features for this project is paused). I might look into it another time if more such actions come up. For now I see this more as a hack for a very specific use-case.

You can implement it yourself and then either open a PR or use it locally, of course.

noahares commented 2 years ago

I would start here: telescope docs under replace_if. There you can specify the condition and change the action.

erooke commented 2 years ago

I have bodged together an implementation for this over at https://github.com/erooke/telescope-bibtex.nvim/tree/open-file. Simply specify the pdf reader in the config:

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

then call Telescope bibtex open and select what you want opened.

Currently has a quirk where if you close the terminal hosting vim before closing vim the reader closes. I'm not sure how to stop that happening.

noahares commented 2 years ago

This looks good. How exactly is the format of the file field in the entry? To solve the problem of the viewer closing: plenary.Job takes a table of arguments to pass to libUV. LibUV has the option detached which acts like a disown and would keep the viewer alive even after neovim exits. (see options after uv.spawn(...) at libUV

erooke commented 2 years ago

This looks good. How exactly is the format of the file field in the entry?

That is a great question I wish I had an answer to. I was unable to find a good description of what was going on. The following is my best guess based on searching through all the bib files in the jabref repository:

The current implementation deals with very little:

For my use case all of that is true but it's the main reason I hadn't submitted it as a pull request yet as it feels too hacky at the moment.

erooke commented 2 years ago

For what its worth helm-bibtex has implemented this feature. They support:

as file specifications.

anandkumar89 commented 3 months ago

I've proposed a reply here : https://github.com/nvim-telescope/telescope-bibtex.nvim/issues/73#issuecomment-2058456940

uses mappings to add this feature.