refactor: Use default key for default filtering
Inspired by lazyvim
This commit is contained in:
@@ -412,7 +412,7 @@ Per-filetype filtering example:
|
|||||||
- For other file types, include all but string
|
- For other file types, include all but string
|
||||||
```lua
|
```lua
|
||||||
symbols.filter = {
|
symbols.filter = {
|
||||||
['*'] = { 'String', exclude=true },
|
default = { 'String', exclude=true },
|
||||||
python = { 'Function', 'Class' },
|
python = { 'Function', 'Class' },
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ function M.should_include_symbol(kind, bufnr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local filter_table = M.o.symbols.filter[ft]
|
local filter_table = M.o.symbols.filter[ft]
|
||||||
local default_filter_table = M.o.symbols.filter['*']
|
local default_filter_table = M.o.symbols.filter.default
|
||||||
|
|
||||||
-- When filter table for a ft is not specified, all symbols are shown
|
-- When filter table for a ft is not specified, all symbols are shown
|
||||||
if not filter_table then
|
if not filter_table then
|
||||||
@@ -339,8 +339,8 @@ function M.resolve_filter_config()
|
|||||||
|
|
||||||
---- legacy form -> ft filter list ----
|
---- legacy form -> ft filter list ----
|
||||||
if table_has_content(M.o.symbols.blacklist) then
|
if table_has_content(M.o.symbols.blacklist) then
|
||||||
tmp = { ['*'] = M.o.symbols.blacklist }
|
tmp = { default = M.o.symbols.blacklist }
|
||||||
tmp['*'].exclude = true
|
tmp.default.exclude = true
|
||||||
M.o.symbols.blacklist = nil
|
M.o.symbols.blacklist = nil
|
||||||
else
|
else
|
||||||
---- nil or {} -> include all symbols ----
|
---- nil or {} -> include all symbols ----
|
||||||
@@ -349,14 +349,14 @@ function M.resolve_filter_config()
|
|||||||
-- through the plugin manager); so we let filter = {} denote filter = nil
|
-- through the plugin manager); so we let filter = {} denote filter = nil
|
||||||
-- (or false), meaning include all symbols.
|
-- (or false), meaning include all symbols.
|
||||||
if not table_has_content(tmp) then
|
if not table_has_content(tmp) then
|
||||||
tmp = { ['*'] = { exclude = true } }
|
tmp = { default = { exclude = true } }
|
||||||
|
|
||||||
-- Lazy filter list -> ft filter list
|
-- Lazy filter list -> ft filter list
|
||||||
elseif tmp[1] then
|
elseif tmp[1] then
|
||||||
if type(tmp[1]) == 'string' then
|
if type(tmp[1]) == 'string' then
|
||||||
tmp = { ['*'] = vim.deepcopy(tmp) }
|
tmp = { default = vim.deepcopy(tmp) }
|
||||||
else
|
else
|
||||||
tmp['*'] = vim.deepcopy(tmp[1])
|
tmp.default = vim.deepcopy(tmp[1])
|
||||||
tmp[1] = nil
|
tmp[1] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -375,7 +375,7 @@ function M.resolve_filter_config()
|
|||||||
-- filetype.
|
-- filetype.
|
||||||
-- {
|
-- {
|
||||||
-- python = { String = false, Variable = true, ... },
|
-- python = { String = false, Variable = true, ... },
|
||||||
-- ['*'] = { File = true, Method = true, ... },
|
-- default = { File = true, Method = true, ... },
|
||||||
-- }
|
-- }
|
||||||
for ft, list in pairs(filter) do
|
for ft, list in pairs(filter) do
|
||||||
if type(ft) ~= 'string' then
|
if type(ft) ~= 'string' then
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
-- {
|
-- {
|
||||||
-- python = { 'Variable', exclude = true },
|
-- python = { 'Variable', exclude = true },
|
||||||
-- go = { 'Field', 'Function', 'Method' },
|
-- go = { 'Field', 'Function', 'Method' },
|
||||||
-- ['\*'] = { 'String', exclude = true }
|
-- default = { 'String', exclude = true }
|
||||||
-- }
|
-- }
|
||||||
---@alias outline.FilterFtList { [string]: outline.FilterList } A filter list for each file type
|
---@alias outline.FilterFtList { [string]: outline.FilterList } A filter list for each file type
|
||||||
---@alias outline.FilterConfig outline.FilterFtList|outline.FilterList
|
---@alias outline.FilterConfig outline.FilterFtList|outline.FilterList
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
---@alias outline.FilterTable { [string]: boolean } Each kind:include pair where include is boolean, whether to include this kind. Used internally.
|
---@alias outline.FilterTable { [string]: boolean } Each kind:include pair where include is boolean, whether to include this kind. Used internally.
|
||||||
-- {
|
-- {
|
||||||
-- python = { String = false, Variable = true, ... },
|
-- python = { String = false, Variable = true, ... },
|
||||||
-- ['\*'] = { File = true, Method = true, ... },
|
-- default = { File = true, Method = true, ... },
|
||||||
-- }
|
-- }
|
||||||
---@alias outline.FilterFtTable { [string]: outline.FilterTable } A filter table for each file type. Used internally.
|
---@alias outline.FilterFtTable { [string]: outline.FilterTable } A filter table for each file type. Used internally.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user