blob: ea229b6a492f972ee3346a147564a01da04f9ac7 [file] [log] [blame]
Bram Moolenaar86b48162022-12-06 18:20:10 +00001" Vim filetype plugin file
Tisenod1d93162024-05-21 23:27:03 +02002" Language: Zig
3" Maintainer: Mathias Lindgren <math.lindgren@gmail.com>
4" Last Change: 2024 May 21
5" Based on: https://github.com/ziglang/zig.vim
Bram Moolenaar86b48162022-12-06 18:20:10 +00006
Bram Moolenaar86b48162022-12-06 18:20:10 +00007if exists("b:did_ftplugin")
8 finish
9endif
10
11let b:did_ftplugin = 1
12
Tisenod1d93162024-05-21 23:27:03 +020013let s:cpo_save = &cpo
Bram Moolenaar86b48162022-12-06 18:20:10 +000014set cpo&vim
15
16compiler zig_build
17
18" Match Zig builtin fns
19setlocal iskeyword+=@-@
Bram Moolenaar86b48162022-12-06 18:20:10 +000020setlocal formatoptions-=t formatoptions+=croql
Tisenod1d93162024-05-21 23:27:03 +020021setlocal suffixesadd=.zig,.zir,.zon
22let &l:define='\v(<fn>|<const>|<var>|^\s*\#\s*define)'
23let b:undo_ftplugin = 'setl isk< fo< sua< mp< def<'
Bram Moolenaar86b48162022-12-06 18:20:10 +000024
Tisenod1d93162024-05-21 23:27:03 +020025if get(g:, 'zig_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<'
31endif
Bram Moolenaar86b48162022-12-06 18:20:10 +000032
33if has('comments')
Gregory Anderse08bfef2023-10-19 10:16:59 -050034 setlocal comments=:///,://!,://
Bram Moolenaar86b48162022-12-06 18:20:10 +000035 setlocal commentstring=//\ %s
Tisenod1d93162024-05-21 23:27:03 +020036 let b:undo_ftplugin .= ' | setl com< cms<'
Bram Moolenaar86b48162022-12-06 18:20:10 +000037endif
38
39if has('find_in_path')
40 let &l:includeexpr='substitute(v:fname, "^([^.])$", "\1.zig", "")'
41 let &l:include='\v(\@import>|\@cInclude>|^\s*\#\s*include)'
Tisenod1d93162024-05-21 23:27:03 +020042 let b:undo_ftplugin .= ' | setl inex< inc<'
Bram Moolenaar86b48162022-12-06 18:20:10 +000043endif
Bram Moolenaar86b48162022-12-06 18:20:10 +000044
45if exists('g:zig_std_dir')
Tisenod1d93162024-05-21 23:27:03 +020046 let &l:path .= ',' . g:zig_std_dir
47 let b:undo_ftplugin .= ' | setl pa<'
Bram Moolenaar86b48162022-12-06 18:20:10 +000048endif
49
Tisenod1d93162024-05-21 23:27:03 +020050let &cpo = s:cpo_save
51unlet s:cpo_save
Bram Moolenaar86b48162022-12-06 18:20:10 +000052" vim: tabstop=8 shiftwidth=4 softtabstop=4 expandtab