mirror of https://github.com/dense-analysis/ale
Add desktop-file-validate
This commit is contained in:
parent
8319e0f8c7
commit
3838ae118d
|
@ -0,0 +1,31 @@
|
|||
call ale#Set('desktop_desktop_file_validate_options', '')
|
||||
|
||||
" Example matches for pattern:
|
||||
"
|
||||
" foo.desktop: warning: key "TerminalOptions" in group ...
|
||||
" foo.desktop: error: action "new-private-window" is defined, ...
|
||||
let s:pattern = '\v^(.+): ([a-z]+): (.+)$'
|
||||
|
||||
function! ale_linters#desktop#desktop_file_validate#Handle(buffer, lines) abort
|
||||
" The error format doesn't specify lines, so we can just put all of the
|
||||
" errors on line 1.
|
||||
return ale#util#MapMatches(a:lines, s:pattern, {match -> {
|
||||
\ 'lnum': 1,
|
||||
\ 'col': 1,
|
||||
\ 'type': match[2] is? 'error' ? 'E' : 'W',
|
||||
\ 'text': match[3],
|
||||
\}})
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('desktop', {
|
||||
\ 'name': 'desktop_file_validate',
|
||||
\ 'aliases': ['desktop-file-validate'],
|
||||
\ 'executable': 'desktop-file-validate',
|
||||
\ 'command': {b ->
|
||||
\ '%e'
|
||||
\ . ale#Pad(ale#Var(b, 'desktop_desktop_file_validate_options'))
|
||||
\ . ' %t'
|
||||
\ },
|
||||
\ 'callback': 'ale_linters#desktop#desktop_file_validate#Handle',
|
||||
\ 'output_stream': 'both',
|
||||
\})
|
|
@ -0,0 +1,21 @@
|
|||
===============================================================================
|
||||
ALE desktop Integration *ale-desktop-options*
|
||||
|
||||
|
||||
===============================================================================
|
||||
desktop-file-validate *ale-desktop-desktop-file-validate*
|
||||
|
||||
ALE supports checking .desktop files with `desktop-file-validate.`
|
||||
|
||||
|
||||
g:ale_desktop_desktop_file_validate_options
|
||||
*g:ale_desktop_desktop_file_validate_options*
|
||||
*b:ale_desktop_desktop_file_validate_options*
|
||||
Type: |String|
|
||||
Default: `''`
|
||||
|
||||
This variable can be changed to set options for `desktop-file-validate`,
|
||||
such as `'--warn-kde'`.
|
||||
|
||||
===============================================================================
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
|
@ -126,6 +126,8 @@ Notes:
|
|||
* `dartanalyzer`!!
|
||||
* `dartfmt`!!
|
||||
* `language_server`
|
||||
* desktop
|
||||
* `desktop-file-validate`
|
||||
* Dhall
|
||||
* `dhall-format`
|
||||
* `dhall-freeze`
|
||||
|
|
|
@ -2697,6 +2697,8 @@ documented in additional help files.
|
|||
analysis_server.......................|ale-dart-analysis_server|
|
||||
dartanalyzer..........................|ale-dart-dartanalyzer|
|
||||
dartfmt...............................|ale-dart-dartfmt|
|
||||
desktop.................................|ale-desktop-options|
|
||||
desktop-file-validate.................|ale-desktop-desktop-file-validate|
|
||||
dhall...................................|ale-dhall-options|
|
||||
dhall-format..........................|ale-dhall-format|
|
||||
dhall-freeze..........................|ale-dhall-freeze|
|
||||
|
|
|
@ -135,6 +135,8 @@ formatting.
|
|||
* [dartanalyzer](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) :floppy_disk:
|
||||
* [dartfmt](https://github.com/dart-lang/sdk/tree/master/utils/dartfmt)
|
||||
* [language_server](https://github.com/natebosch/dart_language_server)
|
||||
* desktop
|
||||
* [desktop-file-validate](https://www.freedesktop.org/wiki/Software/desktop-file-utils/)
|
||||
* Dhall
|
||||
* [dhall-format](https://github.com/dhall-lang/dhall-lang)
|
||||
* [dhall-freeze](https://github.com/dhall-lang/dhall-lang)
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
Before:
|
||||
call ale#assert#SetUpLinterTest('desktop', 'desktop_file_validate')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default command should be correct):
|
||||
AssertLinter 'desktop-file-validate',
|
||||
\ ale#Escape('desktop-file-validate') . ' %t'
|
||||
|
||||
Execute(Extra options should work):
|
||||
let b:ale_desktop_desktop_file_validate_options = '--warn-kde'
|
||||
|
||||
AssertLinter 'desktop-file-validate',
|
||||
\ ale#Escape('desktop-file-validate') . ' --warn-kde %t'
|
|
@ -0,0 +1,26 @@
|
|||
Before:
|
||||
runtime ale_linters/desktop/desktop_file_validate.vim
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The desktop-file-validate handler should parse lines correctly):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 1,
|
||||
\ 'col': 1,
|
||||
\ 'type': 'W',
|
||||
\ 'text': 'key "TerminalOptions" in group "Desktop Entry" is deprecated',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 1,
|
||||
\ 'col': 1,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'action "new-private-window" is defined, but there is no matching "Desktop Action new-private-window" group',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#desktop#desktop_file_validate#Handle(bufnr(''), [
|
||||
\ 'foo.desktop: warning: key "TerminalOptions" in group "Desktop Entry" is deprecated',
|
||||
\ 'foo.desktop: error: action "new-private-window" is defined, but there is no matching "Desktop Action new-private-window" group',
|
||||
\ ])
|
Loading…
Reference in New Issue