summaryrefslogtreecommitdiffstats
path: root/indent/nix.vim
diff options
context:
space:
mode:
Diffstat (limited to 'indent/nix.vim')
-rw-r--r--indent/nix.vim23
1 files changed, 23 insertions, 0 deletions
diff --git a/indent/nix.vim b/indent/nix.vim
index fd277dcc..2910cbd6 100644
--- a/indent/nix.vim
+++ b/indent/nix.vim
@@ -21,6 +21,8 @@ let s:cpo_save = &cpo
set cpo&vim
let s:skip_syntax = '\%(Comment\|String\)$'
+let s:binding_open = '\%(\<let\>\|{\)'
+let s:binding_close = '\%(\<in\>\|}\)'
let s:block_open = '\%({\|[\)'
let s:block_close = '\%(}\|]\)'
@@ -43,6 +45,23 @@ function! GetNixIndent()
let current_line = getline(v:lnum)
let last_line = getline(lnum)
+ if current_line =~ '^\s*in\>'
+ let save_cursor = getcurpos()
+ normal ^
+ let bslnum = searchpair(s:binding_open, '', s:binding_close, 'bnW',
+ \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "StringSpecial$"')
+ call setpos('.', save_cursor)
+ return indent(bslnum)
+ endif
+
+ if last_line =~ ';$'
+ let bslnum = searchpair(s:binding_open, '', s:binding_close, 'bnW',
+ \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "StringSpecial$"')
+ if bslnum != 0
+ let ind = indent(bslnum) + &sw
+ endif
+ endif
+
if last_line =~ s:block_open . '\s*$'
let ind += &sw
endif
@@ -51,6 +70,10 @@ function! GetNixIndent()
let ind -= &sw
endif
+ if last_line =~ '[(=]$'
+ let ind += &sw
+ endif
+
if last_line =~ '\<let\s*$'
let ind += &sw
endif