A source for nvim-cmp that provides completion for bibliography reference keys.
- Global bibliography definition: set the bibliography source file only once for all files
- Format reference preview: define how the selected reference is shown in the preview
Make the plugin available to nvim with Lazy by specifying it as a dependency to nvim-cmp
:
{
'hrsh7th/nvim-cmp',
...
dependencies = {
...
'skepticspriggan/cmp-reference'
}
}
Add the plugin as completion source for nvim-cmp
:
require('cmp').setup({
sources = {
...
{ name = 'reference' },
},
})
Add a table to the option
field in the definition of the completion source:
cmp.setup {
...
sources = {
{
name = 'reference',
option = {
file = "/path/to/bibliography.bib"
format =
[[
**{{title}}**
*{{year}}*
{{author}}
]]
}
}
}
}
The available parameters are:
file
The path to the file of the bibliography source.
Default: "~/.pandoc/bibliography.bib"
Examples: "/path/to/bibliography.bib"
format
The template used to print citation information in the documentation hover menu. The citation fields can be specified as {{field}}
.
Missing fields will be removed.
Default:
[[
**{{title}}**
*{{year}}*
{{author}}
]]
- Multiple bibliography file types
- Local bibliography file definition in YAML frontmatter
The package was inspired by: