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

Add option to open doc preview window in a vertical right split

GergelyKalmar opened this issue · comments

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside
the brackets) before filing your issue:

  • I have read and understood YCM's [CONTRIBUTING][cont] document.
  • I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
  • I have read and understood YCM's [README][readme], especially the
    [Frequently Asked Questions][faq] section.
  • 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.

Thank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.

Issue Details

  • What did you do?

Executed :rightbelow vertical YcmCompleter GetDoc.

  • What did you expect to happen?

I expected the documentation to appear in a vertical split on the right side, similar to how :rightbelow vertical YcmCompleter GoTo opens a split in a vertical split on the right side.

  • What actually happened?

The documentation / preview window appeared on the top. I was able to move the preview window to the bottom by setting set splitbelow (as recommended in #2355). I tried setting set splitright, however, that did not seem to have any effect.

This might be possible. I'll have a look.

When handling the GetDoc response, we open the preview window, but it looks like we ignore any mods that were supplied to the command. I'll take a look.

Can you test drive PR #4155 ?

Hm it does open the preview window on the right, however, the width is very narrow. Is there a way to configure that? If it used 1/3 of the width that would also be ok, but right now it seems to render at 16 column width.

The GoTo commands seem to create a split in the middle, it's not optimal but it would be better than the current setup. Optimally we could specify the width separately for the GoTo* commands and the GetDoc command.

Does rightbelow vertical 80YcmCompleter GetDoc open 80 column ?

That gives an "invalid range" error it seems.

Ok thanks for testing. I'll take a look at making that work.

Ok thanks for testing. I'll take a look at making that work.

Ugh, it turns out that it's annoying. a command can only have a range or a count, and YcmCompleter already uses a range (for :%YcmCompleter Format).

The best workaround I can think of (for now) would be some custom thing like:

command -count ShowDoc let g:ph=&previewheight <bar> set previewheight=<count> <bar> <mods> YcmCompleter GetDoc <bar> let &previewheight=g:ph

This sets previewheight temporarily, then does YcmCompleter GetDoc with whatever mods you supply, e.g.

:rightbelow vertical 80ShowDoc

That can work. Couldn't we use a range anyways and just ignore a part of it? Like 80,1YcmCompleter GetDoc?

Your solution has a nicer interface though, I have to admit.

That can work. Couldn't we use a range anyways and just ignore a part of it? Like 80,1YcmCompleter GetDoc?

No, that's just a hack

I decided to just document the above workaround, as I think this is pretty niche.