mirror of https://github.com/dense-analysis/ale
Only run stack if a stack.yaml config is found (#1752)
* Only run stack if a stack.yaml config is found It is necessary to check for a stack.yaml file to distinguish between cabal-only projects or stack projects (which are also cabal projects since stack is built on top of cabal). * Test that stack is called if stack.yaml exists
This commit is contained in:
parent
9bdd5771ef
commit
02c0d5bcb9
|
@ -16,7 +16,7 @@ call ale#linter#Define('haskell', {
|
|||
\ 'name': 'stack_build',
|
||||
\ 'aliases': ['stack-build'],
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'stack',
|
||||
\ 'executable_callback': 'ale#handlers#haskell#GetStackExecutable',
|
||||
\ 'command_callback': 'ale_linters#haskell#stack_build#GetCommand',
|
||||
\ 'lint_file': 1,
|
||||
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
||||
|
|
|
@ -5,7 +5,7 @@ call ale#linter#Define('haskell', {
|
|||
\ 'name': 'stack_ghc',
|
||||
\ 'aliases': ['stack-ghc'],
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'stack',
|
||||
\ 'executable_callback': 'ale#handlers#haskell#GetStackExecutable',
|
||||
\ 'command': 'stack ghc -- -fno-code -v0 %t',
|
||||
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
||||
\})
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: Error handling for the format GHC outputs.
|
||||
"
|
||||
function! ale#handlers#haskell#GetStackExecutable(bufnr) abort
|
||||
if ale#path#FindNearestFile(a:bufnr, 'stack.yaml') isnot# ''
|
||||
return 'stack'
|
||||
endif
|
||||
|
||||
" if there is no stack.yaml file, we don't use stack even if it exists,
|
||||
" so we return '', because executable('') apparently always fails
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Remember the directory used for temporary files for Vim.
|
||||
let s:temp_dir = fnamemodify(ale#util#Tempname(), ':h')
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
Before:
|
||||
call ale#assert#SetUpLinterTest('haskell', 'stack_build')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The linter should not be executed when there's no stack.yaml file):
|
||||
AssertLinterNotExecuted
|
||||
|
||||
Execute(The linter should be executed when there is a stack.yaml file):
|
||||
call ale#test#SetFilename('stack_build_paths/test.hs')
|
||||
|
||||
AssertLinter 'stack', 'stack build --fast'
|
|
@ -0,0 +1,14 @@
|
|||
Before:
|
||||
call ale#assert#SetUpLinterTest('haskell', 'stack_ghc')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The linter should not be executed when there's no stack.yaml file):
|
||||
AssertLinterNotExecuted
|
||||
|
||||
Execute(The linter should be executed when there is a stack.yaml file):
|
||||
call ale#test#SetFilename('stack_ghc_paths/test.hs')
|
||||
|
||||
AssertLinter 'stack', 'stack ghc -- -fno-code -v0 %t'
|
||||
|
Loading…
Reference in New Issue