37 completeopt = "menu,menuone,noinsert,noselect", |
37 completeopt = "menu,menuone,noinsert,noselect", |
38 }, |
38 }, |
39 mapping = cmp.mapping.preset.insert({ |
39 mapping = cmp.mapping.preset.insert({ |
40 ["<C-b>"] = cmp.mapping.scroll_docs(-4), |
40 ["<C-b>"] = cmp.mapping.scroll_docs(-4), |
41 ["<C-f>"] = cmp.mapping.scroll_docs(4), |
41 ["<C-f>"] = cmp.mapping.scroll_docs(4), |
42 ["<Tab>"] = cmp.mapping.select_next_item(), |
42 ["<Tab>"] = function(fallback) |
|
43 if cmp.visible() then |
|
44 cmp.select_next_item() |
|
45 else |
|
46 cmp.complete() |
|
47 end |
|
48 end, |
43 ["<S-Tab>"] = cmp.mapping.select_prev_item(), |
49 ["<S-Tab>"] = cmp.mapping.select_prev_item(), |
44 ["<C-g>"] = cmp.mapping.abort(), |
50 ["<C-g>"] = cmp.mapping.abort(), |
45 -- FIXME: add extra space after in select case? |
|
46 ["<Space>"] = cmp.mapping.confirm({select = false}), |
|
47 ["<Right>"] = cmp.mapping.confirm({select = true}), |
51 ["<Right>"] = cmp.mapping.confirm({select = true}), |
|
52 ["<Space>"] = function(fallback) |
|
53 if cmp.visible() then |
|
54 cmp.confirm({select = false}) |
|
55 vim.api.nvim_feedkeys(" ", "n", false) |
|
56 end |
|
57 fallback() |
|
58 end, |
48 }), |
59 }), |
49 sources = cmp.config.sources({ |
60 sources = cmp.config.sources({ |
50 { name = "nvim_lsp" }, |
61 { name = "nvim_lsp" }, |
51 { name = "nvim_lsp_signature_help" }, |
62 { name = "nvim_lsp_signature_help" }, |
52 { name = "nvim_lua" }, |
63 { name = "nvim_lua" }, |
|
64 }, { |
53 { name = "buffer" }, |
65 { name = "buffer" }, |
54 { name = "path" }, |
66 { name = "path" }, |
55 }), |
67 }), |
56 experimental = { |
68 experimental = { |
57 ghost_text = { |
69 ghost_text = { |