aboutsummaryrefslogtreecommitdiffstats
path: root/.vim/UltiSnips/c.snippets
diff options
context:
space:
mode:
authorkatherine <ageha@airen-no-jikken.icu>2019-12-20 23:00:25 -0700
committerkatherine <ageha@airen-no-jikken.icu>2019-12-20 23:00:25 -0700
commit9eb9a2dc9fac1d58ac3c19f11d83cdd46dda1afe (patch)
treef0d0587c477c035fb28b3f20d015b0b68a0dc862 /.vim/UltiSnips/c.snippets
parent1dd672f5bbd53b092137adee070fe7eac9f33e0d (diff)
downloaddotfiles-9eb9a2dc9fac1d58ac3c19f11d83cdd46dda1afe.tar.gz
add ultisnips
Diffstat (limited to '.vim/UltiSnips/c.snippets')
-rw-r--r--.vim/UltiSnips/c.snippets37
1 files changed, 37 insertions, 0 deletions
diff --git a/.vim/UltiSnips/c.snippets b/.vim/UltiSnips/c.snippets
new file mode 100644
index 0000000..3fcf3a3
--- /dev/null
+++ b/.vim/UltiSnips/c.snippets
@@ -0,0 +1,37 @@
+priority -50
+
+snippet ndf "#ifndef ... #define ... #endif"
+#ifndef ${1/([A-Za-z0-9_]+).*/$1/}
+#define ${1:SYMBOL} val
+#endif
+endsnippet
+
+snippet main "main() (main)"
+int main(int argc, char **argv)
+{
+ ${VISUAL}$0
+ return 0;
+}
+endsnippet
+
+snippet ig "include guard"
+`!p
+if not snip.c:
+ name = re.sub(r'[^A-Za-z0-9]+','_', fn).upper()
+ fpath = os.path.abspath(path)
+ val = ''
+ if (os.path.basename(os.path.dirname(fpath)) == 'src'):
+ dname = os.path.dirname(os.path.dirname(fpath))
+ dname = os.path.basename(dname)
+ dname = re.sub(r'[^A-Za-z0-9]+','_', dname).upper()
+ val = ('%s_%s' % (dname,name))
+ else:
+ val = name
+ snip.rv = '#ifndef ' + val + '\n#define ' + val
+else:
+ snip.rv = snip.c`
+
+${VISUAL}$0
+
+#endif
+endsnippet