summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorEvan Borden <eborden@users.noreply.github.com>2018-09-28 04:05:01 -0400
committerw0rp <w0rp@users.noreply.github.com>2018-09-28 09:05:01 +0100
commita8915d885b79ba8e243c228c9f38dddbcb1c479a (patch)
treee3d0549ec17717a8ad5a3a66c4fb5dbc63d83c07 /ale_linters
parenta26b3319a1f37c82be8098b6eae4e6f2985a31eb (diff)
downloadale-a8915d885b79ba8e243c228c9f38dddbcb1c479a.zip
Add better support for Haskell stack compiler tools (#1851)
* Add better support for Haskell stack compiler tools This commit adds support for `stack` as the executable of a tool. This follows a pattern that has been implemented for `bundler`'s tool chain. * Move hlint command to linter file * Add vader test for stack exec handling * Update ghc-mod to support stack execution `ghc-mod` was previously broken into 2 linters. 1. ghc_mod 2. stack_ghc_mod This additional linter is not necessary with proper support for executable variables and `stack exec` handling. * Support stack exec in hfmt * Support stack in hdevtools
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/haskell/ghc-mod.vim18
-rw-r--r--ale_linters/haskell/ghc_mod.vim19
-rw-r--r--ale_linters/haskell/hdevtools.vim5
-rw-r--r--ale_linters/haskell/hie.vim15
-rw-r--r--ale_linters/haskell/hlint.vim10
5 files changed, 36 insertions, 31 deletions
diff --git a/ale_linters/haskell/ghc-mod.vim b/ale_linters/haskell/ghc-mod.vim
deleted file mode 100644
index eb032f50..00000000
--- a/ale_linters/haskell/ghc-mod.vim
+++ /dev/null
@@ -1,18 +0,0 @@
-" Author: wizzup <wizzup@gmail.com>
-" Description: ghc-mod for Haskell files
-
-call ale#linter#Define('haskell', {
-\ 'name': 'ghc_mod',
-\ 'aliases': ['ghc-mod'],
-\ 'executable': 'ghc-mod',
-\ 'command': 'ghc-mod --map-file %s=%t check %s',
-\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
-\})
-
-call ale#linter#Define('haskell', {
-\ 'name': 'stack_ghc_mod',
-\ 'aliases': ['stack-ghc-mod'],
-\ 'executable': 'stack',
-\ 'command': 'stack exec ghc-mod -- --map-file %s=%t check %s',
-\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
-\})
diff --git a/ale_linters/haskell/ghc_mod.vim b/ale_linters/haskell/ghc_mod.vim
new file mode 100644
index 00000000..9762be7a
--- /dev/null
+++ b/ale_linters/haskell/ghc_mod.vim
@@ -0,0 +1,19 @@
+" Author: wizzup <wizzup@gmail.com>
+" Description: ghc-mod for Haskell files
+
+call ale#Set('haskell_ghc_mod_executable', 'ghc-mod')
+
+function! ale_linters#haskell#ghc_mod#GetCommand (buffer) abort
+ let l:executable = ale#Var(a:buffer, 'haskell_ghc_mod_executable')
+
+ return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'ghc-mod')
+ \ . ' --map-file %s=%t check %s'
+endfunction
+
+call ale#linter#Define('haskell', {
+\ 'name': 'ghc_mod',
+\ 'aliases': ['ghc-mod'],
+\ 'executable_callback': ale#VarFunc('haskell_ghc_mod_executable'),
+\ 'command_callback': 'ale_linters#haskell#ghc_mod#GetCommand',
+\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
+\})
diff --git a/ale_linters/haskell/hdevtools.vim b/ale_linters/haskell/hdevtools.vim
index fbd5278e..cc5ce56f 100644
--- a/ale_linters/haskell/hdevtools.vim
+++ b/ale_linters/haskell/hdevtools.vim
@@ -5,7 +5,10 @@ call ale#Set('haskell_hdevtools_executable', 'hdevtools')
call ale#Set('haskell_hdevtools_options', get(g:, 'hdevtools_options', '-g -Wall'))
function! ale_linters#haskell#hdevtools#GetCommand(buffer) abort
- return '%e check' . ale#Pad(ale#Var(a:buffer, 'haskell_hdevtools_options'))
+ let l:executable = ale#Var(a:buffer, 'haskell_hdevtools_executable')
+
+ return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'hdevtools')
+ \ . ' check' . ale#Pad(ale#Var(a:buffer, 'haskell_hdevtools_options'))
\ . ' -p %s %t'
endfunction
diff --git a/ale_linters/haskell/hie.vim b/ale_linters/haskell/hie.vim
index 558d36a3..3ff1180a 100644
--- a/ale_linters/haskell/hie.vim
+++ b/ale_linters/haskell/hie.vim
@@ -3,10 +3,6 @@
call ale#Set('haskell_hie_executable', 'hie')
-function! ale_linters#haskell#hie#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'haskell_hie_executable')
-endfunction
-
function! ale_linters#haskell#hie#GetProjectRoot(buffer) abort
" Search for the stack file first
let l:project_file = ale#path#FindNearestFile(a:buffer, 'stack.yaml')
@@ -35,10 +31,17 @@ function! ale_linters#haskell#hie#GetProjectRoot(buffer) abort
return l:project_file
endfunction
+function! ale_linters#haskell#hie#GetCommand(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'haskell_hie_executable')
+
+ return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'hie')
+\ . ' --lsp'
+endfunction
+
call ale#linter#Define('haskell', {
\ 'name': 'hie',
\ 'lsp': 'stdio',
-\ 'command': '%e --lsp',
-\ 'executable_callback': 'ale_linters#haskell#hie#GetExecutable',
+\ 'command_callback': 'ale_linters#haskell#hie#GetCommand',
+\ 'executable_callback': ale#VarFunc('haskell_hie_executable'),
\ 'project_root_callback': 'ale_linters#haskell#hie#GetProjectRoot',
\})
diff --git a/ale_linters/haskell/hlint.vim b/ale_linters/haskell/hlint.vim
index 3ee864bf..fbb49fdb 100644
--- a/ale_linters/haskell/hlint.vim
+++ b/ale_linters/haskell/hlint.vim
@@ -1,9 +1,6 @@
" Author: jparoz <jesse.paroz@gmail.com>
" Description: hlint for Haskell files
-call ale#Set('haskell_hlint_executable', 'hlint')
-call ale#Set('haskell_hlint_options', get(g:, 'hlint_options', ''))
-
function! ale_linters#haskell#hlint#Handle(buffer, lines) abort
let l:output = []
@@ -32,14 +29,15 @@ endfunction
function! ale_linters#haskell#hlint#GetCommand(buffer) abort
let l:hlintopts = '--color=never --json'
- return '%e'
+ return ale#handlers#hlint#GetExecutable(a:buffer)
\ . ' ' . ale#Var(a:buffer, 'haskell_hlint_options')
- \ . ' ' . l:hlintopts . ' -'
+ \ . ' ' . l:hlintopts
+ \ . ' -'
endfunction
call ale#linter#Define('haskell', {
\ 'name': 'hlint',
\ 'executable_callback': ale#VarFunc('haskell_hlint_executable'),
-\ 'command_callback': 'ale_linters#haskell#hlint#GetCommand',
+\ 'command_callback': 'ale_linters#haskell#hlint#GetCommand' ,
\ 'callback': 'ale_linters#haskell#hlint#Handle',
\})