zig.vim (1524B)
1 " Vim filetype plugin file 2 " Language: Zig 3 " Maintainer: Mathias Lindgren <math.lindgren@gmail.com> 4 " Last Change: 2024 Oct 04 5 " 2026 Jun 27 by Vim Project (normalize recommended style guard) 6 " Based on: https://codeberg.org/ziglang/zig.vim 7 8 if exists("b:did_ftplugin") 9 finish 10 endif 11 12 let b:did_ftplugin = 1 13 14 let s:cpo_save = &cpo 15 set cpo&vim 16 17 " Match Zig builtin fns 18 setlocal iskeyword+=@-@ 19 setlocal formatoptions-=t formatoptions+=croql 20 setlocal suffixesadd=.zig,.zir,.zon 21 let &l:define='\v(<fn>|<const>|<var>|^\s*\#\s*define)' 22 let b:undo_ftplugin = 'setl isk< fo< sua< mp< def<' 23 24 if get(g:, 'zig_recommended_style', 25 \ get(g:, 'filetype_recommended_style', 1)) 26 setlocal expandtab 27 setlocal tabstop=8 28 setlocal softtabstop=4 29 setlocal shiftwidth=4 30 let b:undo_ftplugin .= ' | setl et< ts< sts< sw<' 31 endif 32 33 if has('comments') 34 setlocal comments=:///,://!,:// 35 setlocal commentstring=//\ %s 36 let b:undo_ftplugin .= ' | setl com< cms<' 37 endif 38 39 if has('find_in_path') 40 let &l:includeexpr='substitute(v:fname, "^([^.])$", "\1.zig", "")' 41 let &l:include='\v(\@import>|\@cInclude>|^\s*\#\s*include)' 42 let b:undo_ftplugin .= ' | setl inex< inc<' 43 endif 44 45 if exists('g:zig_std_dir') 46 let &l:path .= ',' . g:zig_std_dir 47 let b:undo_ftplugin .= ' | setl pa<' 48 endif 49 50 if !exists('current_compiler') 51 compiler zig_build 52 let b:undo_ftplugin .= "| compiler make" 53 endif 54 55 let &cpo = s:cpo_save 56 unlet s:cpo_save 57 " vim: tabstop=8 shiftwidth=4 softtabstop=4 expandtab