Fix #804 - Do not run scalac for sbt files

This commit is contained in:
w0rp 2017-07-26 10:29:46 +01:00
parent e45c16d9bb
commit 86297a7c65
2 changed files with 42 additions and 4 deletions

View File

@ -1,6 +1,26 @@
" Author: Zoltan Kalmar - https://github.com/kalmiz " Author: Zoltan Kalmar - https://github.com/kalmiz,
" w0rp <devw0rp@gmail.com>
" Description: Basic scala support using scalac " Description: Basic scala support using scalac
function! ale_linters#scala#scalac#GetExecutable(buffer) abort
if index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0
" Don't check sbt files with scalac.
return ''
endif
return 'scalac'
endfunction
function! ale_linters#scala#scalac#GetCommand(buffer) abort
let l:executable = ale_linters#scala#scalac#GetExecutable(a:buffer)
if empty(l:executable)
return ''
endif
return ale#Escape(l:executable) . ' -Ystop-after:parser %t'
endfunction
function! ale_linters#scala#scalac#Handle(buffer, lines) abort function! ale_linters#scala#scalac#Handle(buffer, lines) abort
" Matches patterns line the following: " Matches patterns line the following:
" "
@ -38,8 +58,8 @@ endfunction
call ale#linter#Define('scala', { call ale#linter#Define('scala', {
\ 'name': 'scalac', \ 'name': 'scalac',
\ 'executable': 'scalac', \ 'executable_callback': 'ale_linters#scala#scalac#GetExecutable',
\ 'output_stream': 'stderr', \ 'command_callback': 'ale_linters#scala#scalac#GetCommand',
\ 'command': 'scalac -Ystop-after:parser %t',
\ 'callback': 'ale_linters#scala#scalac#Handle', \ 'callback': 'ale_linters#scala#scalac#Handle',
\ 'output_stream': 'stderr',
\}) \})

View File

@ -0,0 +1,18 @@
Before:
runtime ale_linters/scala/scalac.vim
After:
call ale#linter#Reset()
Given scala(An empty Scala file):
Execute(The default executable and command should be correct):
AssertEqual 'scalac', ale_linters#scala#scalac#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('scalac') . ' -Ystop-after:parser %t',
\ ale_linters#scala#scalac#GetCommand(bufnr(''))
Given scala.sbt(An empty SBT file):
Execute(scalac should not be run for sbt files):
AssertEqual '', ale_linters#scala#scalac#GetExecutable(bufnr(''))
AssertEqual '', ale_linters#scala#scalac#GetCommand(bufnr(''))