-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #46 #99
Fixes #46 #99
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @sunwukonga !
Welcome and thanks a lot for your contribution 🎉
This has been a very long running problem and your solution is more than welcome !
I have added a few design comments that I think could help, let me know what you think about them
plugin/latexlivepreview.vim
Outdated
if exists('g:livepreview_biber') && g:livepreview_biber > 0 | ||
let s:bibexec = 'biber *.bcf' | ||
else | ||
let s:bibexec = 'bibtex *.aux' | ||
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other configuration flags ( engine
, previewer
) can set the binary directly, we could try to do something similar for bibliography
if exists('g:livepreview_biber') && g:livepreview_biber > 0 | |
let s:bibexec = 'biber *.bcf' | |
else | |
let s:bibexec = 'bibtex *.aux' | |
endif | |
if (s:bibengine == 'biber') | |
let s:bibexec = 'biber ' . l:tmp_root_dir . '/*.bcf' | |
else | |
let s:bibexec = s:bibengine . ' ' . l:tmp_root_dir . '/*.aux' | |
endif |
We should also set this in the Initialize
function ( found this in https://stackoverflow.com/a/33775128, to be tested though )
" Get the bib engine
let s:bibengine = get(g:, 'livepreview_bibengine', 'bibtex')
vim-latex-live-preview/plugin/latexlivepreview.vim
Lines 230 to 252 in 855c309
" Get the tex engine | |
if exists('g:livepreview_engine') | |
let s:engine = g:livepreview_engine | |
else | |
for possible_engine in ['pdflatex', 'xelatex'] | |
if executable(possible_engine) | |
let s:engine = possible_engine | |
break | |
endif | |
endfor | |
endif | |
" Get the previewer | |
if exists('g:livepreview_previewer') | |
let s:previewer = g:livepreview_previewer | |
else | |
for possible_previewer in ['evince', 'okular'] | |
if executable(possible_previewer) | |
let s:previewer = possible_previewer | |
break | |
endif | |
endfor | |
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went back and forth on this, but I finally settled on disagreeing with this suggested change for the following reasons:
pdflatex
andxelatex
are drop in replacements of each other, as areevince
andokular
, howeverbibtex
andbiber
have usages divergent enough to break things. They will be a binary choice for the foreseeable future.- I don't think we should ask the user to spell something when they can simply select instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did however use get()
with some added validation for both g:livepreview_engine
and g:livepreview_previewer
which now gives a warning if no valid executable is available for either of those roles.
plugin/latexlivepreview.vim
Outdated
\ ' && ' . | ||
\ b:livepreview_buf_data['run_cmd'] . | ||
\ ' && ' . | ||
\ 'cd ' . l:tmp_root_dir . ' && ' . s:bibexec . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should try to avoid using cd as much as possible, as this could lead some unintended behaviors and makes the code quite hard to reason about
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. It's bitten me more than once on other scripts. However, I have a memory that using a path to reference the file failed for one of the bib executables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually, I wasn't able to find a way around cd
like behaviour with bibtex
because it doesn't allow writing to external directories without a special option set outside the purview of vim-llp.
plugin/latexlivepreview.vim
Outdated
" Update compile command with bibliography | ||
let b:livepreview_buf_data['run_cmd'] = | ||
\ 'env ' . | ||
\ 'TEXMFOUTPUT=' . l:tmp_root_dir . ' ' . | ||
\ 'TEXINPUTS=' . l:tmp_root_dir | ||
\ . ':' . b:livepreview_buf_data['root_dir'] | ||
\ . ': ' . | ||
\ 'bibtex ' . l:tmp_root_dir . '/*.aux' . | ||
\ ' && ' . | ||
\ b:livepreview_buf_data['run_cmd'] . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inflight run_cmd
is already being called once previous to this point in code, and it is called again a few lines below, do we need it here too ?
silent call system(b:livepreview_buf_data['run_cmd']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On review, this was all kind of a mess. When I first submitted the PR, I made the simplest and easiest changes I could without upsetting the surrounding code.
After your comment, I ripped out a section of code and replaced it instead. Which cleans this up.
I've made changes over multiple commits that reduce the clarity of the conversation to date. With your permission, I'd like to squash all the commits and Old comments only persist if they were made on the PR directly or on the An alternative is for me to create a new branch and squash on it, and reference this PR in a new one. Then this PR can be rejected; but the conversation will remain intact, and a new conversation can begin on the new PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah yeah yeah, feel free to do whatever you need to get a clean and clear history
I'm totally fine with force pushes, we can keep this PR
( added a few nitpicks in the meantime )
README.md
Outdated
`biber`, but uses `biber` by default. To use `bibtex`, add `backend=bibtex` | ||
to your `biblatex` usepackage declaration. | ||
|
||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``` | |
```latex |
README.md
Outdated
If you're using `biblatex` this is most likely caused by not also setting | ||
`g:livepreview_use_biber = 1` in your `.vimrc`. Or if you intended to use | ||
`bibtex` not using that option when using the `biblatex` package. i.e. | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``` | |
```latex |
plugin/latexlivepreview.vim
Outdated
let l:matches = matchstr(getline(l:position), specific_pattern) | ||
if ( l:matches == '' ) | ||
" expect s:useBiber=1 | ||
if ( s:useBiber == 0 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use snake case here instead of camel case, in order to keep it consistent with other variables
Run tex engine before and after bib executable Add support for both `bibtex` and `biber` - Add global variable `g:latexlivepreview_use_biber` Add Bibliography section to README - Detail usage of `g:latexlivepreview_use_biber` - Detail usage with `biblatex` Clean up calls to bibexec commands Remove `cd` from processing of bib commands - Move code that selects this option to the initializer Give more meaningful feedback when `engine` and `preview` commands are not valid - Throw errors from this context Catch errors in the initializer and then stop execution Move README section about bibliographies Update README to reflect change of g:latexlivepreview_biber Add section in Known Issues about bibliographies to README Add auto handling of certain bib setting mismatches Fix bugged warning when `biblatex` not used Add latex label to latex code in README Use snake_case not camelCase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for your contribution 🎉
Run tex engine before and after bib executable
Add support for both
bibtex
andbiber
g:livepreview_biber
Add Bibliography section to README
g:livepreview_biber
biblatex
Summary
Provide a general description of the code changes in your pull request... were there any bugs you had fixed? If so,
mention them. If these bugs have open GitHub issues, be sure to tag them here as well, to keep the conversation linked
together.
Other Information
If there's anything else that's important and relevant to your pull request, mention that information here. This could
include benchmarks, or other information.
If you are updating any of the CHANGELOG files or are asked to update the CHANGELOG files by reviewers, please add the
CHANGELOG entry at the top of the relevant section.
Thanks for contributing to
vim-latex-live-preview
!