glacambre / firenvim

Embed Neovim in Chrome, Firefox & others.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use Firenvim when Vim and Neovim share their `runtimepath`?

MahdiNazemi opened this issue · comments

  • OS Version: macOS Ventura 13.2.1
  • Browser Version: Firefox 111.0.1
  • Browser Addon Version: 0.2.14
  • Neovim Plugin Version:

What I tried to do

Firenvim sometimes fails to activate when editing a textarea.

What happened

While trying to debug the issue, I realized I get the follwing output when I run ps aux | grep nvim:

/opt/homebrew/Cellar/neovim/0.8.3/bin/nvim --headless --cmd let g:firenvim_config={'globalSettings':{},'localSettings':{'.*':{}}}|let g:firenvim_i=[]|let g:firenvim_o=[]|let g:Firenvim_oi={i,d,e->add(g:firenvim_i,d)}|let g:Firenvim_oo={t->[chansend(2,t)]+add(g:firenvim_o,t)}|let g:firenvim_c=stdioopen({'on_stdin':{i,d,e->g:Firenvim_oi(i,d,e)},'on_print':{t->g:Firenvim_oo(t)}}) --cmd let g:started_by_firenvim = v:true -c try|call firenvim#run()|catch /Unknown function/|call chansend(g:firenvim_c,["f\n\n\n"..json_encode({"messages":["Your plugin manager did not load the Firenvim plugin for neovim."],"version":"0.0.0"})])|call chansend(2,["Firenvim not in runtime path. &rtp="..&rtp])|qall!|catch|call chansend(g:firenvim_c,["l\n\n\n"..json_encode({"messages": ["Something went wrong when running firenvim. See troubleshooting guide."],"version":"0.0.0"})])|call chansend(2,[v:exception])|qall!|endtry

where I assume the important part is

"Your plugin manager did not load the Firenvim plugin for neovim."

I get this output even during the times when Firenvim works as expected (like now that I am writing this issue).

My init.vim is a bit unusual because I share the same runtime path between vim and neovim as explained in neovim docs:

set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath=&runtimepath
source ~/.vimrc

Could this be the cause of the issue? If not, what else can I do to ensure Firenvim works properly all the time?

Hi, thanks for opening this issue. Could you try running echo 'abcde{}' | ${XDG_DATA_HOME:-${HOME}/.local/share}/firenvim/firenvim in your shell and let me know what happens?

Thank you! Here is the output I get:

{"messages": [], "version": "0.2.14", "settings": {"localSettings": {".*": {"priority": 0, "cmdline": "neovim", "takeover": "always", "selector": "textarea", "content": "text"}}, "globalSettings": {"ignoreKeys": {"all": ["<D-r>", "<S-D-r>", "<D-v>", "<S-D-a>"]}}}}%

I added the globalSettings and localSettings recently, and I was facing this issue before that too.

Generally, I get the expected output in all troubleshooting steps mentioned here.

Okay, so if the script works fine, we can rule out runtime/init.vim configuration issues.

The other two possibilities are:

  1. The neovim binary disappears from your $PATH. The neovim binary path you showed above contains a version number, I would guess that upgrading Neovim could result in the path becoming invalid.
  2. The textareas Firenvim does not work on aren't actually textareas but fancy JS editors.
  3. Your neovim takes more than 10 seconds to start and runs into the timeout limit.

I've opened #1526 for 1).

For 2), I'd need you to point me to the textareas in question in order to figure out what's really going on.

For 3), I'd suggest trying to fix your config (you can run neovim with its --startuptime argument in order to figure out what's taking time.

Thank you for your detailed response.

  1. I was experiencing this issue on Slack, but have not run into it in the past few minutes.

  2. The startup time is around 265 ms.

Oh, yeah, Slack really falls in the category of fancy JS editors. There could be two reasons for Firenvim failing to trigger itself on slack's editor:

  1. Firenvim doesn't detect that the input box is an editable text element
  2. Slack focuses the input box before Firenvim is able to create its event listeners

For 1), you can help Firenvim figure out what element it should trigger itself on with the 'selector' setting, e.g.:

let g:firenvim_config = {
  \ 'localSettings': {
    \ 'slack.com': {
      \ 'selector': 'div.ql-editor.ql-blank[role=textbox]'
  \ }
\ }

For 2), you selecting another element in the UI (e.g. slack's search bar) and then re-selecting the chat input box should trigger Firenvim.

Closing this issue because

  • Firenvim has been detecting Slack's textbox correctly in the past hour or so.
  • I disabled Firenvim on Slack and only enable it manually when needed
  • The solutions mentioned above will probably resolve the issue.

Thank you!