A blazing-fast in-process server providing word (based on frequency score and) path completion.
It enables smooth word completion in nearly 10,000 lines of text and provides instant completion in projects with thousands of files.
In the Phoenix, a Trie tree is used to store words, ensuring that the completion results can be obtained in O(L) time (L is the length of the word). Additionally, the weight of each word is calculated based on its usage frequency and last usage time, and low-frequency words are asynchronously cleaned up periodically to ensure that the desired results can be obtained quickly with each input.
For path completion, Phoenix uses an LRU (Least Recently Used) cache to handle the results, and the completion results can be obtained in O(1) time. Meanwhile, the cache is cleaned up based on a set time period to ensure that the directory status is kept synchronized.
Install with any plugin manager or builtin :help packages.
Phoenix can work with any completion plugin which support lsp source or neovim
nightly vim.lsp.completion module.
Used vim.g.phoenix option table and modified the field what you need before
plugin loaded.
---Default configuration values for Phoenix---@typePhoenixConfigvim.g.phoenix= {
-- Enable for all filetypes by defaultfiletypes= { '*' },
-- Dictionary settings control word storagedict= {
capacity=50000, -- Store up to 50k wordsmin_word_length=2, -- Ignore single-letter wordsword_pattern='[^%s%.%_:%p%d]+', -- Word pattern
},
-- Completion control the scoringcompletion= {
max_items=1000, -- Max result itemsdecay_minutes=30, -- Time period for decay calculationweights= {
recency=0.3, -- 30% weight to recent usagefrequency=0.7, -- 70% weight to frequency
},
priority=500,
},
-- Cleanup settings control dictionary maintenancecleanup= {
cleanup_batch_size=1000, -- Process 1000 words per batchfrequency_threshold=0.1, -- Keep words used >10% of max frequencycollection_batch_size=100, -- Collect 100 words before yieldingrebuild_batch_size=100, -- Rebuild 100 words before yieldingidle_timeout_ms=1000, -- Wait 1s before cleanupcleanup_ratio=0.9, -- Cleanup at 90% capacityenable_notify=false, -- Enable notify when cleanup dictionary
},
-- Scanner settings control filesystem interactionscanner= {
scan_batch_size=1000, -- Scan 1000 items per batchcache_duration_ms=5000, -- Cache results for 5sthrottle_delay_ms=5000, -- Wait 5000ms between updatesignore_patterns= {}, -- Dictionary or file ignored when path completion
},
snippet='' -- path of snippet json file like c.json/zig.json/go.json
}Phoenix should works with any completion plugin which support lsp source.
I have a simple wrapper around
vim.lsp.completionfor works on character which does not exist in server triggerCharacters sincevim.lsp.completionusedInsertcharPrefor autotrigger. Notice this script does not works when deleted a character if you want need useTextChangedI.
vim.opt.cot='menu,menuone,noinsert,fuzzy,popup'vim.opt.cia='kind,abbr,menu'api.nvim_create_autocmd('LspAttach', {
group=g,
callback=function(args)
localbufnr=args.buflocalclient=lsp.get_client_by_id(args.data.client_id)
ifnotclientornotclient:supports_method(ms.textDocument_completion) thenreturnendlocalchars=client.server_capabilities.completionProvider.triggerCharactersifcharsthenfori=string.byte('a'), string.byte('z') doifnotvim.list_contains(chars, string.char(i)) thentable.insert(chars, string.char(i))
endendendcompletion.enable(true, client.id, bufnr, {
autotrigger=true,
convert=function(item)
return {
abbr=item.label:gsub('%b()', ''),
kind=item.kind:gsub('^.', string.lower)
}
end,
})
end,
})