Skip to content

Open Neovim floating windows with "minimal" style #549

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

Merged
merged 1 commit into from
Nov 2, 2019

Conversation

dradtke
Copy link
Contributor

@dradtke dradtke commented Oct 25, 2019

I've been using vim-lsp a fair amount recently, and I noticed that a lot of completion popups didn't seem to set the width appropriately:

Screen Shot 2019-10-25 at 9 54 13 AM

After digging in to this, I realized that the little gutter on the left-hand side of the popup was probably being counted by Neovim as part of the window's width, while vim-lsp was setting the width to the length of the longest line exactly.

To fix this, I discovered the style option for configuring popup windows:

 style : Configure the appearance of the window.
Currently only takes one non-empty value:
• "minimal" Nvim will display the window with
  many UI options disabled. This is useful
  when displaying a temporary float where the
  text should not be edited. Disables
  'number', 'relativenumber', 'cursorline',
  'cursorcolumn', 'foldcolumn', 'spell' and
  'list' options. 'signcolumn' is changed to
  auto . The end-of-buffer region is hidden
  by setting eob flag of 'fillchars' to a
  space char, and clearing the EndOfBuffer
  region in 'winhighlight'.

Here's what it looks like:

Screen Shot 2019-10-25 at 9 55 33 AM

Note that the first line fits entirely in the window, rather than wrapping the final two characters to a new line.

@clason
Copy link
Contributor

clason commented Oct 28, 2019

Yes, that looks like a reasonable change (and is in fact the intended style for such popups).

There's a plan to rework the floats, making better use of the neovim api when it is available, in #510; feel free to add your thoughts there. One thing that is missing currently is to account for soft-wrapping: if the location is at a wrapped line (after the softwrap), the popup placement is off (right-aligned at window for hover, too low for completion).

(@thomasfaingnaert I tested this, and it seems fine to merge.)

@thomasfaingnaert
Copy link
Collaborator

@clason @dradtke Is this supported in all Neovim versions with a floating window, or do we need to add a version check for this?

@clason
Copy link
Contributor

clason commented Nov 2, 2019

@thomasfaingnaert Yes, the first version with floating windows (0.4.0) already supports the minimal style (neovim/neovim@ef3e32d).

@thomasfaingnaert thomasfaingnaert merged commit 19e5b08 into prabirshrestha:master Nov 2, 2019
@thomasfaingnaert
Copy link
Collaborator

Merged, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants