Skip to content

micangl/cmp-vimtex

Repository files navigation

cmp-vimtex

nvim-cmp source providing bespoke support for Vimtex's omnifunc.

Check out the tutorial for an in-depth explanation of the plugin's functionality.

Table of contents

Features

Provides support for:

  • Fuzzy matching against all info provided by Vimtex (including bibliographic details, useful for citations):
  • Perform websearches of bibliographic completion items on research databases and search engines (check out the tutorial);
  • Parse and display all details contained in bibtex files:
  • Trimming long strings in the completion menu (adds space for the documenation window):
  • Trigger the completion menu automatically after typing \cite{ (normally, it has to be done manually).
  • Conveniently toggling symbols and additional information shown in the completion menu:
  • Granuarly configuring the menus, and more (check out the tutorial).

Installation

Install the plugin through your plugin manager:

lazy.nvim:

require("lazy").setup({
  "micangl/cmp-vimtex",
})

Setup

Add cmp-vimtex as a completion source:

require('cmp').setup({
  sources = {
    { name = 'vimtex', },
  },
})

If you're manually specifying a custom format function (this doesn't apply to lspkind.nvim), make sure not to overwrite cmp-vimtex's additional information:

format = function(entry, vim_item)
  vim_item.menu = ({
    -- Use this line if you wish to add a specific kind for cmp-vimtex:
    --vimtex = "[Vimtex]" .. (vim_item.menu ~= nil and vim_item.menu or ""),
    vimtex = vim_item.menu,
    buffer = "[Buffer]",
    nvim_lsp = "[LSP]",
  })[entry.source.name]

  return vim_item
end

Eventually, apply your configuration (note:this is not necessary unless you want to apply a custom configuration):

require('cmp_vimtex').setup({
    -- Eventual options can be specified here.
    -- Check out the tutorial for further details.
})

Advanced setup

This is covered in the tutorial.

Acknowledgments

This plugin is based on @hrsh7th's cmp-omni. The timer implementation has been taken from cmp-buffer. The bibtex parser is a lua rewrite of Vimtex's integrated parser, which has also been adapted for asynchronous execution.

I'd like to thank @lervag for all the help provided when developing this plugin.

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •