Closed cridemichel closed 4 years ago
I noticed this too. It seems the only solution is to set 'wrap': 0
for the popup here
But that has its own problems.
I really don't want to write more complex code for popup positioning...
not sure what to do here.
actually I cooked up some logic that might work....
call popup_hide( s:cursorhold_popup )
let [ _, row, col, _, _ ] = getcurpos()
let pos = screenpos( win_getid(), row, col )
let lines = split( response, "\n" )
let len = max( map( lines, "len( v:val )" ) )
let wrap = 0
if len >= &columns
let place_at = 'botleft'
let wrap = 1
elseif pos.col + len >= &columns
let place_at = 'botright'
else
let place_at = 'botleft'
endif
let s:cursorhold_popup = popup_atcursor(
\ split( response, "\n" ),
\ {
\ 'pos': place_at,
\ 'padding': [ 0, 1, 0, 1 ],
\ 'moved': 'word',
\ 'maxwidth': &columns,
\ 'close': 'click',
\ 'wrap': wrap,
\ }
\ )
thank you for the prompt reply ...but how could I test this? My idea was simply the following: if cursor is at position (x,y) (where 1 < x <= winwidth and 1 < y <= winheight), then if x+minwidth > winwidth, set x = winwidth-minwidth, and mutatis mutandis do the same for y-axis.
Try changing these lines to the above
still getting this:
You can't have made the changes correctly then. At the very least, wrap should have been disabled.
I pushed the change to my fork
I copied the file autoload/youcompleteme.vim from your fork over mine
and I am still getting this:
Please list exact steps to reproduce, per CONTRIBUTING.md
Please also try with the minimal vimrc, per the CONTRIBUTING.md instructions.
I have already provided a minimal vimrc file to use and all what you have to do is to open the hover popup...
There's a reason that I asked for that.
The reasons are clearly explained in CONTRIBUTING.md. Your test case is not minimal and you have not listed the exact steps to reproduce.
Frankly I find that attitude disappointing and somewhat entitled. We do this in our spare time with literally no reward, so when I see that sort of response I'm often disinclined to work further on the request or issue. I have many other things I could be doing with my Sunday.
I'm going to give the benefit of the doubt here and assume you didn't mean to come across as entitled or unwilling to engage.
Dear, I apologize if I have hurt you somehow, it was not my intention at all. I think that the culprit was the use use of "botleft" in the first "place_at", indeed if I replace "botleft" with "botright", i.e.
if len >= &columns
let place_at = 'botright'
let wrap = 1
elseif pos.col + len >= &columns
let place_at = 'botright'
else
let place_at = 'botleft'
endif
I get the more pleasant layout as follows:
an issue of the present solution is that the popup overlaps the sign column, best Cristiano
hmm. I think that would go wrong now on the other side of the screen.
I think I worked it out. When a single line of the text is > the screen width, we have to be smarter.
I pushed a new commit: https://github.com/puremourning/YouCompleteMe/commit/2828271b092a3bf34c330b9a317f77177b280955
I was able to repro with this (btw, this is how you write steps to reproduce, you'll find this useful when approaching other open source or professional issues)
test.py
with these contents:def Really_Long_Method( which, has, some, param, that, take, the, whole, line ):
"""Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum egestas libero urna, vel sagittis felis condimentum in. Nulla arcu eros, aliquet vel mollis vitae, semper eu ex. Donec posuere quam et ornare sagittis. Curabitur nunc ex, fringilla quis lorem sed, dignissim congue felis. Integer vestibulum ac elit vel blandit. Nam non dui urna. Integer eu semper massa. Nullam ac elit interdum, aliquet elit nec, porttitor orci. Duis tempus justo lorem, ac fringilla ante viverra egestas. Etiam eleifend enim ac libero dapibus, quis condimentum lectus tristique. Fusce feugiat, lorem et faucibus eleifend, ipsum nisi maximus justo, at consectetur ligula leo vitae justo."""
# Really long one-line
pass
def Really_Long_Method_2():
"""Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum egestas
libero urna, vel sagittis felis condimentum in. Nulla arcu eros, aliquet vel
mollis vitae, semper eu ex. Donec posuere quam et ornare sagittis. Curabitur
nunc ex, fringilla quis lorem sed, dignissim congue felis. Integer vestibulum
ac elit vel blandit. Nam non dui urna. Integer eu semper massa. Nullam ac elit
interdum, aliquet elit nec, porttitor orci. Duis tempus justo lorem, ac
fringilla ante viverra egestas. Etiam eleifend enim ac libero dapibus, quis
condimentum lectus tristique. Fusce feugiat, lorem et faucibus eleifend, ipsum
nisi maximus justo, at consectetur ligula leo vitae justo."""
# Really long one para
pass
def Moan():
Really_Long_Method()
Really_Long_Method_2()
vim -Nu /path/to/YCM/vimrc_ycm_minimal test.py
:nmap <leader>D <plug>(YCMHover)
:rightbelow 80vsplit
\D
Expect: The popup shows the full text of the lorum ipsom Actual: It is squished.
With my latest change:
Expect: the popup shows the full text of the lorum ipsum Actual: Popup is shown at column 1 and wrapped :
by setting 'col' to 1 if
len >= &columns
seems to fix the issue and now the placement of the popup is ok.
The other minor issue I noticed is that popup window overlaps the sign column but this is a thing one can get to live with.
The other minor issue I noticed is that popup window overlaps the sign column but this is a thing one can get to live with.
How can I repro this? When you say overlaps, do you mean that the signs are drawn on top of the popup or, that you don't want the popup to draw on top of the signs ?
I did a quick test and vim draws popups over the signs, which Is what I would expect.
yes I get popups over the signs (see below), if this is what expected, that's fine!
That's what "column 1" means. Technically, the popup could be offsetted by the sign column width which is always 2 characters. Something like:
if &signcolumn ==# 'no'
column = 1
elseif &signcolumn ==# 'always'
column = 3
elseif &signcolumn ==# 'auto'
if len(sign_getplaced('%'))
column = 3
else
column = 1
endif
else " &signcolumn ==# 'number'
" 1, except when the line column is disabled and there are signs placed...
if !&number || !&relativenumber
if len(sign_getplaced('%'))
column = 3
endif
else
column = 1
endif
endif
" Let's offset by the width of the line number columns count
if &relativenumber || &number
column += max(4, log10(getbufinfo('%').linecount) + 1)
endif
" One-liner for curious (it's branch-free, so a C compiler will be happier with the solution below):
column = 1 + 2 * (&signcolumn ==# 'always' || (&signcolumn ==# 'auto' && bool(len(sign_getplaced('%')))) || (&signcolumn ==# 'number' && !&nu && !&rnu && len(sign_getplaced('%')))) + (&rnu || &nu) * max(4, log10(getbufinfo('%').linecount) + 1)
I'm not sure the added complexity here is justified.
I'm not sure the added complexity here is justified.
nor me. ;)
I pushed a.PR to resolve this.
Issue Prelude
Please complete these steps and check these boxes (by putting an
x
inside the brackets) before filing your issue:vim --version
.:YcmDebugInfo
.:YcmToggleLogs
command.vim -Nu /path/to/YCM/vimrc_ycm_minimal
, including what I expected to happen and what actually happened.install.py
(orcmake
/make
/ninja
) including its invocationThank 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
I used the new hover function to get documentation of LSP symbols (from texlab LSP) via the following mapping:
and if symbol hovered is close to left margin, this is what I get:
please note the shrunk popup on the right margin. Is there a way to set a minimum width for the popup window?
minimal .vimrc to reproduce the issue
Output of
vim --version
Output of
YcmDebugInfo
Output of
YcmDiags
Output of
git rev-parse HEAD
in YouCompleteMe installation directoryContents of YCM, ycmd and completion engine logfiles
OS version, distribution, etc.
mac osx catilina 10.15.4
Output of build/install commands