mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-16 23:14:27 +08:00
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
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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,
|
||||
|
||||
7
autoload/ale/handlers/haskell_stack.vim
Normal file
7
autoload/ale/handlers/haskell_stack.vim
Normal file
@@ -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
|
||||
8
autoload/ale/handlers/hlint.vim
Normal file
8
autoload/ale/handlers/hlint.vim
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user