A minimal and dependency-free auto-completion plugin built on top of Vim's ins-completion mechanism.
- Asynchronous auto completion with a custom debounce
- Supports Neovim's native snippet expansion (See
:h vim.snippet.expand()
) - Ability to apply additional text edits (e.g. auto-imports)
- Dynamic sorting of completion items
- Fuzzy matching capabilities
- Smart text replace when completing the same word after cursor
- Zero flicker when refreshing completion items list
- Info windows
- Multiple completion sources
- Fancy popup menu highlights
Using lazy.nvim:
{
"brianaung/compl.nvim",
opts = {
-- Default options
-- fuzzy = false,
-- completion = {
-- timeout = 100,
-- },
-- info = {
-- timeout = 100,
-- },
},
}
-- A set of options for better completion experience. See `:h completeopt`
vim.opt.completeopt = { "menuone", "noselect", "noinsert" }
-- Hides the ins-completion-menu messages. See `:h shm-c`
vim.opt.shortmess:append "c"
By default, this plugin follows ins-completion mappings (See :h ins-completion-menu
, :h popupmenu-keys
). However, they can be easily remapped.
Below are some recipes using the vim.keymap.set()
interface. See :h vim.keymap.set()
.
Accept completion using <CR>
vim.keymap.set("i", "<CR>", function()
if vim.fn.complete_info()["selected"] ~= -1 then return "<C-y>" end
if vim.fn.pumvisible() ~= 0 then return "<C-e><CR>" end
return "<CR>"
end, { expr = true })
Change selection using <Tab>
and <Shift-Tab>
vim.keymap.set("i", "<Tab>", function()
if vim.fn.pumvisible() ~= 0 then return "<C-n>" end
return "<Tab>"
end, { expr = true })
vim.keymap.set("i", "<S-Tab>", function()
if vim.fn.pumvisible() ~= 0 then return "<C-p>" end
return "<S-Tab>"
end, { expr = true })
Snippet jumps
vim.keymap.set({ "i", "s" }, "<C-k>", function()
if vim.snippet.active { direction = 1 } then
return "<cmd>lua vim.snippet.jump(1)<cr>"
end
end, { expr = true })
vim.keymap.set({ "i", "s" }, "<C-j>", function()
if vim.snippet.active { direction = -1 } then
return "<cmd>lua vim.snippet.jump(-1)<cr>"
end
end, { expr = true })