summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2018-01-19 17:10:29 +0000
committerGitHub <noreply@github.com>2018-01-19 17:10:29 +0000
commit7b50b3ec8249af6107a12a03820fb35854014b95 (patch)
tree9c8010e33596299f87f41585ffc23b120f4cab20 /ale_linters
parenta5ec4143d2ed0527649d4143e244b62b9f879661 (diff)
parent547716eabb3a436f2de623555fb488d3496ccbd4 (diff)
downloadale-7b50b3ec8249af6107a12a03820fb35854014b95.zip
Merge pull request #1272 from Codezerker/master
Add a luac linter for Lua
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/lua/luac.vim40
1 files changed, 40 insertions, 0 deletions
diff --git a/ale_linters/lua/luac.vim b/ale_linters/lua/luac.vim
new file mode 100644
index 00000000..4a6bb403
--- /dev/null
+++ b/ale_linters/lua/luac.vim
@@ -0,0 +1,40 @@
+" Author: Jon Xie https://github.com/xiejiangzhi
+" Description: luac linter for lua files
+
+call ale#Set('lua_luac_executable', 'luac')
+
+function! ale_linters#lua#luac#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'lua_luac_executable')
+endfunction
+
+function! ale_linters#lua#luac#GetCommand(buffer) abort
+ let l:executable = ale_linters#lua#luac#GetExecutable(a:buffer)
+ return ale#Escape(l:executable) . ' -p - '
+endfunction
+
+function! ale_linters#lua#luac#Handle(buffer, lines) abort
+ " Matches patterns line the following:
+ "
+ " luac: stdin:5: '=' expected near ')'
+ " luac: stdin:8: ')' expected (to close '(' at line 6) near '123'
+ let l:pattern = '\v^.*:(\d+): (.+)$'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ call add(l:output, {
+ \ 'lnum': l:match[1] + 0,
+ \ 'type': 'E',
+ \ 'text': l:match[2],
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('lua', {
+\ 'name': 'luac',
+\ 'executable_callback': 'ale_linters#lua#luac#GetExecutable',
+\ 'command_callback': 'ale_linters#lua#luac#GetCommand',
+\ 'output_stream': 'stderr',
+\ 'callback': 'ale_linters#lua#luac#Handle',
+\})