commit 9e26b43ada8959f533604be3622fa56bf1d54752 (tree)
parent 978b1475b0e7f504f255de64bd7aeb5f57f70f92
Author: Faerryn <alexandre.liao@gmail.com>
Date: Mon, 14 Sep 2020 03:35:08 -0400
Setup vim's include-search for Zig
Vim can search for definitions inside of `#include`d files in C source files with the keybindings [i for first occurrence, [d for first definition, and so on.
`:h include-search` for more detail.
Notably, &include and &define still keep their old C values, since Zig will often interfaces with C.
Diffstat:
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/ftplugin/zig.vim b/ftplugin/zig.vim
@@ -24,6 +24,16 @@ if has("comments")
setlocal commentstring=//\ %s
endif
+if has('find_in_path')
+ let &l:includeexpr='substitute(v:fname, "^([^.])$", "\1.zig", "")'
+ let &l:include='\v(\@import>|\@cInclude>|^\s*\#\s*include)'
+ let &l:define='\v(<fn>|<const>|<var>|^\s*\#\s*define)'
+endif
+
+if has('eval')
+ execute 'setlocal path+=' . json_decode(system('zig env'))['std_dir']
+endif
+
let b:undo_ftplugin = "setl et< ts< sts< sw< fo< sua< mp< com< cms<"
let &cpo = s:cpo_orig