+20
-10
lines changedFilter options
+20
-10
lines changed Original file line number Diff line number Diff line change
@@ -162,21 +162,23 @@ end
162
162
163
163
164
164
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references
165
-
M['textDocument/references'] =function(_, result, ctx, config)
165
+
M['textDocument/references'] = function(_, result, ctx, config)
166
166
if not result or vim.tbl_isempty(result) then
167
167
vim.notify('No references found')
168
168
else
169
169
config = config or {}
170
170
if config.loclist then
171
171
vim.fn.setloclist(0, {}, ' ', {
172
-
title = 'Language Server';
172
+
title = 'References';
173
173
items = util.locations_to_items(result, ctx.offset_encoding);
174
+
context = ctx;
174
175
})
175
176
api.nvim_command("lopen")
176
177
else
177
178
vim.fn.setqflist({}, ' ', {
178
-
title = 'Language Server';
179
+
title = 'References';
179
180
items = util.locations_to_items(result, ctx.offset_encoding);
181
+
context = ctx;
180
182
})
181
183
api.nvim_command("botright copen")
182
184
end
@@ -193,23 +195,26 @@ end
193
195
--- loclist: (boolean) use the location list (default is to use the quickfix list)
194
196
---
195
197
---@param map_result function `((resp, bufnr) -> list)` to convert the response
196
-
---@param entity name of the resource used in a `not found` error message
197
-
local function response_to_list(map_result, entity)
198
-
return function(_,result, ctx, config)
198
+
---@param entity string name of the resource used in a `not found` error message
199
+
---@param title_fn function Function to call to generate list title
200
+
local function response_to_list(map_result, entity, title_fn)
201
+
return function(_, result, ctx, config)
199
202
if not result or vim.tbl_isempty(result) then
200
203
vim.notify('No ' .. entity .. ' found')
201
204
else
202
205
config = config or {}
203
206
if config.loclist then
204
207
vim.fn.setloclist(0, {}, ' ', {
205
-
title = 'Language Server';
208
+
title = title_fn(ctx);
206
209
items = map_result(result, ctx.bufnr);
210
+
context = ctx;
207
211
})
208
212
api.nvim_command("lopen")
209
213
else
210
214
vim.fn.setqflist({}, ' ', {
211
-
title = 'Language Server';
215
+
title = title_fn(ctx);
212
216
items = map_result(result, ctx.bufnr);
217
+
context = ctx;
213
218
})
214
219
api.nvim_command("botright copen")
215
220
end
@@ -219,10 +224,15 @@ end
219
224
220
225
221
226
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentSymbol
222
-
M['textDocument/documentSymbol'] = response_to_list(util.symbols_to_items, 'document symbols')
227
+
M['textDocument/documentSymbol'] = response_to_list(util.symbols_to_items, 'document symbols', function(ctx)
228
+
local fname = vim.fn.fnamemodify(vim.uri_to_fname(ctx.params.textDocument.uri), ":.")
229
+
return string.format('Symbols in %s', fname)
230
+
end)
223
231
224
232
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_symbol
225
-
M['workspace/symbol'] = response_to_list(util.symbols_to_items, 'symbols')
233
+
M['workspace/symbol'] = response_to_list(util.symbols_to_items, 'symbols', function(ctx)
234
+
return string.format("Symbols matching '%s'", ctx.params.query)
235
+
end)
226
236
227
237
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rename
228
238
M['textDocument/rename'] = function(_, result, ctx, _)
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4