glacambre / firenvim

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

Neovim window is small in Protonmail #1292

Open Louis-dM opened 2 years ago

Louis-dM commented 2 years ago

tldr: neovim only displays a few rows in protonmail

Detailed explanation:

What I tried to do

Expected behaviour

Gmail (https://mail.google.com/mail/u/0/#inbox) demonstrates the expected behaviour:

The same (expected) behaviour also happens on Reddit: whether using the small editing box or the larger editor, neovim fills the whole space.

What happened

Software

Possibly relevant lines of Neovim config (can provide full file if needed but it's mostly just remaps):

" HIDING BARS AT BOTTOM
set laststatus=0
set noruler

" PLUGINS
call plug#begin()
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
cal plug#end()

" FIRENVIM STUFF
let g:firenvim_config = { 
    \ 'globalSettings': {
        \ 'alt': 'all',
    \  },
    \ 'localSettings': {
        \ '.*': {
            \ 'cmdline': 'neovim',
            \ 'content': 'text',
            \ 'priority': 0,
            \ 'selector': 'textarea',
            \ 'takeover': 'never',
        \ },
    \ }
\ }

Firefox config

In Firefox's "Manage Extension Shortcuts" settings, I have set the shortcut for "Turn the currently focused element into a neovim iframe." to Ctrl+Q. No other shortcuts are set.

Other notes

It seems that the size of the editor changes depending on how many lines are in the email when firenvim is started:

glacambre commented 2 years ago

Thank you for the very detailed report, I really appreciate it :).

Unfortunately, there is nothing Firenvim can do to fix this - the neovim window takes the size of the underlying text area element, and protonmail's "real" text area element doesn't cover all of the "visual" text area.

You can try to work around this by running :set lines=20, possibly from a BufEnter autocommand. It should work as long as you don't also set guifont at the same time.

Louis-dM commented 2 years ago

:(

Using BufEnter might work, but it seems that the "filename" of what's happening in the neovim window is e.g. _blank_DIV-id-squire_<timestamp>Z.txt (i.e. nothing to do with the URL of the webpage). Would it be possible to change this "filename" to include parts of the URL to allow users to have custom BufEnter autocommands for situations like this?

(I've not got much experience with BufEnter, so please correct me if this isn't the way to go about it)

glacambre commented 2 years ago

You can use the filename setting to change the name of the underlying file. It's quite odd that you're not seeing the url of the page in the default file name though - I would have expected it to be there. Its absence probably means that protonmail's text-area lives in an iframe that doesn't have a url (which would also explain the "_blank" path) and unfortunately there's nothing Firenvim can do about this (I'm quite surprised Firenvim works at all, to be honest :sweat_smile:).

Louis-dM commented 2 years ago

Damn, well if it can't detect the URL in that window then I'll just have to hope _blank_DIV-id-squire*.txt is uncommon enough to work for the autocommand. Thanks anyways!