feat(status): Better information and highlights

This commit is contained in:
hedy
2023-11-24 16:31:16 +08:00
parent f4d5eb2dad
commit 896fd2ae63
2 changed files with 19 additions and 10 deletions

View File

@@ -88,23 +88,30 @@ function M.show_status(ctx)
local indent = ' '
if ctx.ft then
table.insert(lines, 'Filetype of current or attached buffer: ' .. ctx.ft)
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(lines, 'Symbols filter:')
table.insert(lines, '')
for _, line in ipairs(get_filter_list_lines(ctx.filter)) do
table.insert(lines, indent .. line)
end
table.insert(lines, '')
table.insert(lines, 'Default symbols filter:')
table.insert(lines, '')
for _, line in ipairs(get_filter_list_lines(ctx.default_filter)) do
table.insert(lines, indent .. line)
end
table.insert(lines, '')
else
table.insert(lines, 'Buffer number of code was invalid, could not get filetype.')
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(lines, '')
end
table.insert(lines, 'Default symbols filter:')
table.insert(lines, '')
for _, line in ipairs(get_filter_list_lines(ctx.default_filter)) do
table.insert(lines, indent .. line)
end
table.insert(lines, '')
if utils.table_has_content(priority) then
pref = 'Configured providers are: '
table.insert(lines, pref .. table.concat(priority, ', ') .. '.')
@@ -144,6 +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' })
end
else
table.insert(lines, 'No supported providers for current buffer.')

View File

@@ -170,10 +170,10 @@ function M.show_status()
if vim.api.nvim_buf_is_valid(buf) then
ctx.ft = vim.api.nvim_buf_get_option(buf, 'ft')
-- TODO: else?
ctx.filter = cfg.o.symbols.user_config_filter[ctx.ft]
-- 'else' is handled in docs.lua
end
ctx.filter = cfg.o.symbols.user_config_filter[ctx.ft]
ctx.default_filter = cfg.o.symbols.user_config_filter.default
local p = _G._outline_current_provider