Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend type -> hl_group mapping with more types; Make case insensitive #1282

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading