Skip to content

Commit 228cf9d

Browse files
committed
add custom pum support with border #360, #359add custom pum support with
border #360, #359
1 parent 35aec2d commit 228cf9d

File tree

6 files changed

+19
-9
lines changed

6 files changed

+19
-9
lines changed

README-cn.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ noremap gb :BackToOriginalBuffer<CR>
169169
| `g:easycomplete_menu_abbr` | 1 | 匹配菜单里menu字段是否显示简写,否则显示全称 |
170170
| `g:easycomplete_custom_snippet` | `""` | 自定义 snippets 路径 |
171171
| `g:easycomplete_use_default_cr` | 1 | 是否使用默认回车的事件绑定 |
172+
| `g:easycomplete_pum_pretty_style` | 1 | 开启 border 时自适应 pum 样式 |
172173

173174
## 语言支持
174175

@@ -365,7 +366,7 @@ You can add custom Pmenu styles by defining these highlight groups:
365366
- `EasyTabNine`: TabNine 图标样式. 默认link到 "Character".
366367
- `EasySnippets`: 行内补全样式. 默认link到 "LineNr"
367368

368-
`g:easycomplete_winborder` 设置为 `1`. Pmenu 匹配菜单的背景色会设置成和文档背景色一致
369+
`g:easycomplete_winborder` 设置为 `1`. Pmenu 匹配菜单的背景色会自动设置成和文档背景色一致。如果你不想被自动设置 pum 背景色,可以这样关掉: `let g:easycomplete_pum_pretty_style = 0`,然后定义新的“Pmenu, FloatBorder, PmenuExtra, PmenuKind” 等样式
369370

370371
更多例子: [例子](custom-config.md)
371372

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ Global configurations:
174174
| `g:easycomplete_menu_abbr` | 1 | Show abbr(shortname) at pum `menu` position, or show fullname |
175175
| `g:easycomplete_custom_snippet` | `""` | Custom snippets path |
176176
| `g:easycomplete_use_default_cr` | 1 | enable or disable default cr action |
177+
| `g:easycomplete_pum_pretty_style` | 1 | Adjust the pum style with border automatically |
177178

178179
Typing `:h easycomplete` for help.
179180

@@ -374,7 +375,7 @@ You can add custom Pmenu styles by defining these highlight groups:
374375
- `EasyTabNine`: TabNine kind icon style. links to "Character" by default.
375376
- `EasySnippets`: TabNine snippets suggestion style. links to "LineNr" by default
376377

377-
When `g:easycomplete_winborder` is set to `1`. The guibg of Pmenu will be set to be the same as the Normal guibg.
378+
When `g:easycomplete_winborder` is set to `1`. The guibg of Pmenu will be set to be the same as the Normal guibg automatically. If you want to redefine pum style, disable the auto setting by `let g:easycomplete_pum_pretty_style = 0`. Then define these highlight group: "FloatBorder, Pmenu, PmenuExtra, PmenuKind" etc.
378379

379380
More examples here: [full config example](custom-config.md)
380381

autoload/easycomplete/popup.vim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ let s:is_vim = !has('nvim')
2121
let s:is_nvim = has('nvim')
2222
" signature/lint
2323
let s:float_type = ""
24+
let s:hlsearch = &hlsearch
2425

2526
augroup easycomplete#popup#au
2627
autocmd!
@@ -632,7 +633,8 @@ function! s:NVimShow(opt, windowtype, float_type)
632633
noa let winid = nvim_open_win(s:buf[a:windowtype], v:false, opt)
633634
let g:easycomplete_popup_win[a:windowtype] = winid
634635
if a:windowtype == "popup" || (a:windowtype == "float" && a:float_type == "signature")
635-
call setwinvar(winid, '&winhl', 'Normal:Pmenu,NormalNC:Pmenu')
636+
call setwinvar(winid, '&winhl', 'Normal:Pmenu,NormalNC:Pmenu,Search:Normal,Error:Pmenu')
637+
call setwinvar(winid, '&spell', 0)
636638
elseif a:windowtype == "float" && a:float_type == "lint"
637639
let bgcolor = easycomplete#ui#GetBgColor("CursorLine")
638640
let fgcolor = s:GetSignGuifgAtCurrentLine()

autoload/easycomplete/pum.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ function! s:hl()
152152
\ "hi link CustomSnippet " . snippet_hl_group,
153153
\ "hi link CustomTabNine " . tabnine_hl_group,
154154
\ "hi link CustomNormal " . pmenu_hl_group,
155+
\ "hi link Error Pmenu",
155156
\ ]
156157
" \ "hi Search guibg=NONE guifg=NONE ctermbg=NONE ctermfg=NONE",
157158
endif

autoload/easycomplete/ui.vim

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,14 @@ function! easycomplete#ui#HighlightWordUnderCursor() " {{{
148148
endfunction
149149

150150
function! easycomplete#ui#HiFloatBorder()
151-
let l:bg = easycomplete#ui#GetBgColor("Normal")
152-
call easycomplete#ui#hi("Pmenu", "", l:bg, {})
153-
call easycomplete#ui#hi("FloatBorder", "", l:bg, {})
154-
call easycomplete#ui#hi("PmenuSBar", "", l:bg, {})
155-
call easycomplete#ui#hi("PmenuExtra", "", l:bg, {})
156-
call easycomplete#ui#hi("PmenuKind", "", l:bg, {})
151+
if g:easycomplete_pum_pretty_style == 1
152+
let l:bg = easycomplete#ui#GetBgColor("Normal")
153+
call easycomplete#ui#hi("Pmenu", "", l:bg, {})
154+
call easycomplete#ui#hi("FloatBorder", "", l:bg, {})
155+
call easycomplete#ui#hi("PmenuSBar", "", l:bg, {})
156+
call easycomplete#ui#hi("PmenuExtra", "", l:bg, {})
157+
call easycomplete#ui#hi("PmenuKind", "", l:bg, {})
158+
endif
157159
endfunction
158160

159161
function! s:IsSearchWord()

plugin/easycomplete.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ endif
126126
if !exists("g:easycomplete_use_default_cr")
127127
let g:easycomplete_use_default_cr = 1
128128
endif
129+
if !exists("g:easycomplete_pum_pretty_style")
130+
let g:easycomplete_pum_pretty_style = 1
131+
endif
129132
if !exists("g:easycomplete_lsp_type_font")
130133
let g:easycomplete_lsp_type_font = {}
131134
endif

0 commit comments

Comments
 (0)