From 7b302a938b84ea4c5ebc3fd0000df211ce819252 Mon Sep 17 00:00:00 2001 From: simrat39 Date: Sun, 18 Apr 2021 21:15:06 -0700 Subject: [PATCH] symbols: Setup basic highlighting for icons (using tree-sitter) Color == cool --- lua/symbols-outline.lua | 11 ++++++--- lua/symbols.lua | 54 ++++++++++++++++++++--------------------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/lua/symbols-outline.lua b/lua/symbols-outline.lua index 7445f83..335e40f 100644 --- a/lua/symbols-outline.lua +++ b/lua/symbols-outline.lua @@ -89,9 +89,14 @@ end local function setup_highlights() -- markers - highlight_text(markers.middle, markers.middle, "Comment") - highlight_text(markers.horizontal, markers.horizontal, "Comment") - highlight_text(markers.bottom, markers.bottom, "Comment") + highlight_text("marker_middle", markers.middle, "Comment") + highlight_text("markers_horizontal", markers.horizontal, "Comment") + highlight_text("markers_bottom", markers.bottom, "Comment") + + for _, value in ipairs(symbols.kinds) do + local symbol = symbols[value] + highlight_text(value, symbol.icon, symbol.hl) + end end local function write(outline_items, bufnr, winnr) diff --git a/lua/symbols.lua b/lua/symbols.lua index cdeb7b7..33ccd42 100644 --- a/lua/symbols.lua +++ b/lua/symbols.lua @@ -1,30 +1,30 @@ M = {} -M.File = "" -M.Module = "" -M.Namespace = "" -M.Package = "" -M.Class = "𝓒" -M.Method = "ƒ" -M.Property = "" -M.Field = "" -M.Constructor = "" -M.Enum = "ℰ" -M.Interface = "ﰮ" -M.Function = "" -M.Variable = "" -M.Constant = "" -M.String = "𝓐" -M.Number = "#" -M.Boolean = "⊨" -M.Array = "" -M.Object = "⦿" -M.Key = "🔐" -M.Null = "NULL" -M.EnumMember = "" -M.Struct = "𝓢" -M.Event = "🗲" -M.Operator = "𝒯" +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.kinds = { "File", "Module", "Namespace", "Package", "Class", "Method", "Property", @@ -33,8 +33,6 @@ M.kinds = { "EnumMember", "Struct", "Event", "Operator" } -function M.icon_from_kind(kind) - return M[M.kinds[kind]] -end +function M.icon_from_kind(kind) return M[M.kinds[kind]].icon end return M