msprev / fzf-bibtex

a BibTeX source for fzf
BSD 3-Clause "New" or "Revised" License
129 stars 15 forks source link

Absolute path for $FZF_BIBTEX_SOURCES from environment var #29

Closed folofjc closed 2 years ago

folofjc commented 2 years ago

Thanks for this! I have been looking for something like this for a long time, and the fzf integration is great!

Perhaps I have set up incorrectly, but in my ~/.vimrc I have $FZF_BIBTEX_SOURCES as an absolute path via an environment variable, something like:

let $FZF_BIBTEX_SOURCES = '$MYBIBDIR/BibTexFiles'

When I try to use this in vim via <leader>c, I get an error that it cannot find the directory, because it is searching relative to my current directory. So it is looking in /path/to/current/dir/$MYBIBDIR/BibTexFiles which does not exist.

If I hard code the absolute path, it works.

folofjc commented 2 years ago

I tried to see how to fix this, I guess around this line? But I don't know go so I wasn't sure how to fix is.

msprev commented 2 years ago

The issue is that you are treating an environment variable as a string literal in your vimscript expression. fzf-bibtex has no way to know what your intended meaning is. Have a look at this to see how to correct it using expansion and concatenation on $MYBIBDIR to set the variable $FZF_BIBTEX_SOURCES:

folofjc commented 2 years ago

Ah, okay thanks! I am able to do that in lots of other vim packages, but those are always for variables, not env vars. Sorry, I got confused.