summaryrefslogtreecommitdiff
path: root/autoload
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 /autoload
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 'autoload')
-rw-r--r--autoload/ale/fixers/brittany.vim10
-rw-r--r--autoload/ale/fixers/hfmt.vim2
-rw-r--r--autoload/ale/fixers/hlint.vim5
-rw-r--r--autoload/ale/fixers/stylish_haskell.vim10
-rw-r--r--autoload/ale/handlers/haskell_stack.vim7
-rw-r--r--autoload/ale/handlers/hlint.vim8
6 files changed, 33 insertions, 9 deletions
diff --git a/autoload/ale/fixers/brittany.vim b/autoload/ale/fixers/brittany.vim
index 57c77325..c2448348 100644
--- a/autoload/ale/fixers/brittany.vim
+++ b/autoload/ale/fixers/brittany.vim
@@ -3,11 +3,17 @@
call ale#Set('haskell_brittany_executable', 'brittany')
-function! ale#fixers#brittany#Fix(buffer) abort
+function! ale#fixers#brittany#GetExecutable(buffer) abort
let l:executable = ale#Var(a:buffer, 'haskell_brittany_executable')
+ return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'brittany')
+endfunction
+
+function! ale#fixers#brittany#Fix(buffer) abort
+ let l:executable = ale#fixers#brittany#GetExecutable(a:buffer)
+
return {
- \ 'command': ale#Escape(l:executable)
+ \ 'command': l:executable
\ . ' --write-mode inplace'
\ . ' %t',
\ 'read_temporary_file': 1,
diff --git a/autoload/ale/fixers/hfmt.vim b/autoload/ale/fixers/hfmt.vim
index ea061da4..0407b713 100644
--- a/autoload/ale/fixers/hfmt.vim
+++ b/autoload/ale/fixers/hfmt.vim
@@ -7,7 +7,7 @@ function! ale#fixers#hfmt#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'haskell_hfmt_executable')
return {
- \ 'command': ale#Escape(l:executable)
+ \ 'command': ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'hfmt')
\ . ' -w'
\ . ' %t',
\ 'read_temporary_file': 1,
diff --git a/autoload/ale/fixers/hlint.vim b/autoload/ale/fixers/hlint.vim
index 94dd736e..88779a55 100644
--- a/autoload/ale/fixers/hlint.vim
+++ b/autoload/ale/fixers/hlint.vim
@@ -1,13 +1,10 @@
" Author: eborden <evan@evan-borden.com>
" Description: Integration of hlint refactor with ALE.
"
-call ale#Set('haskell_hlint_executable', 'hlint')
function! ale#fixers#hlint#Fix(buffer) abort
- let l:executable = ale#Var(a:buffer, 'haskell_hlint_executable')
-
return {
- \ 'command': ale#Escape(l:executable)
+ \ 'command': ale#handlers#hlint#GetExecutable(a:buffer)
\ . ' --refactor'
\ . ' --refactor-options="--inplace"'
\ . ' %t',
diff --git a/autoload/ale/fixers/stylish_haskell.vim b/autoload/ale/fixers/stylish_haskell.vim
index a352312f..ce71c1ce 100644
--- a/autoload/ale/fixers/stylish_haskell.vim
+++ b/autoload/ale/fixers/stylish_haskell.vim
@@ -3,11 +3,17 @@
"
call ale#Set('haskell_stylish_haskell_executable', 'stylish-haskell')
-function! ale#fixers#stylish_haskell#Fix(buffer) abort
+function! ale#fixers#stylish_haskell#GetExecutable(buffer) abort
let l:executable = ale#Var(a:buffer, 'haskell_stylish_haskell_executable')
+ return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'stylish-haskell')
+endfunction
+
+function! ale#fixers#stylish_haskell#Fix(buffer) abort
+ let l:executable = ale#fixers#stylish_haskell#GetExecutable(a:buffer)
+
return {
- \ 'command': ale#Escape(l:executable)
+ \ 'command': l:executable
\ . ' --inplace'
\ . ' %t',
\ 'read_temporary_file': 1,
diff --git a/autoload/ale/handlers/haskell_stack.vim b/autoload/ale/handlers/haskell_stack.vim
new file mode 100644
index 00000000..108301a9
--- /dev/null
+++ b/autoload/ale/handlers/haskell_stack.vim
@@ -0,0 +1,7 @@
+function! ale#handlers#haskell_stack#EscapeExecutable(executable, stack_exec) abort
+ let l:exec_args = a:executable =~? 'stack$'
+ \ ? ' exec ' . ale#Escape(a:stack_exec) . ' --'
+ \ : ''
+
+ return ale#Escape(a:executable) . l:exec_args
+endfunction
diff --git a/autoload/ale/handlers/hlint.vim b/autoload/ale/handlers/hlint.vim
new file mode 100644
index 00000000..b9a8c322
--- /dev/null
+++ b/autoload/ale/handlers/hlint.vim
@@ -0,0 +1,8 @@
+call ale#Set('haskell_hlint_executable', 'hlint')
+call ale#Set('haskell_hlint_options', get(g:, 'hlint_options', ''))
+
+function! ale#handlers#hlint#GetExecutable(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'haskell_hlint_executable')
+
+ return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'hlint')
+endfunction