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

Improve glossaries-extra and bib2gls support #3073

Closed
gssfaw opened this issue Jan 11, 2025 · 7 comments
Closed

Improve glossaries-extra and bib2gls support #3073

gssfaw opened this issue Jan 11, 2025 · 7 comments

Comments

@gssfaw
Copy link

gssfaw commented Jan 11, 2025

Hello, first of all I'd like to give you my gratitude for developing and maintaining this plugin. I've been using it for almost 4 years and have created hundreds of documents using it.

Is your feature request related to a problem? Please describe it.
Currently bib2gls and glossaries lack some features:

  1. You can't use the context menu on gls entries to preview or edit bib entries like you can do with normal bib files with the \cite command.
  2. spellchecking inconsistent for some commands:
  • \gls{entry_name} is not highlighted as a misspelled word and the _ symbol is not highlighted.
  • \Gls{entry_name} is highlighted as a misspelled word and also the _ symbol is highlighted as an illegal symbol.
    Spellcheck demonstation
    illegal symbol demonstration

I have disabled all plugins (so no treesitter) and set vimtex_syntax_enabled = 1.
If I disable syntax the gls command argument is also highlighted as wrong.

Describe the solution you'd like

  1. It would be really good to have an ability to easily preview and edit bib2gls entries (for some reason, ctags also do not work with these bib files either, not sure why).

  2. The highlighting of illegal symbols is a nice feature, so it would be great if it worked consistently.

Describe alternatives you've considered
I've tried using vimtex_syntax_custom_cmds to manually set the argspell (like here #2960 (comment)) and it is working:

g.vimtex_syntax_custom_cmds = {
    { name = 'glsdesc', argspell = 0, argstyle = 'bold', hlgroup = 'texCmd', nextgroup = 'texGlsArg'}
}

I've added also the argstyle argument to visually confirm that I've set it right
20250111_15h02m17s_grim

As you can see, the argspell parameter disables spell checking. The illegal symbol highlighting is disabled by adding the nextgroup parameter.

It's good as a temporary solution, but I am not sure if it is the right way to do it, because I need to add about 100 commands.

@lervag
Copy link
Owner

lervag commented Mar 1, 2025

Hello, first of all I'd like to give you my gratitude for developing and maintaining this plugin. I've been using it for almost 4 years and have created hundreds of documents using it.

Thanks for the kind words! I'm happy to hear it is useful to you!

And sorry for the long delay in answering your issue! I've started to look at the syntax part now. I'll consider the context menu after.

@lervag
Copy link
Owner

lervag commented Mar 1, 2025

Regarding the highlightings; in my opinion, we should not apply spellchecking in the arguments for the \gls variants, and we should also not highlight the _ as errors. Please correct me if you believe I'm wrong.

lervag added a commit that referenced this issue Mar 1, 2025
@lervag
Copy link
Owner

lervag commented Mar 1, 2025

Please update and test if the syntax highlighting works as expected for you now. Notice, the support for the glossaries package is still very incomplete, so feel free to open further issues on this. But please note that it helps a lot of if you provide concrete examples and "definition" of the commands you want highlighted (e.g. you could copy the relevant section from the docs of the glossaries package). I prefer actual text instead of screenshots, because it is easier for me to copy.

@lervag
Copy link
Owner

lervag commented Mar 1, 2025

And there's the initial support for the context menu for glossaries-extra. Please test and let me know how it works for you.

@lervag lervag closed this as completed Mar 1, 2025
@gssfaw
Copy link
Author

gssfaw commented Mar 2, 2025

@lervag Yes, you're absolutely right about the syntax highlighting and spellchecking, I guess I worded it wrong. Speaking of commands, is it possible to use this file https://github.com/lervag/vimtex/blob/master/autoload/vimtex/complete/glossaries to get the list of commands? As far as I know, some of the commands may overlap with commands from other packages, but I think it is safe to add the syntax rules for each gls- and gls- type command in the same way as it is done for triggering completions for them.

I've looked through the manual and I'm not sure it's really possible to add rules for each command, as there are about 500 or 600 of them.

By the way, the context menu seems to work great — really handy tool, I've been trying to find some edge cases but haven't found any at the moment. Cay I ask a question: is it possible to make the context menu open the entry in the new split?

Thank you very much for your efforts!

lervag added a commit that referenced this issue Mar 2, 2025
@lervag
Copy link
Owner

lervag commented Mar 2, 2025

Speaking of commands, is it possible to use this file https://github.com/lervag/vimtex/blob/master/autoload/vimtex/complete/glossaries to get the list of commands?

Yes and no; the point is that, for proper highlighting, I need the syntax as well. I.e., I need to know if there are optional arguments and how many arguments each command takes.

Now, I think the best approach is simply that you let me know if you come over any command that you find yourself using that you don't think is properly highlighted. Look that (or those) command(s) up and give me a quick definition and an example or two. If you do that, then it should be relatively quick for me to add it.

I've looked through the manual and I'm not sure it's really possible to add rules for each command, as there are about 500 or 600 of them.

I never aim for perfect, only good enough. Let's only consider commands that you are actually using.

By the way, the context menu seems to work great — really handy tool, I've been trying to find some edge cases but haven't found any at the moment.

Great, glad to hear it!

Cay I ask a question: is it possible to make the context menu open the entry in the new split?

Yes. Now it is. :)

Thank you very much for your efforts!

My pleasure!

@gssfaw
Copy link
Author

gssfaw commented Mar 2, 2025

@lervag I see, that's understandable. I'll try to make the list of commands over time and share it with you. Maybe I'll try to make a pull request with the appropriate changes myself.

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

2 participants