micangl / cmp-vimtex

Vimtex source for nvim-cmp.
MIT License
78 stars 5 forks source link
neovim nvim-cmp vimtex

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:

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.