summaryrefslogtreecommitdiff
path: root/ale_linters/desktop/desktop_file_validate.vim
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2021-03-19 22:29:06 +0000
committerw0rp <devw0rp@gmail.com>2021-03-19 22:29:06 +0000
commit3838ae118d8f05fa1b1be7952a1c8aa3055d6728 (patch)
treecd4c7ce2c78092b348862b5cc1b1617286a8ffbe /ale_linters/desktop/desktop_file_validate.vim
parent8319e0f8c7e11a6c5f6aa58fb7669f6ccb2651df (diff)
downloadale-3838ae118d8f05fa1b1be7952a1c8aa3055d6728.zip
Add desktop-file-validate
Diffstat (limited to 'ale_linters/desktop/desktop_file_validate.vim')
-rw-r--r--ale_linters/desktop/desktop_file_validate.vim31
1 files changed, 31 insertions, 0 deletions
diff --git a/ale_linters/desktop/desktop_file_validate.vim b/ale_linters/desktop/desktop_file_validate.vim
new file mode 100644
index 00000000..5a97d315
--- /dev/null
+++ b/ale_linters/desktop/desktop_file_validate.vim
@@ -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',
+\})