Skip to content

Commit

Permalink
bugfix for #269
Browse files Browse the repository at this point in the history
  • Loading branch information
jayli committed Dec 9, 2023
1 parent e167ced commit afc5f2d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
5 changes: 4 additions & 1 deletion autoload/easycomplete/tabnine.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
" ./sources/tn.vim 负责pum匹配,这里只负责做代码联想提示
" tabnine suggestion 和 tabnine complete 共享一个 job

let s:tabnine_toolkit = v:lua.require("easycomplete.tabnine")
let s:tabnine_toolkit = easycomplete#util#HasLua() ? v:lua.require("easycomplete.tabnine") : v:null
" 临时存放 suggest 或者 complete
let b:tabnine_typing_type = ""
let s:tabnine_hint_snippet = []
Expand All @@ -10,6 +10,9 @@ function easycomplete#tabnine#ready()
if g:env_is_vim
return v:false
endif
if !easycomplete#util#HasLua()
return v:false
endif
if !easycomplete#ok('g:easycomplete_tabnine_enable')
return v:false
endif
Expand Down
8 changes: 6 additions & 2 deletions autoload/easycomplete/ui.vim
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,14 @@ function! easycomplete#ui#GetHiColor(hiName, sufix)
let my_color= matchstr(hlString,"\\(\\scterm" .sufix. "=\\)\\@<=\\w\\+")
endif

if my_color =~ '^\d\+$'
return str2nr(my_color)
if my_color == ""
return "NONE"
endif

" if my_color =~ '^\d\+$'
" return str2nr(my_color)
" endif

return my_color
endfunction " }}}

Expand Down
8 changes: 8 additions & 0 deletions autoload/easycomplete/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,14 @@ function! easycomplete#util#FindNearestParentFile(path, filename) abort
endif
endfunction

function! easycomplete#util#HasLua()
if g:env_is_nvim && has("nvim-0.5.0")
return v:true
else
return v:false
endif
endfunction

function! easycomplete#util#GetDefaultRootUri()
let current_lsp_ctx = easycomplete#GetCurrentLspContext()
let current_file_path = fnamemodify(expand('%'), ':p:h')
Expand Down
10 changes: 10 additions & 0 deletions lua/easycomplete/tabnine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ function Export.nvim_init_tabnine_hl()
local cursorline_bg = vim.fn["easycomplete#ui#GetBgColor"]("CursorLine")
local normal_bg = vim.fn["easycomplete#ui#GetBgColor"]("Normal")
local linenr_fg = vim.fn["easycomplete#ui#GetFgColor"]("LineNr")
if vim.fn.matchstr(cursorline_bg, "^\\d\\+") ~= "" then
cursorline_bg = vim.fn.str2nr(cursorline_bg)
end
if vim.fn.matchstr(normal_bg, "^\\d\\+") ~= "" then
normal_bg = vim.fn.str2nr(normal_bg)
end
if vim.fn.matchstr(linenr_fg, "^\\d\\+") ~= "" then
linenr_fg = vim.fn.str2nr(linenr_fg)
end

vim.api.nvim_set_hl(0, "TabNineSuggestionFirstLine", {
bg = cursorline_bg,
fg = linenr_fg
Expand Down

0 comments on commit afc5f2d

Please sign in to comment.