Giter Site home page Giter Site logo

Comments (19)

smjonas avatar smjonas commented on August 16, 2024 2

@rebelot I have updated the snippets.lua file and it seems to working now for vsnip snippets :) Will create a PR later and hopefully the issue will be resolved then.

from cmp-nvim-ultisnips.

smjonas avatar smjonas commented on August 16, 2024 1

Hey, I would really like to solve your issue. However, I just tested with your config and it works for me.

This is how it looks like when using your config with vim-snippets in a Java file and hitting <C-space>:
#25

Can you tell me the output of the following command?

:call UltiSnips#SnippetsInCurrentScope(1) | lua print(vim.inspect(vim.g.current_ulti_dict_info))

from cmp-nvim-ultisnips.

smjonas avatar smjonas commented on August 16, 2024 1

@rebelot could you check if the new updates resolve your issue? We completely got rid of the custom parser now :D

from cmp-nvim-ultisnips.

rebelot avatar rebelot commented on August 16, 2024 1

Everything seems to works nicely! Thank you very much! 👍

from cmp-nvim-ultisnips.

smjonas avatar smjonas commented on August 16, 2024

Hey, could you confirm if this is still the case with the latest version? Also, I will create a PR in a few minutes that should resolve some issues with snippets not showing up.

from cmp-nvim-ultisnips.

rebelot avatar rebelot commented on August 16, 2024

Yes, stopped working right after rebuilding latest neovim and updating plugins

not sure what caused the problem tho, could be nvim, cmp or this. But checking out the commit before the one I posted makes it work again

from cmp-nvim-ultisnips.

smjonas avatar smjonas commented on August 16, 2024

Sorry about that, I should have tested the new parser better. This should be fixed once #26 has been merged.

from cmp-nvim-ultisnips.

smjonas avatar smjonas commented on August 16, 2024

@quangnguyen30192 thank you for the fast merging, @rebelot could you pull the latest update and test again?

from cmp-nvim-ultisnips.

rebelot avatar rebelot commented on August 16, 2024

Still not working for me, but thanks for your super quick response!

from cmp-nvim-ultisnips.

rebelot avatar rebelot commented on August 16, 2024

any update? I'll share my minimal config. I can confirm ultisnips is working because <C-X><C-S> lists snippets, they just won't show up in cmp.

use({
    "SirVer/ultisnips",
    requires = {"honza/vim-snippets", rtp = "."},
    config = function()
	vim.g.UltiSnipsExpandTrigger = "<Plug>(ultisnips_expand)"
	vim.g.UltiSnipsJumpForwardTrigger = "<Plug>(ultisnips_jump_forward)"
	vim.g.UltiSnipsJumpBackwardTrigger = "<Plug>(ultisnips_jump_backward)"
	vim.g.UltiSnipsListSnippets = "<c-x><c-s>"
	vim.g.UltiSnipsRemoveSelectModeMappings = 0
    end,
})

use({
    "hrsh7th/nvim-cmp",
    requires = {"quangnguyen30192/cmp-nvim-ultisnips"},
    config = function()
        local cmp = require('cmp')
        cmp.setup {
            snippet = {
                expand = function(args) vim.fn["UltiSnips#Anon"](args.body) end
            },
            mapping = {
                ['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), {'i', 'c'}),
                ['<CR>'] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }),
            },
            sources = {{ name = 'ultisnips' }}
        }
    end
})

from cmp-nvim-ultisnips.

rebelot avatar rebelot commented on August 16, 2024

this is the output of the command for a lua file (trying to complete date global snippet)
git checkout 78a9452 always works.

could there be any conflicting plugins? I have the lspconfig capabilities updated by cmp as per readme.

Screenshot 2021-11-29 at 13 29 12

{
  ["#!"] = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/lua.snippets:1"
  },
  AGPL = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:265"
  },
  AGPL3 = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:86"
  },
  APACHE = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:219"
  },
  BEERWARE = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:235"
  },
  BSD2 = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:112"
  },
  BSD3 = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:140"
  },
  BSD4 = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:167"
  },
  GMGPL = {
    description = "linking exception",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:103"
  },
  GPL2 = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:18"
  },
  GPL3 = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:52"
  },
  ISC = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:281"
  },
  LGPL2 = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:35"
  },
  LGPL3 = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:69"
  },
  MIT = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:197"
  },
  MPL2 = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:260"
  },
  WTFPL = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:244"
  },
  ["c)"] = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:4"
  },
  date = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:6"
  },
  datetime = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:14"
  },
  ddate = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:8"
  },
  diso = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:10"
  },
  elif = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/lua.snippets:32"
  },
  for = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/lua.snippets:10"
  },
  fori = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/lua.snippets:18"
  },
  forp = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/lua.snippets:14"
  },
  fun = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/lua.snippets:6"
  },
  if = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/lua.snippets:22"
  },
  ife = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/lua.snippets:26"
  },
  im = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/lua.snippets:45"
  },
  local = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/lua.snippets:4"
  },
  lorem = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:16"
  },
  print = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/lua.snippets:43"
  },
  repeat = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/lua.snippets:35"
  },
  time = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/_.snippets:12"
  },
  while = {
    description = "",
    location = "/Users/laurenzi/.local/share/nvim/site/pack/packer/start/vim-snippets/snippets/lua.snippets:39"
  }
}

from cmp-nvim-ultisnips.

smjonas avatar smjonas commented on August 16, 2024

Oh I think I know what's the issue. I was convinced that UltiSnips only supports snippets of the form snippet ... ensnippet as one would guess when reading the helpdocs. As can be seen here https://github.com/SirVer/ultisnips/blob/2c83e40ce66814bf813457bb58ea96184ab9bb81/doc/UltiSnips.txt#L1768, apparently UltiSnips also supports snippets using vsnip syntax. I will update the parser for this, thank you for providing the details! We will let you know once this has been fixed, thanks for your patience.

EDIT: for now this can be fixed by

use({
    "SirVer/ultisnips",
    requires = {"honza/vim-snippets", rtp = "."},
    config = function()
	vim.g.UltiSnipsExpandTrigger = "<Plug>(ultisnips_expand)"
	vim.g.UltiSnipsJumpForwardTrigger = "<Plug>(ultisnips_jump_forward)"
	vim.g.UltiSnipsJumpBackwardTrigger = "<Plug>(ultisnips_jump_backward)"
	vim.g.UltiSnipsListSnippets = "<c-x><c-s>"
	vim.g.UltiSnipsRemoveSelectModeMappings = 0
        vim.g.UltiSnipsEnableSnipMate = 0
    end,
})

(see the last line)

from cmp-nvim-ultisnips.

rebelot avatar rebelot commented on August 16, 2024

thank you! but this raises another issue (for me...) why snippets are searched only in vim-snippets/snippets folder and not also in vim-snippets/UltiSnips?

EDIT: @smjonas fixed like that, something horrible happened to rtp and I still think they messed up....

	use({
		"SirVer/ultisnips",
		requires = {{"honza/vim-snippets"}},
		config = function()
		    vim.opt.rtp:append({vim.fn.stdpath('data') .. "/site/pack/packer/start/vim-snippets"})
			vim.g.UltiSnipsExpandTrigger = "<Plug>(ultisnips_expand)"
			vim.g.UltiSnipsJumpForwardTrigger = "<Plug>(ultisnips_jump_forward)"
			vim.g.UltiSnipsJumpBackwardTrigger = "<Plug>(ultisnips_jump_backward)"
			vim.g.UltiSnipsListSnippets = "<c-x><c-s>"
			vim.g.UltiSnipsRemoveSelectModeMappings = 0
		end,
	})

from cmp-nvim-ultisnips.

smjonas avatar smjonas commented on August 16, 2024

That's actually a really good question, the issues with the rtp just happened to me also. Packer actually has some problems with setting rtp, I will test your solution and probably update the readme once it works.

from cmp-nvim-ultisnips.

smjonas avatar smjonas commented on August 16, 2024

@quangnguyen30192 I think we should not support vim-snipmate-like snippets at the moment. That would be quite a lot of work and involve a few edge cases. But we should update the readme again for honza/vim-snippets users.

Or maybe fallback to not using the custom parser if a snipmate snippet is found (then we will only have the tab_trigger and description info).

from cmp-nvim-ultisnips.

rebelot avatar rebelot commented on August 16, 2024

Or maybe fallback to not using the custom parser if a snipmate snippet is found (then we will only have the tab_trigger and description info).

I second this... I find snipmate snippets very useful (like licenses, date, author/program info)

from cmp-nvim-ultisnips.

smjonas avatar smjonas commented on August 16, 2024

While thinking about it, snipmate snippets only have a tab_trigger and description anyway (at least on the main branch). So there is no need to change the parser, we can simply use the info provided by UltiSnips.

from cmp-nvim-ultisnips.

rebelot avatar rebelot commented on August 16, 2024

Not all of them are shown on latest (i.e. box (this one is super useful imo), bbox, docs, MIT, ...). I'm reverting and locking for now. Thanks for the support, hope you'll find a way to implement that!

edit: FYI, regarding the box snipmate snippet, something wierd happens. It seems that the description is passed to nvim-cmp as part of the item abbrev

from cmp-nvim-ultisnips.

quangnguyen30192 avatar quangnguyen30192 commented on August 16, 2024

Thanks @smjonas for your effort

from cmp-nvim-ultisnips.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.