mirror of
https://github.com/dense-analysis/ale.git
synced 2026-05-18 06:19:49 +08:00
Add support for LilyPond syntax (#5117)
* Add support for LilyPond syntax See: https://lilypond.org/ * Fix alpha order of LilyPond * Add support for custom executable and options to lilypond linter Enhances the lilypond linter with configurable options: - Add g:ale_lilypond_lilypond_executable for custom lilypond binary path - Add g:ale_lilypond_lilypond_options 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>
This commit is contained in:
@@ -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',
|
||||
\})
|
||||
Reference in New Issue
Block a user