Skip to content

Disable built-in formatting for zig #28878

Closed
@flexagoon

Description

@flexagoon

Problem

By default, nvim's Zig ftplugin will format zig files on save:

autocmd BufWritePre <buffer> if get(g:, 'zig_fmt_autosave', 1) | call zig#fmt#Format() | endif

This is very confusing, since this behavior is not documented anywhere, and users expect nvim not to format anything unless they configure it to do so.

Steps to reproduce

Have zig installed

nvim --clean test.zig

pub const Test= enum { Foo,
    Bar};

Save the file and it will be automatically formatted

Expected behavior

Nvim should not do any automatic formatting by default which requires an undocumented global variable to disable.

At least the default value should be changed to 0 to disable this setting by default.

Neovim version (nvim -v)

NVIM v0.11.0-dev+18-g63e3a63d2

Vim (not Nvim) behaves the same?

Yes, vim 9.1

Operating system/version

Fedora Silverblue 40

Terminal name/version

Wezterm

$TERM environment variable

xterm-256color

Installation

Occurs with any installation method

Metadata

Metadata

Assignees

No one assigned

    Labels

    has:vim-patchissue is fixed in vim and patch needs to be portedruntimefuntime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions