glacambre / firenvim

Embed Neovim in Chrome, Firefox & others.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to resize text area

musjj opened this issue · comments

commented
  • OS Version: Linux
  • Browser Version: Firefox 115.0b1 (64-bit)
  • Browser Addon Version: 0.2.14
  • Neovim Plugin Version: e2d5a0f

What I tried to do

I tried to resize the text area with set lines=15. I have tried two different variations:

vim.api.nvim_create_autocmd("UIEnter", {
  callback = function()
    vim.notify("hello world!")
    vim.opt.lines = 15
  end,
})
vim.defer_fn(function()
  vim.notify("hello world!")
  vim.opt.lines = 15
end, 3000)

What happened

set lines=15 works when I set it interactively, but it simply does not work when I place any of the above two snippets into my config.
They both successfully prints hello world!, but the number of lines remains unmodified.

Hi, thanks for opening this issue. Your first code snippet is correct and the recommended way to change the dimensions of the window on startup. I copy/pasted your example in my config and it worked.

It's possible that you're encountering a timing issue. In order to confirm this, could you add

vim.api.nvim_create_autocmd("UIEnter", {
  callback = function()
    vim.fn.timer_start(3000, function()
      vim.opt.lines = 15
    end)
  end,
})

To your config and let me know if firenvim eventually gets resized (roughly 3 seconds after a start)? You might need to re-start firenvim twice in order to make sure the change to your init.lua takes effect.

commented

Your snippet works for me, I guess this is some kind of weird race condition. I have a hard time debugging this though, because I'm not sure how to reload the config in a deterministic way. It seems that firenvim sometimes reuse nvim instances even across new tabs. Is there any way to ensure that the instance gets reloaded?

Firenvim does not re-use neovim instances, but it pre-loads one instance at all time.
So, for example, if you write A to your neovim configuration, then starts neovim, then write B to your neovim configuration, then start Firenvim, the Firenvim instance will have config A, not B. Then, if you write C to your config, close Firenvim and start Firenvim again, you will get B, because a neovim instance was pre-loaded when you started Firenvim the first time, and you had B in your config at that time.

There are two ways to ensure that you have the right config loaded in Firenvim: either start firenvim twice in a row, or use the "Reload settings" button of the Firenvim button next to your URL bar.

I would not recommend spending time on debugging your issue though. Although it is not exactly the same, this problem is in the same vein as #800 (comment) , and there is no good solution for it without changing Neovim's protocol :/