Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default setting + frequent :w = use up all the ram and system freeze #89

Closed
amalgame21 opened this issue Dec 23, 2022 · 8 comments · Fixed by #96
Closed

Default setting + frequent :w = use up all the ram and system freeze #89

amalgame21 opened this issue Dec 23, 2022 · 8 comments · Fixed by #96

Comments

@amalgame21
Copy link
Contributor

amalgame21 commented Dec 23, 2022

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.

@kpbochenek
Copy link

same issue 👍
Especially problematic at the beginning when you move things from your previous config and constantly save and test your changes

@amalgame21
Copy link
Contributor Author

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.

@tjdevries
Copy link
Member

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

@senicko
Copy link

senicko commented Dec 25, 2022

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.

@fernandocanizo
Copy link

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.

fernandocanizo added a commit to fernandocanizo/flc-nvim-config that referenced this issue Dec 26, 2022
@tjdevries
Copy link
Member

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.

@amalgame21
Copy link
Contributor Author

amalgame21 commented Dec 26, 2022

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

Thanks for your advice!!!
I tried replacing this line:

command = 'source <afile> | PackerCompile',

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!!!

@tjdevries
Copy link
Member

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants