aboutsummaryrefslogtreecommitdiffstats
path: root/lsp/ts_ls.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lsp/ts_ls.lua')
-rw-r--r--lsp/ts_ls.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/lsp/ts_ls.lua b/lsp/ts_ls.lua
index 33cb5995..20f750b3 100644
--- a/lsp/ts_ls.lua
+++ b/lsp/ts_ls.lua
@@ -97,6 +97,32 @@ return {
return vim.NIL
end,
},
+ commands = {
+ ['editor.action.showReferences'] = function(command, ctx)
+ local client = assert(vim.lsp.get_client_by_id(ctx.client_id))
+ local file_uri, position, references = unpack(command.arguments)
+
+ local quickfix_items = vim.lsp.util.locations_to_items(references, client.offset_encoding)
+ vim.fn.setqflist({}, ' ', {
+ title = command.title,
+ items = quickfix_items,
+ context = {
+ command = command,
+ bufnr = ctx.bufnr,
+ },
+ })
+
+ vim.lsp.util.show_document({
+ uri = file_uri,
+ range = {
+ start = position,
+ ['end'] = position,
+ },
+ }, client.offset_encoding)
+
+ vim.cmd('botright copen')
+ end,
+ },
on_attach = function(client, bufnr)
-- ts_ls provides `source.*` code actions that apply to the whole file. These only appear in
-- `vim.lsp.buf.code_action()` if specified in `context.only`.