Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Put the contents of the preview into the completion or put into command line as a message #1274

Closed
unphased opened this issue Dec 10, 2014 · 11 comments

Comments

@unphased
Copy link

I love having critical argument information about functions, etc, in the preview window (and it works in Javascript as well!), but I really hate how autoclosing the preview window will mess up the window layout of my vim tab (by equalizing spacing).

It is not really a solution to just leave the preview window hanging around for every single window, because say I have 4 (okay... 3 is more realistic) windows open in one tab, that's a lot of wasted space! Alright, the same preview window gets reused, still, but having 4 lines hanging around doing nothing most of the time is still unacceptable.

I also don't know why docs mention that it should show up at the top, but it always shows up underneath, for me. None of that matters. It's both lovely (tells me something often really useful) and vile (destructively undoing my OCD window sizing work) at the same time, so it has to go because that info must have a way to get to me another way.

I get that its probably a Vim limitation that removing a window will bork the layout, but i am hoping there's some alternate way to temporarily view this information. Either by tacking it into the completion somehow, or failing that, just stuffing that info into the Vim command line. I think it's perfectly suited for putting this info into the command line. Its just like warnings/errors text, i only need to look at it for about one quarter of a second.

@unphased unphased changed the title Feature request: Put the contents of the preview into the completion Feature request: Put the contents of the preview into the completion or put into command line as a message Dec 10, 2014
@Valloric
Copy link
Member

Either by tacking it into the completion somehow, or failing that, just stuffing that info into the Vim command line.

That isn't a bad idea, the problem is that we can't fit a lot of info there. Also, in the case of overloads, which overload should we show?

This is a tough problem that's entirely created by Vim's shitty API/lack of features. IDE's solve this in a variety of ways that aren't possible to implement in Vim.

@unphased
Copy link
Author

Hmm, good point. Gotta have my overloads.

Sigh, probably gotta build some independent tweak that has some binds to help manage the closing the preview window (and eventually integrate it into the autoclose system in YCM). I am envisioning something akin to the way that I'm able to save a session and restore it and it even gets the window positions right.

This is out of my vimrc:

 " taken from http://stackoverflow.com/a/6052704/340947 and with some stylistic
 " changes and functional enhancements of mine (the backing up of session files)
 fu! SaveSess()
     " if the session file exists, rename it to a dotfile with a timestamp
     if filereadable(getcwd().'/.session.vim')
         call system('mv '.getcwd().'/.session.vim '.getcwd().'/.session-'.substitute(strftime("%Y %b %d %X"), ' ', '_', 'g').'.vim')
     endif
     set sessionoptions=tabpages,winsize
     execute 'mksession '.getcwd().'/.session.vim'
 endfunction

 fu! RestoreSess()
     if filereadable(getcwd().'/.session.vim')
         execute 'so '.getcwd().'/.session.vim'
     endif
 endfunction

Not sure how helpful mksession might be to achieve this with.

Also found this plugin

But this will surely at least involve some annoying flickering back and forth as we remove the preview window and then scramble to restore state.

@vheon
Copy link
Contributor

vheon commented Dec 11, 2014

@unphased If I'm not wrong the mksession store on disk all that is needed to the session so IMHO is not feasible. I usually don't use the preview window so I'm not accustomed to the problem. Could you provide me a little test case to experience the problem? Plus after I saw this issue I look around for similar things and I came by vim-clang which from the gif in the Readme (I didn't test it though) seems to not have any problem showing the info in a preview-like buffer. We could look into that.

@unphased
Copy link
Author

Its no issue if you've got one window (or heck even vertical split windows, which most folks never progress beyond).

You can reproduce with a window like this:

┌────────┐
│ window │
│   1    │
├────────┤
│        │
│        │
│ window │
│   2    │
│        │
│        │
└────────┘

It is perhaps an "advanced" vim feature.

Then you do some completion, get the preview to open:

┌────────┐
│ window │
│   1    │
├────────┤
│        │
│        │
│ window │
│   2    │
│        │
├────────┤
│preview │
└────────┘

Upon closure of preview it will forcibly reset what you set up.

┌────────┐
│ window │
│   1    │
│        │
│        │
├────────┤
│ window │
│   2    │
│        │
│        │
└────────┘

@vheon
Copy link
Contributor

vheon commented Dec 11, 2014

oh so what you want is to remember for each visible window the width and the height and after the preview windows goes away restore those width and height. That should be pretty easy to do.

@vheon
Copy link
Contributor

vheon commented Dec 11, 2014

Even better, instead of tracking the width and the height we could just store a command for restoring the size of the window using winrestcmd() function and after closing the preview window call the command on every window to restore its state. I'm only trying to figure it out when is the best spot to call the winrestcmd() function.

@oblitum
Copy link
Contributor

oblitum commented Jan 7, 2015

Multiplexing the popup menu to acquire multiple roles, like done in #1300, may also be an alternative to solve this problem.

@ruohola
Copy link

ruohola commented Jul 19, 2018

Any update on fixing this?

@puremourning
Copy link
Member

It’s not broken?

@ruohola
Copy link

ruohola commented Jul 19, 2018

Not broken per se, but would be nice if the preview window wouldn't resize splits.

@puremourning
Copy link
Member

YCM now support signature help for most languages and you can set completeopt+=popup to use a popup for the preview information too.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants