diff --git a/README.md b/README.md index 4157e72..e29eefe 100644 --- a/README.md +++ b/README.md @@ -659,6 +659,22 @@ preview_window = { }, ``` +### Help windows + +| Highlight | Link | +| ------------------------- | -------- | +| OutlineHelpTip | Comment | +| OutlineStatusFt | Type | +| OutlineStatusError | ErrorMsg | +| OutlineStatusProvider | Special | +| OutlineKeymapHelpKey | Special | +| OutlineKeymapHelpDisabled | Comment | + +Help windows include: +1. the keymap help from pressing `?` in the outline window +1. `:OutlineStatus` + + ### Other highlight groups | Highlight | Description | diff --git a/lua/outline/docs.lua b/lua/outline/docs.lua index 2b19731..3d2a425 100644 --- a/lua/outline/docs.lua +++ b/lua/outline/docs.lua @@ -9,12 +9,12 @@ function M.show_help() local title = 'Current keymaps:' local lines = { keyhint, '', title, '' } ---@type outline.HL[] - local hl = { { line = 0, from = 0, to = #keyhint, name = 'Comment' } } + local hl = { { line = 0, from = 0, to = #keyhint, name = 'OutlineHelpTip' } } local left = {} local right = {} local max_left_width = 0 local indent = ' ' - local key_hl = 'Special' + local key_hl = 'OutlineKeymapHelpKey' for action, keys in pairs(cfg.o.keymaps) do if type(keys) == 'string' then @@ -30,8 +30,8 @@ function M.show_help() table.insert(hl, { line = #left + 3, from = #indent, + name = 'OutlineKeymapHelpDisabled', to = #indent + 6, - name = 'Comment', }) else local i = #indent @@ -80,7 +80,7 @@ function M.show_status(ctx) local keyhint = 'Press q or to close this window.' local lines = { keyhint, '' } ---@type outline.HL[] - local hl = { { line = 0, from = 0, to = #keyhint, name = 'Comment' } } + local hl = { { line = 0, from = 0, to = #keyhint, name = 'OutlineHelpTip' } } local p = ctx.provider ---@type string[] local priority = ctx.priority @@ -90,7 +90,7 @@ function M.show_status(ctx) if ctx.ft then pref = 'Filetype of current or attached buffer: ' table.insert(lines, pref .. ctx.ft) - table.insert(hl, { line = #lines - 1, from = #pref, to = -1, name = 'Type' }) + table.insert(hl, { line = #lines - 1, from = #pref, to = -1, name = 'OutlineStatusFt'}) table.insert(lines, 'Symbols filter:') table.insert(lines, '') for _, line in ipairs(get_filter_list_lines(ctx.filter)) do @@ -101,7 +101,7 @@ function M.show_status(ctx) table.insert(lines, 'Filetype of current or attached buffer: N/A') table.insert(lines, 'Symbols filter: N/A') table.insert(lines, 'Buffer number of code was invalid, could not get filetype!') - table.insert(hl, { line = #lines - 1, from = 0, to = -1, name = 'ErrorMsg' }) + table.insert(hl, { line = #lines - 1, from = 0, to = -1, name = 'OutlineStatusError' }) table.insert(lines, '') end @@ -117,20 +117,20 @@ function M.show_status(ctx) table.insert(lines, pref .. table.concat(priority, ', ') .. '.') local i = #pref for _, name in ipairs(priority) do - table.insert(hl, { line = #lines - 1, from = i, to = i + #name, name = 'Special' }) + table.insert(hl, { line = #lines - 1, from = i, to = i + #name, name = 'OutlineStatusProvider' }) i = i + #name + 2 end else pref = 'config ' local content = 'providers.priority' table.insert(lines, pref .. content .. ' is an empty list!') - table.insert(hl, { line = #lines - 1, from = #pref, to = #pref + #content, name = 'ErrorMsg' }) + table.insert(hl, { line = #lines - 1, from = #pref, to = #pref + #content, name = 'OutlineStatusError' }) end if p ~= nil then pref = 'Current provider: ' table.insert(lines, pref .. p.name) - table.insert(hl, { line = #lines - 1, from = #pref, to = -1, name = 'Special' }) + table.insert(hl, { line = #lines - 1, from = #pref, to = -1, name = 'OutlineStatusProvider' }) if p.get_status then table.insert(lines, 'Provider info:') table.insert(lines, '') @@ -151,8 +151,8 @@ function M.show_status(ctx) else table.insert(lines, 'Code window is not active!') table.insert(lines, 'Try closing and reopening the outline.') - table.insert(hl, { line = #lines - 2, from = 0, to = -1, name = 'ErrorMsg' }) - table.insert(hl, { line = #lines - 1, from = 0, to = -1, name = 'ErrorMsg' }) + table.insert(hl, { line = #lines - 2, from = 0, to = -1, name = 'OutlineStatusError' }) + table.insert(hl, { line = #lines - 1, from = 0, to = -1, name = 'OutlineStatusError' }) end else table.insert(lines, 'No supported providers for current buffer.') diff --git a/lua/outline/float.lua b/lua/outline/float.lua index a8a4272..3b2622d 100644 --- a/lua/outline/float.lua +++ b/lua/outline/float.lua @@ -1,3 +1,4 @@ +---@class outline.Float local Float = {} ---@class outline.Float @@ -9,6 +10,7 @@ function Float:new() return setmetatable({ bufnr = nil, winnr = nil, ns = nil }, { __index = Float }) end +---Set up a floating window with OutlineHelp ft ---@param lines string[] ---@param hl outline.HL[] ---@param title string diff --git a/lua/outline/highlight.lua b/lua/outline/highlight.lua index 7d943df..c9f2401 100644 --- a/lua/outline/highlight.lua +++ b/lua/outline/highlight.lua @@ -62,6 +62,12 @@ function M.setup_highlights() Details = 'Comment', Lineno = 'LineNr', JumpHighlight = 'Visual', + HelpTip = 'Comment', + StatusFt = 'Type', + StatusProvider = 'Special', + StatusError = 'ErrorMsg', + KeymapHelpKey = 'Special', + KeymapHelpDisabled = 'Comment', }) do if vim.fn.hlexists('Outline' .. name) == 0 then vim.api.nvim_set_hl(0, 'Outline' .. name, { link = link })