I'm trying to map ctrl+click event to generic navigation for java types using YouCompleteMe plugin. There's plugin command to do that: :YcmCompleter GoTo it navigates to "most sensible" place for type under cursor: https://github.com/ycm-core/YouCompleteMe#the-goto-subcommand:

This command tries to perform the "most sensible" GoTo operation it can

This is my .vim/ftplugin/java.vim:

nnoremap <buffer> <C-LeftMouse> :YcmCompleter GoTo<CR>

It's working but with one exception: it doesn't change cursor position before performing GoTo command, e.g. if the cursor is located on one type and I'm clicking another type, it will open first type. It seems that I'm doing something wrong here. I need first move cursor to clicking position and then execute the command, or maybe I'm doing something wrong here and vim has another way to implement such feature. How to implement it correctly?

  • Would something like nnoremap <buffer> <C-LeftMouse> :norm! <LeftMouse><CR>:YcmCompleter GoTo<CR> work? I didn't test but the idea is to make your mapping actually click the mouse and then use the YcmCompleter command. – statox Jun 25 at 14:42
  • @statox no, it doesn't. :norm! \<LeftMouse\> doesn't change the word under cursor. – g4s8 Jun 25 at 16:00
  • Well is was just a supposition too bad it didn't work... But I'm sure someone on here will be able to help you :) – statox Jun 25 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.