MAJOR: Refactor configuration structure
The details of the change is documented in the readme. If your config stops working, I'm fully responsible :)
This commit is contained in:
@@ -3,9 +3,6 @@ local vim = vim
|
||||
local M = {}
|
||||
|
||||
M.defaults = {
|
||||
position = 'right',
|
||||
width = 25,
|
||||
highlight_hovered_item = true,
|
||||
guides = {
|
||||
enabled = true,
|
||||
markers = {
|
||||
@@ -15,24 +12,39 @@ M.defaults = {
|
||||
horizontal = '─',
|
||||
},
|
||||
},
|
||||
border = 'single',
|
||||
relative_width = true,
|
||||
auto_close = false,
|
||||
auto_goto = false,
|
||||
auto_preview = false,
|
||||
open_hover_on_preview = true,
|
||||
show_numbers = false,
|
||||
show_relative_numbers = false,
|
||||
show_cursorline = true,
|
||||
show_symbol_details = true,
|
||||
show_symbol_lineno = false,
|
||||
preview_bg_highlight = 'Pmenu',
|
||||
winblend = 0,
|
||||
autofold_depth = nil,
|
||||
auto_unfold_hover = true,
|
||||
fold_markers = { '', '' },
|
||||
wrap = false,
|
||||
focus_on_open = true,
|
||||
outline_items = {
|
||||
show_symbol_details = true,
|
||||
show_symbol_lineno = false,
|
||||
highlight_hovered_item = true,
|
||||
},
|
||||
outline_window = {
|
||||
position = 'right',
|
||||
width = 25,
|
||||
relative_width = true,
|
||||
wrap = false,
|
||||
focus_on_open = true,
|
||||
auto_close = false,
|
||||
auto_goto = false,
|
||||
show_numbers = false,
|
||||
show_relative_numbers = false,
|
||||
show_cursorline = true,
|
||||
},
|
||||
preview_window = {
|
||||
auto_preview = false,
|
||||
width = 50,
|
||||
min_width = 100,
|
||||
relative_width = true,
|
||||
bg_hl = 'Pmenu',
|
||||
border = 'single',
|
||||
border_hl = 'Pmenu',
|
||||
open_hover_on_preview = true,
|
||||
winblend = 0,
|
||||
},
|
||||
symbol_folding = {
|
||||
autofold_depth = nil,
|
||||
auto_unfold_hover = true,
|
||||
markers = { '', '' },
|
||||
},
|
||||
keymaps = {
|
||||
show_help = '?',
|
||||
close = { '<Esc>', 'q' },
|
||||
@@ -53,53 +65,59 @@ M.defaults = {
|
||||
down_and_goto = '<C-j>',
|
||||
up_and_goto = '<C-k>',
|
||||
},
|
||||
lsp_blacklist = {},
|
||||
symbol_blacklist = {},
|
||||
symbols = {
|
||||
File = { icon = '', hl = '@text.uri' },
|
||||
Module = { icon = '', hl = '@namespace' },
|
||||
Namespace = { icon = '', hl = '@namespace' },
|
||||
Package = { icon = '', hl = '@namespace' },
|
||||
Class = { icon = '𝓒', hl = '@type' },
|
||||
Method = { icon = 'ƒ', hl = '@method' },
|
||||
Property = { icon = '', hl = '@method' },
|
||||
Field = { icon = '', hl = '@field' },
|
||||
Constructor = { icon = '', hl = '@constructor' },
|
||||
Enum = { icon = 'ℰ', hl = '@type' },
|
||||
Interface = { icon = '', hl = '@type' },
|
||||
Function = { icon = '', hl = '@function' },
|
||||
Variable = { icon = '', hl = '@constant' },
|
||||
Constant = { icon = '', hl = '@constant' },
|
||||
String = { icon = '𝓐', hl = '@string' },
|
||||
Number = { icon = '#', hl = '@number' },
|
||||
Boolean = { icon = '⊨', hl = '@boolean' },
|
||||
Array = { icon = '', hl = '@constant' },
|
||||
Object = { icon = '⦿', hl = '@type' },
|
||||
Key = { icon = '🔐', hl = '@type' },
|
||||
Null = { icon = 'NULL', hl = '@type' },
|
||||
EnumMember = { icon = '', hl = '@field' },
|
||||
Struct = { icon = '𝓢', hl = '@type' },
|
||||
Event = { icon = '🗲', hl = '@type' },
|
||||
Operator = { icon = '+', hl = '@operator' },
|
||||
TypeParameter = { icon = '𝙏', hl = '@parameter' },
|
||||
Component = { icon = '', hl = '@function' },
|
||||
Fragment = { icon = '', hl = '@constant' },
|
||||
-- ccls
|
||||
TypeAlias = { icon = ' ', hl = '@type' },
|
||||
Parameter = { icon = ' ', hl = '@parameter' },
|
||||
StaticMethod = { icon = ' ', hl = '@function' },
|
||||
Macro = { icon = ' ', hl = '@macro' },
|
||||
providers = {
|
||||
lsp = {
|
||||
blacklist_clients = {},
|
||||
},
|
||||
},
|
||||
symbols = {
|
||||
blacklist = {},
|
||||
icons = {
|
||||
File = { icon = '', hl = '@text.uri' },
|
||||
Module = { icon = '', hl = '@namespace' },
|
||||
Namespace = { icon = '', hl = '@namespace' },
|
||||
Package = { icon = '', hl = '@namespace' },
|
||||
Class = { icon = '𝓒', hl = '@type' },
|
||||
Method = { icon = 'ƒ', hl = '@method' },
|
||||
Property = { icon = '', hl = '@method' },
|
||||
Field = { icon = '', hl = '@field' },
|
||||
Constructor = { icon = '', hl = '@constructor' },
|
||||
Enum = { icon = 'ℰ', hl = '@type' },
|
||||
Interface = { icon = '', hl = '@type' },
|
||||
Function = { icon = '', hl = '@function' },
|
||||
Variable = { icon = '', hl = '@constant' },
|
||||
Constant = { icon = '', hl = '@constant' },
|
||||
String = { icon = '𝓐', hl = '@string' },
|
||||
Number = { icon = '#', hl = '@number' },
|
||||
Boolean = { icon = '⊨', hl = '@boolean' },
|
||||
Array = { icon = '', hl = '@constant' },
|
||||
Object = { icon = '⦿', hl = '@type' },
|
||||
Key = { icon = '🔐', hl = '@type' },
|
||||
Null = { icon = 'NULL', hl = '@type' },
|
||||
EnumMember = { icon = '', hl = '@field' },
|
||||
Struct = { icon = '𝓢', hl = '@type' },
|
||||
Event = { icon = '🗲', hl = '@type' },
|
||||
Operator = { icon = '+', hl = '@operator' },
|
||||
TypeParameter = { icon = '𝙏', hl = '@parameter' },
|
||||
Component = { icon = '', hl = '@function' },
|
||||
Fragment = { icon = '', hl = '@constant' },
|
||||
-- ccls
|
||||
TypeAlias = { icon = ' ', hl = '@type' },
|
||||
Parameter = { icon = ' ', hl = '@parameter' },
|
||||
StaticMethod = { icon = ' ', hl = '@function' },
|
||||
Macro = { icon = ' ', hl = '@macro' },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
M.options = {}
|
||||
M.o = {}
|
||||
|
||||
function M.has_numbers()
|
||||
return M.options.show_numbers or M.options.show_relative_numbers
|
||||
return M.o.outline_window.show_numbers or M.o.outline_window.show_relative_numbers
|
||||
end
|
||||
|
||||
function M.get_position_navigation_direction()
|
||||
if M.options.position == 'left' then
|
||||
if M.o.outline_window.position == 'left' then
|
||||
return 'h'
|
||||
else
|
||||
return 'l'
|
||||
@@ -107,15 +125,15 @@ function M.get_position_navigation_direction()
|
||||
end
|
||||
|
||||
function M.get_window_width()
|
||||
if M.options.relative_width then
|
||||
return math.ceil(vim.o.columns * (M.options.width / 100))
|
||||
if M.o.outline_window.relative_width then
|
||||
return math.ceil(vim.o.columns * (M.o.outline_window.width / 100))
|
||||
else
|
||||
return M.options.width
|
||||
return M.o.outline_window.width
|
||||
end
|
||||
end
|
||||
|
||||
function M.get_split_command()
|
||||
if M.options.position == 'left' then
|
||||
if M.o.outline_window.position == 'left' then
|
||||
return 'topleft vs'
|
||||
else
|
||||
return 'botright vs'
|
||||
@@ -136,7 +154,7 @@ function M.is_symbol_blacklisted(kind)
|
||||
if kind == nil then
|
||||
return false
|
||||
end
|
||||
return has_value(M.options.symbol_blacklist, kind)
|
||||
return has_value(M.o.symbols.blacklist, kind)
|
||||
end
|
||||
|
||||
function M.is_client_blacklisted(client_id)
|
||||
@@ -144,17 +162,21 @@ function M.is_client_blacklisted(client_id)
|
||||
if not client then
|
||||
return false
|
||||
end
|
||||
return has_value(M.options.lsp_blacklist, client.name)
|
||||
return has_value(M.o.providers.lsp.blacklist_clients, client.name)
|
||||
end
|
||||
|
||||
function M.show_help()
|
||||
print 'Current keymaps:'
|
||||
print(vim.inspect(M.options.keymaps))
|
||||
print(vim.inspect(M.o.keymaps))
|
||||
end
|
||||
|
||||
function M.setup(options)
|
||||
vim.g.symbols_outline_loaded = 1
|
||||
M.options = vim.tbl_deep_extend('force', {}, M.defaults, options or {})
|
||||
M.o = vim.tbl_deep_extend('force', {}, M.defaults, options or {})
|
||||
local guides = M.o.guides
|
||||
if type(guides) == 'boolean' and guides then
|
||||
M.o.guides = M.defaults.guides
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user