Open anstadnik opened 2 years ago
Thanks for reporting.
Aha, I just understood that it might be wrong handling of the i
parameter (in-word expansion), and not the context thing.
We would need to change the keyword pattern for this. As I understood it, this is a Vim regex that the line needs to match in order to trigger completion of a completion item.
However changing it to something like "\\.\\*"
which should match any characters does not work for whatever reason (the snippet won't even show up then). PR / suggestions welcome.
Any workaround or solution?
I thought about this a but more and came to the conclusion that the keyword_pattern
is not the issue. The problem is that cmp
will not invoke completion when typing directly after an existing word.
Let's say that you have a snippet with mrm
as the trigger. Also assume that this is the buffer content and |
is the cursor position:
end|
Currently, nvim-cmp will only show words that contain all of the characters in end
. This is why the mrm
snippet will not be suggested.
So what nvim-cmp needs to support is the following:
After endm|
was typed, besides the words e
, en
, end
and endm
cmp needs to also match ndm
, dm
and m
. This way, if you have a snippet mdm
, it will be suggested because it starts with m
.
So I think you should open an issue on nvim-cmp
and include this as usecase.
Minimum init.lua
```lua --------------------------------------------------------------------------------- -- Packer -- --------------------------------------------------------------------------------- local install_path = vim.fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' if vim.fn.empty(vim.fn.glob(install_path)) > 0 then vim.fn.termopen(('git clone --depth 1 https://github.com/wbthomason/packer.nvim %q'):format(install_path)) end require('packer').startup({ function(use) use 'wbthomason/packer.nvim' use 'nvim-treesitter/nvim-treesitter' use { 'hrsh7th/nvim-cmp', requires = { 'quangnguyen30192/cmp-nvim-ultisnips' } } use 'SirVer/ultisnips' use { 'https://gitlab.com/astadnik/snippets.git', rtp = '.' } end }) --------------------------------------------------------------------------------- -- TreeSitter -- --------------------------------------------------------------------------------- require 'nvim-treesitter.configs'.setup { ensure_installed = "latex" } --------------------------------------------------------------------------------- -- Options -- --------------------------------------------------------------------------------- vim.g.UltiSnipsExpandTrigger = 'Example file
```tex \documentclass{scrartcl} \usepackage{mathtools} \begin{document} % \(When I put the cursor between
\(\)
, and writemrm
, there is no completion suggestion. If I writemrm
(with space before), there is.Hovewer, if in the snippet file I set the options to
iA
instead ofi
(to expand automatically), the snippet is expanded, which IMO indicates that cmp-nvim-ultisnips passes whether to show snippet or not to the cmp wrongly.