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

Sun, 05 Mar 2023 15:14:39 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 05 Mar 2023 15:14:39 -0500
changeset 1060
c20cb89a2ee9
parent 1056
235dd39d6629
child 1064
fcfa295076a8
permissions
-rw-r--r--

Add "comment" parser

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 = {
1054
3a0ff0563a7b tweak completion a little more
Meredith Howard <mhoward@roomag.org>
parents: 1044
diff changeset
19 keyword_length = 3,
1044
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
20 },
1054
3a0ff0563a7b tweak completion a little more
Meredith Howard <mhoward@roomag.org>
parents: 1044
diff changeset
21 formatting = {
3a0ff0563a7b tweak completion a little more
Meredith Howard <mhoward@roomag.org>
parents: 1044
diff changeset
22 format = function(entry, vim_item)
1056
235dd39d6629 Pretty sig help
Meredith Howard <mhoward@roomag.org>
parents: 1055
diff changeset
23 if entry.source.name == "nvim_lsp_signature_help" then
235dd39d6629 Pretty sig help
Meredith Howard <mhoward@roomag.org>
parents: 1055
diff changeset
24 vim_item.kind = ""
235dd39d6629 Pretty sig help
Meredith Howard <mhoward@roomag.org>
parents: 1055
diff changeset
25 elseif vim_item.kind == "Text" then
1054
3a0ff0563a7b tweak completion a little more
Meredith Howard <mhoward@roomag.org>
parents: 1044
diff changeset
26 vim_item.kind = entry.source.name
3a0ff0563a7b tweak completion a little more
Meredith Howard <mhoward@roomag.org>
parents: 1044
diff changeset
27 end
3a0ff0563a7b tweak completion a little more
Meredith Howard <mhoward@roomag.org>
parents: 1044
diff changeset
28 return vim_item
3a0ff0563a7b tweak completion a little more
Meredith Howard <mhoward@roomag.org>
parents: 1044
diff changeset
29 end,
3a0ff0563a7b tweak completion a little more
Meredith Howard <mhoward@roomag.org>
parents: 1044
diff changeset
30 },
1044
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
31 mapping = cmp.mapping.preset.insert({
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
32 ["<C-b>"] = cmp.mapping.scroll_docs(-4),
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
33 ["<C-f>"] = cmp.mapping.scroll_docs(4),
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
34 ["<Tab>"] = cmp.mapping.select_next_item(),
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
35 ["<S-Tab>"] = cmp.mapping.select_prev_item(),
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
36 ["<C-g>"] = cmp.mapping.abort(),
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
37 ["<Right>"] = cmp.mapping.confirm({select = true}),
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
38 ["<Space>"] = function(fallback)
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
39 if cmp.visible() then
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
40 cmp.confirm({select = false}, function()
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
41 vim.api.nvim_feedkeys(" ", "n", false)
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
42 end)
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
43 end
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
44 fallback()
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
45 end,
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
46 }),
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
47 sources = cmp.config.sources({
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
48 { name = "nvim_lsp" },
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
49 { name = "nvim_lsp_signature_help" },
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
50 { name = "nvim_lua" },
1054
3a0ff0563a7b tweak completion a little more
Meredith Howard <mhoward@roomag.org>
parents: 1044
diff changeset
51 { name = "buffer", option = { keyword_pattern = [[\k\+]] } },
1044
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
52 { name = "path" },
1055
ba91fd3b81e1 completion fixes, but leave omni off
Meredith Howard <mhoward@roomag.org>
parents: 1054
diff changeset
53 -- { name = "omni" },
1044
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
54 { name = "tags" },
1054
3a0ff0563a7b tweak completion a little more
Meredith Howard <mhoward@roomag.org>
parents: 1044
diff changeset
55 { name = "calc" },
1044
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
56 }),
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
57 }
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
58 end,
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
59 },
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
60 }
8b90bfdedd2b spin out completion.lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
61

mercurial