Verified Commit 1b6c28d5 authored by Marco Kellershoff's avatar Marco Kellershoff 馃じ

馃 Initial import

parents
MIT License
Copyright (c) 2018 Super Evil Mega Co
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Taskfile.nvim
=============
A Vim/Neovim plugin to run [Taskfile][Taskfile] tasks.
You need to have `Taskfile` in the current working directory of Vim/Neovim.
## Usage
You can run the `build` task of the Taskfile like so:
`:Taskfile build` or `:call Taskfile#Run("build")`
### Cache
The Tasks of the Taskfile are cached, if you modify the Taskfile and add jobs,
you need to reload the Taskfile like so:
```
:call Taskfile#Reload()<CR>
```
[Taskfile]: https://git.superevilmegaco.com/bash/Taskfile
#!/bin/bash
function build {
echo "This serves as an super evil example."
sleep 2
local foo=0
echo -ne "Doing stuff ..."
while [ $foo -lt 10 ]; do
sleep 1
echo -ne "."
((foo++))
done
echo ""
}
function tasks {
compgen -A function
}
function help {
echo "$0 <task> <args>"
echo "Tasks:"
tasks | cat -n
}
${@:-list}
*Taskfile.txt* A Vim/Neovim plugin to run `Taskfile` tasks.
Author: Marco Kellershoff <https://gorilla.moe/>
License: MIT License (see |license|)
INTRODUCTION *Taskfile*
This plugin's main purpose is to upload every file that you save to a remote
location. This can be defined on a per-project-basis via a configuration file
(`.AutoRemoteSync.json`).
COMMANDS *Taskfile-commands*
:Taskfile
MAPPINGS *Taskfile-mappings*
There are no mappings registered by the plugin.
You need to map it according to your preference.
*Taskfile#Run()*
Uploads the file opened in the current buffer when no argument is passed.
You can pass the filepath relative to the current working directory,
if you want to upload a different file manually.
*Taskfile#Reload()*
Downloads the file opened in the current buffer when no argument is passed.
You can pass the filepath relative to the current working directory,
if you want to download a different file manually.
ABOUT *Taskfile-about*
Grab the latest version or report a bug:
http://git.superevilmegaco.com/superevilmegaco/Neovim/Taskfile.nvim
vim:tw=78:et:ft=help:norl:
if exists("g:loaded_Taskfile")
finish
endif
let g:loaded_Taskfile = 1
let s:PluginName = "Taskfile.nvim"
let s:isVerbose = 0
function! Taskfile#Verbose(enable)
if a:enable == 1
let s:isVerbose = 1
else
let s:isVerbose = 0
endif
endfunction
function! Taskfile#Run(...)
let task = get(a:, 1, "")
let cmd = "./Taskfile " . task
call s:ExecExternalCommand(cmd)
endfunction
function! Taskfile#List()
let cfg = s:GetAllTasks()
let cmd = s.GetTaskfileFilename()
call s:ExecExternalCommand(cmd)
endfunction
function! s:OnJobEventHandler(job_id, data, event) dict
if a:event == 'stdout'
let str = self.shell.' stdout: '.join(a:data)
elseif a:event == 'stderr'
let str = self.shell.' stderr: '.join(a:data)
else
let str = self.shell.' finished'
endif
echom str
endfunction
let s:jobEventCallbacks = {
\ 'on_stdout': function('s:OnJobEventHandler'),
\ 'on_stderr': function('s:OnJobEventHandler'),
\ 'on_exit': function('s:OnJobEventHandler')
\ }
function! s:GetAllTasks()
let filepath = getcwd() . "/" . s:GetTaskfileFilename()
let str = s:ReadfileAsString(filepath)
return str
endfunction
function! s:GetTaskfileFilename()
return "Taskfile"
endfunction
function! s:ExecExternalCommand(command)
if has("nvim") == 1
if s:isVerbose == 0
call jobstart(["bash", "-c", a:command])
else
new | call termopen(["bash", "-c", a:command], extend({"shell": s:PluginName}, s:jobEventCallbacks))
endif
elseif v:version >= 800
if s:isVerbose == 0
call job_start("bash -c " . a:command)
else
new termopen(["bash", "-c", a:command], extend({"shell": s:PluginName}, s:jobEventCallbacks))
endif
else
if s:isVerbose == 1
execute "!" . a:command
else
silent execute "!" . a:command
endif
endif
endfunction
function! s:GetBasename(...)
let buffername = bufname("%")
let filepath = get(a:, 1, buffername)
return fnamemodify(filepath, ":t")
endfunction
function! s:ReadfileAsString(filepath)
return readfile(a:filepath)
endfunction
function! s:GetCurrentFile()
return expand("%")
endfunction
command! -nargs=1 Taskfile call Taskfile#Run(<f-args>)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment