-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add nvim floating window support (replaces #3314) #3470
Conversation
Also: * Extract floating preview to its own file. * Ignore 'stay_here' option. Moving into the floating preview window seems confusing at best. * Re-use existing floating preview window if it's still up. * Flush out floating preview documentation. Known issues: * Needs tests. * When floating preview coupled with g:ale_cursor_detail, the window is redrawn in a tight loop. Presumably in the non-floating version, moving into the preview window (via stay_here) keeps this from happening.
@w0rp I'm going to work on tests next. |
Was still hitting race conditions where close happened mid call.
eec1f07
to
a960b40
Compare
Currently considering progress on this blocked by #3448 since I can't run passing tests locally. Working on that first. |
Floating previews open a new window, so when that window is written to, it moves briefly there at a different position than the original window. This makes repeated positions detected when positions are tracked at a s: level. Instead, we change the variable to window scoped, which only fires a message if the cursor has changed from the last position in *that window*.
c39a27c
to
416d604
Compare
Just an update here - I've got a PR in to fix #3448. It's waiting on review/feedback/merge. I'm happy to write the tests to finish this up, but wanted a basic "this seems like the right thing" sanity check before I go learn vader. |
Still waiting on any kind of feedback. 🤷♂️ Just maintaining my own branch that I’m using daily in the meantime. Works fine afaict. |
@kevinclark with Rubocop, the floating preview is missing the option that caused the error: |
@cj I’ll take a look. Would you mind supplying any ale options you’ve got set so I can repro? |
@kevinclark of course - https://gist.github.com/cj/39eeb5de63691f114f50832b444fdc3f, let me know if you need any thing else! |
@cj Thanks! And just in case it matters (I don’t think it should) - what version of NeoVim? |
|
Thanks for this @kevinclark ! So another nice-to-have would be But I'm already very grateful for this PR! Maybe someone else (like me) should take this on after we get this PR merged in it's current form. |
@davidatbu I think what you're looking for already exists. If you turn on There is a slight difference in output, which @cj points out and I refer to in #3505 where the |
And some cleanup of floating_preview test state
Open question (possibly for a follow up PR): when using ALEDocumentation, should floating windows be an option? |
@hsanson Huh. That works fine for me. To clarify - when you say ale from git master - do you mean the ale from my branch? I hadn't merged from ale master in a little while, but I have now and it's still working fine. A little repetitive with |
Sorry, not master... I am using your branch: git checkout -b kevinclark-nvim-floating master
git pull git://github.com/kevinclark/ale.git nvim-floating nvim -v
NVIM v0.5.0-888-g8b2887bd5
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/hs/Apps/neovim.git/build/config -I/home/hs/Apps/neovim.git/src -I/home/hs/Apps/neovim.git/.deps/usr/include -I/usr/include -I/home/hs/Apps/neovim.git/build/src/nvim/auto -I/home/hs/Apps/neovim.git/build/include
Compiled by hs@ex
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info |
@hsanson Got it. I'm on nvim 0.4.4 - I'll move to 0.5 and see if there's a change. Appreciate the responsiveness! |
@hsanson Works with nightly 0.5 too. How odd. Are you seeing any test failures when you run them? |
Ok, so I tried with a minimal vim configuration and worked fine. After commenting line by line my config I found this particular setting causes the issue to occur:
Commenting this line solves the issue and the PR seems to work as expected. Unfortunately I am inclined to believe this configuration is common in the wild (see https://vim.fandom.com/wiki/Keep_your_cursor_centered_vertically_on_the_screen) so this PR can potentially break things to many people as it did for me. Maybe is a bug in neovim itself that ALE has no way of working around. Would be good if someone can test this in vim to see if the same problem occurs. |
@hsanson Thanks so much for tracking that down - I'll do some digging and see if I can't isolate the problem. |
@hsanson So, with nightly nvim I can't get the branch to fail setting scroll off and I'm seeing test pass with this diff: diff --git a/test/test_floating_preview.vader b/test/test_floating_preview.vader
index 43415556..46213641 100644
--- a/test/test_floating_preview.vader
+++ b/test/test_floating_preview.vader
@@ -1,4 +1,7 @@
Before:
+ Save scrolloff
+ set scrolloff=9999
+
let g:ale_floating_preview = 0
let g:ale_hover_to_floating_preview = 0
let g:ale_detail_to_floating_preview = 0 Kind of stumped. Does it blow up on that two line ruby file with that scrolloff or does it need to be something larger? |
@kevinclark I updated my neovim installation to latest master and the issue I had no longer occurs. There are many changes between my previous version and the latest one so is difficult to tell what was the problem. I think this works as expected and can be merged but I also think @w0rp should check on this and merge it. |
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.
Changes look good and tested it works as expected using latest neovim build.
@hsanson Thank you for the help! |
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.
I just have a couple of comments here. Otherwise this is fine.
Sorry for not looking anything to do with ALE for a while. Given the times we are in and my day job, I haven't felt like doing too much with ALE for now.
autoload/ale/floating_preview.vim
Outdated
endif | ||
|
||
" Remove the close autocmd so it doesn't happen mid update | ||
augroup NvimFloating |
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 prefix groups we create with ALE
so we don't conflict with other groups.
doc/ale.txt
Outdated
g:ale_floating_preview *g:ale_floating_preview* | ||
|
||
Type: |Number| | ||
Default: `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.
The default is 0
.
@hsanson GitHub really needs a private message system some day. I've given you Admin permissions for the ALE repo, so if you couldn't merge something before, you definitely should be able to merge things now. |
@w0rp @hsanson I've made those changes. Let me know if there's anything else needed to get this in. Also - it'd make work going forward a lot easier if tests were portable. In master right now some of the testing tooling is from the host system instead of the docker container. I've fixed that in #3471. If I could get some attention there, I'd appreciate it. |
Awesome, thank you! |
Thank you for this feature PR - Great work! |
This continues the work begun in #3341 by @jargonzombies and responds to the feedback from @w0rp. In particular, it splits out configuration of the individual floating-window usecases and pulls that code into a separate file.
Known issues:
Needs tests. Since it's my first time working in viml, I wanted to make sure the basics were right before digging in here.Done and passing as of 60287b0.When floating preview coupled with g:ale_cursor_detail, the window is redrawn in a tight loop. Presumably in the non-floating version, moving into the preview window (viaThis now fixed in c39a27c.stay_here
) keeps this from happening. Butstay_here
doesn't make sense in a floating-window world, so we may need another fix.As far as I'm concerned this is ready to go. Just waiting on review and a merge.