Lazy loading firenvim #463
-
Hi, I'm having trouble lazy loading firenvim. I don't want firenvim to be loaded when I'm just using Neovim in the terminal, but I want it to be loaded when it is opened in the browser. So far, I have searched pretty much everywhere on GitHub and Reddit and I couldn't find any examples of lazy loading firenvim. Currently, when I set firenvim to lazy load, it wouldn't load in the browser and it will just refuse to start, saying Neovim is not responding, so I have it loaded when starting Neovim. Please help, thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 12 comments 27 replies
-
Firenvim sets a global variable EDIT: Link to the docs: https://github.com/glacambre/firenvim#building-a-firenvim-specific-config |
Beta Was this translation helpful? Give feedback.
-
Here's the configuration that worked for me for everyone else that is facing the same issue: {
"glacambre/firenvim",
lazy = not vim.g.started_by_firenvim,
module = false,
build = function()
vim.fn["firenvim#install"](0)
end,
} This means that Thanks to @abeldekat for providing the configuration. This is currently the best way to lazy load This is the commit that changed the functionality of the This reply was written in firenvim! |
Beta Was this translation helpful? Give feedback.
-
You can make Lazy manually load firenvim so the install function works by doing the following: {
"glacambre/firenvim",
lazy = false,
build = function()
require("lazy").load({ plugins = "firenvim", wait = true })
vim.fn["firenvim#install"](0)
end,
cond = not not vim.g.started_by_firenvim,
} |
Beta Was this translation helpful? Give feedback.
-
For folks like me who aren't paying attention to what they're pasting in from websites, note that in order to configure firenvim, you have to put that in Lazy's return {
'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,
-- configure FireNvim here:
config = function()
vim.g.firenvim_config = {
-- config values, like in my case:
localSettings = {
[".*"] = {
takeover = "never",
},
},
}
end
} In my case, this makes FireNvim much less of a hassle since on some sites I don't want it to takeover the textareas. For those (on Chrome), if I press CMD-E, FireNvim kicks in on command. BTW, this comment was also written in FireNvim |
Beta Was this translation helpful? Give feedback.
-
No matter what I do it just says "Vim:E117 Unknown function: firenvim#install" |
Beta Was this translation helpful? Give feedback.
-
Hello @hankertrix, I installed firenvim after reading this discussion. A great plugin! Thank you for investigating the setup using lazy.nvim! It is worth mentioning that on first install, the line containing the "cond" keyword should be a comment. Restart nvim in the terminal for the plugin to install and build. Activate the condition by uncommenting the respective line and the plugin is ready to use. |
Beta Was this translation helpful? Give feedback.
-
Reply: It does work
That surprises me... It would have been kind if you said so directly after I showed you my solution, when I asked in our discussion above:
I really wonder why you answered like you did. I would appreciate any feedback regarding my tone in the above conversation. Recently, Folke accepted my pull request. Reply: bandaid solution
Respectfully, this is your opinion, not a fact. Using Using Lazy.nvim only installs, updates and builds plugins that are active, both loaded and not loaded. Disabled plugins, including Reply: possible bug
My opinion: This is by design. It's up to Folke to decide. EDIT: See this commit and its comments: cond is now the same as enabled, but skips clean, dated 2023.07.06 Reply: loading by other means
The only means causing lazy.nvim to load the plugin when in regular nvim are intentional:
Reply: updated my answer
I read the updated answer and I think a lot of the information you supply is currently not correct. I hope I motivated that statement in this reply. EDIT: I think the commit causing the confusion can be found here, dated 2023.07.06 In addition:
My requestPlease update your accepted answer mentioning the solution without the text that is up for debate. Lazy.nvim example in firenvim's readmeAs the example is accepted, the example on the site of firenvim needs to be updated. |
Beta Was this translation helpful? Give feedback.
-
Thanks! |
Beta Was this translation helpful? Give feedback.
-
The code snippet for packer is: use {
'glacambre/firenvim',
run = function() vim.fn['firenvim#install'](0) end
} The code snippet for lazy can be improved by removing the {
"glacambre/firenvim",
-- if firenvim -> vim.g.started_by_firenvim == true -> lazy must be false.
lazy = not vim.g.started_by_firenvim,
build = function()
vim.fn["firenvim#install"](0)
end,
} |
Beta Was this translation helpful? Give feedback.
-
Hello @hankertrix, I submitted the PR that removes firenvim from the description of the Would you consider updating your selected answer to also include |
Beta Was this translation helpful? Give feedback.
-
For me, this was the best way: return {
"glacambre/firenvim",
lazy = not vim.g.started_by_firenvim,
build = function()
vim.fn["firenvim#install"](0)
end,
{ "noice.nvim", cond = not vim.g.started_by_firenvim },
{ "lualine.nvim", cond = not vim.g.started_by_firenvim }, -- not useful in the browser
} |
Beta Was this translation helpful? Give feedback.
-
I'm trying to make firenvim work with lazyvim too but I'm trying to whitelist the plugins I wanna use instead of disabling ones I don't want to use. Here's my attempt so far (following the VSCode extra) but it's not working: if not vim.g.started_by_firenvim then
-- need to keep an entry here otherwise lazy.nvim will uninstall it
return {
{
"glacambre/firenvim",
-- Lazy load firenvim
-- Explanation: https://github.com/folke/lazy.nvim/discussions/463#discussioncomment-4819297
lazy = true,
module = false,
build = function()
vim.fn["firenvim#install"](0)
end,
},
}
end
local enabled = {
"flit.nvim",
"lazy.nvim",
"leap.nvim",
"mini.ai",
"mini.pairs",
"mini.surround",
"vim-repeat",
"yanky.nvim",
"glacambre/firenvim",
"LazyVim",
}
local Config = require("lazy.core.config")
Config.options.checker.enabled = false
Config.options.change_detection.enabled = false
Config.options.defaults.cond = function(plugin)
return vim.tbl_contains(enabled, plugin.name)
end
return {
{
"LazyVim/LazyVim",
config = function(_, opts)
opts = opts or {}
-- disable the colorscheme
-- opts.colorscheme = function() end
require("lazyvim").setup(opts)
end,
},
{
"glacambre/firenvim",
lazy = false,
priority = 100,
module = false,
build = function()
vim.fn["firenvim#install"](0)
end,
},
} Appreciate any help! |
Beta Was this translation helpful? Give feedback.
Here's the configuration that worked for me for everyone else that is facing the same issue:
This means that
lazy
istrue
whenfirenvim
is not active, which meanslazy.nvim
will not loadfirenvim
when using Neovim in the terminal, unless you call the build function to buildfirenvim
. Also,lazy
will befalse
whenfirenvim
is being used in the browser, which would getfirenvim
to load immediately when starting Neovim in the browser.module = false
will causefirenvim
to throw an error when it is loaded in arequire
call by another…