Closed Zeioth closed 8 months ago
What is your neovim version
Try removing event = "VeryLazy"
@kawre NVIM v0.10.0-dev-1378+gc49cfd89fd (neovim-git on arch linux)
Same result after removing VeryLazy and updating leetcode.nvim to latest.
Ok, it actually works if I specify lazy = false
But as I say this necesity was introduced only after the commit I mention.
It's because i've changed leetcode.nvim
to mount after VimEnter
as there were some problems with other plugins/options overriding my local plugin options on boot.
Probably VeryLazy
triggers after VimEnter
resulting in leetcode.nvim
never having a chance to even mount. If you want to mess around with lazy loading you can check out recipes.
Fixed version just in case someone finds this on google
return {
-- leetcode.nvim
-- https://github.com/kawre/leetcode.nvim
-- You found an easter egg!
-- To use it, uncomment this, exit nvim and write "nvim leetcode.nvim"
{
"kawre/leetcode.nvim",
lazy = false,
dependencies = {
"nvim-treesitter/nvim-treesitter",
"nvim-telescope/telescope.nvim",
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
"nvim-tree/nvim-web-devicons",
"rcarriga/nvim-notify",
},
opts = {
-- HOW TO ENABLE TYPESCRIPT/JAVASCRIPT LINTING FOR THIS PLUGIN
-- -----------------------------------------------------------
-- * Install the eslint packages:
-- npm install @typescript-eslint/eslint-plugin @typescript-eslint/parser
-- * Then copy paste this into ~/.local/share/nvim/leetcode/.eslintrc.json
-- https://pastebin.com/raw/aQXjpLuE
lang = "typescript",
},
config = function(_, opts)
-- Require it only if neovim starts with the argument 'leetcode.nvim'
if vim.tbl_contains(vim.fn.argv(), 'leetcode.nvim') then
require("leetcode").setup(opts)
end
end,
},
}
@Zeioth The problem with this is that it doesn't achieve anything actually. config
gets executed after all of the required dependencies were loaded which is the main problem there.
Having a function checking whether to lazy load leetcode.nvim
like in recipes will prevent all of the required dependencies from loading when not necessary.
Did you try it? It works as expected on my end. It might be redundant though if the plugin is already doing the same.
@kawre it would be cool being able to use the plugin with VeryLazy
again, because as it is right now, (using lazy=false) it adds a good 30ms to startup time.
@Zeioth
This startup time is because from what ive observed lazynvim
waits for the dependencies required by my plugin and combines theirs startup time into mine. So if my plugin startup time is lets say 5ms and treesitters is 30ms it will combine it into 35ms.
If you are sure that some of the dependencies will load anyway, you can remove them from the dependencies list.
Right now my leetcode.nvim
config has 0 dependencies as i load them elsewhere by events like "VeryLazy" anyway. This reduces the startup time to below 1ms.
You can also play around with lazy loading and see how it works, as i said before.
Ok I've been able to fix this by requiring the plugin in init
only when the leetcode.nvim argument is passed to nvim.
{
"kawre/leetcode.nvim",
dependencies = {
"nvim-treesitter/nvim-treesitter",
"nvim-telescope/telescope.nvim",
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
"nvim-tree/nvim-web-devicons",
"rcarriga/nvim-notify",
},
init = function(_, opts)
-- Require only when needed
if vim.tbl_contains(vim.fn.argv(), 'leetcode.nvim') then
require("leetcode").setup(opts)
end
end,
opts = {
lang = "typescript",
},
},
So same fix I had, but on init, to ensure it is applied on startup.
This is the last commit where I can use
nvim leetcode.nvim
.Any other commit I've tried after that one, won't start leetcode.nvim
My config
Screenshots
Working commit![screenshot_2023-10-22_03-06-16_573320584](https://github.com/kawre/leetcode.nvim/assets/3357792/6113a42f-8df2-487e-8c0f-5618d6d1c755)
After that![screenshot_2023-10-22_03-06-39_148783201](https://github.com/kawre/leetcode.nvim/assets/3357792/e25db491-d965-43d1-9086-f9fae5d22c04)