@@ -426,6 +426,69 @@ this.REG_CMP_HANDLER = {
426426 end
427427 end
428428 },
429+ {
430+ -- help
431+ pattern = {
432+ " ^h%s[%w_]+$" ,
433+ " ^help%s[%w_]+$"
434+ },
435+ get_cmp_items = function ()
436+ if this .insearch () then
437+ return this .get_normal_search_cmp ()
438+ else
439+ local all_tags = this .get_help_completions ()
440+ local typing_word = this .get_typing_word ()
441+ local guide_char = string.sub (typing_word , 1 , 1 )
442+ local result = util .filter (all_tags , function (item )
443+ if string.find (string.lower (string.sub (item , 1 , 2 )), string.lower (guide_char )) and
444+ not string.find (item , " [%s<>%+%-]" ) then
445+ return true
446+ else
447+ return false
448+ end
449+ end )
450+ return result
451+ end
452+ end
453+ },
454+ {
455+ -- highlight colors name
456+ pattern = {
457+ " ^hi%s.*gui[fb]g=$" ,
458+ " ^hi%s.*gui[fb]g=%w+$" ,
459+ " ^highlight%s.*gui[fb]g=$" ,
460+ " ^highlight%s.*gui[fb]g=%w+$" ,
461+ },
462+ get_cmp_items = function ()
463+ if this .insearch () then
464+ return this .get_normal_search_cmp ()
465+ else
466+ local colors = this .native_colors
467+ return colors
468+ end
469+ end
470+ },
471+ {
472+ -- highlight color groups
473+ pattern = {
474+ " ^hi%s+[%w@]+$" ,
475+ " ^highlight%s+[%w@]+$" , -- 几个常见的属性 TODO
476+ " ^hi%s+link%s+$" ,
477+ " ^hi%s+link%s+[%w@]+$" ,
478+ " ^hi%s+link%s+[%w@]+%s+$" ,
479+ " ^hi%s+link%s+[%w@]+%s+[%w@]+$"
480+ },
481+ get_cmp_items = function ()
482+ if this .insearch () then
483+ return this .get_normal_search_cmp ()
484+ else
485+ local typing_word = this .get_typing_word ()
486+ local guide_str = string.sub (typing_word , 1 , 1 )
487+ local result = vim .fn .getcompletion (guide_str , " highlight" )
488+ return result
489+ end
490+ end
491+ },
429492 {
430493 pattern = {
431494 " ^[a-zA-Z0-9_]+%s$" , -- 命令输入完毕,并敲击空格
@@ -475,40 +538,6 @@ this.REG_CMP_HANDLER = {
475538 end
476539 end
477540 },
478- {
479- -- highlight colors name
480- pattern = {
481- " ^hi%s.*gui[fb]g=$" ,
482- " ^hi%s.*gui[fb]g=%w+$" ,
483- " ^highlight%s.*gui[fb]g=$" ,
484- " ^highlight%s.*gui[fb]g=%w+$" ,
485- },
486- get_cmp_items = function ()
487- if this .insearch () then
488- return this .get_normal_search_cmp ()
489- else
490- local colors = this .native_colors
491- return colors
492- end
493- end
494- },
495- {
496- -- highlight color groups
497- pattern = {
498- " ^hi%s.*$" ,
499- " ^highlight%s.*$" ,
500- },
501- get_cmp_items = function ()
502- if this .insearch () then
503- return this .get_normal_search_cmp ()
504- else
505- local typing_word = this .get_typing_word ()
506- local guide_str = string.sub (typing_word , 1 , 1 )
507- local result = vim .fn .getcompletion (guide_str , " highlight" )
508- return result
509- end
510- end
511- },
512541 {
513542 -- 输入路径
514543 pattern = {
@@ -682,6 +711,23 @@ function this.cmd_match(rgx)
682711 end
683712end
684713
714+ -- 得到所有的文档中的tags
715+ local help_all_tags = nil
716+ function this .get_help_completions ()
717+ if help_all_tags ~= nil then
718+ return help_all_tags
719+ else
720+ local help_files = vim .api .nvim_get_runtime_file (' doc/tags' , true )
721+ local all_tags = {}
722+ for _ , filename in ipairs (help_files ) do
723+ local tags = util .get_file_tags (filename )
724+ for _ , v in ipairs (tags ) do table.insert (all_tags , v ) end
725+ end
726+ help_all_tags = all_tags
727+ return all_tags
728+ end
729+ end
730+
685731this .cmd_type = {
686732 -- File completion
687733 file = {
@@ -703,7 +749,7 @@ this.cmd_type = {
703749 diff_buffer = { ' diffthis' , ' diffoff' , ' diffupdate' },
704750 command = { ' command' , ' delcommand' },
705751 option = { ' set' , ' setlocal' , ' setglobal' },
706- help = { ' help' },
752+ -- help = { 'help' },
707753 expression = {
708754 ' substitute' , ' global' , ' vglobal' , ' let' ,
709755 ' echo' , ' echom' , ' echon' ,
0 commit comments