dcampos / cmp-snippy

nvim-snippy completion source for nvim-cmp.
51 stars 2 forks source link

Snippets with backslash at the beginning are not shown #6

Open moshiur-raj opened 7 months ago

moshiur-raj commented 7 months ago

Snippets defined with \ at the beginning are not shown for autocompletion. image If I use two backslash then custom snippets are shown. image Snippets from the LSP work just fine though. image

dcampos commented 2 months ago

Hey! Sorry for the late response.

I'm afraid I'm unable to reproduce the issue. I created a plaintex.snippets file containing the following snippets:

snippet begin
    Just begin.
snippet \begin
    \begin{${0|figure,list,math|}}

Then, when I type \b, my snippet shows up correctly:

image

It's possible that the issue was fixed upstream in nvim-cmp in the meantime.

Below are my minimal reproduction steps.

minimal.vim ```vim if has('vim_starting') set encoding=utf-8 endif scriptencoding utf-8 if &compatible set nocompatible endif let s:plug_dir = expand('/tmp/plugged/vim-plug') if !filereadable(s:plug_dir .. '/plug.vim') execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir) end execute 'set runtimepath+=' . s:plug_dir call plug#begin(s:plug_dir) Plug 'honza/vim-snippets' Plug 'hrsh7th/nvim-cmp' Plug 'dcampos/nvim-snippy' Plug 'dcampos/cmp-snippy' call plug#end() PlugInstall | quit imap snippy#can_expand_or_advance() ? '(snippy-expand-or-advance)' : '' imap snippy#can_jump(-1) ? '(snippy-previous)' : '' smap snippy#can_jump(1) ? '(snippy-next)' : '' smap snippy#can_jump(-1) ? '(snippy-previous)' : '' xmap (snippy-cut-text) lua << EOF local cmp = require'cmp' cmp.setup({ snippet = { -- REQUIRED - you must specify a snippet engine expand = function(args) -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. require('snippy').expand_snippet(args.body) -- For `snippy` users. -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. -- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+) end, }, window = { -- completion = cmp.config.window.bordered(), -- documentation = cmp.config.window.bordered(), }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.abort(), [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. }), sources = cmp.config.sources({ { name = 'nvim_lsp' }, -- { name = 'vsnip' }, -- For vsnip users. -- { name = 'luasnip' }, -- For luasnip users. -- { name = 'ultisnips' }, -- For ultisnips users. { name = 'snippy' }, -- For snippy users. }, { { name = 'buffer' }, }) }) require('snippy').setup({ hl_group = 'Search', snippet_dirs = '/tmp/snippets/', }) EOF ```
moshiur-raj commented 2 months ago

Thanks for the reply. I think I have identified the problem. It seems the issue occurs when I am using the lsp server from texlab. Can you test it with texlab enabled?

require('lspconfig')['texlab'].setup{ capabilities=require('cmp_nvim_lsp').default_capabilities() }