iron.nvim icon indicating copy to clipboard operation
iron.nvim copied to clipboard

REPL float window does not integrate with window layout

Open matthiasdold opened this issue 3 years ago • 1 comments
trafficstars

Good morning,

I just realized a strange behavior on how the float window is created / toggled. The float window for the REPL seems to somehow no longer be attached to the other windows. I.e. I can no longer switch between the regular buffer window and the REPL with <C-w> LEFT / RIGHT. However using <C-w>w brings me to the REPL and leaving works with <C-w> LEFT/RIGHT again. Note also how the lualine is covered by the new float window

2022-06-13_08-26_floating_auto

If I move to the REPL and create a vsplit (<C-w>v), the newly created split is integrated into the window layout as expected.

2022-06-13_08-26_after_calling_split

Not sure if this is a bug or a design choice. If it is on purpose, could you please add a config option to restore the old behavior of how the REPL is created as a window?

Many thanks for the awesome plugin!

P.S.: This seems also to be linked to issue #259 -> If :IronRestart is called from the split window (where the lualine is displayed properly), the restart works without closing the window

matthiasdold avatar Jun 13 '22 06:06 matthiasdold

Hi, Same issue here, I have a set of mappings for switching between buffer windows, but noticed that they didn't work with Iron, forcing me to use the mouse to switch between windows. At least I found here that <C-W>W still works

jorgesca avatar Aug 24 '22 21:08 jorgesca

I finally had a bit of time to look into this and found a workaround for me. Or basically, I do not think this is a bug anymore.

The relevant part is in lua/iron/lowlevel.lua where the new_window function is defined

ll.new_window = function(bufnr)
  if type(config.repl_open_cmd) == "function" then
    local result = config.repl_open_cmd(bufnr)
    if type(result) == "table" then
      return view.openfloat(result, bufnr)
    else
      return result
    end
  else
    vim.cmd(config.repl_open_cmd)
    vim.api.nvim_set_current_buf(bufnr)
    return vim.fn.bufwinid(bufnr)
  end
end

This basically tells me that whenever a function is defined in the config object, it will create a float window. Which probably is a deliberate design decision. However, it seems like the vim.api does not offer creating normal windows.

So previously my config contained a function to make the repl window taking 30% of the current windows width like so:

local iron = require("iron.core")

iron.setup {
  config = {
     ...
    repl_open_cmd =  require('iron.view').right(
        function()
            return math.floor(vim.o.columns / 3)
        end
    ),

Now simply using a regular vim command works perfectly for me, although of course the size is no longer dynamic. Maybe piping multiple commands could solve this. But for now, this is my config which fits into my workflow:

local iron = require("iron.core")

iron.setup {
  config = {
     ...
    repl_open_cmd =  "80vs",

matthiasdold avatar Oct 28 '22 16:10 matthiasdold