feat(Status): Better provider info and show filter info
This commit is contained in:
@@ -363,6 +363,8 @@ function M.resolve_filter_config()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
M.o.symbols.user_config_filter = vim.deepcopy(tmp)
|
||||||
|
|
||||||
---@type outline.FilterFtList
|
---@type outline.FilterFtList
|
||||||
local filter = tmp
|
local filter = tmp
|
||||||
---@type outline.FilterFtTable
|
---@type outline.FilterFtTable
|
||||||
|
|||||||
@@ -66,6 +66,15 @@ function M.show_help()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function get_filter_list_lines(f)
|
||||||
|
if f == nil then
|
||||||
|
return { '(not configured)' }
|
||||||
|
elseif f == false or (f and #f == 0 and f.exclude) then
|
||||||
|
return { '(all symbols included)' }
|
||||||
|
end
|
||||||
|
return vim.split(vim.inspect(f), '\n', { plain = true })
|
||||||
|
end
|
||||||
|
|
||||||
---Display outline window status in a floating window
|
---Display outline window status in a floating window
|
||||||
---@param ctx outline.StatusContext
|
---@param ctx outline.StatusContext
|
||||||
function M.show_status(ctx)
|
function M.show_status(ctx)
|
||||||
@@ -74,8 +83,28 @@ function M.show_status(ctx)
|
|||||||
---@type outline.HL[]
|
---@type outline.HL[]
|
||||||
local hl = { { line = 0, from = 0, to = #keyhint, name = 'Comment' } }
|
local hl = { { line = 0, from = 0, to = #keyhint, name = 'Comment' } }
|
||||||
local p = ctx.provider
|
local p = ctx.provider
|
||||||
local priority = cfg.o.providers.priority
|
---@type string[]
|
||||||
|
local priority = ctx.priority
|
||||||
local pref
|
local pref
|
||||||
|
local indent = ' '
|
||||||
|
|
||||||
|
if ctx.ft then
|
||||||
|
table.insert(lines, 'Filetype of current or attached buffer: ' .. ctx.ft)
|
||||||
|
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.')
|
||||||
|
end
|
||||||
|
|
||||||
if utils.table_has_content(priority) then
|
if utils.table_has_content(priority) then
|
||||||
pref = 'Configured providers are: '
|
pref = 'Configured providers are: '
|
||||||
@@ -92,8 +121,6 @@ function M.show_status(ctx)
|
|||||||
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 = 'ErrorMsg' })
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(lines, '')
|
|
||||||
|
|
||||||
if p ~= nil then
|
if p ~= nil then
|
||||||
pref = 'Current provider: '
|
pref = 'Current provider: '
|
||||||
table.insert(lines, pref .. p.name)
|
table.insert(lines, pref .. p.name)
|
||||||
@@ -102,7 +129,6 @@ function M.show_status(ctx)
|
|||||||
table.insert(lines, 'Provider info:')
|
table.insert(lines, 'Provider info:')
|
||||||
table.insert(lines, '')
|
table.insert(lines, '')
|
||||||
local l = p.get_status()
|
local l = p.get_status()
|
||||||
local indent = ' '
|
|
||||||
for _, line in ipairs(vim.split(l, '\n', { plain = true, trimempty = false })) do
|
for _, line in ipairs(vim.split(l, '\n', { plain = true, trimempty = false })) do
|
||||||
table.insert(lines, indent .. line)
|
table.insert(lines, indent .. line)
|
||||||
end
|
end
|
||||||
@@ -115,8 +141,6 @@ function M.show_status(ctx)
|
|||||||
('Outline window is %s.'):format((ctx.outline_open and 'open') or 'not open')
|
('Outline window is %s.'):format((ctx.outline_open and 'open') or 'not open')
|
||||||
)
|
)
|
||||||
|
|
||||||
table.insert(lines, '')
|
|
||||||
|
|
||||||
if ctx.code_win_active then
|
if ctx.code_win_active then
|
||||||
table.insert(lines, 'Code window is active.')
|
table.insert(lines, 'Code window is active.')
|
||||||
else
|
else
|
||||||
@@ -124,7 +148,7 @@ function M.show_status(ctx)
|
|||||||
table.insert(lines, 'Try closing and reopening the outline.')
|
table.insert(lines, 'Try closing and reopening the outline.')
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
table.insert(lines, 'No providers.')
|
table.insert(lines, 'No supported providers for current buffer.')
|
||||||
end
|
end
|
||||||
|
|
||||||
local f = Float:new()
|
local f = Float:new()
|
||||||
|
|||||||
@@ -629,9 +629,16 @@ end
|
|||||||
|
|
||||||
function M.show_status()
|
function M.show_status()
|
||||||
---@type outline.StatusContext
|
---@type outline.StatusContext
|
||||||
local ctx = {}
|
local ctx = { priority = cfg.o.providers.priority }
|
||||||
|
|
||||||
|
if vim.api.nvim_buf_is_valid(M.state.code_buf) then
|
||||||
|
ctx.ft = vim.api.nvim_buf_get_option(M.state.code_buf, 'ft')
|
||||||
|
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
|
local p = _G._outline_current_provider
|
||||||
if not M.is_focus_in_outline() then
|
if not M.view or not M.view:is_open() then
|
||||||
p = providers.find_provider()
|
p = providers.find_provider()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,10 @@
|
|||||||
---@field provider outline.Provider?
|
---@field provider outline.Provider?
|
||||||
---@field outline_open boolean?
|
---@field outline_open boolean?
|
||||||
---@field code_win_active boolean?
|
---@field code_win_active boolean?
|
||||||
|
---@field ft string?
|
||||||
|
---@field filter outline.FilterList?
|
||||||
|
---@field default_filter outline.FilterList?
|
||||||
|
---@field priority string[]?
|
||||||
|
|
||||||
-- API
|
-- API
|
||||||
|
|
||||||
|
|||||||
@@ -137,12 +137,12 @@ function M.echo(module, message)
|
|||||||
vim.api.nvim_echo({ prefix_chunk, { message } }, true, {})
|
vim.api.nvim_echo({ prefix_chunk, { message } }, true, {})
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param t table
|
---@param t table?
|
||||||
function M.table_has_content(t)
|
function M.table_has_content(t)
|
||||||
return t and next(t) ~= nil
|
return t and next(t) ~= nil
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param t table|string
|
---@param t table|string?
|
||||||
function M.str_or_nonempty_table(t)
|
function M.str_or_nonempty_table(t)
|
||||||
return type(t) == 'string' or M.table_has_content(t)
|
return type(t) == 'string' or M.table_has_content(t)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user