3 " Maintainer: Heikki Junes <hjunes@cc.hut.fi>
4 " Last Change: 2010 Jul 26
6 " Installed As: vim/indent/lilypond.vim
8 " Only load this indent file when no other was loaded.
9 if exists("b:did_indent")
14 setlocal indentexpr=GetLilyPondIndent()
15 setlocal indentkeys=o,O,},>>,!^F
17 " Only define the function once.
18 if exists("*GetLilyPondIndent")
22 function GetLilyPondIndent()
27 "Find a non-blank line above the current line.
28 let lnum = prevnonblank(v:lnum - 1)
29 "Check if a block was started: '{' or '<<' is the last non-blank character of the previous line.
30 if getline(lnum) =~ '^.*\({\|<<\)\s*$'
31 let ind = indent(lnum) + &sw
33 let ind = indent(lnum)
36 "Check if a block was ended: '}' or '>>' is the first non-blank character of the current line.
37 if getline(v:lnum) =~ '^\s*\(}\|>>\)'
41 " Check if the previous line is a `lilyScheme' region, and if
42 " so, use lisp-style indentation for the current line.
43 " TODO: only works in version 7.1.215 or later, though it should
44 " silently fail in older versions.
45 for id in synstack(lnum, 1)
46 if synIDattr(id, "name") == "lilyScheme"
47 let ind = lispindent(v:lnum)