No longer maintained This project has been abandoned, because the texlab
language server performs its main function. Also, because it was difficult to
maintain with changes upstream (telescope, and the latex treesitter grammar),
and I am not writing much latex anymore.
This is a Neovim plugin to manage citations and crossreferences in Latex documents. It was also going to provide an outline of the whole document, which can be useful for larger projects with multiple files.
In order to use full functionality, the setup function has to be run first.
This can be placed in ftplugin/tex.vim
:
:lua require("nvim-latex").setup_document()
The function setup_document(bufnr)
tracks all the .tex
and .bib
files in
the current document. If a substantial change is made (adding an \input{}
or
\bibliography{}
, then the function needs to be called again to see the
changes in citations or the outline.
Insert a cross-reference:
" keepinsert will keep the cursor in insert mode, ready to continue typing
:inoremap <c-r> <CMD>lua require("nvim-latex.telescope").cross_reference { keepinsert = true }<CR>
" for normal mode,
:nnoremap <leader>r <CMD>lua require("nvim-latex.telescope").cross_reference()<CR>
Insert a citation
:inoremap <c-r> <CMD>lua require("nvim-latex.telescope").citation { keepinsert = true }<CR>
:nnoremap <leader>r <CMD>lua require("nvim-latex.telescope").citation()<CR>
- [/] Cross-references
- Find cross-references in whole document.
- Find and list all
\label{}
s in a file. - pull labels, references, and citations from all files
- Find and list all
- insert a reference from a menu
- specific to sections and floats for
\ref
- equation references with
\eqref
- specific to sections and floats for
- Find cross-references in whole document.
- [/] Citations
- Full document support
- Pull citation keys from the
\bibliography
command (bibtex) - find
\bibliography
for all files
- Pull citation keys from the
- [/] insert a citation from a menu
- insert selected citations with
\cite{}
- insert selected citations with
- integrate with zotero
- Full document support
- Multi-file documents
- Update on document changes
- [/] Flag if something has changed with autocommand
- Add flag to the module
- create autocommand
- Re-scan from functions (bibliography or outline) if the flag is set
- [/] Flag if something has changed with autocommand
- reliably determine which file is the root document
(checks for
\documentclass
, then looks for.latexmkrc
) - track all related buffers, ideally in all buffers
- Update on document changes
- [/] Outlining
- Find all chapters, sections, subsections, etc
- Find all figures with captions and labels
- [/] Create a scratch buffer (
nvim_create_buf(false, true)
) that presents an outline of the document- name the buffer "outline"
We use nvim-treesitter/nvim-treesitter
to parse the latex, and
nvim-telescope/telescope.nvim
for the searchable menu. To install the parser,
execute :TSInstall latex
.