-
Notifications
You must be signed in to change notification settings - Fork 10
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
Implement hover and go to definition providers for citations #29
Implement hover and go to definition providers for citations #29
Conversation
Replace newline with double space then a newline to actually get a newline. Double newline is a paragraph break, which we don't want.
Show raw bibtex on Ctrl+hover, and go to item's location in bibtex file on click. Same with F12.
Was only working with the first citation key on a line
a3cb2a0
to
7856bfa
Compare
src/providers/definition.ts
Outdated
@@ -10,15 +11,15 @@ export class DefinitionProvider implements vscode.DefinitionProvider { | |||
|
|||
provideDefinition(document: vscode.TextDocument, position: vscode.Position): vscode.Location | undefined { | |||
// look for an @ at the start of the current word (start) and the end of the current word or line (end) |
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 can try to help with the regex
, but first I need to make sure I understand how the matching should happen. Based on lines 14
and 15
I deduce that you need two positions:
startResult
: match words that follow after@
until a space or line endendResult
: what should it match?
One final question, can we use a positive lookbehind assertion? Based on this page, it seems to be possible from ECMAScript 2018.
Would the following work (i.e., see demo here)?
startResult
:(?<=@)\w+
, or to allow for-
in the citation key(?<=@)[\w|-]+
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.
But personally, I find your option already very good (i.e., demo here).
VSCode has an inbuilt function to make this a lot easier
Sorry, I based that method on how it was done in LaTeX Workshop so it was probably a bit confusing. I just found a nice inbuilt VSCode function to make getting a word at the current cursor position much easier. It should be clearer now. Should dashes be allowed in the citation keys in general? |
No worries! I am happy to hear VSCode has a built-in function for that!
According to this answer on TeX there a range of characters that can be used as delimiters for BibTeX keys. However, I propose to keep it simple and ignore this for now. I can imagine that these are not very common use cases. |
Wow! Thanks for the excellent contribution @Dominic-DallOsto and for suggesting this in the first place @mihaiconstantin ! |
Addresses #28
Hover provider:

Go to definition provider (Ctrl + hover):

This is mostly a simplified version from LaTeX workshop's hover provider and go to definition provider.