blob: ea584ed086c050b51756857b298fe0a6798da173 [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>
Konfekt7c3f9af2024-10-05 17:26:46 +02004" Last Change: 2024 Oct 04
Tisenod1d93162024-05-21 23:27:03 +02005" 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
Bram Moolenaar86b48162022-12-06 18:20:10 +000016" Match Zig builtin fns
17setlocal iskeyword+=@-@
Bram Moolenaar86b48162022-12-06 18:20:10 +000018setlocal formatoptions-=t formatoptions+=croql
Tisenod1d93162024-05-21 23:27:03 +020019setlocal suffixesadd=.zig,.zir,.zon
20let &l:define='\v(<fn>|<const>|<var>|^\s*\#\s*define)'
21let b:undo_ftplugin = 'setl isk< fo< sua< mp< def<'
Bram Moolenaar86b48162022-12-06 18:20:10 +000022
Tisenod1d93162024-05-21 23:27:03 +020023if get(g:, 'zig_recommended_style', 1)
24 setlocal expandtab
25 setlocal tabstop=8
26 setlocal softtabstop=4
27 setlocal shiftwidth=4
28 let b:undo_ftplugin .= ' | setl et< ts< sts< sw<'
29endif
Bram Moolenaar86b48162022-12-06 18:20:10 +000030
31if has('comments')
Gregory Anderse08bfef2023-10-19 10:16:59 -050032 setlocal comments=:///,://!,://
Bram Moolenaar86b48162022-12-06 18:20:10 +000033 setlocal commentstring=//\ %s
Tisenod1d93162024-05-21 23:27:03 +020034 let b:undo_ftplugin .= ' | setl com< cms<'
Bram Moolenaar86b48162022-12-06 18:20:10 +000035endif
36
37if has('find_in_path')
38 let &l:includeexpr='substitute(v:fname, "^([^.])$", "\1.zig", "")'
39 let &l:include='\v(\@import>|\@cInclude>|^\s*\#\s*include)'
Tisenod1d93162024-05-21 23:27:03 +020040 let b:undo_ftplugin .= ' | setl inex< inc<'
Bram Moolenaar86b48162022-12-06 18:20:10 +000041endif
Bram Moolenaar86b48162022-12-06 18:20:10 +000042
43if exists('g:zig_std_dir')
Tisenod1d93162024-05-21 23:27:03 +020044 let &l:path .= ',' . g:zig_std_dir
45 let b:undo_ftplugin .= ' | setl pa<'
Bram Moolenaar86b48162022-12-06 18:20:10 +000046endif
47
Konfekt7c3f9af2024-10-05 17:26:46 +020048if !exists('current_compiler')
49 compiler zig_build
50 let b:undo_ftplugin .= "| compiler make"
51endif
52
Tisenod1d93162024-05-21 23:27:03 +020053let &cpo = s:cpo_save
54unlet s:cpo_save
Bram Moolenaar86b48162022-12-06 18:20:10 +000055" vim: tabstop=8 shiftwidth=4 softtabstop=4 expandtab