ycm-core / YouCompleteMe

A code-completion engine for Vim

Home Page:http://ycm-core.github.io/YouCompleteMe/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

YCMFindSymbolInWorkspace Ctrl-w not working in prompt buffer + UI suggestions

stonebrakert6 opened this issue · comments

Issue Prelude

  • [x ] I have read and understood YCM's [CONTRIBUTING][cont] document.
  • [ x] I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
  • [ x] I have read and understood YCM's [README][readme], especially the
    [Frequently Asked Questions][faq] section.
  • [ ]x I have searched YCM's issue tracker to find issues similar to the one I'm
    about to report and couldn't find an answer to my problem. ([Example Google
    search.][search])
  • If filing a bug report, I have included the output of vim --version.
  • If filing a bug report, I have included the output of :YcmDebugInfo.
  • If filing a bug report, I have attached the contents of the logfiles using
    the :YcmToggleLogs command.
  • If filing a bug report, I have included which OS (including specific OS
    version) I am using.
  • If filing a bug report, I have included a minimal test case that reproduces
    my issue, using vim -Nu /path/to/YCM/vimrc_ycm_minimal, including what I
    expected to happen and what actually happened.
  • If filing a installation failure report, I have included the entire output
    of install.py (or cmake/make/ninja) including its invocation
  • I understand this is an open-source project staffed by volunteers and
    that any help I receive is a selfless, heartfelt gift of their free time. I
    know I am not entitled to anything and will be polite and courteous.
  • I understand my issue may be closed if it becomes obvious I didn't
    actually perform all of these steps.

Issue Details

First of all thanks a lot for this plugin. I've been using it for years and this is the first time I am creating an issue. Thank you for all your work and patience.

I am using the mapping

 au FileType c,cpp,python nnoremap <Leader>x <Plug>(YCMFindSymbolInWorkspace)

in my .vimrc

This opens a prompt buffer and puts me in insert mode of that prompt buffer when I press <Leader>x
There are 2 minor issues I have

  1. While I am in the insert mode, I expect <Ctrl-w> to work(It should delete a word)
    You can check :h i_CTRL-W. I know I can go into normal mode and delete the word and then come back into insert mode to add a new word but this is awkward. Consider an additional mapping I've
au FileType c,cpp,python nnoremap <Leader>c :let @"=expand('<cword>')<CR> <Plug>(YCMFindSymbolInWorkspace)<C-r>"

This directly searches for the word under the cursor in the Workspace(skipping the typing step) and occasionaly I've to delete the word and Ctrl-w not working is certainly problematic for this workflow. So instead I've to use <Esc>bcw

  1. Second issue is about the UI. Due to my vim colorscheme, the selector line(to select the entries populated by YCMFindSymbolInWorkspace) is completely invisible and I am unable to decipher which entry is currently highlighted
    I am attaching a screenshot. It may not be visible to you, but the entry highlighted is 5th/last one.

Screenshot from 2023-08-15 18-12-16

Now consider this screenshot which uses the fzf vim plugin

Screenshot from 2023-08-15 18-13-26

where I can clearly see the entry selected, because of the red > and bold white colors of selected line.
Both of these issues are non-existent with fzf but certainly YCMFindSymbolInWorkspace is better for symbol search.

The ability to search for the symbol using YCMFindSymbolInWorkspace is a great feature, but I am unable to use it because of these minor issues.

Even if you decide not to fix these, I would be grateful if you can help me with workarounds to fix this

References : PR-3859
CC: @puremourning who implemented this

  1. see :help prompt-buffer.

It says:

The CTRL-W key can be used to start a window command, such as CTRL-W w to
switch to the next window. This also works in Insert mode (use Shift-CTRL-W
to delete a word). When leaving the window Insert mode will be stopped. When
coming back to the prompt window Insert mode will be restored.

  1. the problem is the 'CursorLine' highlight in your colourscheme. I imagine you'd have the same issue if you :set cursorline in a normal buffer. Best to raise this with the author of your colourscheme. All YCM does is set cursorline within the window displaying the popup buffer.

Thanks a lot @puremourning. Fixed 2 by using

hi CursorLine ctermbg=NONE ctermfg=NONE guibg=#303030 guifg=NONE cterm=bold gui=NONE

Regarding 1
Even though the documentation says that Shift-CTRL-W would delete the word, it is not working for me
Tested on

  1. My linux machine
  2. Macbook pro laptop
  3. Tested with vim -u NONE and then :new | set buftype=prompt | startinsert
    Ctrl-Shift-W just switches the window, which I believe is because of the fact that it behaves identically to Ctrl-W
    This is not related to YouCompleteMe. Can someone just confirm this? Does it work for you?
  4. I also tried a lot of things for a couple of hours, including insert mode keybindings using inoremap in that prompt-buffer but they don't seem to gel well with the implementation

Maybe I a missing something very basic. Would be grateful if someone could give a nudge in the right direction.

If someone can confirm that after setting buftype=prompt in a buffer, Ctrl-Shift-w doesn't delete the previous word in insert mode, then I would most likely file a bug report in vim.

Seems like it is not a vim bug but due to fact that I am using gnome terminal