Skip to content
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

bibtex-tidy as a new vimetex friend? #2487

Closed
ccaprani opened this issue Sep 14, 2022 · 5 comments
Closed

bibtex-tidy as a new vimetex friend? #2487

ccaprani opened this issue Sep 14, 2022 · 5 comments

Comments

@ccaprani
Copy link

Duplicate keys, bad formatting, and a host of other problems can make working with bib files a pain.

bibtex-tidy is a cool tool that makes this much easier. It has a CLI through npm and I'm wondering if it would be relatively easy to add it to vimtex as an optional add-on?

That is, if bibtex-tidy is on your system (npm install -g bibtex-tidy), then execute something like <localleader>lT to run bibtex-tidy on the current bib file.

I don't have the skills to execute this idea unfortunately.

lervag added a commit that referenced this issue Sep 15, 2022
@lervag
Copy link
Owner

lervag commented Sep 15, 2022

Thanks for mentioning this! I've started by adding a short comment on this plugin in the docs (see :help vimtex-af-ftplugin-bib).

Reg. an optional add-on within VimTeX: I'm not sure it is a good idea. Several reasons:

  1. Different users will probably want different behaviour. This means we would need one or more extra options. We would also need documentation to guide users on how to install and similar.
  2. It is actually quite easy to make a custom mapping that does what you want. This would also allow to customize exactly as you want it.

As a short proof of the latter point: put the below code in e.g. your ~/.vim/ftplugin/bib.vim or ~/.config/nvim/ftplugin/bib.vim:

nnoremap <localleader>lT :!bibtex-tidy %:p<cr>

You could also use more advanced options:

nnoremap <localleader>lT :!bibtex-tidy --omit=id,name --space --sort %:p<cr>

@lervag lervag closed this as completed Sep 15, 2022
@ccaprani
Copy link
Author

ccaprani commented Sep 21, 2022

Dear people from the future: this works a treat; though <leader>lT clashed with the default contents mapping, so I've used the following, with my own preferences for the CLI args:

nnoremap <localleader>bt :!bibtex-tidy --align --space=4 --duplicates --merge=combine %:p<cr>

As ever @lervag has been super helpful for a not-too-skilled person like me. Nicest guy in the business - thank you!

@lervag
Copy link
Owner

lervag commented Sep 21, 2022

As ever @lervag has been super helpful for a not-too-skilled person like me. Nicest guy in the business - thank you!

My pleasure! :)

@nachovizzo
Copy link

For those also looking into bibtex-tidy. I've added a "formatter" to use the tools, just a formatting tool. More info on the Neoformat repo: sbdchd/neoformat#456

@lervag
Copy link
Owner

lervag commented Apr 13, 2023

Cool, thanks for the heads up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants