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

Mon, 27 Mar 2023 15:27:01 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Mon, 27 Mar 2023 15:27:01 -0500
changeset 1093
3d970272f1a3
parent 1071
e76020af023d
child 1097
7df98d33285d
permissions
-rw-r--r--

fix surprise reindent

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

mercurial