diff --git a/indent/coffee.vim b/indent/coffee.vim index 6e58d5e..12e2f3a 100644 --- a/indent/coffee.vim +++ b/indent/coffee.vim @@ -10,6 +10,7 @@ endif let b:did_indent = 1 setlocal autoindent +setlocal nosmartindent setlocal indentexpr=GetCoffeeIndent(v:lnum) " Make sure GetCoffeeIndent is run when these are typed so they can be " indented or outdented. @@ -184,17 +185,7 @@ endfunction " Get the nearest previous line that isn't a comment. function! s:GetPrevNormalLine(startlinenum) - let curlinenum = a:startlinenum - - while curlinenum - let curlinenum = prevnonblank(curlinenum - 1) - - if !s:IsCommentLine(curlinenum) - return curlinenum - endif - endwhile - - return 0 + return prevnonblank(a:startlinenum - 1) endfunction " Try to find a comment in a line. @@ -243,13 +234,6 @@ function! GetCoffeeIndent(curlinenum) return -1 endif - let prevlinenum = a:curlinenum - 1 - - " If continuing a comment, keep the indent level. - if s:IsCommentLine(prevlinenum) - return indent(prevlinenum) - endif - let prevlinenum = s:GetPrevNormalLine(a:curlinenum) " Don't do anything if there's no code before. @@ -257,6 +241,11 @@ function! GetCoffeeIndent(curlinenum) return -1 endif + " If continuing a comment, keep the indent level. + if s:IsCommentLine(prevlinenum) + return -1 + endif + " Indent based on the current line. let curline = s:GetTrimmedLine(a:curlinenum) @@ -345,7 +334,6 @@ function! GetCoffeeIndent(curlinenum) endif endif - " If no indent or outdent is needed, keep the indent level of the previous - " line. - return previndent + " If no indent or outdent is needed, keep the indent level of the cursor + return -1 endfunction