summaryrefslogtreecommitdiff
path: root/vim/.vim/indent
diff options
context:
space:
mode:
authorUrbain Vaes <urbain@vaes.uk>2017-06-07 13:04:32 +0100
committerUrbain Vaes <urbain@vaes.uk>2017-06-07 13:04:32 +0100
commit4ef38f411ec198328b5c18ba4b56b1499e4bc798 (patch)
treec385e8e47ce2ae7e6967ae7384775dcebc82e059 /vim/.vim/indent
parent2da45eb37e5207a0a0f62f0714e0f2f3676f3fe3 (diff)
Add script to facilitate qutebrowser navigation
Diffstat (limited to 'vim/.vim/indent')
-rw-r--r--vim/.vim/indent/gmsh.vim59
1 files changed, 59 insertions, 0 deletions
diff --git a/vim/.vim/indent/gmsh.vim b/vim/.vim/indent/gmsh.vim
new file mode 100644
index 0000000..845b668
--- /dev/null
+++ b/vim/.vim/indent/gmsh.vim
@@ -0,0 +1,59 @@
+" Vim indent file
+
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetGeoIndent()
+setlocal indentkeys&
+setlocal autoindent
+setlocal commentstring=//%s
+
+if exists("*GetGeoIndent")
+ finish
+endif
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+let s:skip_syntax = '\%(Comment\|String\)$'
+
+function! GetGeoIndent()
+
+ let lnum = prevnonblank(v:lnum - 1)
+
+ if lnum == 0
+ return 0
+ endif
+
+ let ind = indent(lnum)
+ let last_line = getline(lnum)
+ let current_line = getline(v:lnum)
+
+ if last_line =~ '\(^\/\/\|^\/\*\)'
+ return ind
+ endif
+
+ if last_line =~ '\(\<If\>\|\<For\>\|\<Macro\>\)'
+ let ind += &shiftwidth
+ endif
+
+ if last_line =~ '\({[^}]*$\)'
+ let ind += &shiftwidth
+ endif
+
+ if current_line =~ '\(^[^{]*}\)'
+ let ind -= &shiftwidth
+ endif
+
+ if current_line =~ '\(\<EndIf\>\|\<EndFor\>\|\<Return\>\)$'
+ let ind -= &shiftwidth
+ endif
+
+ return ind
+
+endfunction
+
+let &cpo = s:cpo_save
+unlet s:cpo_save