mirror of https://github.com/dense-analysis/ale
Add some utility functions for changing directories for commands
This commit is contained in:
parent
6550cdfbd0
commit
2d1d6fb850
|
@ -144,3 +144,16 @@ endfunction
|
|||
function! ale#util#ClockMilliseconds() abort
|
||||
return float2nr(reltimefloat(reltime()) * 1000)
|
||||
endfunction
|
||||
|
||||
|
||||
" Output 'cd <directory> && '
|
||||
" This function can be used changing the directory for a linter command.
|
||||
function! ale#util#CdString(directory) abort
|
||||
return 'cd ' . fnameescape(a:directory) . ' && '
|
||||
endfunction
|
||||
|
||||
" Output 'cd <buffer_filename_directory> && '
|
||||
" This function can be used changing the directory for a linter command.
|
||||
function! ale#util#BufferCdString(buffer) abort
|
||||
return ale#util#CdString(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
endfunction
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
Before:
|
||||
silent! cd /testplugin/test/util
|
||||
|
||||
Execute(CdString should output the correct command string):
|
||||
AssertEqual 'cd /foo\ bar/baz && ', ale#util#CdString('/foo bar/baz')
|
||||
|
||||
Execute(BufferCdString should output the correct command string):
|
||||
Assert match(ale#util#BufferCdString(bufnr('')), '^cd .*test/util && $') >= 0,
|
||||
\ 'String didn''t match regex: ' . ale#util#BufferCdString(bufnr(''))
|
Loading…
Reference in New Issue