glacambre / firenvim

Embed Neovim in Chrome, Firefox & others.
GNU General Public License v3.0
4.73k stars 146 forks source link

Can Firenvim show a floating window on the page rather than replace the textbox? #1640

Open YousufSSyed opened 2 weeks ago

YousufSSyed commented 2 weeks ago

I just started using Firenvim and its been kinda buggy, especially on small text boxes. It seems like a floating window / element would be more helpful if I could still see the textbox (and perhaps as it's being edited!), and avoid the issue of small text boxes.

glacambre commented 2 weeks ago

Does automatically expanding the size of the Firenvim frame to match the buffer's height solve your problem? You can add the following piece of code to your init.lua to do that:

if vim.g.started_by_firenvim then
  local max_height = 10
  local id = vim.api.nvim_create_augroup("ExpandLinesOnTextChanged", { clear = true })
  vim.api.nvim_create_autocmd({"TextChanged", "TextChangedI"}, {
    group = id,
    callback = function(ev)
      local height = vim.api.nvim_win_text_height(0, {}).all
      if height > vim.o.lines then
        if height < max_height then
          vim.o.lines = height
        else
          vim.o.lines = max_height
        end
      end
    end
  })