zig.vim 1.4 KB

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