@@ -2,7 +2,7 @@ local M = {}
22
33local mentions_namespace = vim .api .nvim_create_namespace (' OpencodeMentions' )
44
5- function M .highlight_all_mentions (buf )
5+ function M .highlight_all_mentions (buf , callback )
66 -- Pattern for mentions
77 local mention_pattern = ' @[%w_%-%./][%w_%-%./]*'
88
@@ -24,6 +24,10 @@ function M.highlight_all_mentions(buf)
2424 break
2525 end
2626
27+ if callback then
28+ callback (line :sub (mention_start + 1 , mention_end ), row , mention_start , mention_end )
29+ end
30+
2731 -- Add extmark for this mention
2832 vim .api .nvim_buf_set_extmark (buf , mentions_namespace , row - 1 , mention_start - 1 , {
2933 end_col = mention_end ,
@@ -66,4 +70,25 @@ function M.mention(get_name)
6670 end )
6771end
6872
73+ function M .restore_mentions (buf )
74+ local context = require (' opencode.context' )
75+
76+ context .clear_subagents ()
77+ context .clear_files ()
78+
79+ M .highlight_all_mentions (buf , function (name )
80+ local agents = require (' opencode.config_file' ).get_subagents ()
81+
82+ if vim .tbl_contains (agents , name ) then
83+ require (' opencode.context' ).add_subagent (name )
84+ return
85+ end
86+
87+ if vim .fn .filereadable (name ) == 1 then
88+ require (' opencode.context' ).add_file (name )
89+ return
90+ end
91+ end )
92+ end
93+
6994return M
0 commit comments