Add simple help messages to nvim stacc
This commit is contained in:
parent
ac93ce1b91
commit
6dfc4c08ce
1 changed files with 15 additions and 10 deletions
|
@ -3,16 +3,21 @@ local stacc = require "stacc"
|
||||||
vim.api.nvim_create_user_command("Stacc", function(params)
|
vim.api.nvim_create_user_command("Stacc", function(params)
|
||||||
if params.args == "" then
|
if params.args == "" then
|
||||||
local count = #stacc.locations
|
local count = #stacc.locations
|
||||||
for i, location in ipairs(stacc.locations) do
|
if count == 0 then
|
||||||
local bufnr, id, description = unpack(location)
|
print("Stacc is empty. Push with `:Stacc description of current task`")
|
||||||
--- @type number[]
|
else
|
||||||
local mark = vim.api.nvim_buf_get_extmark_by_id(bufnr, stacc.namespace, id, {})
|
for i, location in ipairs(stacc.locations) do
|
||||||
print(string.format("%s %s:%i -- %s",
|
local bufnr, id, description = unpack(location)
|
||||||
string.format("%" .. math.floor(math.log(count, 10)+1) .. "i", i),
|
--- @type number[]
|
||||||
vim.api.nvim_buf_get_name(bufnr):match("[^/]*$"),
|
local mark = vim.api.nvim_buf_get_extmark_by_id(bufnr, stacc.namespace, id, {})
|
||||||
mark[1] + 1,
|
print(string.format("%s %s:%i -- %s",
|
||||||
description
|
string.format("%" .. math.floor(math.log(count, 10)+1) .. "i", i),
|
||||||
))
|
vim.api.nvim_buf_get_name(bufnr):match("[^/]*$"),
|
||||||
|
mark[1] + 1,
|
||||||
|
description
|
||||||
|
))
|
||||||
|
end
|
||||||
|
print(":Stacc pop|clear")
|
||||||
end
|
end
|
||||||
elseif params.args == "clear" then
|
elseif params.args == "clear" then
|
||||||
stacc.clear()
|
stacc.clear()
|
||||||
|
|
Loading…
Reference in a new issue