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

Thu, 23 Feb 2023 13:58:37 -0600

author
Meredith Howard <mhoward@roomag.org>
date
Thu, 23 Feb 2023 13:58:37 -0600
changeset 1049
3f01468ffc32
parent 1044
8b90bfdedd2b
child 1054
3a0ff0563a7b
permissions
-rw-r--r--

Switch to themer jellybeans

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

mercurial