- Notifications
You must be signed in to change notification settings - Fork8
Yet Another Build System/Code Runner for Neovim, written in lua
License
pianocomposer321/yabs.nvim
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Yet Another Build System for Neovim, written in lua.
As you can probably tell from the fact that the most recent commit was 2 yearsago (and the fact that unless you are somehow reading this within 30 seconds ofme pushing this commit, the repository is archived) I am no longer maintainingthis plugin. If you want to continue using this, go ahead, and if someone elsewants to fork this and take over maintinance, that would be awesome too.Otherwise I can recommendoverseer.nvim as an alternative.I'm currently using overseer.nvim along with my ownofficer.nvim.
yabs.nvim adds vscode-like tasks feature to neovim. It allows you to define specific commands that are associated with certain filetypes (or whole projects), as well as where the output for those commands should go, and execute them with a keybinding. For example, for a python file you could have arun task that runspython3 % in the terminal; for rust you could have abuild task and arun task that executescargo build, sending the output to the quickfix list, andcargo run, sending the output to the terminal, respectively; and for javascript, you could have a task to start the frontend server, one to start the backend server, and another one to run tests.
use {'pianocomposer321/yabs.nvim',requires= {'nvim-lua/plenary.nvim'}}
Plug'nvim-lua/plenary.nvim'`Plug'pianocomposer321/yabs.nvim'`
require('yabs'):setup({languages= {-- List of languages in vim's `filetype` formatlua= {tasks= {run= {command='luafile %',-- The command to run (% and other-- wildcards will be automatically-- expanded)type='vim',-- The type of command (can be `vim`, `lua`, or-- `shell`, default `shell`) }, }, },c= {default_task='build_and_run',tasks= {build= {command='gcc main.c -o main',output='quickfix',-- Where to show output of the-- command. Can be `buffer`,-- `consolation`, `echo`,-- `quickfix`, `terminal`, or `none`opts= {-- Options for output (currently, there's only-- `open_on_run`, which defines the behavior-- for the quickfix list opening) (can be-- `never`, `always`, or `auto`, the default)open_on_run='always', }, },run= {-- You can specify as many tasks as you want per-- filetypecommand='./main',output='consolation', },build_and_run= {-- Setting the type to lua means the command-- is a lua functioncommand=function()-- The following api can be used to run a task when a-- previous one finishes-- WARNING: this api is experimental and subject to-- changesrequire('yabs'):run_task('build', {-- Job here is a plenary.job object that represents-- the finished task, read more about it here:-- https://github.com/nvim-lua/plenary.nvim#plenaryjobon_exit=function(Job,exit_code)-- The parameters `Job` and `exit_code` are optional,-- you can omit extra arguments or-- skip some of them using _ for the nameifexit_code==0thenrequire('yabs').languages.c:run_task('run')endend, })end,type='lua', }, }, }, },tasks= {-- Same values as `language.tasks`, but globalbuild= {command='echo building project...',output='consolation', },run= {command='echo running project...',output='echo', },optional= {command='echo runs on condition',-- You can specify a condition which determines whether to enable a-- specific task-- It should be a function that returns boolean,-- not a boolean directly-- Here we use a helper from yabs that returns such function-- to check if the files existscondition=require('yabs.conditions').file_exists('filename.txt'), }, },opts= {-- Same values as `language.opts`output_types= {quickfix= {open_on_run='always', }, }, },})
localyabs=require('yabs')-- runs the task `build` for the current language, falling back to a global-- task with that name if it is not found for the current languageyabs:run_task('build')-- runs the task that is specified as the default (see configuration section-- above), or the first one if not specifiedyabs:run_default_task()-- Run command `echo hello, world` directly. Output is specified by the second-- argument (same possible values as `output` option for tasks above), and-- additional arguments are defined with the third argument (same as-- `task.opts` above)yabs.run_command('echo hello, world','quickfix', {open_on_run='always'})
You can create project-local configurations by creating.yabs filein the project working directory. It will be sourced as a lua file thefirst time you executeyabs:run_task(). The file should return atable with additional task that will extend your main configuration,overriding any values already defined there.
The syntax is the same as forsetup():
return {languages= {python= {tasks= {run= {command='python %',output='quickfix', }, }, }, },tasks= {build= {command='cargo build',output='consolation', }, }}
You can execute tasks from Telescope by running:Telescope yabs tasks /:Telescope yabs current_language_tasks or:Telescope yabs global_tasks.
If you use the telescope integration, it is recommended to addrequire('telescope').load_extension('yabs') to your configuraiton in order to have command completion.
Thelanguage.command option inyabs:setup() can be either a string or a function that returns a string. Defining a function can be useful for more advanced commands.
Likewise, thelanguage.output option can be one of the included types (buffer,consolation,echo,quickfix,terminal, ornone), or a function accepting one argument - the command to run. For example, if you are using tmux, you could write a function to send the command to a tmux pane.
You can set a task to run when a previous one is finished by setting theon_exitvalue of theopts table inyabs:run_task(). This API is experimental andsubject to change, and is not recommended to be used in normal configurations.
About
Yet Another Build System/Code Runner for Neovim, written in lua
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors4
Uh oh!
There was an error while loading.Please reload this page.



