mirror of https://github.com/dense-analysis/ale
WIP cd to project path
This commit is contained in:
parent
f0f569f14a
commit
864818a385
|
@ -31,11 +31,11 @@ function! ale_linters#elixir#mix#Handle(buffer, lines) abort
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#elixir#mix#FindProjectRoot(buffer) abort
|
function! ale_linters#elixir#mix#FindProjectRoot(buffer) abort
|
||||||
let l:project_root = ale#path#FindNearestFile(a:buffer, 'mix.exs')
|
let l:mix_file = ale#path#FindNearestFile(a:buffer, 'mix.exs')
|
||||||
if !empty(l:project_root)
|
if !empty(l:mix_file)
|
||||||
return fnamemodify(l:project_root, ':h')
|
return fnamemodify(l:mix_file, ':p:h')
|
||||||
endif
|
endif
|
||||||
return ''
|
return '.'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#elixir#mix#GetCommand(buffer) abort
|
function! ale_linters#elixir#mix#GetCommand(buffer) abort
|
||||||
|
@ -47,7 +47,7 @@ function! ale_linters#elixir#mix#GetCommand(buffer) abort
|
||||||
\ ? 'set MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) . ' && '
|
\ ? 'set MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) . ' && '
|
||||||
\ : 'MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) . ' '
|
\ : 'MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) . ' '
|
||||||
|
|
||||||
return ale#path#CdString(l:project_root)
|
return ale#path#CdString(l:project_root)
|
||||||
\ . l:mix_build_path
|
\ . l:mix_build_path
|
||||||
\ . ' mix compile %s'
|
\ . ' mix compile %s'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
use Mix.Config
|
|
@ -3,13 +3,15 @@ Before:
|
||||||
|
|
||||||
call ale#test#SetDirectory('/testplugin/test/command_callback')
|
call ale#test#SetDirectory('/testplugin/test/command_callback')
|
||||||
|
|
||||||
|
let g:project_root = ale#path#Simplify(g:dir . '/mix_paths/wrapped_project')
|
||||||
|
|
||||||
let g:env_prefix = has('win32')
|
let g:env_prefix = has('win32')
|
||||||
\ ? 'set MIX_BUILD_PATH=TEMP && '
|
\ ? 'set MIX_BUILD_PATH=TEMP && '
|
||||||
\ : 'MIX_BUILD_PATH=TEMP '
|
\ : 'MIX_BUILD_PATH=TEMP '
|
||||||
|
|
||||||
|
|
||||||
function! GetCommand() abort
|
function! GetCommand(buffer) abort
|
||||||
let l:command = ale_linters#elixir#mix#GetCommand(bufnr(''))
|
let l:command = ale_linters#elixir#mix#GetCommand(a:buffer)
|
||||||
|
|
||||||
let l:split_command = split(l:command, 'MIX_BUILD_PATH=[^ ]*\s')
|
let l:split_command = split(l:command, 'MIX_BUILD_PATH=[^ ]*\s')
|
||||||
|
|
||||||
|
@ -22,6 +24,7 @@ After:
|
||||||
Restore
|
Restore
|
||||||
|
|
||||||
unlet! g:env_prefix
|
unlet! g:env_prefix
|
||||||
|
unlet! g:project_root
|
||||||
|
|
||||||
call ale#linter#Reset()
|
call ale#linter#Reset()
|
||||||
call ale#test#RestoreDirectory()
|
call ale#test#RestoreDirectory()
|
||||||
|
@ -29,8 +32,10 @@ After:
|
||||||
delfunction GetCommand
|
delfunction GetCommand
|
||||||
|
|
||||||
Execute(The default mix command should be correct):
|
Execute(The default mix command should be correct):
|
||||||
|
call ale#test#SetFilename('mix_paths/wrapped_project/lib/app.ex')
|
||||||
|
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ GetCommand(),
|
\ GetCommand(bufnr('')),
|
||||||
\ 'cd '''' && '
|
\ ale#path#CdString(g:project_root)
|
||||||
\ . g:env_prefix
|
\ . g:env_prefix
|
||||||
\ . 'mix compile %s'
|
\ . 'mix compile %s'
|
||||||
|
|
Loading…
Reference in New Issue