diff options
| author | samb0t | 2026-04-10 09:09:18 -0500 |
|---|---|---|
| committer | GitHub | 2026-04-10 23:09:18 +0900 |
| commit | 6b63f4e70a9e63408e150beed600d22241b2f3b6 (patch) | |
| tree | 79e3c1d947435e59e2af45f6fc98a187f5587125 | |
| parent | ba8b9cbab95131e284c5be926642f803b2be0058 (diff) | |
| download | ale-6b63f4e70a9e63408e150beed600d22241b2f3b6.tar.gz | |
Add support for LilyPond syntax (#5117)
- Add support for LilyPond syntax
Fix alpha order of LilyPond
Add support for custom executable and options to lilypond linter
Enhances the lilypond linter with configurable options: - Add g:alelilypondlilypondexecutable for custom lilypond binary path - Add g:alelilypondlilypondoptions for additional command-line flags - Refactor linter to use GetCommand() function for dynamic command building - Add linter tests covering configuration scenarios - Update documentation with usage examples and proper formatting
Co-authored-by: samb0t <sambottoni@gmail.com>
| -rw-r--r-- | ale_linters/lilypond/lilypond.vim | 40 | ||||
| -rw-r--r-- | doc/ale-lilypond.txt | 29 | ||||
| -rw-r--r-- | doc/ale-supported-languages-and-tools.txt | 2 | ||||
| -rw-r--r-- | doc/ale.txt | 2 | ||||
| -rw-r--r-- | supported-tools.md | 2 | ||||
| -rw-r--r-- | test/handler/test_lilypond.vader | 49 | ||||
| -rw-r--r-- | test/linter/test_lilypond.vader | 35 |
7 files changed, 159 insertions, 0 deletions
diff --git a/ale_linters/lilypond/lilypond.vim b/ale_linters/lilypond/lilypond.vim new file mode 100644 index 000000000..8469b5d61 --- /dev/null +++ b/ale_linters/lilypond/lilypond.vim @@ -0,0 +1,40 @@ +" Author: Sam Bottoni +" Description: lilypond linter for LilyPond files + +call ale#Set('lilypond_lilypond_executable', 'lilypond') + +let g:ale_lilypond_lilypond_options = get(g:, 'ale_lilypond_lilypond_options', '') + +function! ale_linters#lilypond#lilypond#GetCommand(buffer) abort + return '%e --loglevel=WARNING -dbackend=null -dno-print-pages -o /tmp' + \ . ale#Pad(ale#Var(a:buffer, 'lilypond_lilypond_options')) + \ . ' %t 2>&1' +endfunction + +function! ale_linters#lilypond#lilypond#Handle(buffer, lines) abort + let l:output = [] + + for l:line in a:lines + " Match: file:line:col: error|warning|programming error: message + let l:match = matchlist(l:line, + \ '\v^.*:(\d+):(\d+): (error|warning|programming error): (.*)$') + + if !empty(l:match) + call add(l:output, { + \ 'lnum': str2nr(l:match[1]), + \ 'col': str2nr(l:match[2]), + \ 'type': l:match[3] =~? 'error' ? 'E' : 'W', + \ 'text': l:match[4] + \}) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('lilypond', { +\ 'name': 'lilypond', +\ 'executable': {b -> ale#Var(b, 'lilypond_lilypond_executable')}, +\ 'command': function('ale_linters#lilypond#lilypond#GetCommand'), +\ 'callback': 'ale_linters#lilypond#lilypond#Handle', +\}) diff --git a/doc/ale-lilypond.txt b/doc/ale-lilypond.txt new file mode 100644 index 000000000..0b4d51a56 --- /dev/null +++ b/doc/ale-lilypond.txt @@ -0,0 +1,29 @@ +=============================================================================== +ALE LilyPond Integration *ale-lilypond-options* + + +=============================================================================== +lilypond *ale-lilypond* + +g:ale_lilypond_lilypond_executable *g:ale_lilypond_lilypond_executable* + *b:ale_lilypond_lilypond_executable* + Type: |String| + Default: `'lilypond'` + + This variable can be changed to modify the executable used for lilypond. + + +g:ale_lilypond_lilypond_options *g:ale_lilypond_lilypond_options* + *b:ale_lilypond_lilypond_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to lilypond. + + For example, to add custom include paths: > + + let g:ale_lilypond_lilypond_options = '--include=/path/to/includes' +< + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index fdd8f24dc..44812b93f 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -383,6 +383,8 @@ Notes: * `lessc` * `prettier` * `stylelint` +* LilyPond + * `lilypond` * LLVM * `llc` * Lua diff --git a/doc/ale.txt b/doc/ale.txt index e0192177a..f7a52df63 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -3722,6 +3722,8 @@ documented in additional help files. lessc.................................|ale-less-lessc| prettier..............................|ale-less-prettier| stylelint.............................|ale-less-stylelint| + lilypond................................|ale-lilypond-options| + lilypond..............................|ale-lilypond| llvm....................................|ale-llvm-options| llc...................................|ale-llvm-llc| lua.....................................|ale-lua-options| diff --git a/supported-tools.md b/supported-tools.md index 8988fa72b..94670d15f 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -393,6 +393,8 @@ formatting. * [lessc](https://www.npmjs.com/package/less) * [prettier](https://github.com/prettier/prettier) * [stylelint](https://github.com/stylelint/stylelint) +* LilyPond + * [lilypond](https://lilypond.org/) * LLVM * [llc](https://llvm.org/docs/CommandGuide/llc.html) * Lua diff --git a/test/handler/test_lilypond.vader b/test/handler/test_lilypond.vader new file mode 100644 index 000000000..b3f92d902 --- /dev/null +++ b/test/handler/test_lilypond.vader @@ -0,0 +1,49 @@ +Before: + runtime ale_linters/lilypond/lilypond.vim + call ale#linter#Reset() + +Execute(The lilypond handler should parse a single error correctly): + AssertEqual + \ [ + \ { + \ 'lnum': 2, + \ 'col': 5, + \ 'type': 'E', + \ 'text': 'syntax error, unexpected NOT_A_TOKEN', + \ } + \ ], + \ ale_linters#lilypond#lilypond#Handle(0, [ + \ 'test.ly:2:5: error: syntax error, unexpected NOT_A_TOKEN' + \ ]) + +Execute(The lilypond handler should parse warnings and errors): + AssertEqual + \ [ + \ { + \ 'lnum': 3, + \ 'col': 1, + \ 'type': 'W', + \ 'text': 'deprecated syntax', + \ }, + \ { + \ 'lnum': 5, + \ 'col': 12, + \ 'type': 'E', + \ 'text': 'unknown symbol', + \ } + \ ], + \ ale_linters#lilypond#lilypond#Handle(0, [ + \ 'test.ly:3:1: warning: deprecated syntax', + \ 'test.ly:5:12: error: unknown symbol' + \ ]) + +Execute(The lilypond handler should ignore non-matching lines): + AssertEqual + \ [], + \ ale_linters#lilypond#lilypond#Handle(0, [ + \ 'This is some unrelated output', + \ 'Another line without structure' + \ ]) + +After: + call ale#linter#Reset() diff --git a/test/linter/test_lilypond.vader b/test/linter/test_lilypond.vader new file mode 100644 index 000000000..90983ba21 --- /dev/null +++ b/test/linter/test_lilypond.vader @@ -0,0 +1,35 @@ +Before: + call ale#assert#SetUpLinterTest('lilypond', 'lilypond') + call ale#test#SetFilename('test.ly') + + let g:ale_lilypond_lilypond_executable = 'lilypond' + let g:ale_lilypond_lilypond_options = '' + +After: + call ale#assert#TearDownLinterTest() + +Execute(The executable should default to lilypond): + AssertLinter 'lilypond', + \ ale#Escape('lilypond') . ' --loglevel=WARNING -dbackend=null -dno-print-pages -o /tmp %t 2>&1' + +Execute(Should be able to set a custom executable): + let g:ale_lilypond_lilypond_executable = 'bin/lilypond' + + AssertLinter 'bin/lilypond', + \ ale#Escape('bin/lilypond') . ' --loglevel=WARNING -dbackend=null -dno-print-pages -o /tmp %t 2>&1' + +Execute(Should be able to set custom options): + let g:ale_lilypond_lilypond_options = '--include=/path/to/includes' + + AssertLinter 'lilypond', + \ ale#Escape('lilypond') . ' --loglevel=WARNING -dbackend=null -dno-print-pages -o /tmp' + \ . ' --include=/path/to/includes %t 2>&1' + +Execute(Should be able to set both custom executable and options): + let g:ale_lilypond_lilypond_executable = '/usr/local/bin/lilypond' + let g:ale_lilypond_lilypond_options = '--include=/custom/path -dlog-file=/tmp/lily.log' + + AssertLinter '/usr/local/bin/lilypond', + \ ale#Escape('/usr/local/bin/lilypond') . ' --loglevel=WARNING -dbackend=null -dno-print-pages -o /tmp' + \ . ' --include=/custom/path -dlog-file=/tmp/lily.log %t 2>&1' + |