Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
jayli committed Jan 1, 2024
1 parent 04e70c4 commit 961eb1c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
40 changes: 28 additions & 12 deletions autoload/easycomplete/pum.vim
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
" ------------------------------
" TODO 连续tab移动选中态,很卡 jayli,比如在js文件中输入hi
" ------------------------------
" for nvim only
" 默认 pum window 初始化属性
let s:default_pum_pot = {
\ "relative": "editor",
\ "focusable": v:false,
\ "zindex": 50,
\ "bufpos": [0,0]
\ }
" Scrollbar 默认属性
let s:default_scroll_pot = {
\ "relative": "editor",
\ "focusable": v:false,
Expand Down Expand Up @@ -63,11 +62,12 @@ endfunction
" EasyKind: "|", 继承 PmenuKind
" EasyExtra: "^", 继承 PmenuExtra
"
" vscode 提供了超过五种 kind 颜色配置,以把 lsp 和 text
" 区分开,这里增加两种常见的配置
" EasyFunction: "%", Function/Method
" EasySnippet: "&", Snippet
" vscode 提供了超过五种 kind 颜色配置, lsp 和 text
" 区分开,这里增加四种常见的颜色配置
" EasyFunction: "%", Function/Constant/Scruct
" EasySnippet: "&", Snippet/snip
" EasyTabNine: ";", TabNine
" EasyNormal: ":", Buf/Text/dict - Pmenu 默认色
function! s:hl()
let hl_group = empty(g:easycomplete_fuzzymatch_hlgroup) ? "Constant" : g:easycomplete_fuzzymatch_hlgroup
if easycomplete#util#IsGui()
Expand All @@ -82,12 +82,14 @@ function! s:hl()
\ 'syntax region EasyFunction matchgroup=Conceal start=/%\([^%]%\)\@=/ matchgroup=Conceal end=/\(%[^%]\)\@<=%/ concealends',
\ 'syntax region EasySnippet matchgroup=Conceal start=/&\([^&]&\)\@=/ matchgroup=Conceal end=/\(&[^&]\)\@<=&/ concealends',
\ 'syntax region EasyTabNine matchgroup=Conceal start=/;\([^;];\)\@=/ matchgroup=Conceal end=/\(;[^;]\)\@<=;/ concealends',
\ 'syntax region EasyNormal matchgroup=Conceal start=/:\([^:]:\)\@=/ matchgroup=Conceal end=/\(:[^:]\)\@<=:/ concealends',
\ "hi EasyFuzzyMatch " . dev . "fg=" . easycomplete#ui#GetFgColor(hl_group),
\ "hi link EasyKind PmenuKind",
\ "hi link EasyExtra PmenuExtra",
\ "hi link EasyFunction Conditional",
\ "hi link EasySnippet Number",
\ "hi link EasyTabNine Character",
\ "hi link EasyNormal Pmenu",
\ ]
" \ 'syntax region EasyKind matchgroup=Conceal start=/\%(||\)\@!|/ matchgroup=Conceal end=/\%(||\)\@!|/ concealends',
" \ 'syntax region EasyFunction matchgroup=Conceal start=/\%(¡¡\)\@!¡/ matchgroup=Conceal end=/\%(¡¡\)\@!¡/ concealends',
Expand Down Expand Up @@ -297,8 +299,7 @@ endfunction
function! easycomplete#pum#CursoredItem()
if !s:pumvisible() | return {} | endif
if s:selected_i == 0 | return {} | endif
" TODO jayli here - ----------------------------------------------
" tab 移动过程中会报错
" TODO tab 移动过程中会报错,未复现
if s:selected_i > len(s:curr_items)
call s:log("ERR", string(len(s:curr_items)) . " " . string(s:selected_i) . s:original_ctx["typing"])
return {}
Expand Down Expand Up @@ -709,7 +710,12 @@ endfunction
function! s:MaxLength(lines)
let max_length = 0
for item in a:lines
let curr_length = strdisplaywidth(substitute(item, "\[`|^%&;]", "", "g"))
let remove_style_wrapper = item
let remove_style_wrapper = substitute(remove_style_wrapper, "\\s%\[^%\]%\\s", " x ", "g")
let remove_style_wrapper = substitute(remove_style_wrapper, "\\s&\[^&\]&\\s", " x ", "g")
let remove_style_wrapper = substitute(remove_style_wrapper, "\\s;\[^;\];\\s", " x ", "g")
let remove_style_wrapper = substitute(remove_style_wrapper, "\\s:\[^:\]:\\s", " x ", "g")
let curr_length = strdisplaywidth(substitute(remove_style_wrapper, "\[`|^]", "", "g"))
if curr_length > max_length
let max_length = curr_length
endif
Expand All @@ -727,12 +733,22 @@ function! s:MapFunction(key, val)
if g:easycomplete_nerd_font
let kind_o = get(a:val, "kind", "")
if kind_o ==# g:easycomplete_lsp_type_font["function"] ||
\ kind_o ==# g:easycomplete_lsp_type_font["constant"]
\ kind_o ==# g:easycomplete_lsp_type_font["constant"] ||
\ kind_o ==# g:easycomplete_lsp_type_font["struct"]
" 颜色1
let kind_char = "%"
elseif kind_o ==# g:easycomplete_menu_skin["snip"]["kind"]
elseif kind_o ==# g:easycomplete_menu_skin["snip"]["kind"] ||
\ kind_o ==# g:easycomplete_lsp_type_font["snippet"]
" 颜色2
let kind_char = "&"
elseif kind_o ==# g:easycomplete_menu_skin["tabnine"]["kind"]
" 颜色3
let kind_char = ";"
elseif kind_o ==# g:easycomplete_menu_skin["buf"]["kind"] ||
\ kind_o ==# g:easycomplete_menu_skin["dict"]["kind"] ||
\ kind_o ==# g:easycomplete_lsp_type_font["text"]
" 颜色4,标准色
let kind_char = ":"
endif
endif
let format_object = {
Expand Down
3 changes: 2 additions & 1 deletion custom-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ vim.g.easycomplete_kind_icons = {
dict = "󰈍",
snip = "",
tabnine = "󱙺",
operator = "󰞷",
class = "",
constant = "",
enum = "",
Expand Down Expand Up @@ -51,7 +52,7 @@ vim.g.easycomplete_kind_icons = {
}

-- Custom pum format. Only avilable with `g:easycomplete_nerd_font == 1` in nvim
vim.g.easycomplete_pum_format = ["kind", "abbr", "menu"]
vim.g.easycomplete_pum_format = {"kind", "abbr", "menu"}

-- Define highlight group for fuzzy matched charactors.
vim.g.easycomplete_fuzzymatch_hlgroup = "MyGroup"
Expand Down
3 changes: 2 additions & 1 deletion plugin/easycomplete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ if g:easycomplete_nerd_font == 1
\ 'event': get(kind_icons, "event", ''), 'var': get(kind_icons, "var", ""),
\ 'const': get(kind_icons, "const", ""), 'alias': get(kind_icons, 'alias', ""),
\ 'let': get(kind_icons, "let", ""), 'parameter': get(kind_icons, 'parameter', "󰏗"),
\ 'operator': get(kind_icons, 'operator', "󱧕"),
\ 'r':'', 't':'',
\ 'f':'f', 'c':'',
\ 'u':'𝘶', 'e':'𝘦',
\ 's':'󰙅', 'v':'',
\ 'i':'𝘪', 'm':'',
\ 'p':'𝘱', 'k':'𝘬',
\ 'o':"𝘰", 'd':'𝘥',
\ 'o':"󱧕", 'd':'𝘥',
\ 'l':"𝘭", 'a':"𝘢",
\ }
endif
Expand Down

0 comments on commit 961eb1c

Please sign in to comment.