@@ -1546,7 +1546,7 @@ local function tryWord(state, position, triggerCharacter, results)
15461546 local env = guide .getENV (state .ast , startPos )
15471547 if env then
15481548 checkGlobal (state , word , startPos , position , env , false , results )
1549- checkModule (state , word , startPos , results )
1549+ checkModule (state , word , startPos , results )
15501550 end
15511551 end
15521552 end
@@ -2256,6 +2256,35 @@ local function tryluaDocOfFunction(doc, results, pad)
22562256 }
22572257end
22582258
2259+ --- Checks for a lua symbol reference in comment
2260+ --- @async
2261+ local function trySymbolReference (state , position , results )
2262+ local doc = getLuaDoc (state , position )
2263+ if not doc then
2264+ return
2265+ end
2266+
2267+ local line = doc .originalComment .text --- @type string
2268+ local col = select (2 , guide .rowColOf (position )) - 2 --- @type integer
2269+
2270+ -- User will ask for completion at end of symbol name so we need to perform a reverse match to see if they are in a symbol reference
2271+ -- Matching in reverse allows the symbol to be of any length and we can still match all the way back to `](lua://` from right to left
2272+ local symbol = string.match (string.reverse (line ), " %)?([%w%s-_.*]*)//:aul%(%]" , # line - col )
2273+
2274+ if symbol then
2275+ -- flip it back the right way around
2276+ symbol = string.reverse (symbol )
2277+
2278+ for _ , match in ipairs (wssymbol (symbol )) do
2279+ results [# results + 1 ] = {
2280+ label = match .name ,
2281+ kind = define .CompletionItemKind .Class ,
2282+ insertText = match .name
2283+ }
2284+ end
2285+ end
2286+ end
2287+
22592288--- @async
22602289local function tryLuaDoc (state , position , results )
22612290 local doc = getLuaDoc (state , position )
@@ -2327,6 +2356,7 @@ end
23272356--- @async
23282357local function tryCompletions (state , position , triggerCharacter , results )
23292358 if getComment (state , position ) then
2359+ trySymbolReference (state , position , results )
23302360 tryLuaDoc (state , position , results )
23312361 tryComment (state , position , results )
23322362 return
0 commit comments