From 1a5b574ef6ba34bb041e04ca3b3323305f1e5a76 Mon Sep 17 00:00:00 2001 From: rootiest Date: Sat, 1 Mar 2025 11:07:16 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Bug(blink.cmp):=20cmdline=20min?= =?UTF-8?q?=20keyword=20length?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cleaner cmdline completion with ghost-text and require a minimum of 2 characters entered before showing suggestions. This prevents `:q` from being autocompleted to `:qall` and similar mis-completions for short cmds. --- lua/plugins/cmp.lua | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index ebbcb6d..2ccd8d2 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -69,7 +69,10 @@ if vim.g.useblinkcmp then }, cmdline = { enabled = true, - completion = { menu = { auto_show = true } }, + completion = { + menu = { auto_show = true }, + ghost_text = { enabled = true }, + }, sources = function() local type = vim.fn.getcmdtype() -- Search forward and backward @@ -90,6 +93,21 @@ if vim.g.useblinkcmp then [''] = { 'accept_and_enter', 'fallback' }, }, }, + sources = { + providers = { + cmdline = { + min_keyword_length = function(ctx) + -- when typing a command, only show when the keyword is 2 characters or longer + if + ctx.mode == 'cmdline' and string.find(ctx.line, ' ') == nil + then + return 2 + end + return 0 + end, + }, + }, + }, }, keys = require('data.keys').blink, },