Skip to content

Commit 6caaf6a

Browse files
committed
bugfix for undo and recover
1 parent 96ea39b commit 6caaf6a

File tree

3 files changed

+75
-5
lines changed

3 files changed

+75
-5
lines changed

autoload/easycomplete.vim

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,6 +2957,26 @@ function! s:CloseQuickFix()
29572957
silent! noa cclose
29582958
endfunction
29592959

2960+
function! easycomplete#LintRefreash()
2961+
call easycomplete#sign#DiagHoverFlush()
2962+
call easycomplete#sign#LintPopup()
2963+
endfunction
2964+
2965+
function! easycomplete#Undo()
2966+
call easycomplete#LintRefreash()
2967+
return "u"
2968+
endfunction
2969+
2970+
function! easycomplete#SingleDelete()
2971+
call easycomplete#LintRefreash()
2972+
return "x"
2973+
endfunction
2974+
2975+
function! easycomplete#Recover()
2976+
call easycomplete#LintRefreash()
2977+
return "\<c-r>"
2978+
endfunction
2979+
29602980
function! easycomplete#InsertEnter()
29612981
call s:SnapShoot()
29622982
call easycomplete#sign#DiagHoverFlush()

lua/easycomplete/cmdline.lua

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,13 +451,30 @@ this.REG_CMP_HANDLER = {
451451
end
452452
end
453453
},
454+
{
455+
-- highlight attr names
456+
pattern = {
457+
"^hi%s.*gui=%w*$",
458+
"^hi%s.*cterm=%w*$",
459+
"^highlight%s.*gui=%w*$",
460+
"^highlight%s.*cterm=%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.hl_attrs
467+
return colors
468+
end
469+
end
470+
},
454471
{
455472
-- highlight colors name
456473
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+$",
474+
"^hi%s.*gui[fb]g=%w*$",
475+
"^hi%s.*cterm[fb]g=%w*$",
476+
"^highlight%s.*gui[fb]g=%w*$",
477+
"^highlight%s.*cterm[fb]g=%w*$",
461478
},
462479
get_cmp_items = function()
463480
if this.insearch() then
@@ -468,6 +485,26 @@ this.REG_CMP_HANDLER = {
468485
end
469486
end
470487
},
488+
{
489+
-- 输入 highlight 的 属性
490+
-- hi Normal |
491+
-- hi Normal g|
492+
-- hi Normal guifg=red |
493+
-- hi Normal guifg=red gui|
494+
pattern = {
495+
"^hi%s+[%w@]+%s$",
496+
"^hi%s+[%w@]+%s.*%s$",
497+
"^hi%s+[%w@]+%s+%w+$",
498+
"^hi%s+[%w@]+%s.*%s%w+$",
499+
},
500+
get_cmp_items = function()
501+
if this.insearch() then
502+
return this.get_normal_search_cmp()
503+
else
504+
return this.hl_args
505+
end
506+
end
507+
},
471508
{
472509
-- highlight color groups
473510
pattern = {
@@ -805,7 +842,17 @@ this.native_colors = {
805842
"mediumpurple","rebeccapurple","blueviolet","indigo","darkorchid","darkviolet",
806843
"mediumorchid","thistle","plum","violet","purple","darkmagenta","fuchsia","magenta",
807844
"orchid","mediumvioletred","deeppink","hotpink","lavenderblush","palevioletred",
808-
"crimson","pink","lightpink"
845+
"crimson","pink","lightpink","NONE"
846+
}
847+
848+
this.hl_args = {
849+
"guifg","guibg","ctermfg","ctermbg","guisp","gui","cterm"
850+
}
851+
852+
this.hl_attrs = {
853+
"bold", "underline","undercurl","underdouble","underdotted","underdashed",
854+
"strikethrough","reverse","inverse","italic","standout","altfont","nocombine",
855+
"NONE"
809856
}
810857

811858
function this.init_once()

plugin/easycomplete.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,9 @@ endif
674674
nnoremap <expr> n easycomplete#ui#TrackSearchNext()
675675
nnoremap <expr> N easycomplete#ui#TrackSearchPrev()
676676
nnoremap <expr> * easycomplete#ui#TrackSearchGlobal()
677+
nnoremap <expr> u easycomplete#Undo()
678+
nnoremap <expr> x easycomplete#SingleDelete()
679+
nnoremap <expr> <c-r> easycomplete#Recover()
677680
cnoremap <expr><CR> easycomplete#ui#CmdlineCR()
678681
inoremap <silent><expr> <BS> easycomplete#BackSpace()
679682
inoremap <Plug>EasycompleteTabTrigger <c-r>=easycomplete#CleverTab()<cr>

0 commit comments

Comments
 (0)