-
Notifications
You must be signed in to change notification settings - Fork 304
[WIP] Refactor neovim floats #509
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
Conversation
call nvim_win_set_option(s:winid, 'relativenumber', v:false) | ||
call nvim_win_set_option(s:winid, 'cursorline', v:false) | ||
let l:opts['style'] = 'minimal' | ||
let s:winid = nvim_open_win(buf, v:false, l:opts) | ||
" Enable closing the preview with esc, but map only in the scratch buffer | ||
nmap <buffer><silent> <esc> :pclose<cr> |
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.
Now that we're not focusing the float, this would apply to the main buffer, I believe.
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.
Ah, you're right. Didn't notice that. How weird...
But even without that line, I get strange styling of the main buffer whenever a float is open (color changes in the status bar).
Maybe we should also consider getting rid of the "adjust size" functions, and only have a function "set content" that sets the content, and sets the size automatically (just like Vim floats behave). |
Weird, doesn't work for me (with texlab), even with \begin{equation}\label{eq:1}
1+2=2
\end{equation} Maybe we should postpone this until v0.4.0 is released and there is a (semi-)stable API to target (and compare). |
Yeah, there's too many intersecting code paths currently depending on the LSP function. I don't know the difference between half of these functions... Might be good to modularize it. Maybe also separate vim, neovim and preview and hide the different implementations behind a higher-level API: have @hrsh7th You're also currently working on float-related stuff |
Yeah, might be a good idea to cleanup |
Would you be OK with turning this PR is a general "refactor output.vim" PR? |
I would be OK with that; unless there is someone better suited for actually implementing it? (Is there a way to allow others to push to this branch?) |
Not that I know of, but I've added your fork as remote, so I can branch off from your branch and |
You can also add them as collaborators to your fork, but then they'll be able to push to all branches, which may or may not be what you want. |
Sounds good. This PR probably ends up being junked anyway and replaced with a clean proposal for merging. |
Things would be a lot simpler if nvim floats mirrored Vim's API somewhat (or vice versa) ;) |
I trust you ;) Maybe that's more convenient. |
Probably good though to precisely document which functions will be available before starting, and what their parameters should be. For the creation of the buffer+float, does it make sense to have that in the common API, because all features will have a different way of doing that: hover/peek def will want to create one located at the cursor, documentation on Vim will want to use the Vim float (and not open one itself), documentation on Neovim will create one manually placed next to the completion menu. (At least until |
One possibility for the API would be to first define a lower-level API that mirrors what you would like to have, and then for vim just pass it through while for neovim we'd try to implement the same behavior with their (even lower-level) API -- if they end up including higher-level APIs, too, we then just replace them.
Yes, we should decide on an LSP-centric high-level API that actually gets called from outside (and if we find a new situation, a new high-level function should be created instead of trying to directly use low-level calls). |
As a start (basically what we need from Vim's API):
For now, I think we need
Something like this? |
Probably also What about wrapping?
(Neovim plans to add higher-level APIs in the 0.5.0 cycle. One plan is to add functions for "ballooneval-as-floats", which seems to be half of what we need here, the other half being |
Well, for Vim |
For the |
Is there an approximate release date for |
So (No release date for |
I can't really think of a situation where you wouldn't want to wrap. |
Let's maybe also discuss the opening and setting content: would it make sense to have the |
Pushed small basic vimdoc, feel free to expand. |
Looks good! Comments, for discussion:
|
Yes, the API will be strictly hierarchical, I just added it in the documentation to have a quick overview, as a sort of summary of our discussion, I guess. The other layers should be removed later.
Yeah, I basically regard it as "top-level, but LSP specific", i.e. we would have a function that calls
Sure, I'll add that.
For hover and documentation, you would call |
Nice work =) positioning at the cursor (as anchor) was already possible when I wrote it. It did not make the code any easier, as the size and position (above/below and left/right) calculation requires the same information (in fact it was some how uglier). I would not recommend leaving the old preview behind as by far not everybody has a recent vim or neovim at hand. Still have to look at the code itself, I liked what I saw at a first glance. |
@jerdna-regeiz @clason Maybe adding @jerdna-regeiz as a collaborator would be good as well? |
That's also something that needs discussing. I assume we still want to keep the doubletap functionality, which is only possible in Neovim at the moment. |
Can be kept, because more documentation = more better, just with a caveat.
Makes sense 👍
That comment was fired from the hip, ignore that. It's fine as is.
Good point; these things will go in options, and the backend just ignore options it can't handle (yet). I actually prefer no borders to vim's massive Great Walls, but YMMV. (Nested floats look neat, but are not worth the effort with resizing/positioning).
True; the
I had assumed that people who work with language servers are not upgrade averse, but may be wrong, of course. The problem is that preview only makes sense for signature help and documentation, while hover and peek don't. In particular, signature is a tooltip feature for popup and float, but a documentation-like feature for preview. That makes everything hard (but not impossible) to separate cleanly. But the current proposal should make it easy to add new backends, including preview -- that was one of the points! (I'd just prefer not to have to worry about that at first.)
Yes, the current code is garbage. :)
Done! |
Keep in mind you're speaking to the person who wrote it :p |
No, I meant the current code in this PR! The current code on master is working fine, after all, in contrast to the one I knocked out :) (Edited the comment to make this a bit clearer.) |
That's the plan. Can you add the options to the doc (and any additional ones, if you think of them). (As an aside; once the academic year resumes next week, I'll probably not have much time anymore. I really hope this gains some traction so I don't have to miss the progress :) ) |
Will do -- once I come to a conclusion on which way around ;) @jerdna-regeiz Can you think of any?
We still have four more weeks, but these will be very busy weeks for me -- moreso as I've been procrastinating here a bit ;) So the same goes for me, although I'll try to not let it go completely dormant. |
I noticed. Now I'm actually wondering if my professors work on their Vim config during the holidays ;) |
If their definition of a holiday is "a slow week at the office, and a grant proposal to write", possibly -- unless they use Emacs. (Or, more likely, TeXShop.) |
closed in favor of #510 to focus on the API design. @thomasfaingnaert @jerdna-regeiz @hrsh7th (To avoid littering that issue with too many back-and-forth comments, some discussion could be moved to gitter -- a vim-lsp chatroom might be useful.) |
@clason Haven't used Gitter before. Can I create the room or must the repo owner do that? |
Good question! You could simply try?
|
Seems like I can create a community, but if I want to link it to the GitHub repo, I need to own it. |
Makes sense, although that would only get the fancy feed and linking to issues/PRs -- for discussion, it doesn't have to be linked. (I'm worried of having 100+ comments on the new PR in the first day already -- I tend to think by writing ;)) |
Also seems that I can't create a community with the name |
Ah. In this case, it would indeed be better for @prabirshrestha to do this (and maybe move the vim-lsp(-related) repo(s) to this organization)? (If this is in fact his organization and not someone else's...) |
I think it is someone else's, but still |
Let's just create a gitter for your fork for now, might be easier? |
Then it might be possible (and reasonable) to appropriate it; I think github has procedures for that. Otherwise I agree; but I can definitely create a temporary one for this PR. I don't have an organization, but I just named it |
Even I find Gitter easier to use. Let me know what name you want. It would be good to have a permanent one. |
The purpose of this PR is to avoid entering the buffer opened with
nvim_open_win
, which triggers -- possibly very expensive --CursorMoved
autocommands on the original buffer, see #507.This PR also contains commits from #500 and #507 in order to easily test the
Documentation
behavior; it should be removed before merging.This is not quite working yet:
documentation.vim
trying to put the float on the left side of the pum but failing for some reason.)@jerdna-regeiz @thomasfaingnaert I would appreciate feedback, since the interaction of the functions in
output.vim
isn't quite clear to me.