hrsh7th / cmp-vsnip

nvim-cmp source for vim-vsnip
MIT License
90 stars 4 forks source link

Complete returns duplicated results for vsnip #1

Closed crispgm closed 2 years ago

crispgm commented 2 years ago

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"
  }
}
hrsh7th commented 2 years ago

@crispgm I think you did install the friendly-snippet. So the snippet actually duplicated in your environment.

You can remove duplicated snippet via cmp's following config.

cmp.setup {
  formatting = {
    format = function(entry, vim_item)
      vim_item.dup = ({
        vsnip = 0
      })[entry.source.name] or 1
    end
  }
}
crispgm commented 2 years ago

@crispgm I think you did install the friendly-snippet. So the snippet actually duplicated in your environment.

You can remove duplicated snippet via cmp's following config.

cmp.setup {
  formatting = {
    format = function(entry, vim_item)
      vim_item.dup = ({
        vsnip = 0
      })[entry.source.name] or 1
    end
  }
}

Thanks for this workaround. But I did not install other snippet, you may investigate my nvim configs here.

hrsh7th commented 2 years ago

@crispgm You seems to set { name = 'vsnip' } twice.

crispgm commented 2 years ago

@crispgm You seems to set { name = 'vsnip' } twice.

😅 OMG, that's my fault. Maybe I should make a PR for deduplicate this?

hrsh7th commented 2 years ago

I'm suprising nvim-cmp shows both sources. 🤣 No. The PR is not needed. Thank you.