summaryrefslogtreecommitdiffstats
path: root/indent
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2020-09-10 16:38:32 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2020-09-10 16:38:32 +0200
commit05ff14bfdaeca8def902c644d119f3946009bf14 (patch)
treee6e9dbb371a1e4ecf4d4f72e05589248f82494ae /indent
parent9243367ba376050621e4c05e8f0439742c1f0f82 (diff)
downloadvim-polyglot-05ff14bfdaeca8def902c644d119f3946009bf14.tar.gz
vim-polyglot-05ff14bfdaeca8def902c644d119f3946009bf14.zip
Add odin support, closes #544
Diffstat (limited to 'indent')
-rw-r--r--indent/odin.vim41
1 files changed, 41 insertions, 0 deletions
diff --git a/indent/odin.vim b/indent/odin.vim
new file mode 100644
index 00000000..b00b5387
--- /dev/null
+++ b/indent/odin.vim
@@ -0,0 +1,41 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'odin') == -1
+
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal nosmartindent
+setlocal nolisp
+setlocal autoindent
+
+setlocal indentexpr=GetOdinIndent(v:lnum)
+
+if exists("*GetOdinIndent")
+ finish
+endif
+
+function! GetOdinIndent(lnum)
+ let prev = prevnonblank(a:lnum-1)
+
+ if prev == 0
+ return 0
+ endif
+
+ let prevline = getline(prev)
+ let line = getline(a:lnum)
+
+ let ind = indent(prev)
+
+ if prevline =~ '[({]\s*$'
+ let ind += &sw
+ endif
+
+ if line =~ '^\s*[)}]'
+ let ind -= &sw
+ endif
+
+ return ind
+endfunction
+
+endif