-- Performant, batteries-included completion plugin for Neovim. -- https://github.com/Saghen/blink.cmp return { "blink.cmp", event = "InsertEnter", load = function(name) vim.cmd.packadd(name) vim.cmd.packadd("blink-emoji.nvim") end, after = function() require("blink-cmp").setup({ -- Enables keymaps, completions and signature help when true (doesn't apply to cmdline or term) -- -- If the function returns 'force', the default conditions for disabling the plugin will be ignored -- Default conditions: (vim.bo.buftype ~= 'prompt' and vim.b.completion ~= false) -- Note that the default conditions are ignored when `vim.b.completion` is explicitly set to `true` -- -- Exceptions: vim.bo.filetype == 'dap-repl' --enabled = function() -- return not vim.tbl_contains({ "lua", "markdown" }, vim.bo.filetype) --end, -- Disable cmdline -- cmdline = { enabled = false }, fuzzy = { -- ToDo: re-enable after the fix https://github.com/Saghen/blink.cmp/issues/1743 --implementation = "prefer_rust_with_warning", implementation = "lua", sorts = { "score", -- Primary sort: by fuzzy matching score "sort_text", -- Secondary sort: by sortText field if scores are equal "label", -- Tertiary sort: by label if still tied }, }, completion = { -- 'prefix' will fuzzy match on the text before the cursor -- 'full' will fuzzy match on the text before _and_ after the cursor -- example: 'foo_|_bar' will match 'foo_' for 'prefix' and 'foo__bar' for 'full' keyword = { range = "prefix" }, trigger = { --show_on_backspace = true, --show_on_backspace_in_keyword = true, }, -- Disable auto brackets -- NOTE: some LSPs may add auto brackets themselves anyway accept = { auto_brackets = { enabled = false } }, list = { selection = { preselect = true, auto_insert = true, }, }, -- or set via a function --list = { -- selection = { -- preselect = function(ctx) -- return vim.bo.filetype ~= "markdown" -- end, -- }, --}, menu = { auto_show = true, -- nvim-cmp style menu --draw = { -- columns = { -- { "label", "label_description", gap = 1 }, -- { "kind_icon", "kind" }, -- }, --}, }, -- Show documentation when selecting a completion item documentation = { auto_show = true, auto_show_delay_ms = 2000 }, -- Whether to display a preview of the selected item on the current line ghost_text = { enabled = true }, }, keymap = { -- set to 'none' to disable the 'default' preset preset = "none", [""] = { "show", "show_documentation", "hide_documentation" }, [""] = { "hide", "fallback" }, --[""] = { "select_next" }, --[""] = { "select_prev" }, --[""] = { "show_and_insert_or_accept_single" }, [""] = { "accept", "fallback" }, --[""] = { "snippet_forward", "fallback" }, --[""] = { "snippet_backward", "fallback" }, [""] = { "select_prev", "fallback" }, [""] = { "select_next", "fallback" }, [""] = { "select_prev", "fallback_to_mappings" }, [""] = { "select_next", "fallback_to_mappings" }, [""] = { "scroll_documentation_up", "fallback" }, [""] = { "scroll_documentation_down", "fallback" }, [""] = { "show_signature", "hide_signature", "fallback" }, }, sources = { -- Remove 'buffer' if you don't want text completions, -- by default it's only enabled when LSP returns no items default = { "path", "lsp", "snippets", "buffer", "emoji" }, providers = { -- Always show the buffer source even when the LSP provides some completion lsp = { fallbacks = {} }, buffer = { score_offset = -3, opts = { get_bufnrs = function() return vim.api.nvim_list_bufs() end, -- from all "normal" buffers -- get_bufnrs = function() -- return vim.tbl_filter(function(bufnr) -- return vim.bo[bufnr].buftype == "" -- end, vim.api.nvim_list_bufs()) -- end, -- buffers when searching with `/` or `?` get_search_bufnrs = function() return { vim.api.nvim_get_current_buf() } end, retention_order = { "focused", "visible", "recency", "largest" }, use_cache = true, enable_in_ex_commands = false, }, }, emoji = { module = "blink-emoji", name = "Emoji", score_offset = 15, -- Tune by preference opts = { insert = true, -- Insert emoji (default) or complete its name ---@type string|table|fun():table trigger = function() return { ":" } end, }, should_show_items = function() return vim.tbl_contains( -- Enable emoji completion only for git commits and markdown. -- By default, enabled for all file-types. { "gitcommit", "markdown", "jj" }, vim.o.filetype ) end, }, path = { opts = { -- get_cwd = function(_) -- return vim.fn.getcwd() -- end, }, }, }, }, -- Use a preset for snippets, check the snippets documentation for more information snippets = { preset = "default" }, -- | "luasnip" | "mini_snippets" | "vsnip" -- Experimental signature help support signature = { enabled = true }, }) end, }