-
Notifications
You must be signed in to change notification settings - Fork 58
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
Remove format-on-save as the default #51
Comments
Not only that, adding an automatic saving feature makes this plugin less consistent with most other filetype plugins, but I'm not sure if that is a particularly bad thing. |
I will leave this issue open, but I'm not particularly fond of changing the behavior because it isn't "consistent" with other plugins. @Himujjal as far as I'm aware, both use |
@haze I figured out why it was slow in my setup (I had fish as the default vim shell instead of bash). I totally forgot about this issue. Sorry for not closing it sooner. Anyways, I still think that having autosave on is a bad default and its of course very heavily opinion based. I am not sure if the option to disable it was available when I first opened this issue (cant remember). Since its available now, my problem is done. Thank you. |
If there is a growing audience for moving the default to not saving on default I'm happy to reopen this |
I can second this request. |
I want to point out that format-on-save breaks redo, which is pretty frustrating. Sometimes I do I don't know why format-on-save breaks redo. It doesn't seem like it should. |
This has made its way into upstream vim/neovim runtime files and is very confusing when using zls. It automatically puts errors in my loclist by default too which is annoying. |
I wanted to learn Zig and wasted quite a lot of time on this. I seriously dislike autoformatting and one of the reasons I use NeoVim is that it stays out of my way and does not do things like this unless I explicitly ask it to. The behaviour of this plugin breaks that, and it was pretty difficult to find out how to disable it, especially since I never even thought to suspect NeoVim's built-in runtime files to be at fault here. It won't be an issue for me anymore, since I just plopped the |
+1 on this request. Please let the users -choose- when they want to format their own code. Don't make decisions for us. Thank you. |
Also had this issue. Frustrating. |
It's by definition impossible to let users choose the default setting. The config file is where users make a choice |
I think you missed the point of that message. I'm asking for the default to not be that I'm forced to find some hidden lsp config option to disable the formatting, when I'm learning and getting used to the lang, and everything is already foreign enough as it is. Every other lang/tool I know lets you choose -when- you format. It doesn't just format your code without asking if you wanted to format your own code. That' just makes no sense. If power users want to format their own code, they will. Even if its disabled by default and they want it auto, they will figure it out. If a newcomer to the lang wants to -not- format their code, because they are learning and used to their own ways of doing things and getting used to the new way of working... the current forced-format-default causes an unnecessary amount of frustration that basically serves no purpose. I can even understand the not-configurable-by-design formatting choice. But... force-formatting by default is just something else. |
I literally just tried Zig for the first time, I copied some sample code into nvim, I type I did not even know I had a Zig language plugin installed! I never installed it. It looks like it’s shipped by default. And it just magically changes the text without asking me, without any message whatsoever, something that happens with no other programming language. I had to google this issue to figure out what is causing this and luckily I found this thread within like 5 minutes, but one might not always be so lucky. Stuff like this should never be enabled by default. This is unexpected, annoying and frustrating. Leave my text editor alone. |
Was as surprised as the others to see my qflist being populated/opened without asking it to or seeing my code autoformat. If this was just an opt-in plugin, I wouldn't really care, but now that I also would like to note that there are now better ways to format code that won't break the undo/redo list (and that are non-blocking), so having auto-formatting that completely replace the buffer by default doesn't really make sense anymore. |
This is an unreasonable default. No other built in language support does auto formatting (or population of qflist) by default. If it were a plugin it would be fine, however it would still lie about what the scope is. From the readme:
That should be the only thing this piece of code does. It is not only intrusive as it destroys your buffer when you did not ask for it, but it also has a performance hit on save, which is totally unreasonable as a default. This seriously made me reevaluate using neovim over vim. How did this make it into the neovim runtime? Edit: I realise this rant should probably be in the neovim repo, not here 😅. Edit2: Actually this plugin is included in vim as well, which is absurd. |
While I disagree with the autoformat on save being the default, you can just:
And it'll disable the behavior. No need to recompile anything. |
For me its equally fast as I am already compiling from source and rather not pollute my config with options that should not exist. BUT the real point is that I do not want BufWritePre auto commands being registered in the first place, not that I do not want auto formatting. augroup vim-zig
autocmd! * <buffer>
autocmd BufWritePre <buffer> if get(g:, 'zig_fmt_autosave', 1) | call zig#fmt#Format() | endif
augroup END That should be something a user should register themselves if they want it. In the latest neovim release 9.4 zig is the only language that does this and has its own folder under runtime/autoload (except for xml for some reason which has some wierd stuff). But... after some digging around I discovered, to my horror, that the rust language support also does a BufWritePre au by default in the later releases of vim and has its own folder with a bunch of stuff inherited from the https://github.com/rust-lang/rust.vim. |
As an example, go has done it exactly the way I described with |
Sorry for re-opening this issue, but just wanted to post yet another request for format-on-save not being the default. Similar to @Spiffyk, I was just learning zig for the first time, and was experiencing slow edits + weird behavior due to the format no save feature (I have an autosave plugin, so "save" happens every time I enter normal mode). Ended up spending 1 hour tracking down the issue. Not an ideal experience. Of course not a big deal after I found out the |
Same, I had zig 0.12 installed and after saving any .zig file in vim, it winds up completely reformatted. I definitely don't expect or want this behavior and it's completely surprising as well as extremely difficult to troubleshoot for any "normal" user. Uninstalling the zig 0.12 package was the only way I found make vim stop doing this terrible thing. Thanks for the tip to add |
I have a PR for removing this behavior from the vim runtime (vim/vim#13803), but I lost a little steam as I am no vim script expert. And I couldn't really find any concrete guidelines for what the correct course of action should be, like what is the philosophy here, for instance, the rust plugin does a shit ton of things, but everything is opt-in. To me this should all get removed, i.e. the au command and std dir setup. |
Putting my 1 cent here as zig fmt takes forever to complete on my end. And it's not even done in async. |
FYI this is now removed from the vim and neovim runtimes vim/vim#13803 |
I might be late but this is completely ironic. Zig strives to not use hidden-control, yet the default (control) is to enforce formatting on the use (at least with neovim)... |
I don't really maintain this plugin other than editing the syntax file for new keywords because I don't know vim script and I plan to never learn it, so I have no plans to tackle this issue. But @haze said he would reopen it if a lot of people want it, and it's clear that is the case, so I will click the button. Please note that if you don't have ast-check enabled on save, you're 100% definitely doing it wrong. Format-on-save off, OK, but you absolutely need to see those quick errors on save. It's a game changer. (from the CLI that's congratulations to this for getting under my skin:
🙄 c'mon man give me a break. that doesn't make any sense |
I don't disagree, but there are multiple ways to get that, and there will be users who will just plop a language server in their config and be done with it. ZLS does this and more for Zig. Enabling ast-check by default will be in conflict with setups that already use ZLS. The problem with enabling things like this by default is that there is no standardized way to disable them in (Neo)Vim, and generally, (Neo)Vim users will expect the editor to do nothing extra, unless instructed to do so by their own config. Especially when talking about behavior for specific languages (i.e. the editor does nothing like this for C, JavaScript, Go... but does for Zig - that is very surprising and hard to track down). And (Neo)Vim doing stuff besides text editing by default will conflict with people's setups, which do get complex. It is the established culture, which may not be to everyone's taste, and that is understandable, but it is the reason why people use (Neo)Vim in the first place. |
Ah, sorry, I didn't see the last comments in vim/vim#13803, which basically imply this I am fully on board with the current state, with this plugin here being completely opt-in installable with whatever defaults its (future?) maintainer wishes it to have, and the built-in one only including file detection and syntax highlighting. |
My apologies @andrewrk, it was not my intention to cause grief. TLDR; @Spiffyk explained my gripe with this behavior vs expectation just about perfectly. I don't use auto-save features for various reasons nor any Zig related (neovim) plugins |
makes my vim hang when saving a .zon file. nice one |
I found this issue because neovim was hanging for between 1 and 6 seconds every time I saved a
These led me to check which autocommands were actually being run, and to my surprise there's an autocommand in a filetype plugin of all places. I disabled format on save and lo and behold no hanging issues (I can't reliably reproduce the crash and I'm not sure what's causing it, but that may very well be gone too). I don't know where the conflict actually is, but it'd be nice if format on save was an opt in feature, not opt out, as that would've saved me this headache that I've had for a while. I'm happy to make a PR for this if necessary. The change should be as simple as just changing the 1 to a 0 here Line 55 in 15d6510
|
@cyuria you can grab a pre-release from https://github.com/neovim/neovim/releases such as the latest NVIM v0.11.0-dev-1046+g25b53b593 (look under Assets for the appropriate binary for ex. nvim-linux64.tar.gz or Mac or Win or appimage etc). |
@Spiffyk @edrozenberg thanks I didn't notice that. My offer is still on the table if you want to change the behaviour here of course |
Just here to say that I spent like an hour thinking that conform.nvim or zls had an issue until I realized it was neovim doing autoformatting for me. Thank god it's getting removed |
Is it getting removed? I thought the fix noted above solves the slowdown not the autosave problem? I just reformatted a friends project and pushed it to his repo before noticing that vim had reformatted THE ENTIRE FILE not just the bits visible to me on screen when I saved. Please consider this a plea to remove this behavior asap. Now I'm faced with rolling back the mess I made and reapplying my changes, and also messing with configurations and hoping I don't mess up again tomorrow by using a different computer and forgetting to turn off the auto-scribble feature there. |
This plugin/repo won't get any changes, however the version bundled with (neo)vim is being updated (idk the status of that off the top of my head). I do wonder why you don't want the formatted zig though, as it just uses the standard zig formatter (i.e. |
@meshula it is removed from neovim nightly, and will be a part of the 0.11 release, I believe. |
I don't have write access to this repository anymore. I suggest someone open a PR to disable and let @andrewrk merge. |
@cyuria The answer to your question is that I need to conform to a house style that is not the same as the style zig fmt implements. For sure, it is great when everyone agrees on matters of legibility and aesthetics, for all the familiar reasons! |
The plugin automatically calls
zig fmt
to format the code as soon as we save the file. This can be set as option rather than the default.When developing on large files,
zig fmt
slows down the formatting when called from scratch. I for example use the ZLS (zig language server) to format which is much faster. I can disable this plugin for sure, but I would suggest keeping this as not the default.The text was updated successfully, but these errors were encountered: