summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorKevin Tindall <kevinkjt2000@gmail.com>2018-02-10 13:04:43 -0600
committerKevin Tindall <kevinkjt2000@gmail.com>2018-02-10 13:17:53 -0600
commit716b46e10d2abe54daa09e876d4b7a6b56024ad0 (patch)
treeed72234ef8237e68c92e018b5df13891a7a0a0d3 /autoload
parenta3329ef3fc44a04a2617941eb46deef6c184f4af (diff)
downloadale-716b46e10d2abe54daa09e876d4b7a6b56024ad0.zip
functional pony linter
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/handlers/pony.vim34
1 files changed, 34 insertions, 0 deletions
diff --git a/autoload/ale/handlers/pony.vim b/autoload/ale/handlers/pony.vim
new file mode 100644
index 00000000..0ac18e76
--- /dev/null
+++ b/autoload/ale/handlers/pony.vim
@@ -0,0 +1,34 @@
+scriptencoding utf-8
+" Description: This file defines a handler function which ought to work for
+" any program which outputs errors in the format that ponyc uses.
+
+function! s:RemoveUnicodeQuotes(text) abort
+ let l:text = a:text
+ let l:text = substitute(l:text, '[`´‘’]', '''', 'g')
+ let l:text = substitute(l:text, '\v\\u2018([^\\]+)\\u2019', '''\1''', 'g')
+ let l:text = substitute(l:text, '[“”]', '"', 'g')
+
+ return l:text
+endfunction
+
+function! ale#handlers#pony#HandlePonycFormat(buffer, lines) abort
+ " Look for lines like the following.
+ " /home/code/pony/classes/Wombat.pony:22:30: can't lookup private fields from outside the type
+
+ let l:pattern = '\v^([^:]+):(\d+):(\d+)?:? (.+)$'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ let l:item = {
+ \ 'filename': l:match[1],
+ \ 'lnum': str2nr(l:match[2]),
+ \ 'col': str2nr(l:match[3]),
+ \ 'type': 'E',
+ \ 'text': s:RemoveUnicodeQuotes(l:match[4]),
+ \}
+
+ call add(l:output, l:item)
+ endfor
+
+ return l:output
+endfunction