Aerijo / autocomplete-latex

A LaTeX autocomplete provider for Atom
MIT License
10 stars 2 forks source link

Integrate bibtex completions with citations commands #9

Closed werunom closed 6 years ago

werunom commented 6 years ago

Thanks for triggering the autocomplete suggestions for bibtex references on using @.

Given this, can I suggest the following - why not make this bibtex autocomplete more native and automated? That is, instead of calling the autocomplete suggestions only on @ keypress, if I am within latex citations commands, the reference autocomplete suggestions can be called. So, e.g., if I am within the curly braces of citation commands (like \autocite{} or \parencite{}), bibtex references can be invoked on typing.

This has the following advantages -

  1. Most important motivation is to make this package more 'complete'. Having this feature obviates using someother package (like autocomplete-latex-cite).

  2. Currently, the feature of @ is limited only to one citation command (either autocite or parencite or cite depending on the regex given at the settings page). But in latex document, depending on situation, various commands are used. So, having the bibtex references tied up only to @ key (which is associated with one citation command) curtails/limits the functionality that it provides in the first place.

  3. Moreover, since the parsing of bibtex is already being done and reference completion functionality is already provided (on keypress of @), generalizing this (for calling with the curly braces of citation commands) might require just tweaking. [Of course, I am here presuming that the implementation of this suggestion does not require more work. Excuse if this no true :)]

The above points are positive points. The last one I want to suggest is a negative one. Hope this fine.

  1. I am not currently using the @ autocomplete functionality because it results in more keypress. Of course this is not true when what is required is just \autocite{bibkey}. But as I had mentioned in other issues, usually we require the snippet which works like this - \autocite$2{$1}$3. If you include triggering of bibkey suggestions within curly braces, then this will be taken care of.

As I mentioned - this is just my suggestion. You might have other rationale for including the @ feature. Needless to mention, I am happy that you are providing essential packages for my latex writings :)

Aerijo commented 6 years ago

A couple of reasons:

  1. I didn't actually mean to rewrite autocomplete-latex-cite. The current parsing is extremely basic, and prone to errors, and improving it further would take some effort. I understand the desire to make this package more complete, but I would rather leave the heavy lifting to a package maintained by someone else. There are ways of sharing functions between packages though, so I'm looking to use his package as a backend, while I simply trigger it with this package when a @ is seen.

  2. My experience with citations so far has been required to be a certain style, so I almost entirely used \autocite{} (which makes the @... work well). For different types of citation, autocomplete-latex-cite can still be relied upon.

  3. Same as above; I (probably) could trigger it inside a cite command, but I want to work with the autocomplete-latex-cite package, not against it.

  4. You make a good point. It was actually a quick fix to improve the cursor placement, and now positional $n syntax works. Just replace what was a $ in the old one with ${cite}, and the entire ${cite} will be replaced by the actual reference.

Aerijo commented 6 years ago

Also, if you haven't seen it already, I'm trying to integrate some LaTeX word counting tools into a package. It's still early stages, but they work well enough that it's better than nothing. I'm not too sure if it works on Windows yet, but hopefully that won't be too difficult.

werunom commented 6 years ago

Yah...I am aware of the latex-count package and happily using it :)

And agree with your response and rationale. And excuse - I didnt mean to bring competition or make other packages redundant. I just thought of mentioning that package as example. But glad to hear that you are planning to make autocomplete-latex-cite an integral part of your package.

A clarification - did not understand the work around you suggest in point 4. The default is \autocite{$}. The current workaround I have is \autocite[]{$}. But with this, still the tab-key (to move the cursor around) does not work as it works in the case of snippets, like e.g., \autocite$2{$1}$3.

Aerijo commented 6 years ago

It won't work until I release the update to Atom. I'll do it now, but you might want to consider using the github version of the package instead.

werunom commented 6 years ago

Ok... Will wait for the release.

I will close this issue now.

werunom commented 6 years ago

A small correction - the default autocompletion for @ misses an extra slash. It should be \\autocite...; currently its just \autocite...