@@ -1514,6 +1514,7 @@ local function tryluaDocCate(word, results)
15141514 ' module' ,
15151515 ' async' ,
15161516 ' nodiscard' ,
1517+ ' cast' ,
15171518 } do
15181519 if matchKey (word , docType ) then
15191520 results [# results + 1 ] = {
@@ -1662,8 +1663,27 @@ local function tryluaDocBySource(state, position, source, results)
16621663 }
16631664 end
16641665 end
1666+ return true
16651667 elseif source .type == ' doc.module' then
16661668 collectRequireNames (' require' , state .uri , source .module or ' ' , source , source .smark , position , results )
1669+ return true
1670+ elseif source .type == ' doc.cast.name' then
1671+ local locals = guide .getVisibleLocals (state .ast , position )
1672+ for name , loc in util .sortPairs (locals ) do
1673+ if matchKey (source [1 ], name ) then
1674+ results [# results + 1 ] = {
1675+ label = name ,
1676+ kind = define .CompletionItemKind .Variable ,
1677+ id = stack (function () --- @async
1678+ return {
1679+ detail = buildDetail (loc ),
1680+ description = buildDesc (loc ),
1681+ }
1682+ end ),
1683+ }
1684+ end
1685+ end
1686+ return true
16671687 end
16681688 return false
16691689end
@@ -1758,6 +1778,22 @@ local function tryluaDocByErr(state, position, err, docState, results)
17581778 end
17591779 elseif err .type == ' LUADOC_MISS_MODULE_NAME' then
17601780 collectRequireNames (' require' , state .uri , ' ' , docState , nil , position , results )
1781+ elseif err .type == ' LUADOC_MISS_LOCAL_NAME' then
1782+ local locals = guide .getVisibleLocals (state .ast , position )
1783+ for name , loc in util .sortPairs (locals ) do
1784+ if name ~= ' _ENV' then
1785+ results [# results + 1 ] = {
1786+ label = name ,
1787+ kind = define .CompletionItemKind .Variable ,
1788+ id = stack (function () --- @async
1789+ return {
1790+ detail = buildDetail (loc ),
1791+ description = buildDesc (loc ),
1792+ }
1793+ end ),
1794+ }
1795+ end
1796+ end
17611797 end
17621798end
17631799
0 commit comments