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

Slow formatting in neovim #109

Open
zoeesilcock opened this issue Jan 15, 2025 · 0 comments
Open

Slow formatting in neovim #109

zoeesilcock opened this issue Jan 15, 2025 · 0 comments

Comments

@zoeesilcock
Copy link

Formatting is very slow when called via zig#fmt#Format() and when using zig_fmt_autosave on neovim. In all of my testing I have found that running zig fmt ****.zig directly in the terminal is instant, so my suspicion is that the shell is too slow at pushing large amounts of data through stdout.

I tested with a file that has 2297 lines and got the following results (two different machines, so they aren't comparable to each other):

  • Windows (PowerShell): 31 seconds
  • Mac: 13 seconds

I really want to use format-on-save, but it really doesn't take long to hit a line count that leads to a pause on every save which is very distracting.

The workaround I am using now is to disable format-on-save and bind a key to run the shell command and reload the file manually: <cmd>!zig fmt %<CR><cmd>:e<CR><cmd>LspRestart<CR>. But it would be more convenient if I could just leave zig_fmt_autosave enabled. It's also problematic for new users as it isn't obvious that neovim includes this plugin and that it has format-on-save enabled by default and could give the impression that zig or zig fmt is slow.

Versions:

PS > nvim -v       
NVIM v0.10.2
Build type: Release
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info
PS > zig version
0.13.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant