summaryrefslogtreecommitdiffstats
path: root/indent
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2019-03-05 09:34:59 +0100
committerAdam Stankiewicz <sheerun@sher.pl>2019-03-05 09:34:59 +0100
commit86721731c740d0ea07e6b90e601a80770c3d9f36 (patch)
tree6f8b5ea6e94d818ab1580b003ac219dade1664ff /indent
parent6f7257ade246f62993a71066f394a3652f9493b6 (diff)
downloadvim-polyglot-86721731c740d0ea07e6b90e601a80770c3d9f36.tar.gz
vim-polyglot-86721731c740d0ea07e6b90e601a80770c3d9f36.zip
Add lilypond support, closes #278
Diffstat (limited to 'indent')
-rw-r--r--indent/lilypond.vim64
1 files changed, 64 insertions, 0 deletions
diff --git a/indent/lilypond.vim b/indent/lilypond.vim
new file mode 100644
index 00000000..169a6758
--- /dev/null
+++ b/indent/lilypond.vim
@@ -0,0 +1,64 @@
+if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'lilypond') != -1
+ finish
+endif
+
+" LilyPond indent file
+" Language: LilyPond
+" Maintainer: Heikki Junes <hjunes@cc.hut.fi>
+" Last Change: 2010 Jul 26
+"
+" Installed As: vim/indent/lilypond.vim
+"
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetLilyPondIndent()
+setlocal indentkeys=o,O,},>>,!^F
+
+" Only define the function once.
+if exists("*GetLilyPondIndent")
+ finish
+endif
+
+function GetLilyPondIndent()
+ if v:lnum == 1
+ return 0
+ endif
+
+ "Find a non-blank line above the current line.
+ let lnum = prevnonblank(v:lnum - 1)
+ "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
+
+ " 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
+"
+"
+"