diff --git a/lua/outline/config.lua b/lua/outline/config.lua index 2640255..2ead5c7 100644 --- a/lua/outline/config.lua +++ b/lua/outline/config.lua @@ -1,4 +1,4 @@ -local vim = vim +local utils = require('outline.utils') local M = {} @@ -198,7 +198,7 @@ end ---Check for inconsistent or mutually exclusive opts. Does not alter the opts function M.check_config() if M.o.outline_window.hide_cursor and not M.o.outline_window.show_cursorline then - vim.notify("[outline.config]: hide_cursor enabled WITHOUT cursorline enabled!", vim.log.levels.ERROR) + utils.echo("config", "hide_cursor enabled without cursorline enabled!") end end diff --git a/lua/outline/init.lua b/lua/outline/init.lua index 275c2a2..23ff0bb 100644 --- a/lua/outline/init.lua +++ b/lua/outline/init.lua @@ -497,9 +497,8 @@ end function M._map_follow_cursor() if not M.follow_cursor({ focus_outline = true }) then - vim.notify( - "Code window no longer active. Try closing and reopening the outline.", - vim.log.levels.ERROR + utils.echo( + "Code window no longer active. Try closing and reopening the outline." ) end end @@ -554,7 +553,7 @@ function M.open_outline(opts) if not M.view:is_open() then local found = providers.request_symbols(handler, opts) if not found then - vim.notify("[outline]: No providers found for current buffer", vim.log.levels.WARN) + utils.echo("No providers found for current buffer") end end end diff --git a/lua/outline/utils/init.lua b/lua/outline/utils/init.lua index 03c520c..d4513c6 100644 --- a/lua/outline/utils/init.lua +++ b/lua/outline/utils/init.lua @@ -55,7 +55,7 @@ end ---@param old_node table Old node ---@param index? number Index of old_item in parent ---@param parent? table Parent of old_item -M.merge_items_rec = function(new_node, old_node, index, parent) +function M.merge_items_rec(new_node, old_node, index, parent) local failed = false if not new_node or not old_node then @@ -110,7 +110,7 @@ M.merge_items_rec = function(new_node, old_node, index, parent) end end -M.flash_highlight = function(winnr, lnum, durationMs, hl_group) +function M.flash_highlight(winnr, lnum, durationMs, hl_group) hl_group = hl_group or "Visual" if durationMs == true or durationMs == 1 then durationMs = 300 @@ -123,4 +123,20 @@ M.flash_highlight = function(winnr, lnum, durationMs, hl_group) vim.defer_fn(remove_highlight, durationMs) end +---@param module string Used as message if second param omitted +---@param message string? +function M.echo(module, message) + if not message then + message = module + module = "" + end + local prefix = "outline" + if module ~= "" then + prefix = prefix.."."..module + end + local prefix_chunk = { '('..prefix..') ', "WarningMsg" } + -- For now we don't echo much, so add all to history + vim.api.nvim_echo({ prefix_chunk, { message } }, true, {}) +end + return M