Skip to content

Commit

Permalink
bugfix for cpp fuzzy match err
Browse files Browse the repository at this point in the history
  • Loading branch information
jayli committed Jan 8, 2024
1 parent 408ef21 commit e90e00c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
21 changes: 20 additions & 1 deletion autoload/easycomplete/sources/cpp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,28 @@ endfunction
function! easycomplete#sources#cpp#filter(matches)
let ctx = easycomplete#context()
let matches = map(copy(a:matches), function("easycomplete#util#FunctionSurffixMap"))
return matches
let matches_ret = map(copy(matches), function("s:CppItemPrefixHandling"))
return matches_ret
endfunction

function! s:CppItemPrefixHandling(key, val)
" `•clockid_t` -> `clockid_t`
" ` std::chrono` -> `std::chrono`
let item = a:val
let first_char = strcharpart(item['abbr'], 0, 1)
let abbr = item['abbr']
if char2nr(first_char) == 32 " 首字符是空格
let item['abbr'] = substitute(abbr, "^\\s\\+\\(.\\{\-}\\)$","\\1","g")
elseif strlen(first_char) > 1
let item['abbr'] = strcharpart(abbr, 1)
endif
return item
endfunction

function! s:log(...)
return call('easycomplete#util#log', a:000)
endfunction

function! s:console(...)
return call('easycomplete#log#log', a:000)
endfunction
2 changes: 2 additions & 0 deletions autoload/easycomplete/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ endfunction " }}}
" trim {{{
function! easycomplete#util#trim(str)
if !empty(a:str)
" 删除头部空格
let a1 = substitute(a:str, "^\\s\\+\\(.\\{\-}\\)$","\\1","g")
" 删除尾部空格
let a1 = substitute(a:str, "^\\(.\\{\-}\\)\\s\\+$","\\1","g")
return a1
endif
Expand Down
18 changes: 9 additions & 9 deletions plugin/easycomplete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ if g:easycomplete_nerd_font == 1
\ 'error': "",
\ 'warning': "",
\ 'information': '',
\ 'hint': ''
\ 'hint': ''
\ }
let g:easycomplete_lsp_type_font = {
\ 'class': get(kind_icons, "class", ""), 'color': get(kind_icons, "color", ""),
Expand All @@ -66,14 +66,14 @@ if g:easycomplete_nerd_font == 1
\ 'let': get(kind_icons, "let", ""), 'parameter': get(kind_icons, 'parameter', "󰏗"),
\ 'operator': get(kind_icons, 'operator', "󱧕"), 'property': get(kind_icons, 'property', "󰙅"),
\ 'local': get(kind_icons, 'local', ""),
\ 'r':'', 't':'',
\ 'f':'f', 'c':'',
\ 'u':'𝘶', 'e':'𝘦',
\ 's':'󰙅', 'v':'',
\ 'i':'𝘪', 'm':'',
\ 'p':'𝘱', 'k':'𝘬',
\ 'o':"󱧕", 'd':'𝘥',
\ 'l':"", 'a':"𝘢",
\ 'r':'', 't':'',
\ 'f':'f', 'c':'',
\ 'u':'𝘶', 'e':'𝘦',
\ 's':'󰙅', 'v':'',
\ 'i':'𝘪', 'm':'',
\ 'p':'𝘱', 'k':'𝘬',
\ 'o':"󱧕", 'd':'𝘥',
\ 'l':"", 'a':"𝘢",
\ }
endif

Expand Down

0 comments on commit e90e00c

Please sign in to comment.