Closed TroySigX closed 1 year ago
I also tried with google chrome (version 111.0.5563.64-1) and it behaved exactly the same.
This happens because the textarea is being focused again, which triggers Firenvim again. You might want to set the takeover
setting to once
, which would ensure Firenvim only triggers once per textarea. An alternative could be to set it to never
and then only trigger Firenvim through its keyboard shortcut.
I'm going to close this issue because everything is working as expected here, but feel free to ask more questions :)
I tried to set the takeover
to once
and never
, but the problem still persists.
If it helps, here's my config:
{
'glacambre/firenvim',
cond = not not vim.g.started_by_firenvim,
build = function()
require('lazy').load({ plugins = 'firenvim', wait = true })
vim.fn['firenvim#install'](0)
end,
config = function()
require('config.firenvim')
end,
},
And here's my config.firenvim:
vim.g.firenvim_config.localSettings['.*'] = { takeover = 'never' }
I suspect that your config.firenvim
is not being loaded, otherwise you would be getting an error due to vim.g.firenvim_config
not existing. You need to define the whole object.
Thanks @glacambre! It works For those who need, here's my config:
{
'glacambre/firenvim',
cond = not not vim.g.started_by_firenvim,
build = function()
require('lazy').load({ plugins = 'firenvim', wait = true })
vim.fn['firenvim#install'](0)
end,
config = function()
vim.g.firenvim_config = {
globalSettings = { alt = "all" },
l localSettings = {
[".*"] = {
cmdline = 'neovim',
content = 'text',
priority = 0,
selector = 'textarea',
takeover = 'never'
}
}
}
end,
},
Running require("foo")
in Lua will NOT necessarily run the code in foo, it will make sure it has been loaded once at some point. It almost definitely will not run it when you want it to, especially when you are dealing with lazy-loading plugin managers. It might just be stuffed in the module preloader somewhere, but it is up to you to actually do something with it.
Lua has other functions for this, such as loadfile()
that will actually execute a Lua file in place.
That being said the more traditional way to handle this would be to return a closure:
{
'glacambre/firenvim',
cond = not not vim.g.started_by_firenvim,
build = function()
require('lazy').load({ plugins = 'firenvim', wait = true })
vim.fn['firenvim#install'](0)
end,
config = require('config.firenvim')
},
And the config file:
return function ()
vim.g.firenvim_config.localSettings['.*'] = { takeover = 'never' }
end
This ensures that the code will get run, not just loaded.
Also you could keep the original structure for the plugin loader end, still return a function from the config, and use require("config.firenvim")()
(note trailing parents) to load & execute it, but since what you need is the function to give as a callback anyway just passing the function works.
Documentation: https://www.lua.org/pil/8.html
Note that loadstring()
is not a convenient drop in replacement for require()
when you want to run code because the module search path handling is different, hence the recommendation of staying with require()
but passing a function that you can explicitly execute where and how you want it to run.
Thank you very much, @alerque ! Appreciate it.
What I tried to do
completely exit firenvim after typing
:q
What happened
After I typed
:q
, then switch tab and finally go back to the original tab, firenvim kept showing up even though I didn't trigger it.To be specific, here are the steps I did:
:q
After the 6th step, firenvim automatically turns on.