@@ -2256,6 +2256,37 @@ local function tryluaDocOfFunction(doc, results, pad)
22562256 }
22572257end
22582258
2259+ --- Checks for a lua symbol reference in comment and returns an async callback if found
2260+ local function trySymbolReference (state , position , results )
2261+ local doc = getLuaDoc (state , position )
2262+ if not doc then
2263+ return
2264+ end
2265+
2266+ local line = doc .originalComment .text --- @type string
2267+ local col = select (2 , guide .rowColOf (position )) - 2 --- @type integer
2268+
2269+ -- 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
2270+ -- 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
2271+ local symbol = string.match (string.reverse (line ), " %)?(.*)//:aul%(%]" , # line - col )
2272+
2273+ if symbol then
2274+ -- flip it back the right way around
2275+ symbol = string.reverse (symbol )
2276+
2277+ --- @async
2278+ return function ()
2279+ for _ , match in ipairs (wssymbol (symbol )) do
2280+ results [# results + 1 ] = {
2281+ label = match .name ,
2282+ kind = define .CompletionItemKind .Class ,
2283+ insertText = match .name
2284+ }
2285+ end
2286+ end
2287+ end
2288+ end
2289+
22592290--- @async
22602291local function tryLuaDoc (state , position , results )
22612292 local doc = getLuaDoc (state , position )
@@ -2327,8 +2358,13 @@ end
23272358--- @async
23282359local function tryCompletions (state , position , triggerCharacter , results )
23292360 if getComment (state , position ) then
2361+ local callback = trySymbolReference (state , position , results )
2362+ if callback then
2363+ callback ()
2364+ else
2365+ tryComment (state , position , results )
2366+ end
23302367 tryLuaDoc (state , position , results )
2331- tryComment (state , position , results )
23322368 return
23332369 end
23342370 if postfix (state , position , results ) then
0 commit comments