...
 
Commits (2)
...@@ -13,12 +13,11 @@ You can run the `build` task of the Taskfile like so: ...@@ -13,12 +13,11 @@ You can run the `build` task of the Taskfile like so:
You can also autocomplete tasks pressing `<tab>`, or `<tab><tab>`. You can also autocomplete tasks pressing `<tab>`, or `<tab><tab>`.
### Verbose ### Asynchronous
If you like to see the output of the tasks, you can set the plugin to be more Taskfile tasks are run synchronous by default.
verbose with `TaskVerbose 1`. This will spawn a term for every task executed. You can set `g:TaskfileAsynchronous=1` in your `nvim/init.vim`/`.vimrc`
to enable asynchronous mode.
If you want to disable the verbosity again, simply run `TaskVerbose 0`.
[Taskfile]: https://git.superevilmegaco.com/bash/Taskfile [Taskfile]: https://git.superevilmegaco.com/bash/Taskfile
...@@ -15,27 +15,14 @@ Task *:Task* ...@@ -15,27 +15,14 @@ Task *:Task*
Run tasks defined in the Taskfile. Run tasks defined in the Taskfile.
`:Task <tab><tab>` `:Task <tab><tab>`
TaskVerbose *:TaskVerbose*
After setting verbose mode to 1 each task is executed in a
Vim term.
`:TaskVerbose 1|0`
MAPPINGS *Taskfile-mappings* MAPPINGS *Taskfile-mappings*
There are no mappings registered by the plugin. There are no mappings registered by the plugin.
You need to map it according to your preference. You need to map it according to your preference.
*Taskfile#Run()* *Taskfile#Run()*
Runs the task passed as argument to the function.
*Taskfile#Verbose()*
Sets output to verbose. Each task is executed in a Vim term.
`:call Taskfile#Verbose(1)`
To disable verbose mode, just call the function with 0.
`:call Taskfile#Verbose(0)`
Runs the task passed as argument to the function.
ABOUT *Taskfile-about* ABOUT *Taskfile-about*
......
...@@ -4,7 +4,6 @@ endif ...@@ -4,7 +4,6 @@ endif
let g:loaded_Taskfile = 1 let g:loaded_Taskfile = 1
let s:PluginName = "Taskfile.nvim" let s:PluginName = "Taskfile.nvim"
let s:isVerbose = 0
let s:taskList = [""] let s:taskList = [""]
let s:TaskfileWindow = 0 let s:TaskfileWindow = 0
...@@ -16,14 +15,6 @@ function! s:FileExists(filepath) ...@@ -16,14 +15,6 @@ function! s:FileExists(filepath)
endif endif
endfunction endfunction
function! Taskfile#Verbose(enable)
if a:enable == 1
let s:isVerbose = 1
else
let s:isVerbose = 0
endif
endfunction
function! Taskfile#Run(...) function! Taskfile#Run(...)
let filepath = s:GetTaskfileAbsoluteFilepath() let filepath = s:GetTaskfileAbsoluteFilepath()
if s:FileExists(filepath) == 0 if s:FileExists(filepath) == 0
...@@ -107,26 +98,22 @@ endfunction ...@@ -107,26 +98,22 @@ endfunction
function! s:ExecExternalCommand(command) function! s:ExecExternalCommand(command)
if has("nvim") == 1 if has("nvim") == 1
if s:isVerbose == 0 if exists("g:TaskfileAsynchronous")
call jobstart(["bash", "-c", a:command]) call jobstart(["bash", "-c", a:command])
else else
let winnr = winnr() execute "!" . a:command
botright new | call termopen(["bash", "-c", a:command], extend({"shell": s:PluginName}, s:termEventCallbacks))
let s:TaskfileWindow = winnr()
execute "normal! G"
execute winnr . "wincmd w"
endif endif
elseif v:version >= 800 elseif v:version >= 800
if s:isVerbose == 0 if exists("g:TaskfileAsynchronous")
call job_start("bash -c " . a:command) call job_start("bash -c " . a:command)
else else
new termopen(["bash", "-c", a:command], extend({"shell": s:PluginName}, s:termEventCallbacks)) execute "!" . a:command
endif endif
else else
if s:isVerbose == 1 if exists("g:TaskfileAsynchronous")
execute "!" . a:command
else
silent execute "!" . a:command silent execute "!" . a:command
else
execute "!" . a:command
endif endif
endif endif
endfunction endfunction
...@@ -146,5 +133,4 @@ function! s:GetCurrentFile() ...@@ -146,5 +133,4 @@ function! s:GetCurrentFile()
endfunction endfunction
command! -bang -complete=customlist,s:taskListCompletion -nargs=* Task call Taskfile#Run(<f-args>) command! -bang -complete=customlist,s:taskListCompletion -nargs=* Task call Taskfile#Run(<f-args>)
command! -nargs=1 TaskVerbose call Taskfile#Verbose(<f-args>)