Skip to content

Commit

Permalink
Extend type -> hl_group mapping with more types; Make case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
mfussenegger committed Jul 17, 2024
1 parent 6f79b82 commit 0a54fc9
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lua/dap/entity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ local M = {}
local variable = {}
M.variable = variable

local syntax_mapping = {
boolean = 'Boolean',
String = 'String',
int = 'Number',
long = 'Number',
double = 'Float',
float = 'Float',
local types_to_hl_group = {
boolean = "Boolean",
string = "String",
int = "Number",
long = "Number",
number = "Number",
double = "Float",
float = "Float",
["function"] = "Function",
}


Expand All @@ -35,7 +37,7 @@ function variable.render_parent(var)
if var.name then
return variable.render_child(var --[[@as dap.Variable]], 0)
end
local syntax_group = var.type and syntax_mapping[var.type]
local syntax_group = var.type and types_to_hl_group[var.type:lower()]
if syntax_group then
return var.result, {{syntax_group, 0, -1},}
end
Expand All @@ -51,7 +53,7 @@ function variable.render_child(var, indent)
{'Identifier', indent, #var.name + indent + 1}
}
local prefix = string.rep(' ', indent) .. var.name .. ': '
local syntax_group = var.type and syntax_mapping[var.type]
local syntax_group = var.type and types_to_hl_group[var.type]
if syntax_group then
table.insert(hl_regions, {syntax_group, #prefix, -1})
end
Expand Down

0 comments on commit 0a54fc9

Please sign in to comment.