]> git.donarmstrong.com Git - lilypond.git/blobdiff - vim/lilypond-indent.vim
(local-uninstall): remove
[lilypond.git] / vim / lilypond-indent.vim
index e2426d6d89c2e66633bfd32b94279c0ef79cd671..25d92e9baaaac42bae678df6ddd6d39692e2d1da 100644 (file)
@@ -2,7 +2,9 @@
 " Language:     LilyPond
 " Maintainer:   Heikki Junes <hjunes@cc.hut.fi>
 " Last Change:  2004 Mar 01
-
+"
+" Installed As:        vim/indent/lilypond.vim
+"
 " Only load this indent file when no other was loaded.
 if exists("b:did_indent")
   finish
@@ -10,6 +12,7 @@ endif
 let b:did_indent = 1
 
 setlocal indentexpr=GetLilyPondIndent()
+setlocal indentkeys=o,O,},>>,!^F
 
 " Only define the function once.
 if exists("*GetLilyPondIndent")
@@ -23,7 +26,17 @@ function GetLilyPondIndent()
 
   "Find a non-blank line above the current line.
   let lnum = prevnonblank(v:lnum - 1)
-  let ind = indent(lnum)
+  "Check if a block was started: '{' or '<<' is the last non-blank character of the previous line.
+  if getline(lnum) =~ '^.*\({\|<<\)\s*$'
+    let ind = indent(lnum) + &sw
+  else
+    let ind = indent(lnum)
+  endif
+
+  "Check if a block was ended: '}' or '>>' is the first non-blank character of the current line.
+  if getline(v:lnum) =~ '^\s*\(}\|>>\)'
+    let ind = ind - &sw
+  endif
 
   return ind
 endfunction