codota / tabnine-vim

Vim client for TabNine. https://vimawesome.com/plugin/tabnine-vim
https://www.tabnine.com/install/vim
GNU General Public License v3.0
671 stars 36 forks source link

Provide keyboard shortcut to close tabnine auto complete window #20

Closed dannyalan closed 3 years ago

dannyalan commented 5 years ago

Issue originally and incorrectly opened against https://github.com/zxqfl/TabNine/issues/59

Firstly, cracking plugin! I use this in vim and it has transformed the way in which I develop! Nice one!

This issue is to recognise the lack of a keyboard shortcut (I use Vim 8) to close the auto complete window. In Visual Studio products, the shortcut is (esc) although, this takes me out of Insert mode and even at that, the auto complete window still does not close until I press any other key.

The ability to close or hide the auto complete window would allow me entire visibility of the code I am editing again so I can gently stroke my beard and think carefully of my next bold code change!

soonseah commented 4 years ago

agreed. in vim, i am using snipmate and was trying to close the autocomplete window for tabnine, so that i can fire the snipmate snippets (template code) when i needed to....but now, i can't do that (unless i hit 'ESC' and 'a' keys to exit and re-enter insert mode, which makes the autocomplete window goes away, but the defaults the purpose as it is too many keystrokes to have the benefits)

Shougo commented 4 years ago

You can close the window by C-e key.

marslo commented 4 years ago

I suppose this can be done by following function (but doesn't work in my environment):

function! TriggerYCM()
  if g:loaded_youcompleteme == 1
    let g:loaded_youcompleteme = 0
  else
    let g:loaded_youcompleteme = 1
  endif
endfunction
map <M-j> :call TriggerYCM()<CR>

so, I've using filetype to specific enable/disable :

if !(&filetype == 'vim')      " if index( ['vim'], &filetype) == -1
  let g:loaded_youcompleteme = 1
endif

or

let g:ycm_filetype_blacklist = {
      \ 'vim' : 1 ,
      \ 'vimshell': 1 ,
      \ 'vimwiki': 1,
      \ }
let g:ycm_filetype_specific_completion_to_disable = {
      \ 'gitcommit': 1
      \ }

or