uga-rosa / cmp-dictionary

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

Some words are not displaying #53

Closed fcying closed 5 months ago

fcying commented 5 months ago

I have added several words to my general dictionary, but some of them are not displaying

dictionary

x86_64-windows
x86_64-windows-gnu
x86_64-windows-musl
x86_64-linux-gnu
x86_64-linux-musl
aarch64-linux-gnu
aarch64-linux-musl

result: image miss x86_64-windows-musl

my config:

    local dict = require("cmp_dictionary")
    local dict_path = g.config_dir .. "/dict/"
    dict.setup({
        exact = 2,
        first_case_insensitive = false,
        document = false,
        document_command = "wn %s -over",
        async = false,
        sqlite = false,
        max_items = -1,
        capacity = 5,
        debug = true,
    })
    dict.switcher({
        filetype = {
            go = { dict_path .. "go.dict" },
        },
        filepath = {
            [".*"] = { dict_path .. "dictionary" },
            [".*xmake.lua"] = { dict_path .. "xmake.dict" },
        },
    })
uga-rosa commented 5 months ago

I don't use cmp anymore, so to investigate I would have to start by building an environment. Please provide a complete init.lua that works alone and does not contain any extra configuration. You may use the plugin manager.

fcying commented 5 months ago

init.lua

local g, fn, lsp = vim.g, vim.fn, vim.lsp
g.config_dir = fn.fnamemodify(fn.resolve(fn.expand("<sfile>:p")), ":h")
g.plug_dir = g.config_dir .. "/plugged"

local lazypath = g.plug_dir .. "/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "https://github.com/folke/lazy.nvim.git",
        "--branch=stable", -- latest stable release
        lazypath,
    })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
    {
        "hrsh7th/nvim-cmp",
        event = "InsertEnter",
        version = false, -- last release is way too old
        dependencies = {
            { "uga-rosa/cmp-dictionary" },
        },
        config = function()
            local cmp = require("cmp")
            cmp.setup({
                sources = cmp.config.sources({
                    { name = "dictionary" },
                }),
                formatting = {
                    format = function(entry, vim_item)
                        vim_item.menu = ({
                            dictionary = "[Dict]",
                        })[entry.source.name]
                        return vim_item
                    end,
                },
            })

            local dict = require("cmp_dictionary")
            local dict_path = g.config_dir .. "/"
            dict.setup({
                exact = 2,
                first_case_insensitive = false,
                document = false,
                document_command = "wn %s -over",
                sqlite = false,
                max_items = -1,
                capacity = 5,
                debug = true,
            })
            dict.switcher({
                filepath = {
                    [".*"] = { dict_path .. "dictionary" },
                },
            })
        end,
    },
}, {
    root = g.plug_dir,
    lockfile = g.plug_dir .. "/lazy-lock.json",
    state = g.plug_dir .. "/state.json",
})

vim.cmd.colorscheme("desert")

dictionary

x86_64-windows
x86_64-windows-gnu
x86_64-windows-musl
x86_64-linux-gnu
x86_64-linux-musl
aarch64-linux-gnu
aarch64-linux-musl

reproduce(NVIM v0.9.5)

nvim -u ./init.lua
i
x86
uga-rosa commented 5 months ago

Thank you. Reproduced.

uga-rosa commented 5 months ago

Fixed. Also, I modified the algorithm to use trie trees, which probably made it faster.