uga-rosa / cmp-dictionary

A dictionary completion source for nvim-cmp
MIT License
236 stars 16 forks source link

source name was not shown #33

Closed zanglg closed 1 year ago

zanglg commented 1 year ago
   96         sources = cmp.config.sources({
   97             { name = "nvim_lsp" },
   98             { name = "luasnip" },
   99             { name = "path" },
  100             { name = "buffer" },
  101             { name = "nvim_lsp_signature_help" },
  102             { name = "dictionary", keyword_length = 3 },
  103         }),
  104
  105         diagnost
  106        ┌──────────────────────────────────┐
  107        │ diagnostic       Variable [LSP] │
  108        │ diagnostics      Variable [LSP] │em)
  109        │ diagnostics      Variable [LSP] │at("%s %s", kind_icons[vim_item.kind], vim_item.kind)
  110        │ diagnostics      Variable [LSP] │
  111        │ diagnostic       Variable [LSP] │
  112        │ diagnostics      Variable [LSP] │
  113        │ diagnosticls     Variable [LSP] │
  114        │ diagnostic       Text           │
  115        │ diagnostics      Text           │
  116        │ diagnosticate    Text           │
  117        │ diagnostician    Text           │
  118     }) │ diagnostically   Text           │
  119        │ diagnostication  Text           │
  120     -- └──────────────────────────────────┘s

the text was not shown with dictionary, how should I config for that purpose, here was my config:

  147     use({
  148         "uga-rosa/cmp-dictionary",
  149         config = function()
  150             require("cmp_dictionary").setup({
  151                 dic = {
  152                     ["*"] = { "/usr/share/dict/words" },
  153                 },
  154             })
  155         end,
  156     })
uga-rosa commented 1 year ago

A part of my setup

cmp.setup({
    ...
    formatting = {
        format = function(entry, vim_item)
            vim_item.kind = lspkind[vim_item.kind] .. " " .. vim_item.kind
            vim_item.menu = ({
                buffer = "[Buffer]",
                path = "[Path]",
                nvim_lsp = "[LSP]",
                nvim_lua = "[NvimLua]",
                luasnip = "[LuaSnip]",
                dictionary = "[Dict]",
            })[entry.source.name]
            vim_item.dup = ({
                buffer = 0,
                nvim_lua = 0,
                dictionary = 0,
            })[entry.source.name] or 1
            return vim_item
        end,
    },
    ...
})
zanglg commented 1 year ago

that works, thanks.