From 35b712381cf91294629f85c8598055f6b5babf06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 2 Feb 2021 11:33:17 +0800 Subject: `LuaDoc` compatible with `--@` --- changelog.md | 1 + script/core/completion.lua | 7 +++---- script/parser/luadoc.lua | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index 27ae4251..e6682a13 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,7 @@ * `NEW` flush cache after 5 min * `NEW` `VSCode` help semantic color with market theme * `CHG` create/delete/rename files no longer reload workspace (only if client supports file operation protocol) +* `CHG` `LuaDoc`: compatible with `--@` * `FIX` `VSCode` settings * `FIX` [#368](https://github.com/sumneko/lua-language-server/issues/368) diff --git a/script/core/completion.lua b/script/core/completion.lua index 83842f45..33c8f70e 100644 --- a/script/core/completion.lua +++ b/script/core/completion.lua @@ -1378,8 +1378,7 @@ local function getLuaDoc(ast, offset) return nil end -local function tryLuaDocCate(line, results) - local word = line:sub(3) +local function tryLuaDocCate(word, results) for _, docType in ipairs { 'class', 'type', @@ -1644,9 +1643,9 @@ local function tryLuaDoc(ast, text, offset, results) return end -- 尝试 ---@$ - local cate = line:match('^-@(%a*)$') + local cate = line:match('^-?%s*@(%a*)$') if cate then - tryLuaDocCate(line, results) + tryLuaDocCate(cate, results) return end end diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index 4512bc9e..fa1cc38b 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -915,7 +915,7 @@ end local function buildLuaDoc(comment) local text = comment.text - local _, startPos = text:find('^%-%s*@') + local _, startPos = text:find('^%-?%s*@') if not startPos then return { type = 'doc.comment', -- cgit v1.2.3