dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

nvim-cmp.lua (1138B)


      1 local cmp = require 'cmp'
      2 require("luasnip.loaders.from_snipmate").lazy_load({paths="~/.dotfiles/vim/snippets"})
      3 local luasnip = require 'luasnip'
      4 luasnip.setup({
      5   history = false
      6 })
      7 
      8 cmp.setup {
      9   snippet = {
     10     expand = function(args)
     11       luasnip.lsp_expand(args.body)
     12     end,
     13   },
     14   mapping = cmp.mapping.preset.insert {
     15     ['<C-d>'] = cmp.mapping.scroll_docs(-4),
     16     ['<C-f>'] = cmp.mapping.scroll_docs(4),
     17     ['<C-Space>'] = cmp.mapping.complete(),
     18     ['<CR>'] = cmp.mapping.confirm {
     19       behavior = cmp.ConfirmBehavior.Replace,
     20       select = true,
     21     },
     22     ['<Tab>'] = cmp.mapping(function(fallback)
     23       if cmp.visible() then
     24         cmp.select_next_item()
     25       elseif luasnip.expand_or_jumpable() then
     26         luasnip.expand_or_jump()
     27       else
     28         fallback()
     29       end
     30     end, { 'i', 's' }),
     31     ['<S-Tab>'] = cmp.mapping(function(fallback)
     32       if cmp.visible() then
     33         cmp.select_prev_item()
     34       elseif luasnip.jumpable(-1) then
     35         luasnip.jump(-1)
     36       else
     37         fallback()
     38       end
     39     end, { 'i', 's' }),
     40   },
     41   sources = {
     42     { name = 'nvim_lsp' },
     43     { name = 'luasnip' },
     44   },
     45 }