diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-01-04 17:19:42 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-01-04 17:19:42 +0800 |
commit | fc5716feb8793140f63218fa2baefdf25c603dd7 (patch) | |
tree | a9d0a62c5236e90ff496a81a93e178c273ffd520 | |
parent | 42618f2abc89a73403ac79c1f5f0e62d512df1a0 (diff) | |
download | lua-language-server-fc5716feb8793140f63218fa2baefdf25c603dd7.zip |
folding LuaDoc
-rw-r--r-- | changelog.md | 2 | ||||
-rw-r--r-- | script/core/folding.lua | 17 | ||||
-rw-r--r-- | script/provider/provider.lua | 5 |
3 files changed, 22 insertions, 2 deletions
diff --git a/changelog.md b/changelog.md index 319efe1f..d2e1cc4d 100644 --- a/changelog.md +++ b/changelog.md @@ -2,7 +2,7 @@ ## 1.10.0 * `NEW` workspace: supports `.dll`(`.so`) in `require` -* `NEW` folding: +* `NEW` folding: `---@class` and docs of function * `CHG` supports `~` in command line * `CHG` completion: improve workspace words * `FIX` [#339](https://github.com/sumneko/lua-language-server/issues/339) diff --git a/script/core/folding.lua b/script/core/folding.lua index cc14728b..f7657631 100644 --- a/script/core/folding.lua +++ b/script/core/folding.lua @@ -9,6 +9,14 @@ local Care = { kind = 'region', } results[#results+1] = folding + if source.bindDocs then + results[#results+1] = { + start = source.bindDocs[1].start, + finish = source.bindDocs[#source.bindDocs].finish, + kind = 'comment', + hideLastLine = true, + } + end end, ['do'] = function (source, text, results) local folding = { @@ -98,6 +106,15 @@ local Care = { } results[#results+1] = folding end, + ['doc.class'] = function (source, text, results) + local folding = { + start = source.start, + finish = source.bindGroup[#source.bindGroup].finish, + kind = 'comment', + hideLastLine = true, + } + results[#results+1] = folding + end, } return function (uri) diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 9cb701c6..60923b95 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -702,7 +702,10 @@ proto.on('textDocument/foldingRange', function (params) local results = {} for _, region in ipairs(regions) do local startLine = define.position(lines, text, region.start).line - local endLine = define.position(lines, text, region.finish).line - 1 + local endLine = define.position(lines, text, region.finish).line + if not region.hideLastLine then + endLine = endLine - 1 + end if startLine < endLine then results[#results+1] = { startLine = startLine, |