glacambre / firenvim

Embed Neovim in Chrome, Firefox & others.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to setup isolated Firenvim-specific config?

eisukeesaki opened this issue · comments

runtime environment

Kernel Version: Linux 6.4.9-arch1-1
Neovim Version: NVIM v0.9.1
Browser Version: 116.0.2 (64-bit)
Browser Addon Version: 0.2.15
Neovim Plugin Version: 0.2.15

What I want to achieve

Set the takeover setting to never) using a Firenvim-specific config (in ~/.config/firenvim/init.lua) isolated from ~/.config/nvim.

What I have tried

  • set export NVIM_APPNAME="nvim" in ~/.bashrc
  • installed glacambre/firenvim Neovim plugin using Packer
  • installed browser add-on
  • confirm :echo g:started_by_firenvim = true
  • in ~/.config/nvim/init.lua, do:
if vim.g.started_by_firenvim == true then
  vim.g.firenvim_config.localSettings['.*'] = { takeover = 'never' }
end
  • remove the above code and do the following in the same file:
vim.api.nvim_create_autocmd({'UIEnter'}, {
    callback = function(event)
        local client = vim.api.nvim_get_chan_info(vim.v.event.chan).client
        if client ~= nil and client.name == "Firenvim" then
          vim.g.firenvim_config.localSettings['.*'] = { takeover = 'never' }
        end
    end
})

Summary

The Neovim frame is still automatically shown in the browser despite the attempt to alter that behavior.

What am I doing wrong?

Hi, thanks for opening this issue. Let's do things one step at a time first. We'll begin with stopping Firenvim from running in your default config. If you open the browserAction (the Firenvim icon next to your URLbar), you'll probably see error messages about vim.g.firenvim_config not existing. If you try to replace your firenvim config in ~/.config/nvim/init.lua with

if vim.g.started_by_firenvim == true then
	vim.g.firenvim_config = {
		localSettings = {
			[".*"] = {
				takeover = "never"
			}
		}
	}
end

The error message should disappear and firenvim should stop appearing by default. Can you confirm that this works?

I did as you said, and the desired behavior (disable takeover by default) was achieved. Are there any downsides to overwriting the entire vim.g.firenvim_config? I tried to see what is inside it before it is overwritten, but the result of print() was not printed when I manually activated the Neovim frame in the browser.

if vim.g.started_by_firenvim == true then
        print(vim.g.firenvim_config)
	vim.g.firenvim_config = {
		localSettings = {
			[".*"] = {
				takeover = "never"
			}
		}
	}
end

Apologies if I confused you. I just meant to let you know that: after following what you said, Firenvim no longer shows up automatically.

Are there any downsides to overwriting the entire vim.g.firenvim_config?

There are no downsides, vim.g.firenvim_config isn't defined by default :)

I just meant to let you know that: after following what you said, Firenvim no longer shows up automatically.

Great! Now, if you are still interested in having a Firenvim-only config, here's how to do it:

  • Edit ~/.config/firenvim/init.lua to add any plugins you need (e.g. packer.nvim, your colorscheme...), including Firenvim
  • In a shell, run NVIM_APPNAME=firenvim nvim and in nvim run :call firenvim#install()

That should be it! The neovim you run in your browser should be using your config defined in ~/.config/firenvim/init.lua .

Closing this issue because it has been awaiting a response from its author for more than a month. Please provide the requested information and this issue will be re-opened.