.config/nvim/lua/plugins/completion.lua

changeset 1044
8b90bfdedd2b
child 1054
3a0ff0563a7b
equal deleted inserted replaced
1043:e55463fb35e2 1044:8b90bfdedd2b
1 return {
2 {
3 "hrsh7th/nvim-cmp",
4 event = "InsertEnter",
5 dependencies = {
6 "hrsh7th/cmp-buffer",
7 "hrsh7th/cmp-calc",
8 "hrsh7th/cmp-nvim-lsp",
9 "hrsh7th/cmp-nvim-lsp-signature-help",
10 "hrsh7th/cmp-nvim-lua",
11 "hrsh7th/cmp-omni",
12 "hrsh7th/cmp-path",
13 "quangnguyen30192/cmp-nvim-tags",
14 },
15 opts = function()
16 local cmp = require("cmp")
17 return {
18 completion = {
19 completeopt = "menu,menuone,noinsert,noselect",
20 },
21 mapping = cmp.mapping.preset.insert({
22 ["<C-b>"] = cmp.mapping.scroll_docs(-4),
23 ["<C-f>"] = cmp.mapping.scroll_docs(4),
24 ["<Tab>"] = cmp.mapping.select_next_item(),
25 ["<S-Tab>"] = cmp.mapping.select_prev_item(),
26 ["<C-g>"] = cmp.mapping.abort(),
27 ["<Right>"] = cmp.mapping.confirm({select = true}),
28 ["<Space>"] = function(fallback)
29 if cmp.visible() then
30 cmp.confirm({select = false}, function()
31 vim.api.nvim_feedkeys(" ", "n", false)
32 end)
33 end
34 fallback()
35 end,
36 }),
37 sources = cmp.config.sources({
38 { name = "nvim_lsp" },
39 { name = "nvim_lsp_signature_help" },
40 { name = "nvim_lua" },
41 }, {
42 { name = "calc" },
43 { name = "buffer" },
44 { name = "path" },
45 }, {
46 { name = "tags" },
47 { name = "omni" },
48 }),
49 }
50 end,
51 },
52 }
53

mercurial