summaryrefslogtreecommitdiffstats
path: root/indent/nix.vim
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2018-07-08 15:16:28 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2018-07-08 15:16:28 +0200
commit055f7710b65dfa2df52fc0b5be2486ae36ac5751 (patch)
tree0b6c36a330e8c0c4e37ad521773d28b6c52ad3ec /indent/nix.vim
parent33f610feb73ce782cf41a7d9a377541991c692b5 (diff)
downloadvim-polyglot-055f7710b65dfa2df52fc0b5be2486ae36ac5751.tar.gz
vim-polyglot-055f7710b65dfa2df52fc0b5be2486ae36ac5751.zip
Update dependencies
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