-
Notifications
You must be signed in to change notification settings - Fork 306
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
Allow setting popup max width #416
Allow setting popup max width #416
Conversation
Works nicely for neovim; I personally prefer its behavior (wrap at whitespace only). Shameless request: is it possible to (optionally) make the popup preferentially open above (or to the right of) the cursor (with correspondingly changed anchor)? |
@clason You mean opening it at that anchor in all cases? If so, this can easily be done by changing the |
@thomasfaingnaert Well, basically switching the current behavior (below unless too close to the bottom) to its opposite (above unless too close to the top) -- or rather, make it a vimrc option since tastes differ. (It's not critical, just a thought.) |
autoload/lsp/ui/vim/output.vim
Outdated
let &l:readonly = 0 | ||
let &l:modifiable = 1 | ||
|
||
normal! gggqGgg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you just give the maxwidth in line 233 call s:adjust_float_placement(l:bufferlines, l:maxwidth)
and enable soft wrap?
Imo turning it modifiable, format and unmodifiable again feels kind of hackish.
If the current solution has any benefit, it should be done in s:setcontent, as it effects the content itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jerdna-regeiz
If you mean something like this:
diff --git a/autoload/lsp/ui/vim/output.vim b/autoload/lsp/ui/vim/output.vim
index 7b52f4c..718b01d 100644
--- a/autoload/lsp/ui/vim/output.vim
+++ b/autoload/lsp/ui/vim/output.vim
@@ -211,7 +211,7 @@ function! lsp#ui#vim#output#preview(data) abort
if s:supports_floating && s:winid && g:lsp_preview_float
if has('nvim')
- call s:adjust_float_placement(l:bufferlines, l:maxwidth)
+ call s:adjust_float_placement(l:bufferlines, 10)
call s:add_float_closing_hooks()
endif
doautocmd User lsp_float_opened
then that doesn't work: it only displays the first line of the popup. Moving it to s:setcontent
would indeed be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, then it depends on the source or some other settings, as it wraps each row nicely for me.
But in setcontent it looks great and a lot less hacky =)
Actually this does now apply to normal preview as well (which is nice in my opinion!). Maybe we should just call the option g:lsp_preview_max_width
as it now applies to every flavor of it.
plugin/lsp.vim
Outdated
@@ -28,6 +28,7 @@ let g:lsp_highlight_references_enabled = get(g:, 'lsp_highlight_references_enabl | |||
let g:lsp_preview_float = get(g:, 'lsp_preview_float', 1) | |||
let g:lsp_preview_autoclose = get(g:, 'lsp_preview_autoclose', 1) | |||
let g:lsp_preview_doubletap = get(g:, 'lsp_preview_doubletap', [function('lsp#ui#vim#output#focuspreview')]) | |||
let g:lsp_popup_max_width = get(g:, 'lsp_popup_max_width', -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should either call both float or popup (meaning g:lsp_preview_float
and g:lsp_popup_max_width
).
Guess it would be a lot of work for very little gain. Imo it is nice as it is now, regardless of different line wraps. |
Regardless of my bikeshedding earlier, I think it's fine as is, too, and would like to see this get merged. Or is there something still missing? I'd be happy to help test. |
I feel really bad about this, but there's one issue with this PR that I didn't notice before the As far as I can see, there are two options:
EDIT: I see from the code that the reflowing is manual ( |
Looking at the code a bit more, I see that Replacing the if g:lsp_preview_max_width > 0
let l:width = min([l:width,g:lsp_preview_max_width])
endif in So I think the underlying issue that led me to request (On a related note, I saw a trick for getting "borders" for neovim floats: Open a slightly larger float of reverse highlight (light for dark or dark for light) under the actual float, see neovim/neovim#9718 (comment)) |
In response to: #395 (comment).
Tested with
Vim 8.1.1592
andNVIM v0.4.0-1149-g8b263c7a6
.Note that Vim and Neovim have slightly different behaviour, Vim wraps on every character:
whereas Neovim only wraps at whitespace:
Should I try to change it so both Vim and Neovim behave the same?