Code Monkey home page Code Monkey logo

cmp-vsnip's Introduction

cmp-vsnip's People

Contributors

hrsh7th avatar sharksforarms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cmp-vsnip's Issues

Duplicate expansion

Peek.2023-01-30.00-47.mp4

Having a weird duplicate expansion. Tab keys aren't working for jumps.

--Approximate config
-- plugins-snippets.lua

local cmp = require("cmp")
cmp.setup({

["<CR>"] = cmp.mapping.confirm({ select = true }),
["<C-S-j>"] = cmp.mapping(function(fallback)
	if vim.fn["vsnip#jumpable"](1) == 1 then
		 feedkey("<Plug>(vsnip-jump-next")
	else
		fallback()
	end
end, {  "s" }),
["<Tab>"] = cmp.mapping(function(fallback)
 --  elseif vim.fn["vsnip#available"](1) == 1 then
	if vim.fn["vsnip#jumpable"](1) == 1 then
		 feedkey("<Plug>(vsnip-jump-next", "")
	elseif cmp.visible() then
		cmp.select_next_item()
	elseif has_words_before() then
		cmp.complete()
	else
	  --The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
		fallback()
	 end
end, { "i", "s" }),

["<S-Tab>"] = cmp.mapping(function()
  if vim.fn["vsnip#jumpable"](-1) == 1 then
	  feedkey("<Plug>(vsnip-jump-prev)", "")
  elseif cmp.visible() then
	  cmp.select_prev_item()
  end
end, { "i", "s" }),


...
end -- setup end
Snippet:
	"workspace doc open": {
		"prefix": "doc.open.content",
		"body": [
			"workspace.openTextDocument({",
			"    content : ${1:\"File content\"},",
			"    language: \"${2|javascript,typescript,texmate.snippet|}\"",
			"});"
		],
		"description": "Open vs code workspace document"
	}

Version

"Tab" behavior changed

After the commit 18ff44c the behavior when I press tab changes from expanding the string to the full snippet prefix to now expanding to the first line in the snippet's body.

I am trying to understand the intention behind that change, so that I can modify my workflow or perhaps change my snippet to work with this change.

The way I am using is to first expand to the full "name" of the snippet first and have another mapping to expand it to the full body. Perhaps the change is trying to do both at once but I can't find a way to set my snippet in such a way that it works.

Complete returns duplicated results for vsnip

It works well with nvim-compe, vim-vsnip, and vim-vsnip-integ.

Screenshot:

image

My vsnip snippets:

{
  "Date": {
    "prefix": ["date"],
    "body": ["${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}"],
    "description": "Date"
  },
  "Datetime": {
    "prefix": ["datetime"],
    "body": ["${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE} ${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}"],
    "description": "Datetime"
  }
}

No snippets shown in nvim-cmp

Hi,

Having updated my config today, I've seen that I get no snippets shown in nvim-cmp. I saw that commit 18ff44c seems to have broken my config. However, replacing the line in:

by the same line in the previous commit:

return '\\%([^[:alnum:][:blank:]]\\|\\w\\+\\)'

seems to have solved the issue. Do you have any idea why that should be and if a fallback to the old line is necessary?

Thanks

Select prev/next immediately closes menu for some snippets

Some snippets cause the menu to immediately close, when selected with prev/next in the menu. They also insert a messed up version of the snippet.

Here is an example snippet:

{
  "msg": {
    "prefix": ["msg"],
    "body": [
      "[$1] $2"
    ]
  }
}

If I type ms the menu opens:
image

If I now just select the first item (i.e. <c-j> without confirming!), the menu closes immediately and inserts the first part of the template:

image

This happens since commit 18ff44c (Improve Symbol handling).

It does not happen for all snippets. I could not find out what exactly makes some snippets cause this problems, while others still work fine.

My nvim-cmp config:

  cmp.setup({
    snippet = {
      expand = function(args)
        vim.fn['vsnip#anonymous'](args.body)
      end,
    },
    mapping = {
      ['<C-j>'] = cmp.mapping(cmp.mapping.select_next_item(), {'i', 'c'}),
      ['<C-k>'] = cmp.mapping(cmp.mapping.select_prev_item(), {'i', 'c'}),
      ['<CR>'] = function(fallback)
        if cmp.visible() and
          cmp.get_selected_entry() and
          not (cmp.get_selected_entry().source.name == 'nvim_lsp_signature_help') then
          cmp.confirm({
            select = false,
          })
        else
          fallback()
        end
      end
    },
    sources = cmp.config.sources({
      { name = 'vsnip' },
    }),
  })

snippet engine is not configured

When I try to select the snippet hint displayed in the completion menu, I get this error:

	E5108: Error executing lua .../.vim/plugged/nvim-cmp/lua/cmp/config/default.lua:24: snippet engine is not configured.
stack traceback:
        [C]: in function 'error'
        .../.vim/plugged/nvim-cmp/lua/cmp/config/default.lua:24: in function 'expand'
        .../.vim/plugged/nvim-cmp/lua/cmp/core.lua:417: in function <.vim/plugged/nvim-cmp/lua/cmp/core.lua:378>
        .../.vim/plugged/nvim-cmp/lua/cmp/utils/feedkeys.lua:51: in function <.vim/plugged/nvim-cmp/lua/cmp/utils/feedkeys.lua:49>

Not sure what's missing

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.