This guide shows how to create quick access to common project tasks using project-specific configuration files.
Every project has repetitive tasks: running migrations, seeding databases, compiling assets, updating dependencies, or viewing routes. Using .nvim.lua files, you can define these tasks once and access them instantly with a simple keybinding.
Security note: Since .nvim.lua executes arbitrary Lua code, only load files from projects you trust. Neovim will prompt you to confirm before loading these files for the first time.
Here's a complete task runner setup for a Rails project:
.nvim.lua (in your project root):
local ergoterm = require("ergoterm")
-- Create factory with shared defaults for tasks
local tasks = ergoterm.with_defaults({
layout = "below",
size = {
below = "30%"
},
tags = { "task" },
auto_list = false,
bang_target = false,
sticky = true,
auto_scroll = true,
default_action = function(term) term:open() end
})Configuration explained:
layout = "below"- Opens as a horizontal split below the current windowsize = { below = "30%" }- Uses 30% of the screen heighttags = { "task" }- Labels terminals for filtering in custom pickersauto_list = false- Hides from default picker (we'll use a custom selector)bang_target = false- Excludes from bang commandssticky = true- Keeps terminals ready for restart even after completionauto_scroll = true- Automatically scrolls to latest outputdefault_action = function(term) term:open() end- Makes terminals open (keeping focus on your current window) when selected
Create terminals for frequent operations:
local db_migrate = tasks:new({
name = "db:migrate",
cmd = "rails db:migrate"
})
local db_rollback = tasks:new({
name = "db:rollback",
cmd = "rails db:rollback"
})
local db_seed = tasks:new({
name = "db:seed",
cmd = "rails db:seed"
})
local db_reset = tasks:new({
name = "db:reset",
cmd = "rails db:reset"
})
local bundle_install = tasks:new({
name = "bundle",
cmd = "bundle install"
})Create a single keybinding to select from all available tasks:
local task_list = ergoterm.filter_by_tag("task")
vim.keymap.set("n", ",t", function()
ergoterm.select({
terminals = task_list,
prompt = "Run Task"
})
end, { noremap = true, silent = true, desc = "Run Task" })How it works:
- Press
,tto open a picker showing all defined tasks - Select a task to run it in a split below your editor
- The terminal opens automatically and shows the command output
- Use
,tagain to run another task or re-run the same one
