X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=vim%2Flilypond-indent.vim;h=224f5de4cdfd511946b9173767f7b36220868460;hb=750b714488c5af6eae22d07163bba8b554734ac6;hp=fd2144b2fd5dce5cc9cba33e984efa93957e1702;hpb=e3c9620c20174bd54c523a9bd892bb4666efc400;p=lilypond.git diff --git a/vim/lilypond-indent.vim b/vim/lilypond-indent.vim index fd2144b2fd..224f5de4cd 100644 --- a/vim/lilypond-indent.vim +++ b/vim/lilypond-indent.vim @@ -1,7 +1,7 @@ " LilyPond indent file " Language: LilyPond " Maintainer: Heikki Junes -" Last Change: 2004 Mar 01 +" Last Change: 2010 Jul 26 " " Installed As: vim/indent/lilypond.vim " @@ -12,7 +12,7 @@ endif let b:did_indent = 1 setlocal indentexpr=GetLilyPondIndent() -setlocal indentkeys+==},>>,!^F +setlocal indentkeys=o,O,},>>,!^F " Only define the function once. if exists("*GetLilyPondIndent") @@ -34,10 +34,25 @@ function GetLilyPondIndent() endif "Check if a block was ended: '}' or '>>' is the first non-blank character of the current line. - elseif getline(v:lnum) =~ '^\s*\(}\|>>\)' + if getline(v:lnum) =~ '^\s*\(}\|>>\)' let ind = ind - &sw endif + " Check if the first character from the previous line is within + " a `lilyScheme' region, and if so, use lisp-style indentation + " for the current line. + " + " TODO: + " - Only works in version 7.1.215 or later, though it should + " silently fail in older versions. + " - We should support `lilyScheme' regions that begin in the + " middle of the line, too. + for id in synstack(lnum, 1) + if synIDattr(id, "name") == "lilyScheme" + let ind = lispindent(v:lnum) + endif + endfor + return ind endfunction "