summaryrefslogtreecommitdiffstats
path: root/lua/conf/plugins/blink.lua
blob: f76d4ee36cbe8e8e60291828b9ef3a83153ae696 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
return { "Saghen/blink.cmp",
  branch = "v1.2.0",
  requires = {
    "xzbdmw/colorful-menu.nvim",
    "L3MON4D3/LuaSnip"
  },
  function()
    local colormenu = require("colorful-menu")
    require("blink.cmp").setup {
      keymap = {
        preset = "none", -- I don't like the default documentation scroll binds
        ["<C-y>"] = { "select_and_accept" },
        ["<C-n>"] = { "select_next", "fallback_to_mappings" },
        ["<C-p>"] = { "select_prev", "fallback_to_mappings" },

        ["<C-u>"] = { "scroll_documentation_up", "fallback" },
        ["<C-d>"] = { "scroll_documentation_down", "fallback" }
      },

      completion = {
        menu = {
          scrollbar = false,
          border = vim.g.border_style,
          draw = {
            columns = {
              { "kind_icon" },
              { "label", "label_description", gap = 1 },
              { "kind" }
            },

            -- blink.cmp should not take this much damn work to make it look
            -- semi-decent
            components = {
              -- we replace the kind icon with the an icon for the source
              kind_icon = {
                text = function(ctx)
                  local menu_icon = {
                    "?", -- fallback
                    lsp = "λ",
                    snippets = "%",
                    buffer = "@",
                    path = "#",
                    cmdline = "$"
                  }

                  local icon = menu_icon[ctx.source_id]
                  if icon == nil then
                    icon = menu_icon[1]
                  end

                  return icon
                end,
                highlight = function(_)
                  return { { group = "CmpItemMenu" } }
                end
              },
              label = {
                text = function(ctx)
                  return colormenu.blink_components_text(ctx)
                end,
                highlight = function(ctx)
                  return colormenu.blink_components_highlight(ctx)
                end
              },
              kind = {
                -- these highlights are technically for nvim-cmp, but they're
                -- built into my colorscheme so I don"t mind using them here
                highlight = function(ctx)
                  return {
                    { group = "CmpItemKind"..ctx.kind, priority = 20000 }
                  }
                end
              }
            }
          }
        },

        ghost_text = {
          enabled = true
        },

        -- documentation should show up immediately
        documentation = {
          auto_show = true,
          auto_show_delay_ms = 0,
          window = {
            border = vim.g.border_style
          }
        }
      },

      -- I like the default command line completion
      cmdline = {
        enabled = false
      },

      -- signature support is necessary
      signature = {
        enabled = true,
        window = {
          border = vim.g.border_style
        }
      },

      -- TODO: find a way to make my fancy luasnip snippets with multiple
      -- triggers not look stupid e.g. "fn\|main" for a function that could
      -- be triggered by fn or main
      snippets = {
        preset = "luasnip"
      },

      sources = {
        default = { "lsp", "path", "snippets", "buffer" }
      },

      fuzzy = {
        implementation = "prefer_rust_with_warning",
        sorts = {
          "score",
          "sort_text"
        }
      }
    }
  end
}