skywind3000 / asynctasks.vim Goto Github PK
View Code? Open in Web Editor NEW:rocket: Modern Task System for Project Building, Testing and Deploying !!
Home Page: https://www.vim.org/scripts/script.php?script_id=5853
License: MIT License
:rocket: Modern Task System for Project Building, Testing and Deploying !!
Home Page: https://www.vim.org/scripts/script.php?script_id=5853
License: MIT License
Could you add a variable for profile name (release, debug)?
The following actions
[project-run:release]
command=cd ../build-$(VIM_PRONAME)-release && ./$(VIM_PRONAME)
cwd=<root>
notify=echo
[project-run:debug]
command=cd ../build-$(VIM_PRONAME)-debug && ./$(VIM_PRONAME)
cwd=<root>
notify=echo
could be simplified to
[project-run]
command=cd ../build-$(VIM_PRONAME)-$(VIM_PROFILE) && ./$(VIM_PRONAME)
cwd=<root>
notify=echo
一个名字里面搜索到配置文件后就可以不管别的名字了.
方便不同项目tasks放在不同的位置里. (自己的放.tasks, 别的不能改的项目放.git 或者.svn里)
let asynctasks_config_name= [
\ '.tasks',
\ '.root/.tasks',
\ '.git/.tasks',
\ '.svn/.tasks',
\ ]
如果可以添加上 job 的 dependency就好了。比如运行 A 命令,可以指定某些命令(自动在运行 A 前触发
就像makefile
Ubuntu 18.04LTS
Error: not find asynctask.py
这个怎么解决啊?谢谢
我的 asynctasj.vim 放在 /home/myname/ 下面
按照作者大大的文档 把 /home/myname/asynctask.vim/bin/asynctask
软链接到 /usr/myname/bin下面
然后 把/usr/myname/bin 加入到用户的 .bashrc的PATH里
export PATH=~/bin:$PATH
这时候 在 /home/myname/bin 执行task 一切正常
但是在 /目录执行就报错了
Error: not find asynctask.py
尝试了以下解决方案 都不行
在 /home/myname/bin 目录增加了一个软链接 asynctask.py 连接到/home/myname/asynctask.vim/bin/asynctask.py
同样报错
把整个asynctask.vim全部复制到 /home/myname/bin目录
同样报错
在 /etc/profile 增加配置
export PATH=~/bin:$PATH
使用 $PATH命令 是可以看到PATH目录包含 /home/myname/bin的
但是在 /目录 执行task 还是报错
Error: not find asynctask.py
在 /home/myname/bin 目录就可以正确执行
When I run a task in an external terminal on Linux, it runs fine, but no terminal opens. Is the a option to customize this?
Hi! Thank you for your plugin.
Currently command :AsyncTaskEdit
will create an example tasks file if it does not exists. I suggest to add a configuration parameter that will allow to create an empty file in this case. It may be very useful with snippets. For example, I can create snippet for regular CMake project, open tasks file and use my custom template.
https://github.com/skywind3000/asynctasks.vim/wiki/FAQ
The sample code is missing a comma
Plug 'skywind3000/asyncrun.vim' {'on': ['AsyncRun', 'AsyncStop'] }
Plug 'skywind3000/asynctasks.vim' {'on': ['AsyncTask', 'AsyncTaskMacro', 'AsyncTaskList', 'AsyncTaskEdit'] }
pop E116: Invalid arguments for function plug#
when start vim.
bottom:内置终端,不可以复用内部终端
每次运行都打开一个终端
vimrc配置:
noremap :AsyncTask file-run
noremap :AsyncTask file-build
let g:asyncrun_open = 6
let g:asynctasks_term_pos = 'bottom'
let g:asynctasks_term_rows = 5
tasks.ini配置:
[file-build]
command=gcc "$(VIM_FILEPATH)" -o "$(VIM_FILEDIR)/$(VIM_FILENOEXT)"
command:go=go build -o "$(VIM_PATHNOEXT)" "$(VIM_FILEPATH)"
cwd=$(VIM_FILEDIR)
output=quickfix
errorformat=%f:%l:%m
save=2
[file-run]
command="$(VIM_FILEPATH)"
command:c,cpp="$(VIM_PATHNOEXT)"
command:go=go run "$(VIM_FILEPATH)"
command:python=python "$(VIM_FILENAME)"
output=terminal
cmd=$(VIM_FILEDIR)
save=2
How to perform a task : AsyncTask gulp-watch
if gulpfile.js exist ?
I try in .vimrc
if filereadable("gulpfile.js")
AsyncTask gulp-watch
endif
But I've an error :
error function AsyncRun_Job_OnTimer[11]
If I use :vert AsyncTaskEdit
it still opens horizontal split. Is it possible to change this behavior? For example, fugitive allows to pass :vert
to G
command. Or maybe add an option where to open configuration buffer?
Hi! I trying to configure errorformat
for CMake.
Here is the example project with few files.
Here is my configuration taken from the wiki:
[project-build:debug]
command=cd ../build-$(VIM_PRONAME)-debug && cmake --build .
cwd=<root>
errorformat=%f:%m:%l
notify=echo
If I remove, for example, ;
after KeyboardDaemon daemon
in main.cpp
I have the following error:
|| [cd ../build-akd-debug && cmake --build .]
|| [1/2] Building CXX object CMakeFiles/akd.dir/src/main.cpp.o
|| FAILED: CMakeFiles/akd.dir/src/main.cpp.o
|| /usr/bin/c++ -std=gnu++17 -MD -MT CMakeFiles/akd.dir/src/main.cpp.o -MF CMakeFiles/akd.dir/src/main.cpp.o.d -o CMakeFiles/akd.dir/src/main.cpp.o -c /mnt/Files/Git/akd/src/main.cpp
|| /mnt/Files/Git/akd/src/main.cpp: В функции «int main()»:
|| /mnt/Files/Git/akd/src/main.cpp:31:9: ошибка: expected initializer before «daemon»
|| 31 | daemon.exec();
|| | ^~~~~~
|| ninja: build stopped: subcommand failed.
|| [Finished in 1 seconds with code 1]
But :cnext
/:cprev
not works to jump between errors. Is this a bug or am I doing something wrong?
I made the following global tasks:
[project-open-build]
command=xdg-open $(VIM_ROOT)/../build-$(VIM_PRONAME)-$(VIM_PROFILE)
silent=1
[project-open-source]
command=xdg-open $(VIM_ROOT)
silent=1
It allow me to quickly open build and source folders. But if I am running compilation or a compiled program, then I can not use the above tasks. Is it possible to just run such tasks without any callbacks and output even if the main task is currently running? Something like save=2
but silent=2
.
Any way to get a dropdown when asking for user input?
[task1]
command=echo hello $(?your name), you are a $(?gender[male,female]).
output=terminal
Not sure if we can use the default vim autocomplete or we would expose a way to use fzf.
I have a task with:
errorformat=%f:%l:%c:\ %m,%-G%.%#errors\ generated.,%-Gmake%m,%-G[%[0-9\ ]%\\\{\\,3}%%]%m
And this part: %-G[%[0-9\ ]%\\\{\\,3}%%]%m
does not work because the [ ] characters are there I think.
How do I escape them so that nvim will see:
errorformat=%f:%l:%c:\ %m,%-G%.%#errors\ generated.,%-Gmake%m,%-G[%[0-9\ ]%\\\{\\,3}%%]%m
asyncrun提供了快速开关quickfix的功能,这里能否也提供类似的toggle term的功能
Working on a rust project, I am setting up:
autocmd BufWritePost * AsyncTask cargo-run
This is perfect to compile and run tiny programs every time I edit the file.
But I cannot set this in global .vimrc since this would be run for all files immaterial of the project (cwd).
Would it be possible to support auto triggering of AsyncTasks on BufWritePost events ?
I considered using localvimrc plugin to inject autocmds.
But that would be another file I need to maintain.
https://www.vim.org/scripts/script.php?script_id=3393
For example, if I am editing a single-file project (C++ source code) and upon running Asyncrun on it, there are no errors or warnings and the build completed successfully, then after a certain user-configurable delay, I would like the quickfix window to disappear automatically.
I know I can do :ccl[ose]
, but it quickly becomes tedious. Instead, I just want the quickfix window to be open for just enough time to comfortably read that [finished in x seconds]
and then just get out of my way.
Can asyncrun
or asynctasks
somehow incorporate this?
Is it possible to run tasks sequentially? For example, in most IDEs, when a project starts, compilation occurs first. It would be convenient to assign build + run to a single key.
P.S. Sorry for a lot of issues :)
If I execute :AsyncTasksEdit
it will open configuration in split. But If I execute this command More than once - I will have another splits of the same window:
Is this expected behavior? As for me it would be nice to just focus previously opened configuration split (as in figitive) or toggle it.
I have been trying for a couple of hours to make .root file for my project but asynctasks doesn't wan't to recognize it no matter what I did.
A simple example: command=echo "2q3" | tee >(column -t) | column -t
. Then,
2q3
2q3
is expected.
But get error:
sh: -c:行0: 未预期的符号“(”附近有语法错误
sh: -c:行0: `echo "2q3" | tee >(column -t) | column -t'
Is it possible to have a pre-command.
For example, if you run for the first time, then it sets up some variable or something (in my case, i want to use direnv).
So, it takes about 5 seconds to setup direnv and while it sets up it outputs. So i was wondering if i can use a pre-cmd so that it sets it up.
The way i do now is:
command= cd .. && cd $(VIM_ROOT) && cargo run
So basically, i go a dir up, then back to activate direnv. Because direnv is activated only on directory change (it acts as a bash/zsh daemon from .bashrc/.zshrc file). And since Asynctasks always opens in the same directory where VIM is open (or project root directory), direnv can't detect the dir change, thus the cd $(VIM_ROOT)
of Asynctasks does not activate direnv.
Having a pre-cmd would be very useful not only for direnv, but other cases too.
my case would be:
pre-command= cd .. && cd $(VIM_ROOT) # to be activated only once
command= cargo run # to ba activated everytime
windows7系统,tasks.ini和_vimrc在同一目录,目录结构如下:
D:\Program Files (x86)\Vim
|------_vimrc
|------tasks.ini
|------vimfiles
|------vim82(vim程序目录)----gvim.exe
文件名是tasks.ini时完全不起作用,改成.tasks只有VIM目录起作用,VIM以外的其他目录均不起作用。
请大神看看是什么原因,谢谢!
在配置文件中添加output=terminal后能否继续设置pos选项指定terminal打开位置
asynctasks.vim/plugin/asynctasks.vim
Lines 936 to 951 in 3c68c42
打开一个 buftype
为 'nofile'
的 buffer,如果执行的命令里面带有 $(VIM_FILEDIR)
,会报错 Warning: macro $(VIM_FILEDIR) is empty in current buffer
.
对于 buftype
为 'nofile'
的 buffer, expand("%:p")
为空字符串,但是 expand("%:p:h")
却返回该缓冲区所在的文件夹路径且不为空,并且在同样的 buffer 里面, $(VIM_FILEDIR)
这个宏在 asyncrun.vim 里也工作正常。
因此可不可以将 $(VIM_FILEDIR)
排除在 disable
之外呢?
NVIM v0.5.0-397-g96059d72e
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/travis/build/neovim/bot-ci/build/neovim/build/config -I/home/travis/build/neovim/bot-ci/build/neovim/src -I/home/travis/build/neovim/bot-ci/build/neovim/.deps/usr/include -I/usr/include -I/home/travis/build/neovim/bot-ci/build/neovim/build/src/nvim/auto -I/home/travis/build/neovim/bot-ci/build/neovim/build/include
Compiled by travis@travis-job-13ebc8c2-4f6f-45b7-ad53-0dc3d8813d5f
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/share/nvim"
I have defined the following two profiles in my ~/.vim/tasks.ini
file:
[project-run:default]
command:java=mvn exec:java
cwd=<root>
output=quickfix
errorformat=%f:%l:%m
save=0
[project-run:io]
command:java=mvn exec:java
cwd=<root>
output=terminal
errorformat=%f:%l:%m
save=0
However, when I run AsyncTaskProfile io
I get the message Current profile: default
. The only way that I can change it is by running :let g:asynctasks_profile = 'io'
.
Arch Linux
Neovim 0.5.0
asynctasks_term_pos = 'external'
does not open external terminal, instead it runs the same as asynctasks_term_pos = 'vim'
Task:
[file-run]
command=fish "$(VIM_FILENAME)"
cwd=$(VIM_FILEDIR)
output=terminal
save=1
Async settings:
let g:asyncrun_open = 6
let g:asynctasks_term_pos = 'external'
I am using the following config:
[debugging]
command=pwd && ls -a
cwd=$(VIM_ROOT)/debug
output=terminal
Unless the debug
folder contains a Makefile
, pwd
prints the project root directory. Is this the desired behaviour? Thank you!
Is there a way to configure the default position and height of the quickfix window?
Terminal window can be configured like this:
output=terminal
pos=top
rows=10
But, what can I do for quickfix window?
自己的配置中已设置了set et
使用插件提供的命令打开配置文件tab没有展开为空格,命令行输入:echo &et 结果为0
[test1]
command=ls
cwd=
output=terminal
pos=floaterm_reuse
position=bottomright
focus=0
when I use above settings.I can't work right.Can realize 'position' and 'focus' when 'pos = floaterm_reuse'?
By the way, 'Asyncrun -term=mode -pos=floaterm_reuse -position=bottomright ls' works right.
You don't have to jump back to your project root manually, because
profile-build
has a cwd=<root>
.
profile-build
should be project-build
.
AND
asynctask -profile=release project-build
notice -profile=release
setting, but no more description, when and where release
take effect?
在开发的时候,我经常会需要在一段时间执行某一个task,并在不同时间进行任务切换。
因此我希望定义一系列任务,并设置一个默认的任务,比如说[run],并将这个任务与vim的快捷键绑定。切换任务时,只需要修改[run]链接到的任务即可,类似如下的配置:
[run]
link=train-peta
[train-peta]
command=python "tools/train.py" "configs/peta.yaml"
cwd=$(VIM_ROOT)
output=terminal
save=1
[train-wider]
command=python "tools/train.py" "configs/wider.yaml"
cwd=$(VIM_ROOT)
output=terminal
请问能否实现?
I would like to have the option to change the locatio nof the local .task file.
personaly I would like to put it in $(VIM_ROOT)/.vim/tasks.json
In the same place as the local coc config file.
maybe add an option like this.
let g:asynctasks_local_tasks_config_prefix='.vim'
Hello! It's a nice vim plugin and I get a lot of benefit from it!
But I meet a problem that I can't change to my root directory on terminal output mode. Here is my project tree.
.
├── .root
├── src
│ └── 1.cpp
└── .tasks
When I open 1.cpp in src directory, and run asynctasks configured like that:
[file-build]
command=pwd
cwd=$(VIM_ROOT)
output=terminal
It shows
/home/qsdrqs/test/src
[Process exited 0]
When I change output
into quickfix
, it shows
|| [pwd]
|| /home/qsdrqs/test
|| [Finished in 0 seconds]
In a word, the "terminal" mode may not works well in changing directory.
Hi,
AsyncTask doesn't seem able to find the tasks defined in ".tasks" when the absolute path contains a space. This will show itself when trying to run ":AsyncTask file-build".
Is it possible to add the ability to define custom variables? For example, I have the following two tasks:
[project-build]
command=cmake --build . --target myawesomprogram
cwd=<root>/../build-$(VIM_PRONAME)-debug
errorformat=%f:%m:%l
[project-run]
command=myawesomprogram --argument example
cwd=<root>/../build-$(VIM_PRONAME)-debug
output=terminal
The first task builds the selected application from the entire project, and the second starts this application. If you need to change the application, then I need to replace its occurrences. It would be convenient to be able to set custom variable at the begging of the file for it.
Alternatively, this variable can be built-in and set from cmd like a profile.
File tree:
[~/project]$ tree -a
.
├── .root
├── subdir
│ └── somefile.txt
└── .tasks.ini
1 directory, 3 files
.tasks.ini
[pwd-terminal]
command=pwd
cwd=/home/user/project/subdir
output=terminal
[pwd-quickfix]
command=pwd
cwd=/home/user/project/subdir
output=quickfix
The task pwd-terminal
outputs /home/user/project
, the task pwd-quickfix
outputs /home/user/project/subdir
. Cwd with the $(VIM_ROOT) macro behaves similarly.
I found out that the vim-rooter plugin causes this behavior. When I turn this plugin off pwd-terminal
task starts printing the correct path /home/user/project/subdir
. Correct behavior also happens when I remove .root file because of different pattern settings:
let g:asynctasks_config_name = '.tasks.ini'
let g:asyncrun_rootmarks = ['.tasks.ini', '.root']
let g:rooter_patterns = ['.root']
:echo asyncrun#get_root('%')
prints /home/user/project
Arch Linux 5.11.9
NVIM v0.4.4
Build type: Release
LuaJIT 2.0.5
Regardless of what I set for cwd
under a file-run task, it seems like the task always runs with the current vim directory (not the cwd I set).
Here's my .tasks file, located in the project root (next to the .git folder):
[file-run]
command=make test
# working directory
cwd="$(VIM_FILEDIR)/.."
output=terminal
Here's the project structure:
root
├── .tasks
└── c
└── hello-world
├── README.md
├── makefile
├── src
│ ├── hello_world.c
│ └── hello_world.h
├── test
│ └── test_hello_world.c
└──── tests.out
If I launch vim in the hello-world dir, then run the file-run task, it works fine (correctly calling make with the makefile). But if I launch vim in any other directory, it fails, as make cannot find the makefile.
I also tried using an absolute path for cwd, but it didn't work either. As a workaround, this is what I'm doing now:
command=cd "$(VIM_FILEDIR)/.." && make test
How can I set the cwd to be used for the command? I tried searching the codebase for opt.cwd, but couldn't find where it was used, so I'd be grateful if you had any ideas.
AsyncTasks seems like a really useful plugin, thanks for all your work on it!
There are actually two problems.
The following is my command profile
[test]
command=echo $(?输入你的名字)
cwd=<root>
It will complain
Traceback (most recent call last):
File "/Users/johnd/program/asynctasks.vim/bin/asynctask.py", line 1242, in <module>
exit(main())
File "/Users/johnd/program/asynctasks.vim/bin/asynctask.py", line 1170, in main
tm.interactive(mode)
File "/Users/johnd/program/asynctasks.vim/bin/asynctask.py", line 1080, in interactive
return self.task_run(text)
File "/Users/johnd/program/asynctasks.vim/bin/asynctask.py", line 918, in task_run
command = self.command_input(command)
File "/Users/johnd/program/asynctasks.vim/bin/asynctask.py", line 852, in command_input
text = raw_input(prompt) # noqa: F821
UnicodeEncodeError: 'ascii' codec can't encode characters in position 16-21: ordinal not in range(128)
my command profile
[test]
command=echo $(?enter your name)
cwd=<root>
and input
> $ task ⬡ 12.16.1
Input argument (enter your name): 你好,世界
it would complain
Traceback (most recent call last):
File "/Users/johnd/program/asynctasks.vim/bin/asynctask.py", line 1242, in <module>
exit(main())
File "/Users/johnd/program/asynctasks.vim/bin/asynctask.py", line 1170, in main
tm.interactive(mode)
File "/Users/johnd/program/asynctasks.vim/bin/asynctask.py", line 1080, in interactive
return self.task_run(text)
File "/Users/johnd/program/asynctasks.vim/bin/asynctask.py", line 918, in task_run
command = self.command_input(command)
File "/Users/johnd/program/asynctasks.vim/bin/asynctask.py", line 860, in command_input
command = command.replace(mark, text)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128)
I checked out the macro section and don't see anything specifying visual selection, is there anyway to invoke a task and pass the current visual selection to it? for example, to search it on some website or invoke some script with it. VIM_CWORD
is the closest I can find, but it's much less flexible than visual selection. async task seems heavily file oriented, I think it can be more useful by working with other vim elements, such as visual selection. thanks.
I am using floaterm and wonder if asynctask
can be combined with floaterm
.
In vim 8.2.814
on linux, using output=terminal
in the .tasks
file doesn't seem to do anything special- the output still goes to the quickfix, as viewed with :copen
. However, if I add pos=bottom
it does open a :terminal
as expected. It is not a big deal, but I am a bit confused about the meaning of the terminal option when pos
is not specified. Is this the expected behavior?
[project-build]
command=cmake --build build
cwd=<root>
output=terminal
# pos=bottom # without uncommenting this line, no terminal opens
errorformat=%f:%l:%m
If I set such a command in tasks.ini
:
[hi]
command=MY_VERSION=1.2 echo hello
When I execute it in asynctask, I would get such an error:
Error: $(VIM_VERSION) is invalid in command line
from /XXX/XXX/.config/asynctask/tasks.ini:
command=MY_VERSION=1.2 echo hello
I've verified that so long as the variable's name contains 'VERSION' it would have this problem.
It seems that this env variable breaks VIM_VERSION
, but they don't have the same name. Is there any fix for this?
When executing the command :AsyncTaskEdit
is proposed to confirm the path to the file with tasks with the possibility of changing it. Could you add an option to bypass this confirmation and always open the file?
在windows下用neovim,用户名中有空格时,无法识别路径?报错如下:
'C:\Users\XXX' 不是内部或外部命令,也不是可运行的程序
或批处理文件。用户文件夹为XXX XX
e.g. $(?prompt:-default value)
or $(?prompt:=default value)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.