Skip to content

Neovim plugin to manage citations and crossreferences in Latex documents

License

Notifications You must be signed in to change notification settings

jladan/nvim-latex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nvim-latex

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.

Usage

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>

TODO / features

  • [/] 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
    • insert a reference from a menu
      • specific to sections and floats for \ref
      • equation references with \eqref
  • [/] Citations
    • Full document support
      • Pull citation keys from the \bibliography command (bibtex)
      • find \bibliography for all files
    • [/] insert a citation from a menu
      • insert selected citations with \cite{}
    • integrate with zotero
  • 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
    • reliably determine which file is the root document (checks for \documentclass, then looks for .latexmkrc)
    • track all related buffers, ideally in all buffers
  • [/] 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"

Dependencies

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.

About

Neovim plugin to manage citations and crossreferences in Latex documents

Resources

License

Stars

Watchers

Forks

Packages

No packages published