Just task runner for neovim
just.nvim
Just task runner for neovimTOC
- Telescope - Completion JingleInstallation
Using lazy (as example){
"al1-ce/just.nvim",
dependencies = {
'nvim-lua/plenary.nvim', -- async jobs
'j-hui/fidget.nvim', -- task progress (optional)
},
config = true
}
Configuration
Default config isrequire("just").setup({
fidgetmessagelimit = 32, -- limit for length of fidget progress message
openqfon_error = true, -- opens quickfix when task fails
openqfon_run = true, -- opens quickfix when running run task (:JustRun)
openqfonany = false; -- opens quickfix when running any task (overrides other openqf options)
autoscroll_qf = true, -- automatically scroll quickfix window on output
register_commands = true, -- if set to true then commands (:Just*) will be registered
notify = vim.notify, -- what to use to show messages/errors
})
API
local just = require("just")
--- Runs vim.ui.select on list of tasks defined in justfile just.runtaskselect()
--- Runs specified task in defined --- @param task_name string just.runtaskname(task_name)
--- Force stops currently running task just.stopcurrenttask()
--- Creates minimal justfile that contains shebang, --- a link to just's reference manual and a default task just.addtasktemplate()
--- Adds callback that will be called on --- successful (return code is 0) completion of task --- @param callback function just.addcallbackon_done(callback)
--- Adds callback that will be called on --- task failure (return code is not 0) --- @param callback function just.addcallbackon_fail(callback)
--- Applies user config and optionally (by default) creates user commands --- @param opts table just.setup(options)
Commands:
Just- If 0 args supplied runsdefaulttask, if 1 arg supplied runs task passes as that arg. If ran with bang (!) then stops currently running task before executing new one.JustSelect- Gives you selection of all tasks injustfile(optionally see picker support).JustStop- Stops currently running task.JustCreateTemplate- Creates templatejustfile.
IMPORTANT - only one task can be executed at same time.
Old features notice
Telescope
Previously just.nvim was dependant on Telescope, it's not the case anymore. Now to use specific picker you need look up how to register it asvim.ui.select (with three most common ones listed here).
- Fzf-Lua setup:
local fzf = require("fzf-lua")
fzf.setup({ --[[ your setup ]] })
fzf.registeruiselect()
- Telescope requires to use telescope-ui-select.nvim instead.
- Mini.Pick automatically registers itself as your ui select method after setup.
- For everything else see how to register my plugin as ui select.
Completion Jingle
I've removed option to play sound in favor of using your own callbacks and doing whatever you would want with them, including playing sounds on completion or failure of the task.-- Example of replicating old behavior
-- async:new creates non-blocking system process
local just = require("just")
local async = require("plenary.job")
just.addcallbackon_fail(function()
async:new({
command = "aplay",
args = {"/home/user/music/fail_sound.wav", "-q"}
}):start()
end)
just.addcallbackon_done(function()
async:new({
command = "aplay",
args = {"/home/user/music/done_sound.wav", "-q"}
}):start()
end)
Screenshots
- Example just file (old default JustCreateTemplate with added build task)
- Fidget hint
- Output of
:Just buildin quickfix
:JustSelectusing telescope
Misc
A quick primer on just.nvim flavor of just (most important part is argument keywords).