@@ -108,6 +108,59 @@ local function is_decompiled(bufname)
108108 return vim .fn .finddir (bufname :sub (1 , endpos ), uv .os_tmpdir ()) ~= ' '
109109end
110110
111+ --- @param client vim.lsp.Client
112+ --- @param action table
113+ local function apply_action (client , action )
114+ if action .edit then
115+ vim .lsp .util .apply_workspace_edit (action .edit , client .offset_encoding )
116+ end
117+ if action .command then
118+ client :exec_cmd (action .command )
119+ end
120+ end
121+
122+ --- @param client vim.lsp.Client
123+ --- @param command table
124+ --- @param bufnr integer
125+ local function handle_fix_all_action (client , command , bufnr )
126+ local arg = command .arguments and command .arguments [1 ]
127+ if type (arg ) ~= ' table' then
128+ vim .notify (' roslyn_ls: invalid fixAllCodeAction arguments' , vim .log .levels .ERROR )
129+ return
130+ end
131+
132+ local flavors = arg .FixAllFlavors
133+ if type (flavors ) ~= ' table' or vim .tbl_isempty (flavors ) then
134+ vim .notify (' roslyn_ls: fixAllCodeAction has no FixAllFlavors' , vim .log .levels .WARN )
135+ return
136+ end
137+
138+ vim .ui .select (flavors , {
139+ prompt = ' Fix All Scope:' ,
140+ }, function (chosen_scope )
141+ if not chosen_scope then
142+ return
143+ end
144+
145+ client :request (' codeAction/resolveFixAll' , {
146+ title = command .title ,
147+ data = arg ,
148+ scope = chosen_scope ,
149+ }, function (err , resolved )
150+ if err then
151+ vim .notify (
152+ ' roslyn_ls: fixAllCodeAction resolve error: ' .. (err .message or tostring (err )),
153+ vim .log .levels .ERROR
154+ )
155+ return
156+ end
157+ if resolved then
158+ apply_action (client , resolved )
159+ end
160+ end , bufnr )
161+ end )
162+ end
163+
111164--- @type vim.lsp.Config
112165return {
113166 name = ' roslyn_ls' ,
@@ -163,20 +216,6 @@ return {
163216 return
164217 end
165218
166- local function apply_action (action )
167- if not action then
168- return
169- end
170-
171- if action .edit then
172- vim .lsp .util .apply_workspace_edit (action .edit , client .offset_encoding )
173- end
174-
175- if action .command then
176- client :exec_cmd (action .command )
177- end
178- end
179-
180219 local function handle (action )
181220 if not action then
182221 return
@@ -188,18 +227,16 @@ return {
188227 vim .notify (err .message or tostring (err ), vim .log .levels .ERROR )
189228 return
190229 end
191-
192230 if resolved then
193231 handle (resolved )
194232 end
195233 end , ctx .bufnr )
196-
197234 return
198235 end
199236
200237 local nested = vim .islist (action ) and action or action .NestedCodeActions
201238 if type (nested ) ~= ' table' or vim .tbl_isempty (nested ) then
202- apply_action (action )
239+ apply_action (client , action )
203240 return
204241 end
205242
@@ -222,6 +259,11 @@ return {
222259
223260 handle (arg )
224261 end ,
262+
263+ [' roslyn.client.fixAllCodeAction' ] = function (command , ctx )
264+ local client = assert (vim .lsp .get_client_by_id (ctx .client_id ))
265+ handle_fix_all_action (client , command , ctx .bufnr )
266+ end ,
225267 },
226268
227269 root_dir = function (bufnr , cb )
0 commit comments