From 6dfc4c08cef99e9615e06de3b7f24369a5b0c8b0 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Tue, 29 Oct 2024 11:10:59 +0100 Subject: [PATCH] Add simple help messages to nvim stacc --- vim/plugin/stacc.lua | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/vim/plugin/stacc.lua b/vim/plugin/stacc.lua index e1bcb47..663f25e 100644 --- a/vim/plugin/stacc.lua +++ b/vim/plugin/stacc.lua @@ -3,16 +3,21 @@ local stacc = require "stacc" vim.api.nvim_create_user_command("Stacc", function(params) if params.args == "" then local count = #stacc.locations - for i, location in ipairs(stacc.locations) do - local bufnr, id, description = unpack(location) - --- @type number[] - local mark = vim.api.nvim_buf_get_extmark_by_id(bufnr, stacc.namespace, id, {}) - print(string.format("%s %s:%i -- %s", - string.format("%" .. math.floor(math.log(count, 10)+1) .. "i", i), - vim.api.nvim_buf_get_name(bufnr):match("[^/]*$"), - mark[1] + 1, - description - )) + if count == 0 then + print("Stacc is empty. Push with `:Stacc description of current task`") + else + for i, location in ipairs(stacc.locations) do + local bufnr, id, description = unpack(location) + --- @type number[] + local mark = vim.api.nvim_buf_get_extmark_by_id(bufnr, stacc.namespace, id, {}) + print(string.format("%s %s:%i -- %s", + 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 elseif params.args == "clear" then stacc.clear()