diff --git a/lua/pending/init.lua b/lua/pending/init.lua index 4e093bf..e70e2fb 100644 --- a/lua/pending/init.lua +++ b/lua/pending/init.lua @@ -87,7 +87,7 @@ end local function require_saved() local bufnr = buffer.bufnr() if bufnr and vim.bo[bufnr].modified then - log.warn('save changes first (:w)') + log.warn('Save changes first (:w).') return false end return true @@ -511,7 +511,7 @@ function M.done(id_str) if bufnr and vim.api.nvim_buf_is_valid(bufnr) then buffer.render(bufnr) end - log.info('Task #' .. id .. ' marked ' .. (was_done and 'pending' or 'done')) + log.info('Task #' .. id .. ' marked ' .. (was_done and 'pending' or 'done') .. '.') end ---@return nil @@ -601,7 +601,7 @@ function M.add(text) s:load() local description, metadata = parse.command_add(text) if not description or description == '' then - log.error('Pending must have a description.') + log.error('Task must have a description.') return end s:add({ @@ -616,7 +616,7 @@ function M.add(text) if bufnr and vim.api.nvim_buf_is_valid(bufnr) then buffer.render(bufnr) end - log.info('Pending added: ' .. description) + log.info('Task added: ' .. description) end ---@type string[] @@ -649,7 +649,7 @@ local function run_sync(backend_name, action) return end if action == 'health' or type(backend[action]) ~= 'function' then - log.error(backend_name .. " backend has no '" .. action .. "' action") + log.error(backend_name .. ": No '" .. action .. "' action.") return end backend[action]() @@ -687,7 +687,7 @@ function M.archive(days) end s:replace_tasks(kept) _save_and_notify() - log.info('Archived ' .. archived .. ' tasks.') + log.info('Archived ' .. archived .. ' task' .. (archived == 1 and '' or 's') .. '.') local bufnr = buffer.bufnr() if bufnr and vim.api.nvim_buf_is_valid(bufnr) then buffer.render(bufnr) @@ -915,7 +915,7 @@ function M.edit(id_str, rest) buffer.render(bufnr) end - log.info('Task #' .. id .. ' updated: ' .. table.concat(feedback, ', ')) + log.info('Task #' .. id .. ' updated: ' .. table.concat(feedback, ', ') .. '.') end ---@param args? string @@ -977,7 +977,7 @@ function M.command(args) elseif cmd == 'undo' then M.undo_write() else - log.error('Unknown Pending subcommand: ' .. cmd) + log.error('Unknown subcommand: ' .. cmd) end end diff --git a/lua/pending/sync/gcal.lua b/lua/pending/sync/gcal.lua index 4669b89..80802a7 100644 --- a/lua/pending/sync/gcal.lua +++ b/lua/pending/sync/gcal.lua @@ -173,7 +173,7 @@ function M.push() oauth.with_token(oauth.google_client, 'gcal', function(access_token) local calendars, cal_err = get_all_calendars(access_token) if cal_err or not calendars then - log.error(cal_err or 'failed to fetch calendars') + log.error(cal_err or 'Failed to fetch calendars.') return end @@ -199,7 +199,7 @@ function M.push() local del_err = delete_event(access_token, cal_id --[[@as string]], event_id --[[@as string]]) if del_err then - log.warn('gcal delete failed: ' .. del_err) + log.warn('Failed to delete calendar event: ' .. del_err) failed = failed + 1 else unlink_remote(task, extra, now_ts) @@ -217,7 +217,7 @@ function M.push() if event_id and cal_id then local upd_err = update_event(access_token, cal_id, event_id, task) if upd_err then - log.warn('gcal update failed: ' .. upd_err) + log.warn('Failed to update calendar event: ' .. upd_err) failed = failed + 1 else updated = updated + 1 @@ -225,12 +225,12 @@ function M.push() else local lid, lid_err = find_or_create_calendar(access_token, cat, calendars) if lid_err or not lid then - log.warn('gcal calendar failed: ' .. (lid_err or 'unknown')) + log.warn('Failed to create calendar: ' .. (lid_err or 'unknown')) failed = failed + 1 else local new_id, create_err = create_event(access_token, lid, task) if create_err then - log.warn('gcal create failed: ' .. create_err) + log.warn('Failed to create calendar event: ' .. create_err) failed = failed + 1 elseif new_id then if not task._extra then diff --git a/lua/pending/sync/gtasks.lua b/lua/pending/sync/gtasks.lua index 5b19118..014e80a 100644 --- a/lua/pending/sync/gtasks.lua +++ b/lua/pending/sync/gtasks.lua @@ -281,7 +281,7 @@ local function push_pass(access_token, tasklists, s, now_ts, by_gtasks_id) if allow_remote_delete() then local err = delete_gtask(access_token, list_id, gtid) if err then - log.warn('gtasks delete failed: ' .. err) + log.warn('Failed to delete remote task: ' .. err) failed = failed + 1 else unlink_remote(task, now_ts) @@ -300,7 +300,7 @@ local function push_pass(access_token, tasklists, s, now_ts, by_gtasks_id) if not synced_at or task.modified > synced_at then local err = update_gtask(access_token, list_id, gtid, task_to_gtask(task)) if err then - log.warn('gtasks update failed: ' .. err) + log.warn('Failed to update remote task: ' .. err) failed = failed + 1 else task._extra = task._extra or {} @@ -314,7 +314,7 @@ local function push_pass(access_token, tasklists, s, now_ts, by_gtasks_id) if not err and lid then local new_id, create_err = create_gtask(access_token, lid, task_to_gtask(task)) if create_err then - log.warn('gtasks create failed: ' .. create_err) + log.warn('Failed to create remote task: ' .. create_err) failed = failed + 1 elseif new_id then if not task._extra then @@ -353,7 +353,7 @@ local function pull_pass(access_token, tasklists, s, now_ts, by_gtasks_id) for list_name, list_id in pairs(tasklists) do local items, err = list_gtasks(access_token, list_id) if err then - log.warn('error fetching list ' .. list_name .. ': ' .. err) + log.warn('Failed to fetch task list "' .. list_name .. '": ' .. err) failed = failed + 1 else fetched_list_ids[list_id] = true @@ -428,7 +428,7 @@ end local function sync_setup(access_token) local tasklists, tl_err = get_all_tasklists(access_token) if tl_err or not tasklists then - log.error(tl_err or 'failed to fetch task lists') + log.error(tl_err or 'Failed to fetch task lists.') return nil, nil, nil end local s = require('pending').store() diff --git a/lua/pending/sync/oauth.lua b/lua/pending/sync/oauth.lua index 8c30268..dabbe2d 100644 --- a/lua/pending/sync/oauth.lua +++ b/lua/pending/sync/oauth.lua @@ -57,7 +57,7 @@ end ---@param callback fun(access_token: string): nil function M.with_token(client, name, callback) if _sync_in_flight then - require('pending.log').warn(name .. ': sync operation in progress — please wait') + require('pending.log').warn(name .. ': Sync already in progress — please wait.') return end _sync_in_flight = true @@ -65,7 +65,7 @@ function M.with_token(client, name, callback) local token = client:get_access_token() if not token then _sync_in_flight = false - require('pending.log').warn(name .. ': not authenticated — run :Pending auth') + require('pending.log').warn(name .. ': Not authenticated — run :Pending auth.') return end local ok, err = pcall(callback, token) @@ -279,7 +279,7 @@ function OAuthClient:get_access_token() if now - obtained > expires - 60 then tokens = self:refresh_access_token(creds, tokens) if not tokens then - log.error(self.name .. ': token refresh failed — re-authenticating...') + log.error(self.name .. ': Token refresh failed — re-authenticating...') return nil end end @@ -364,10 +364,10 @@ function OAuthClient:setup() local path = vim.fn.stdpath('data') .. '/pending/google_credentials.json' local ok = M.save_json_file(path, { client_id = id, client_secret = secret }) if not ok then - log.error(self.name .. ': failed to save credentials') + log.error(self.name .. ': Failed to save credentials.') return end - log.info(self.name .. ': credentials saved, starting authorization...') + log.info(self.name .. ': Credentials saved, starting authorization...') self:auth() end) end @@ -382,7 +382,7 @@ function OAuthClient:auth(on_complete) local creds = self:resolve_credentials() if creds.client_id == BUNDLED_CLIENT_ID then - log.error(self.name .. ': no credentials configured — run :Pending auth') + log.error(self.name .. ': No credentials configured — run :Pending auth.') return end local port = self.port @@ -433,7 +433,7 @@ function OAuthClient:auth(on_complete) local bind_ok, bind_err = pcall(server.bind, server, '127.0.0.1', port) if not bind_ok or bind_err == nil then close_server() - log.error(self.name .. ': port ' .. port .. ' already in use — try again in a moment') + log.error(self.name .. ': Port ' .. port .. ' already in use — try again in a moment.') return end @@ -526,7 +526,7 @@ function OAuthClient:_exchange_code(creds, code, code_verifier, port, on_complet decoded.obtained_at = os.time() self:save_tokens(decoded) - log.info(self.name .. ' authorized successfully.') + log.info(self.name .. ': Authorized successfully.') if on_complete then on_complete() end diff --git a/spec/sync_spec.lua b/spec/sync_spec.lua index a491dd3..7771553 100644 --- a/spec/sync_spec.lua +++ b/spec/sync_spec.lua @@ -33,7 +33,7 @@ describe('sync', function() end pending.command('notreal') vim.notify = orig - assert.are.equal('[pending.nvim]: Unknown Pending subcommand: notreal', msg) + assert.are.equal('[pending.nvim]: Unknown subcommand: notreal', msg) end) it('errors on unknown action for valid backend', function() @@ -46,7 +46,7 @@ describe('sync', function() end pending.command('gcal notreal') vim.notify = orig - assert.are.equal("[pending.nvim]: gcal backend has no 'notreal' action", msg) + assert.are.equal("[pending.nvim]: gcal: No 'notreal' action.", msg) end) it('lists actions when action is omitted', function()