-
-
Notifications
You must be signed in to change notification settings - Fork 182
feat(citations): add Org 9.5 citation support with BibTeX source, completions, and go-to-source #1113
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
Open
NickHu
wants to merge
5
commits into
nvim-orgmode:master
Choose a base branch
from
NickHu:citations
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat(citations): add Org 9.5 citation support with BibTeX source, completions, and go-to-source #1113
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
aa17241
feat(citations): add Org 9.5 citation support with BibTeX source, com…
Copilot a579ee2
docs: use plenary.curl instead of pcall in zotero citation source exa…
NickHu 5845c99
fix: update required treesitter parser version to 2.0.3
NickHu 64c0ecc
fix: autocomplete test completes #+bibliography
NickHu d6d6ee8
Merge branch 'master' into citations
kristijanhusak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| ---@class OrgCompletionCitations:OrgCompletionSource | ||
| ---@field completion OrgCompletion | ||
| ---@field private pattern vim.regex | ||
| local OrgCompletionCitations = {} | ||
| OrgCompletionCitations.__index = OrgCompletionCitations | ||
|
|
||
| ---@param opts { completion: OrgCompletion } | ||
| function OrgCompletionCitations:new(opts) | ||
| return setmetatable({ | ||
| completion = opts.completion, | ||
| pattern = vim.regex([=[\[cite[/:][^\]]*@\zs[^ \]]*$]=]), | ||
| }, OrgCompletionCitations) | ||
| end | ||
|
|
||
| ---@return string | ||
| function OrgCompletionCitations:get_name() | ||
| return 'citations' | ||
| end | ||
|
|
||
| ---@param context OrgCompletionContext | ||
| ---@return number | nil | ||
| function OrgCompletionCitations:get_start(context) | ||
| return self.pattern:match_str(context.line) | ||
| end | ||
|
|
||
| ---@param _ OrgCompletionContext | ||
| ---@return string[] | ||
| function OrgCompletionCitations:get_results(_) | ||
| local citations = self.completion.citations | ||
| if not citations then | ||
| return {} | ||
| end | ||
| local items = citations:get_items() | ||
| return vim.tbl_map(function(item) | ||
| return item.key | ||
| end, items) | ||
| end | ||
|
|
||
| return OrgCompletionCitations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ---@meta | ||
|
|
||
| ---@class OrgCitationItem | ||
| ---@field key string The citation key (e.g. "smith2020") | ||
| ---@field label? string Optional display label used in completion menus | ||
| ---@field description? string Optional human-readable description (author, title, year, etc.) | ||
|
|
||
| ---@class OrgCitationSource | ||
| ---@field get_name fun(self: OrgCitationSource): string Return the unique name of this source | ||
| ---@field get_items fun(self: OrgCitationSource): OrgCitationItem[] Return all citation items | ||
| ---@field follow? fun(self: OrgCitationSource, key: string): boolean Navigate to the entry for the given key; return true if handled |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Let's move this to the top level config as other things to make it consistent. Sources configuration can stay like this.