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

Add a new bib parser written in Lua #2816

Merged
merged 2 commits into from
Oct 25, 2023
Merged

Add a new bib parser written in Lua #2816

merged 2 commits into from
Oct 25, 2023

Conversation

lervag
Copy link
Owner

@lervag lervag commented Oct 22, 2023

Adding a lua parser for bibtex files.

See #2786.

@lervag lervag force-pushed the feat/bib-parser-lua branch 2 times, most recently from d89d308 to 649b83f Compare October 24, 2023 08:34
@lervag lervag changed the title wip: adding a new bib parser in lua Add a new bib parser written in Lua Oct 24, 2023
@micangl
Copy link

micangl commented Oct 24, 2023

I think there may be an issue. When testing this commit, I've noticed that the time it took for the context-menu to show up wasn't significantly lower. I've tried setting the g:vimtex_parser_bib_backend option to alternative with values, but to no avail: the time efficiency was always the same.

When debugging I've seen that, in practically all calls to the vimtex#parse#bib function, the argument { 'backend': 'vim'} is provided, effectively voiding the influence of the global backend option.

Also, in the lua/vimtex/bibparser.lua file, M.parse function, line 230, the format_entry is called on every entry; the goal of said function is to format the results in markdown and improve readability (which I don't think could be called a desired effect here?).

@lervag
Copy link
Owner Author

lervag commented Oct 24, 2023

Yes, sorry, I didn't update the parser for the context menu yet - I've fixed this locally but not pushed it. Thanks for checking, though! Your too fast for me ;)

@lervag
Copy link
Owner Author

lervag commented Oct 24, 2023

There, I think these are fixed now.

@lervag
Copy link
Owner Author

lervag commented Oct 24, 2023

When debugging I've seen that, in practically all calls to the vimtex#parse#bib function, the argument { 'backend': 'vim'} is provided, effectively voiding the influence of the global backend option.

Yes; the reason for this is that the context menu needs the source file and line number entries that we do not get with the bibtex backend. The Vimscript parser was written mostly to support the context menu feature.

@micangl
Copy link

micangl commented Oct 24, 2023

Ok, I've tested the new commit and everything seems to be working well.

@lervag
Copy link
Owner Author

lervag commented Oct 24, 2023

I've improved the code now. It may not be much faster, but at least it is much easier to understand (IMHO).

@lervag
Copy link
Owner Author

lervag commented Oct 24, 2023

I think that's about as far as I'll go with this. I'll leave the PR open a few days before merging in case anyone wants to test. But I think it should be fine and that it should provide a nice speedup for some people.

@lervag lervag force-pushed the feat/bib-parser-lua branch 2 times, most recently from 5063292 to 0a84c88 Compare October 25, 2023 19:40
This is similar to the Vimscript parser ("vim"), but since it is in Lua
it is much faster and comparable to the current fastest parser
("bibtex").

refer: #2786
@lervag lervag merged commit 5454d86 into master Oct 25, 2023
2 checks passed
@lervag lervag deleted the feat/bib-parser-lua branch October 25, 2023 19:50
@lervag
Copy link
Owner Author

lervag commented Oct 25, 2023

Ok, I've merged this now.

@micangl Notice that I've made some quite significant changes both to the Lua and the Vimscript parsers. I believe I've fixed some bugs in the process, and you should consider to either directly rely on the new VimTeX parser in cmp-vimtex or copy and adapt it as you see fit.

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

Successfully merging this pull request may close these issues.

3 participants