Files
neovim/runtime/ftplugin/zig.vim
zeertzjq 07c37f6645 vim-patch:1f33732: runtime: guard recommended style settings consistently
Normalize the 15 existing guards to the documented two-level form
get(g:, 'X_recommended_style', get(g:, 'filetype_recommended_style', 1)):
fix the two non-standard "!exists() || != 0" guards (python, arduino) and
tolk's wrong fallback variable, and convert the simple one-level guards.

Add the guard to filetype plugins that set stylistic indentation/format
options without one: aap, abap, ada, cabal, cobol, elixir, falcon,
graphql, heex, idris2, mermaid, occam, racket, scala, swift, tera.

Settings that are required rather than stylistic are left untouched, e.g.
make/gomod/scdoc (mandatory tabs), chatito and vroom (indent mandated by
the format), and the textwidth/formatoptions cases in gitcommit/help/
jjdescription.

Supported by AI.

fixes:  vim/vim#20036
closes: vim/vim#20650

1f33732613

Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-29 08:47:54 +08:00

58 lines
1.5 KiB
VimL

" Vim filetype plugin file
" Language: Zig
" Maintainer: Mathias Lindgren <math.lindgren@gmail.com>
" Last Change: 2024 Oct 04
" 2026 Jun 27 by Vim Project (normalize recommended style guard)
" Based on: https://codeberg.org/ziglang/zig.vim
if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1
let s:cpo_save = &cpo
set cpo&vim
" Match Zig builtin fns
setlocal iskeyword+=@-@
setlocal formatoptions-=t formatoptions+=croql
setlocal suffixesadd=.zig,.zir,.zon
let &l:define='\v(<fn>|<const>|<var>|^\s*\#\s*define)'
let b:undo_ftplugin = 'setl isk< fo< sua< mp< def<'
if get(g:, 'zig_recommended_style',
\ get(g:, 'filetype_recommended_style', 1))
setlocal expandtab
setlocal tabstop=8
setlocal softtabstop=4
setlocal shiftwidth=4
let b:undo_ftplugin .= ' | setl et< ts< sts< sw<'
endif
if has('comments')
setlocal comments=:///,://!,://
setlocal commentstring=//\ %s
let b:undo_ftplugin .= ' | setl com< cms<'
endif
if has('find_in_path')
let &l:includeexpr='substitute(v:fname, "^([^.])$", "\1.zig", "")'
let &l:include='\v(\@import>|\@cInclude>|^\s*\#\s*include)'
let b:undo_ftplugin .= ' | setl inex< inc<'
endif
if exists('g:zig_std_dir')
let &l:path .= ',' . g:zig_std_dir
let b:undo_ftplugin .= ' | setl pa<'
endif
if !exists('current_compiler')
compiler zig_build
let b:undo_ftplugin .= "| compiler make"
endif
let &cpo = s:cpo_save
unlet s:cpo_save
" vim: tabstop=8 shiftwidth=4 softtabstop=4 expandtab