Skip to content

Commit 0ad89a5

Browse files
committed
新增第六种kind颜色
1 parent be864c7 commit 0ad89a5

File tree

4 files changed

+31
-14
lines changed

4 files changed

+31
-14
lines changed

README-cn.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,9 @@ You can add custom Pmenu styles by defining these highlight groups:
383383
- `EasySnippet`: Snippet 图标样式. 默认link到 "Keyword".
384384
- `EasyTabNine`: TabNine 图标样式. 默认link到 "Character".
385385
- `EasySnippets`: 行内补全样式. 默认link到 "LineNr"
386+
- `EasyNormal`: 默认图标样式,默认link到 Normal.
387+
- `EasyKeyword`: 默认Keyword图标,默认links 到 "Define".
388+
- `EasyModule`: 默认Module 图标. 默认links到"Function".
386389

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

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,9 @@ You can add custom Pmenu styles by defining these highlight groups:
387387
- `EasySnippet`: Snippet kind icon style. links to "Keyword" by default.
388388
- `EasyTabNine`: TabNine kind icon style. links to "Character" by default.
389389
- `EasySnippets`: TabNine snippets suggestion style. links to "LineNr" by default
390+
- `EasyNormal`: Pmenu default style. links to "Normal" by default.
391+
- `EasyKeyword`: Pmenu keyword kind icon style. links to "Define" by default.
392+
- `EasyModule`: Module kind icon style. links to "Function" by default.
390393

391394
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.
392395

autoload/easycomplete/pum.vim

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,27 +90,30 @@ endfunction
9090
" EasyExtra: "‰", 继承 PmenuExtra
9191
"
9292
" vscode 提供了超过五种 kind 颜色配置,把 lsp 和 text
93-
" 区分开,这里增加5种常见的颜色配置:
93+
" 区分开,这里设置6种常见的颜色配置:
94+
" 6种颜色做隔离足够了,ColorScheme 常用颜色一般也就八九个
9495
" EasyFunction: "%", Function/Constant/Scruct
9596
" EasySnippet: "∫", Snippet/snip
9697
" EasyTabNine: "@", TabNine
9798
" EasyNormal: "Φ", Buf/Text/dict - Pmenu 默认色
9899
" EasyKeyword: "♧", Keyword
100+
" EasyModule: "♤", module
99101
function! s:hl()
100102
if empty(s:easycomplete_hl_exec_cmd)
101103
if easycomplete#util#IsGui()
102104
let dev = "gui"
103105
else
104106
let dev = "cterm"
105107
endif
106-
let fuzzymatch_hl_group = s:HLExists("EasyFuzzyMatch") ? "EasyFuzzyMatch" : "PmenuMatch"
107-
let pmenu_kind_hl_group = s:HLExists("EasyPmenuKind") ? "EasyPmenuKind" : "PmenuKind"
108-
let pmenu_extra_hl_group = s:HLExists("EasyPmenuExtra") ? "EasyPmenuExtra" : "PmenuExtra"
109-
let function_hl_group = s:HLExists("EasyFunction") ? "EasyFunction" : "Conditional"
110-
let snippet_hl_group = s:HLExists("EasySnippet") ? "EasySnippet" : "Keyword"
111-
let tabnine_hl_group = s:HLExists("EasyTabNine") ? "EasyTabNine" : "Character"
112-
let pmenu_hl_group = s:HLExists("EasyPmenu") ? "EasyPmenu" : "Pmenu"
113-
let keyword_hl_group = s:HLExists("EasyKeyword") ? "EasyKeyword" : "Define"
108+
let fuzzymatch_hl_group = s:HLExists("EasyFuzzyMatch") ? "EasyFuzzyMatch" : "PmenuMatch"
109+
let pmenu_kind_hl_group = s:HLExists("EasyPmenuKind") ? "EasyPmenuKind" : "PmenuKind"
110+
let pmenu_extra_hl_group = s:HLExists("EasyPmenuExtra") ? "EasyPmenuExtra" : "PmenuExtra"
111+
let function_hl_group = s:HLExists("EasyFunction") ? "EasyFunction" : "Conditional"
112+
let snippet_hl_group = s:HLExists("EasySnippet") ? "EasySnippet" : "Number"
113+
let tabnine_hl_group = s:HLExists("EasyTabNine") ? "EasyTabNine" : "Character"
114+
let pmenu_hl_group = s:HLExists("EasyPmenu") ? "EasyPmenu" : "Pmenu"
115+
let keyword_hl_group = s:HLExists("EasyKeyword") ? "EasyKeyword" : "Define"
116+
let module_hl_group = s:HLExists("EasyModule") ? "EasyModule" : "Function"
114117
let pmenu_cursor_has_reverse = s:HasReverseHighlight("PmenuSel")
115118
if s:HLExists("EasyFuzzyMatch")
116119
let fuzzymatch_bold_str = s:HasBold("EasyFuzzyMatch") ? "gui=bold" : ""
@@ -146,6 +149,7 @@ function! s:hl()
146149
\ 'syntax region CustomSnippet matchgroup=Conceal start=/∫\([^∫]∫\)\@=/ matchgroup=Conceal end=/\(∫[^∫]\)\@<=∫/ concealends oneline',
147150
\ 'syntax region CustomTabNine matchgroup=Conceal start=/@\([^@]@\)\@=/ matchgroup=Conceal end=/\(@[^@]\)\@<=@/ concealends oneline',
148151
\ 'syntax region CustomKeyword matchgroup=Conceal start=/♧\([^♧]♧\)\@=/ matchgroup=Conceal end=/\(♧[^♧]\)\@<=♧/ concealends oneline',
152+
\ 'syntax region CustomModule matchgroup=Conceal start=/♤\([^♤]♤\)\@=/ matchgroup=Conceal end=/\(♤[^♤]\)\@<=♤/ concealends oneline',
149153
\ 'syntax region CustomNormal matchgroup=Conceal start=/Φ\([^Φ]Φ\)\@=/ matchgroup=Conceal end=/\(Φ[^Φ]\)\@<=Φ/ concealends oneline',
150154
\ "hi CustomFuzzyMatch " . dev . "fg=" . fuzzymatch_fg . " " . fuzzymatch_bold_str,
151155
\ "hi CustomPmenuSel " . dev . "fg=" . pmenu_cursor_hl_group_fg . " " . dev . "bg=" . pmenu_cursor_hl_group_bg,
@@ -156,6 +160,7 @@ function! s:hl()
156160
\ "hi link CustomTabNine " . tabnine_hl_group,
157161
\ "hi link CustomNormal " . pmenu_hl_group,
158162
\ "hi link CustomKeyword " . keyword_hl_group,
163+
\ "hi link CustomModule " . module_hl_group,
159164
\ "hi link Error Pmenu",
160165
\ ]
161166
" \ "hi Search guibg=NONE guifg=NONE ctermbg=NONE ctermfg=NONE",
@@ -349,7 +354,7 @@ function! easycomplete#pum#PumGetPos()
349354
\ "width": w - 1,
350355
\ "scrollbar": scrollbar,
351356
\ "size": item_size
352-
\}
357+
\ }
353358
endfunction
354359

355360
function! easycomplete#pum#CompleteChangedEvnet()
@@ -1091,6 +1096,7 @@ function! s:MaxLength(lines)
10911096
let remove_style_wrapper = substitute(remove_style_wrapper, "\\s@\[^@\]@\\s", " x ", "g")
10921097
let remove_style_wrapper = substitute(remove_style_wrapper, "\\\[\]Φ\\s", " x ", "g")
10931098
let remove_style_wrapper = substitute(remove_style_wrapper, "\\s♧\[^♧\]\\s", " x ", "g")
1099+
let remove_style_wrapper = substitute(remove_style_wrapper, "\\s♤\[^♤\]\\s", " x ", "g")
10941100
let curr_length = strdisplaywidth(substitute(remove_style_wrapper, "\[§|‰]", "", "g"))
10951101
if curr_length > max_length
10961102
let max_length = curr_length
@@ -1108,27 +1114,31 @@ function! s:MapFunction(key, val)
11081114
let kind_char = "|"
11091115
if g:easycomplete_nerd_font
11101116
let kind_o = get(a:val, "kind", "")
1111-
if kind_o ==# g:easycomplete_lsp_type_font["function"] ||
1117+
if kind_o ==# g:easycomplete_lsp_type_font["function"] ||
11121118
\ kind_o ==# g:easycomplete_lsp_type_font["constant"] ||
11131119
\ kind_o ==# g:easycomplete_lsp_type_font["struct"]
11141120
" 颜色1
11151121
let kind_char = "%"
1116-
elseif kind_o ==# g:easycomplete_menu_skin["snip"]["kind"] ||
1122+
elseif kind_o ==# g:easycomplete_menu_skin["snip"]["kind"] ||
11171123
\ kind_o ==# g:easycomplete_lsp_type_font["snippet"]
11181124
" 颜色2
11191125
let kind_char = ""
11201126
elseif kind_o ==# g:easycomplete_menu_skin["tabnine"]["kind"]
11211127
" 颜色3
11221128
let kind_char = "@"
1123-
elseif kind_o ==# g:easycomplete_menu_skin["buf"]["kind"] ||
1129+
elseif kind_o ==# g:easycomplete_menu_skin["buf"]["kind"] ||
11241130
\ kind_o ==# g:easycomplete_menu_skin["dict"]["kind"] ||
11251131
\ kind_o ==# g:easycomplete_lsp_type_font["text"]
11261132
" 颜色4,标准色
11271133
let kind_char = "Φ"
1128-
elseif kind_o ==# g:easycomplete_lsp_type_font["keyword"] ||
1134+
elseif kind_o ==# g:easycomplete_lsp_type_font["keyword"] ||
11291135
\ kind_o ==# g:easycomplete_lsp_type_font["class"]
11301136
" 颜色 5
11311137
let kind_char = ""
1138+
elseif kind_o ==# g:easycomplete_lsp_type_font["module"] ||
1139+
\ kind_o ==# g:easycomplete_lsp_type_font["method"]
1140+
" 颜色 6
1141+
let kind_char = ""
11321142
endif
11331143
endif
11341144
let format_object = {

plugin/easycomplete.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ if g:easycomplete_nerd_font == 1
7373
\ 'let': get(kind_icons, "let", ""), 'parameter': get(kind_icons, 'parameter', "󰏗"),
7474
\ 'operator': get(kind_icons, 'operator', "󱧕"), 'property': get(kind_icons, 'property', "󰙅"),
7575
\ 'local': get(kind_icons, 'local', ""), 'cmdline': get(kind_icons, 'cmdline', ""),
76+
\ 'method': get(kind_icons, 'method', ""),
7677
\ 'r':'', 't':'',
7778
\ 'f':'f', 'c':'',
7879
\ 'u':'𝘶', 'e':'𝘦',

0 commit comments

Comments
 (0)