summaryrefslogtreecommitdiff
path: root/common/home/programs/nixvim/plugins/cmp.nix
blob: 27cca049739feaa7be983be94ee57f2d4f8845a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{ ... }:
{
  enable = true;
  autoEnableSources = true;
  settings = {
    mapping = {
      "<C-b>" = "cmp.mapping.scroll_docs(-4)";
      "<C-f>" = "cmp.mapping.scroll_docs(4)";
      "<C-Space>" = "cmp.mapping.complete()";
      "<C-e>" = "cmp.mapping.abort()";
      "<CR>" = "cmp.mapping.confirm({ select = true })";
      "<Tab>" = ''
        cmp.mapping(function(fallback)
        	if cmp.visible() then
        		cmp.select_next_item()
        	else
        		fallback()
        	end
        end, { "i", "s" })
      '';
      "<S-Tab>" = ''
        cmp.mapping(function(fallback)
        	if cmp.visible() then
        		cmp.select_prev_item()
        	else
        		fallback()
        	end
        end, { "i", "s" })
      '';
    };
    snippet = {
      expand = ''
        function(args)
        	require('luasnip').lsp_expand(args.body)
        end
      '';
    };
    sources = [
      { name = "nvim_lsp"; }
      { name = "luasnip"; }
      { name = "path"; }
      { name = "buffer"; }
    ];
  };
}