Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@benknoble
Copy link
Contributor

@benknoble benknoble commented Jul 14, 2021

This PR adds vim-popups as an alternative to neovim's floating windows for things like ALEHover.

Not sure about testing this, but it works! At least for ALEHover and cursor_detail.

Related: #3703

Details on implementation
-------------------------
- we make use of the |popupwin| api
- we split implementations (Nvim* vs. Vim* prefix) and call the right
  one based on has('nvim')
- we follow a similar structure in each function, using the relevant API
  - popup_list, win_execute, popup_settext in VimShow
  - popup_create in VimCreate
  - popup_close in VimClose

Some differences
----------------
- we DON'T have VimPrepareWindowContent because we use arguments to
  popup_create for borders, padding, etc., and it also takes care of
  buffer creation.
- we follow the protocol of setting and using w:preview for information,
  but we only need the ID
- InsertEnter is the only autocommand required, because of
  popup_create's moved argument. Any cursor movement with 'any' will
  close the popup. This in turns means VimClose is only called from
  InsertMode, so no mode-restoration necessary
- we don't tweak too much in the buffer because vim's popup buffers
  already have most relevant settings and aren't editable without
  calling popup functions.
- I enabled scrollbars, close buttons, dragging, and resizing
- vim popups get as big as they need to by default, so no worrying about
  truncating/hiding/size

Note: we might want to consider changing w:preview to w:ale_preview to
avoid clashes if someone else tries to use the same variable
@benknoble
Copy link
Contributor Author

/cc @hsanson now that tests are passing.

Copy link
Contributor

@hsanson hsanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good and I tested it does not break NeoVim. I do not have a recent version of Vim that support popupwin so I am trusting this works and will merge as is a requested feature by many.

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.

2 participants