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 first character from the previous line is within
42 " a `lilyScheme' region, and if so, use lisp-style indentation
43 " for the current line.
46 " - Only works in version 7.1.215 or later, though it should
47 " silently fail in older versions.
48 " - We should support `lilyScheme' regions that begin in the
49 " middle of the line, too.
50 for id in synstack(lnum, 1)
51 if synIDattr(id, "name") == "lilyScheme"
52 let ind = lispindent(v:lnum)