Default setting + frequent `:w` = use up all the ram and system freeze
From the youtube video https://y.com.sb/watch?v=stqUbv-5u2s, I notice this project exist. So I want to test it out and replace my old init.vim and explore more about lua.
However, while playing around with the init.lua, my system freeze. Below is how to reproduce it:
Running nvim ~/.config/nvim/init.lua with default setting.
in htop it will display it spawn a process lua-language-server
when I press :w Enter, one more lua-language-server spawn, and use up maybe more 2% of ram.
when I do the :w Enter again, and use more 2% of ram. and so on
However I just have a bad habit to frequently save the files.
When I do :w too frequently, say 1 sec once for 15 sec
The ram usage surge rapidly, which is much more than 2% per :w mentioned above
and my system freeze.
And I later find out that it is caused by "Automatically source and re-compile packer whenever you save this init.lua" setting.
Just simply do a :wq also help release the ram.
Since this script may target new user of neovim as stated in the video I think it worth mentioning in the readme file.
same issue :+1: Especially problematic at the beginning when you move things from your previous config and constantly save and test your changes
same issue +1 Especially problematic at the beginning when you move things from your previous config and constantly save and test your changes
Yes, after that stage, the automatic recompile is indeed a very good feature.
I though it is the issue of nvim-treesitter or nvim-lspconfig, but it is not.
It take me about half an hour to find out the cause.
Hmm, that's a good point... I wonder if there is a way for us to prevent multiple language servers from being spawned.
Perhaps adding :LspStop to the autocmd might be worthwhile. Or :LspRestart
Personally I just commented the code responsible for automatic source & re-compile.
local packer_group = vim.api.nvim_create_augroup('Packer', { clear = true })
vim.api.nvim_create_autocmd('BufWritePost', {
command = 'source <afile> | PackerCompile',
group = packer_group,
pattern = vim.fn.expand '$MYVIMRC',
})
The lua language server (semnko_lua?) starts every time I do source $MYVIMRC. Because this code ^ makes it run on every save I guess.
I can confirm the bad behaviour and also @senicko observation. Also I checked up PackerCompile and is not clear to me why would we need this auto-command. I would choose the safe thing: remove this code and avoid getting users RAM be eaten.
The purpose of the code is because Packer has some confusing behavior to people on first attempt of using it. So this attempts to fix that, at least for starting up.
Yes you can just remove the code if you're already aware of how to use Packer. I will explore some options of how to solve the problem after Christmas.
Hmm, that's a good point... I wonder if there is a way for us to prevent multiple language servers from being spawned.
Perhaps adding
:LspStopto the autocmd might be worthwhile. Or:LspRestart
Thanks for your advice!!! I tried replacing this line:
https://github.com/nvim-lua/kickstart.nvim/blob/39a941c3851fbadf08731601b9958785e50bee73/init.lua#L90
with this:
command = 'source <afile> | silent! LspStop | silent! LspStart | PackerCompile',
Now I can press :w as fast as I want!
Thank for your work in kickstart.nvim! This make me easier to learn the lua sytle neovim config And the default combination of plugins is extremely good! Way better than other combinations on the internet and Telescope is also very good! Good job!!!
Thanks :) I think I may actually try and switch kickstart to the new lazy.nvim plugin from folke, which could also prevent this from happening (because there is no compilation) -- but I have to do a bit more exploring. In the meantime, #96 solves the problem for now. Thanks!