summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-08-23 11:27:28 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-08-23 11:27:28 +0800
commit95ea163397963b52278b9eb70f2adfebe5490014 (patch)
tree8cd178749946547ff736b46a06bcaa2d79372fb0 /script
parent28e63e50c48126f2438d1ea5f5163352a27bfbcf (diff)
downloadlua-language-server-95ea163397963b52278b9eb70f2adfebe5490014.zip
resolve #586 improve showing multi comments at enums
Diffstat (limited to 'script')
-rw-r--r--script/core/hover/description.lua20
1 files changed, 16 insertions, 4 deletions
diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua
index 9ec5cd72..fc220c74 100644
--- a/script/core/hover/description.lua
+++ b/script/core/hover/description.lua
@@ -166,13 +166,25 @@ local function buildEnumChunk(docType, name)
end
lines[#lines+1] = ('%s: %s'):format(name, table.concat(types))
for _, enum in ipairs(enums) do
- lines[#lines+1] = (' %s %s%s'):format(
- (enum.default and '->')
+ local enumDes = (' %s %s'):format(
+ (enum.default and '->')
or (enum.additional and '+>')
or ' |',
- enum[1],
- enum.comment and (' -- %s'):format(enum.comment) or ''
+ enum[1]
)
+ if enum.comment then
+ local first = true
+ local len = #enumDes
+ for comm in enum.comment:gmatch '[^\r\n]+' do
+ if first then
+ first = false
+ enumDes = ('%s -- %s'):format(enumDes, comm)
+ else
+ enumDes = ('%s\n%s -- %s'):format(enumDes, (' '):rep(len), comm)
+ end
+ end
+ end
+ lines[#lines+1] = enumDes
end
return table.concat(lines, '\n')
end