-
Notifications
You must be signed in to change notification settings - Fork 27
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
Support for simultaneous lean3/lean4 (in separate windows/tabs) #35
Conversation
…ncy; broken infoview.
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 still haven't tried actually using this yet so I don't have functional feedback yet, but just a few things that I'm thinking about:
- I'm not sure yet whether personally I expect per-window infoviews or per-tab infoviews -- what I had in mind was the latter (so switching between windows on one tab would reuse the same shared infoview). I'm guessing from scanning this that you did the former, which I guess may also be reasonable, but yeah I want to see how natural that feels
- Probably what we were discussing on Zulip affects the lspconfig PR as well -- namely when you modify the LSP there we should consider already whether to modify the
leanls
one to look for alean3
filetype (instead oflean
which is what it looks for now) - I think the default behavior you have here is the opposite of the current one if I read it right, namely the current code chooses lean 4 by default if there's no
leanpkg.toml
in the cwd, whereas I think here you default to lean 3?
Will try to leave some more comments as soon as I get a chance to set this up fully. And thanks again!
lua/lean/util.lua
Outdated
local uv = vim.loop | ||
local M = {} | ||
|
||
-- M.path copied from lspconfig/util to avoid creating a dependency... |
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.
lspconfig is Apache 2.0 licensed so in theory we're supposed to add the little blurb here.
I think it makes the most sense for per-window/per-tab to be a configurable option. On larger screens, per-window infoviews could be more convenient. Working on this now... |
4-only. | ||
Note that many simple syntactical things are not yet implemented | ||
(help is of course welcome), and that ``tree-sitter-lean`` is lean | ||
4-only. | ||
|
||
Installation | ||
------------ |
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.
Should remove line 37 here suggesting installing lean.vim I suppose
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.
This is starting to look great!
lua/lean/infoview.lua
Outdated
vim.api.nvim_win_close(M._infoviews[src_win].win, true) | ||
function M.close_win(src_winnr) | ||
if M._infoviews[src_winnr] then | ||
vim.api.nvim_win_close(M._infoviews[src_winnr].win, true) | ||
end | ||
|
||
-- NOTE: it seems this isn't necessary since unlisted buffers are deleted automatically? |
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 added this I believe while seeing tests fail for different reasons and causing later tests to fail. But it's possible it indeed isn't necessary. If it doesn't seem to be, feel free to kill it.
…rrors in per-tab mode.
…tab mode causes infoview to close.
This is expected - when you enter per-window mode, the tab's infoview is closed, and infoviews will only be opened in other windows when you trigger |
@Julian You can put your review on pause for a bit - I'm going to slightly refactor things to put them clearly in terms of persistent infoview state between close/open. Should result in a bit simpler code. |
Alright I've done the refactor with a good amount of testing. The code is a bit longer (because of some utility functions), but I find it conceptually simpler. It's ready for you to check out here: https://github.com/rish987/lean.nvim/tree/infoview_persistence_refactor This refactor should significantly help us in the future, as we implement many new kinds of infoview states that should persist when the window is closed/opened. Though it's up to you whether you want it to go in this PR or a future one. What we have now should be functional enough already if you want to put this off for a bit. An unexpected immediate benefit of this refactor is that we can now preserve open/close states between https://asciinema.org/a/7AfLVjFzx0F3jVS71sIXK1uJm I'm going to do a bit more testing tomorrow morning... have to start a compile of the latest Lean nightly so I can try out the new term goal stuff |
Making some progress here -- I pulled out the piece that fixes #20. In the process I introduced some merge conflicts, sorry, will get to fixing them as I keep merging pieces. The next thing I want to do is remove the erase logic and alongside it |
Aha, ok now re-watching the demo from your last comment, I see finally at least some of the functionality you were implementing beyond the above list -- you want persistent window layout even when switching back and forth too. That makes sense to me too, and explains why things are implemented this way (with the 2 state open), but yeah a bit of this is why I'm finding understanding the implementation hard to follow step-by-step. |
We can add close support if/when it's needed to preserve state.
There are lots of issues in the repo which likely constitute some form of roadmap but who knows what order we'll get to them in. The infoview section probably belongs, but we can document closing and quitting if/when we have persistent windows.
Things work differently on this branch where the check for opening the infoview is done on each update loop, so this actually is broken (but I broke it in an earlier commit). I don't yet see why to do it that way (to check whether to open an infoview) rather than just when entering new lean buffers , but merging this in anyways since I already broke it here and will need to rejigger update() to fix it.
It's true, but it's way too early to mention prominently or think about too hard, other than keeping Lean3 related code in the same place rather than scattered across the plugin.
This makes it a hard dependency for now, but I'd rather do that than copy paste in its path manipulation, at least for the moment. We can worry about removing that dependency later if we want to.
Closes: Julian#13. Co-authored-by: Rishikesh Vaishnav <[email protected]>
lua/lean/infoview.lua
Outdated
@@ -257,13 +246,7 @@ function M.close_win_wrapper(src_winnr, src_tabnr, close_info, already_closed) | |||
end | |||
end | |||
|
|||
if close_info then |
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 removal of this distinction results in E855: Autocommands caused commands to abort
when closing the last (Lean) window in a tab with :close
- I don't think WinClosed
is designed to be able to handle physically closing other windows. From :help QuitPre
: Can be used to close any non-essential window if the current window is the last ordinary window.
No similar support exists for WinClosed
.
lua/lean/infoview.lua
Outdated
@@ -280,8 +280,17 @@ end | |||
-- Close the infoview associated with the current window. | |||
function M.close() | |||
if not M.is_open() then return end | |||
local infoview = M._teardown(get_idx()) |
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.
What's being done here seems to be identical to what close_win()
was doing previously - looks like this was an attempt to fix window closing/toggling? See latest commit.
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.
What I was trying to do overall is to get rid of close_win
and close_win_raw
vs. close_win_wrapper
, and handle their functionality in infoview.close()
for the functionality of "close this window" and an autocmd for "a window was closed, possibly via another means than infoview.close maybe update the sizes of things and clean up state".
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.
Don't quite get it yet - feel free to have a go at it and maybe I'll understand once I see the code.
Jumped on some work calls which means putting this on hold at least for a few hours, but I see you're already fixing more mistakes of mine -- what I'm trying to do at a high level is two things:
In order to do the above I've been really doing some quite bad things, but it's the best I can come up with to untangle at the minute :/ Let me review your comments (and thanks again for fixing!) |
Depends on a merge of nvim-lspconfig that adds lean4 as a new language server.