Add lilypond support, closes #278

This commit is contained in:
Adam Stankiewicz 2019-03-05 09:34:59 +01:00
parent 6f7257ade2
commit 86721731c7
8 changed files with 259 additions and 1 deletions

View File

@ -8,7 +8,7 @@ A collection of language packs for Vim.
> One to rule them all, one to find them, one to bring them all and in the darkness bind them. > One to rule them all, one to find them, one to bring them all and in the darkness bind them.
- It **won't affect your startup time**, as scripts are loaded only on demand\*. - It **won't affect your startup time**, as scripts are loaded only on demand\*.
- It **installs and updates 100+ times faster** than the <!--Package Count-->128<!--/Package Count--> packages it consists of. - It **installs and updates 100+ times faster** than the <!--Package Count-->129<!--/Package Count--> packages it consists of.
- Solid syntax and indentation support (other features skipped). Only the best language packs. - Solid syntax and indentation support (other features skipped). Only the best language packs.
- All unnecessary files are ignored (like enormous documentation from php support). - All unnecessary files are ignored (like enormous documentation from php support).
- No support for esoteric languages, only most popular ones (modern too, like `slim`). - No support for esoteric languages, only most popular ones (modern too, like `slim`).
@ -103,6 +103,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [kotlin](https://github.com/udalov/kotlin-vim) (syntax, indent, ftplugin) - [kotlin](https://github.com/udalov/kotlin-vim) (syntax, indent, ftplugin)
- [latex](https://github.com/LaTeX-Box-Team/LaTeX-Box) (syntax, indent, ftplugin) - [latex](https://github.com/LaTeX-Box-Team/LaTeX-Box) (syntax, indent, ftplugin)
- [less](https://github.com/groenewege/vim-less) (syntax, indent, ftplugin) - [less](https://github.com/groenewege/vim-less) (syntax, indent, ftplugin)
- [lilypond](https://github.com/anowlcalledjosh/vim-lilypond) (syntax, indent, compiler, ftplugin)
- [liquid](https://github.com/tpope/vim-liquid) (syntax, indent, ftplugin) - [liquid](https://github.com/tpope/vim-liquid) (syntax, indent, ftplugin)
- [livescript](https://github.com/gkz/vim-ls) (syntax, indent, compiler, ftplugin) - [livescript](https://github.com/gkz/vim-ls) (syntax, indent, compiler, ftplugin)
- [lua](https://github.com/tbastos/vim-lua) (syntax, indent) - [lua](https://github.com/tbastos/vim-lua) (syntax, indent)

1
build
View File

@ -212,6 +212,7 @@ PACKS="
latex:LaTeX-Box-Team/LaTeX-Box latex:LaTeX-Box-Team/LaTeX-Box
less:groenewege/vim-less less:groenewege/vim-less
liquid:tpope/vim-liquid liquid:tpope/vim-liquid
lilypond:anowlcalledjosh/vim-lilypond
livescript:gkz/vim-ls livescript:gkz/vim-ls
lua:tbastos/vim-lua lua:tbastos/vim-lua
mako:sophacles/vim-bundle-mako mako:sophacles/vim-bundle-mako

23
compiler/lilypond.vim Normal file
View File

@ -0,0 +1,23 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'lilypond') != -1
finish
endif
" LilyPond compiler file
" Language: LilyPond
" Maintainer: Heikki Junes <hjunes@cc.hut.fi>
" Last Change: 2004 Mar 01
"
" Installed As: vim/compiler/lilypond.vim
"
" Only load this indent file when no other was loaded.
if exists("current_compiler")
finish
endif
let current_compiler = "lilypond"
" default make
setlocal makeprg=lilypond\ $*
" errorformat for lily (with columns) and gcc
" (how to see multiple-line error messages?)
setlocal errorformat=%f:%l:%c:\ %m,%f:%l:\ %m,In\ file\ included\ from\ %f:%l:,\^I\^Ifrom\ %f:%l%m
"

View File

@ -667,6 +667,16 @@ au BufNewFile,BufRead */templates/**.liquid,*/layout/**.liquid,*/snippets/**.liq
augroup end augroup end
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'lilypond') == -1
augroup filetypedetect
" lilypond, from lilypond.vim in anowlcalledjosh/vim-lilypond
"
" Installed As: vim/ftdetect/lilypond.vim
"
au! BufNewFile,BufRead *.ly,*.ily set ft=lilypond
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'livescript') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'livescript') == -1
augroup filetypedetect augroup filetypedetect
" livescript, from ls.vim in gkz/vim-ls " livescript, from ls.vim in gkz/vim-ls

61
ftplugin/lilypond.vim Normal file
View File

@ -0,0 +1,61 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'lilypond') != -1
finish
endif
" LilyPond filetype plugin
" Language: LilyPond (ft=ly)
" Maintainer: Heikki Junes <hjunes@cc.hut.fi>
" Last Change: 2010 Jul 26
"
" Installed As: vim/ftplugin/lilypond.vim
" Uses Generated File: vim/syntax/lilypond-words.vim
"
" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
finish
endif
" Don't load another plugin for this buffer
let b:did_ftplugin = 1
setlocal autoindent
setlocal shiftwidth=2
"
" some handy key mappings
"
" <F4> save & make and play midi with timidity
map <buffer> <F4> :w<Return>:se makeprg=lilypond\ \"%<\"<Return>:make<Return>:!timidity "%<.midi"<Return>
"
" <F5> save & make
map <buffer> <F5> :w<Return>:se makeprg=lilypond\ \"%<\"<Return>:make<Return>
"
" <F6> view ps with ghostview
map <buffer> <F6> :!gv --watch "%<.ps" &<Return>
"
" <F7> prev error
map <buffer> <F7> :cp<Return>
"
" <F8> next error
map <buffer> <F8> :cn<Return>
"
" <F9> make
map <buffer> <F9> :w<Return>:se makeprg=make\ -k<Return>:make<Return>
"
" <F10> menu
source $VIMRUNTIME/menu.vim
setlocal wildmenu
setlocal cpo-=<
setlocal wcm=<C-Z>
map <buffer> <F10> :emenu <C-Z>
"
" <F12> comment region
map <buffer> <F12> :g!/%.*/normal 0i%<Return>
"
" <S-F12> remove comments in region
map <buffer> <S-F12> :g/%.*/normal 0x<Return>
"
" Completions in Insert/Replace-mode with <Ctrl-N>
setlocal dictionary-=$VIM/syntax/lilypond-words dictionary+=$VIM/syntax/lilypond-words
setlocal complete-=k complete+=k
"
setlocal showmatch

64
indent/lilypond.vim Normal file
View File

@ -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
"
"
"

File diff suppressed because one or more lines are too long

91
syntax/lilypond.vim Normal file
View File

@ -0,0 +1,91 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'lilypond') != -1
finish
endif
" LilyPond syntax file
" Language: LilyPond
" Maintainer: Heikki Junes <hjunes@cc.hut.fi>
" Last Change: 2010 Jul 26
"
" Installed As: vim/syntax/lilypond.vim
" Uses Generated File: vim/syntax/lilypond-words.vim
"
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
" Read the LilyPond syntax match groups:
" lilyKeyword, lilyReservedWord, lilyNote
if version < 600
so <sfile>:p:h/lilypond-words.vim
else
runtime! syntax/lilypond-words.vim
if exists("b:current_syntax")
unlet b:current_syntax
endif
endif
" Match also parethesis of angle type
setlocal mps+=<:>
" Case matters
syn case match
syn cluster lilyMatchGroup contains=lilyMatcher,lilyString,lilyComment,lilyStatement,lilyNumber,lilySlur,lilySpecial,lilyNote,lilyKeyword,lilyArticulation,lilyReservedWord,lilyScheme
syn region lilyMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[<>]" end="}" contains=@lilyMatchGroup fold
syn region lilyMatcher matchgroup=Delimiter start="\[" end="]" contains=@lilyMatchGroup fold
syn region lilyMatcher matchgroup=Delimiter start="<" skip="\\\\\|\\[{<>}]" end=">" contains=@lilyMatchGroup fold
syn region lilyString start=/"/ end=/"/ skip=/\\"/
syn region lilyComment start="%{" skip="%$" end="%}"
syn region lilyComment start="%\([^{]\|$\)" end="$"
syn match lilyNumber "[-_^.]\?\d\+[.]\?"
syn match lilySlur "[(~)]"
syn match lilySlur "\\[()]"
syn match lilySpecial "\\[<!>\\]"
" avoid highlighting the extra character in situations like
" c--\mf c^^\mf c__\mf
syn match lilyArticulation "[-_^][-_^+|>.]"
" Include Scheme syntax highlighting, where appropriate
syn include @embeddedScheme syntax/scheme.vim
unlet b:current_syntax
syn region lilyScheme matchgroup=Delimiter start="#['`]\?(" matchgroup=Delimiter end=")" contains=@embeddedScheme
" Rest of syntax highlighting rules start here
"
" " Define the default highlighting.
" " For version 5.7 and earlier: only when not done already
" " For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_lily_syn_inits")
if version < 508
let did_lily_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink Delimiter Identifier
HiLink lilyString String
HiLink lilyComment Comment
HiLink lilyNote Identifier
HiLink lilyArticulation PreProc
HiLink lilyKeyword Keyword
HiLink lilyReservedWord Type
HiLink lilyNumber Constant
HiLink lilySpecial Special
HiLink lilySlur ModeMsg
delcommand HiLink
endif
let b:current_syntax = "lilypond"