feat(ui/config): Add config option to change icons and highlights

Closes #37
Kinda related to #19
This commit is contained in:
simrat39
2021-07-17 20:28:50 -07:00
parent fea9ce74e2
commit 3e9e019b03
4 changed files with 72 additions and 32 deletions

View File

@@ -18,13 +18,41 @@ local defaults = {
rename_symbol = "r",
code_actions = "a"
},
lsp_blacklist = {}
lsp_blacklist = {},
symbols = {
File = {icon = "", hl = "TSURI"},
Module = {icon = "", hl = "TSNamespace"},
Namespace = {icon = "", hl = "TSNamespace"},
Package = {icon = "", hl = "TSNamespace"},
Class = {icon = "𝓒", hl = "TSType"},
Method = {icon = "ƒ", hl = "TSMethod"},
Property = {icon = "", hl = "TSMethod"},
Field = {icon = "", hl = "TSField"},
Constructor = {icon = "", hl = "TSConstructor"},
Enum = {icon = "", hl = "TSType"},
Interface = {icon = "", hl = "TSType"},
Function = {icon = "", hl = "TSFunction"},
Variable = {icon = "", hl = "TSConstant"},
Constant = {icon = "", hl = "TSConstant"},
String = {icon = "𝓐", hl = "TSString"},
Number = {icon = "#", hl = "TSNumber"},
Boolean = {icon = "", hl = "TSBoolean"},
Array = {icon = "", hl = "TSConstant"},
Object = {icon = "⦿", hl = "TSType"},
Key = {icon = "🔐", hl = "TSType"},
Null = {icon = "NULL", hl = "TSType"},
EnumMember = {icon = "", hl = "TSField"},
Struct = {icon = "𝓢", hl = "TSType"},
Event = {icon = "🗲", hl = "TSType"},
Operator = {icon = "+", hl = "TSOperator"},
TypeParameter = {icon = "𝙏", hl = "TSParameter"}
}
}
M.options = {}
function M.has_numbers()
return M.options.show_numbers or M.options.show_relative_numbers
return M.options.show_numbers or M.options.show_relative_numbers
end
function M.get_position_navigation_direction()

View File

@@ -1,31 +1,6 @@
local M = {}
local config = require('symbols-outline.config')
M.File = {icon = "", hl = "TSURI"}
M.Module = {icon = "", hl = "TSNamespace"}
M.Namespace = {icon = "", hl = "TSNamespace"}
M.Package = {icon = "", hl = "TSNamespace"}
M.Class = {icon = "𝓒", hl = "TSType"}
M.Method = {icon = "ƒ", hl = "TSMethod"}
M.Property = {icon = "", hl = "TSMethod"}
M.Field = {icon = "", hl = "TSField"}
M.Constructor = {icon = "", hl = "TSConstructor"}
M.Enum = {icon = "", hl = "TSType"}
M.Interface = {icon = "", hl = "TSType"}
M.Function = {icon = "", hl = "TSFunction"}
M.Variable = {icon = "", hl = "TSConstant"}
M.Constant = {icon = "", hl = "TSConstant"}
M.String = {icon = "𝓐", hl = "TSString"}
M.Number = {icon = "#", hl = "TSNumber"}
M.Boolean = {icon = "", hl = "TSBoolean"}
M.Array = {icon = "", hl = "TSConstant"}
M.Object = {icon = "⦿", hl = "TSType"}
M.Key = {icon = "🔐", hl = "TSType"}
M.Null = {icon = "NULL", hl = "TSType"}
M.EnumMember = {icon = "", hl = "TSField"}
M.Struct = {icon = "𝓢", hl = "TSType"}
M.Event = {icon = "🗲", hl = "TSType"}
M.Operator = {icon = "+", hl = "TSOperator"}
M.TypeParameter = {icon = "𝙏", hl = "TSParameter"}
local M = {}
M.kinds = {
"File", "Module", "Namespace", "Package", "Class", "Method", "Property",
@@ -35,9 +10,11 @@ M.kinds = {
}
function M.icon_from_kind(kind)
local symbols = config.options.symbols
-- If the kind is higher than the available ones then default to 'Object'
if kind > #M.kinds then kind = 19 end
return M[M.kinds[kind]].icon
return symbols[M.kinds[kind]].icon
end
return M

View File

@@ -1,5 +1,6 @@
local vim = vim
local symbols = require('symbols-outline.symbols')
local config = require('symbols-outline.config')
local symbol_kinds = require('symbols-outline.symbols').kinds
local M = {}
M.markers = {
@@ -26,13 +27,15 @@ local function highlight_text(name, text, hl_group)
end
function M.setup_highlights()
local symbols = config.options.symbols
-- markers
highlight_text("marker_middle", M.markers.middle, "Comment")
highlight_text("marker_vertical", M.markers.vertical, "Comment")
highlight_text("markers_horizontal", M.markers.horizontal, "Comment")
highlight_text("markers_bottom", M.markers.bottom, "Comment")
for _, value in ipairs(symbols.kinds) do
for _, value in ipairs(symbol_kinds) do
local symbol = symbols[value]
highlight_text(value, symbol.icon, symbol.hl)
end