Skip to content

Commit 194db97

Browse files
committed
add highlithg support
1 parent 8b38ee5 commit 194db97

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

lua/easycomplete/cmdline.lua

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,15 @@ function this.cr_handler()
387387
end
388388
end
389389

390+
function this.get_normal_search_cmp()
391+
local typing_word = this.get_typing_word()
392+
local ret = this.get_buf_keywords(string.sub(typing_word, 1, 1))
393+
local ret = util.filter(ret, function(item)
394+
return string.lower(string.sub(item, 1, 1)) == string.lower(string.sub(typing_word, 1, 1))
395+
end)
396+
return ret
397+
end
398+
390399
-- MAIN ROUTER
391400
this.REG_CMP_HANDLER = {
392401
{
@@ -401,11 +410,7 @@ this.REG_CMP_HANDLER = {
401410
pattern = "^[a-zA-Z0-9_]+$",
402411
get_cmp_items = function()
403412
if this.insearch() then
404-
local typing_word = this.get_typing_word()
405-
local ret = this.get_buf_keywords(string.sub(typing_word, 1, 1))
406-
local ret = util.filter(ret, function(item)
407-
return string.lower(string.sub(item, 1, 1)) == string.lower(string.sub(typing_word, 1, 1))
408-
end)
413+
local ret = this.get_normal_search_cmp()
409414
return ret
410415
elseif vim.g.easycomplete_cmdline_pattern == ":" then
411416
-- command 共有 670 多个,因为太重要了,这里不做过滤了,返回全部
@@ -462,6 +467,23 @@ this.REG_CMP_HANDLER = {
462467
end
463468
end
464469
},
470+
{
471+
-- highlight
472+
pattern = {
473+
"^hi%s.*$",
474+
"^highlight%s.*$"
475+
},
476+
get_cmp_items = function()
477+
if this.insearch() then
478+
return this.get_normal_search_cmp()
479+
else
480+
local typing_word = this.get_typing_word()
481+
local guide_str = string.sub(typing_word, 1, 1)
482+
local result = vim.fn.getcompletion(guide_str, "highlight")
483+
return result
484+
end
485+
end
486+
},
465487
{
466488
-- 输入路径
467489
pattern = {

0 commit comments

Comments
 (0)