diff --git a/contrib/vim/indent/chaiscript.vim b/contrib/vim/indent/chaiscript.vim index ad98e44..247e1a6 100644 --- a/contrib/vim/indent/chaiscript.vim +++ b/contrib/vim/indent/chaiscript.vim @@ -1,6 +1,6 @@ " Vim indent file -" Language: Minnow -" Maintainer: Jason Turner +" Language: ChaiScript +" Maintainer: Jason Turner " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -8,20 +8,15 @@ if exists("b:did_indent") endif let b:did_indent = 1 -setlocal indentexpr=GetMinnowIndent() - -" To make Vim call GetMinnowIndent() when it finds '\s*end' -" on the current line ('else' is default and includes 'elseif'). -setlocal indentkeys+=0=end - +setlocal indentexpr=GetChaiScriptIndent() setlocal autoindent " Only define the function once. -if exists("*GetMinnowIndent") +if exists("*GetChaiScriptIndent") finish endif -function! GetMinnowIndent() +function! GetChaiScriptIndent() " Find a non-blank line above the current line. let lnum = prevnonblank(v:lnum - 1) @@ -31,7 +26,7 @@ function! GetMinnowIndent() endif " Add a 'shiftwidth' after lines that start a block: - " 'function', 'if', 'for', 'while', 'repeat', 'else', 'elseif', '{' + " lines containing a { let ind = indent(lnum) let flag = 0 let prevline = getline(lnum) @@ -40,14 +35,13 @@ function! GetMinnowIndent() let flag = 1 endif - " Subtract a 'shiftwidth' after lines ending with - " 'end' when they begin with 'while', 'if', 'for', etc. too. + " Subtract a 'shiftwidth' after lines containing a { followed by a } + " to keep it balanced if flag == 1 && prevline =~ '.*{.*}.*' let ind = ind - &shiftwidth endif - " Subtract a 'shiftwidth' on end, else (and elseif), until and '}' - " This is the part that requires 'indentkeys'. + " Subtract a 'shiftwidth' on lines ending with } if getline(v:lnum) =~ '^\s*\%(}\)' let ind = ind - &shiftwidth endif diff --git a/contrib/vim/syntax/chaiscript.vim b/contrib/vim/syntax/chaiscript.vim index 1447c96..b9ca849 100644 --- a/contrib/vim/syntax/chaiscript.vim +++ b/contrib/vim/syntax/chaiscript.vim @@ -1,6 +1,6 @@ " Vim syntax file " Language: ChaiScript -" Maintainer: Jason Turner +" Maintainer: Jason Turner syn case match