Add test for indenting
This commit is contained in:
parent
68d7b51d9d
commit
dc958bcc42
2 changed files with 34 additions and 4 deletions
|
|
@ -21,6 +21,10 @@ function! Up()
|
||||||
return (indent(prevnonblank(v:lnum - 1)) + &tabstop)
|
return (indent(prevnonblank(v:lnum - 1)) + &tabstop)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! Hold()
|
||||||
|
return indent(prevnonblank(v:lnum - 1))
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! NimIndent()
|
function! NimIndent()
|
||||||
let line = getline(v:lnum)
|
let line = getline(v:lnum)
|
||||||
let prev = prevnonblank(v:lnum - 1)
|
let prev = prevnonblank(v:lnum - 1)
|
||||||
|
|
@ -28,6 +32,10 @@ function! NimIndent()
|
||||||
let prev2empty = getline(v:lnum - 2) =~ '^\s*$'
|
let prev2empty = getline(v:lnum - 2) =~ '^\s*$'
|
||||||
let prevl = getline(prev)
|
let prevl = getline(prev)
|
||||||
|
|
||||||
|
if prevl =~ ',\s*$'
|
||||||
|
return Hold()
|
||||||
|
endif
|
||||||
|
|
||||||
if prev2empty && prevempty
|
if prev2empty && prevempty
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
@ -52,10 +60,6 @@ function! NimIndent()
|
||||||
return Up()
|
return Up()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if prevl =~ ',\s*$'
|
|
||||||
return -1
|
|
||||||
endif
|
|
||||||
|
|
||||||
if prevempty && prevl =~ '\s*\(result\|return\|break\|continue\|raise\)'
|
if prevempty && prevl =~ '\s*\(result\|return\|break\|continue\|raise\)'
|
||||||
return Down()
|
return Down()
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
26
other/tests/vim/indent.vader
Normal file
26
other/tests/vim/indent.vader
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
Given nim:
|
||||||
|
import
|
||||||
|
sequtils,
|
||||||
|
streams
|
||||||
|
|
||||||
|
type Obj = object
|
||||||
|
x, y: int
|
||||||
|
|
||||||
|
proc nope =
|
||||||
|
echo "foobar"
|
||||||
|
nope()
|
||||||
|
|
||||||
|
Do:
|
||||||
|
gg=G
|
||||||
|
|
||||||
|
Expect:
|
||||||
|
import
|
||||||
|
sequtils,
|
||||||
|
streams
|
||||||
|
|
||||||
|
type Obj = object
|
||||||
|
x, y: int
|
||||||
|
|
||||||
|
proc nope =
|
||||||
|
echo "foobar"
|
||||||
|
nope()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue