Giter Site home page Giter Site logo

vsnip does not work with lsp about nvim-cmp HOT 9 CLOSED

lourenci avatar lourenci commented on June 25, 2024
vsnip does not work with lsp

from nvim-cmp.

Comments (9)

hrsh7th avatar hrsh7th commented on June 25, 2024 1

The vim-vsnip-integ supports vim-lsp, vim-lsc, neovim builtin lsp omnifunc etc.

The nvim-cmp has a customizable snippet configuration point, so it is not needed.

from nvim-cmp.

weizheheng avatar weizheheng commented on June 25, 2024 1

@hrsh7th, Didn't know about that. Just did that and it works now, thank you so much, and have a great day!

from nvim-cmp.

hrsh7th avatar hrsh7th commented on June 25, 2024

You should add { name = 'vsnip' } to sources.

from nvim-cmp.

hrsh7th avatar hrsh7th commented on June 25, 2024

BTW, Your reporting is much clear. Thanks!

from nvim-cmp.

lourenci avatar lourenci commented on June 25, 2024

from nvim-cmp.

hrsh7th avatar hrsh7th commented on June 25, 2024

You don't need to set up vim-vsnip-integ. If you want to show vsnip candidates to completion-menu, You just add sources = { { name = 'nvim_lsp' }, { name = 'vsnip' } } both.

from nvim-cmp.

lourenci avatar lourenci commented on June 25, 2024

from nvim-cmp.

weizheheng avatar weizheheng commented on June 25, 2024

Hi @hrsh7th, sorry for disturbing you.

I am migrating over from nvim-compe and having the same problem where nvim-cmp does not show snippets from vsnip + friendly-snippets. I have already added vsnip to the sources but it still does not work.

Appreciate if you can point me to debug further, thank you.

This is the config

local cmp = require 'cmp'
cmp.setup {
  snippet = {
    expand = function(args)
        vim.fn['vsnip#anonymous'](args.body)
    end
  },
  mapping = {
    ['<C-p>'] = cmp.mapping.prev_item(),
    ['<C-n>'] = cmp.mapping.next_item(),
    ['<C-d>'] = cmp.mapping.scroll(-4),
    ['<C-f>'] = cmp.mapping.scroll(4),
    ['<C-Space>'] = cmp.mapping.complete(),
    ['<C-e>'] = cmp.mapping.close(),
    ['<CR>'] = cmp.mapping.confirm {
      behavior = cmp.ConfirmBehavior.Replace,
      select = true,
    },
    ['<Tab>'] = cmp.mapping.mode({ 'i', 's' }, function(_, fallback)
      if vim.fn.pumvisible() == 1 then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-n>', true, true, true), 'n')
      else
        fallback()
      end
    end),
    ['<S-Tab>'] = cmp.mapping.mode({ 'i', 's' }, function(_, fallback)
      if vim.fn.pumvisible() == 1 then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-p>', true, true, true), 'n')
      else
        fallback()
      end
    end),
  },
  sources = {
    { name = 'nvim_lsp' },
    { name = 'vsnip' },
  },
}

from nvim-cmp.

hrsh7th avatar hrsh7th commented on June 25, 2024

@marcushwz Did you install cmp-vsnip source via your plugin manager?

from nvim-cmp.

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.