From 187579fe197ddd844bc0b0979e7f53c646f4235e Mon Sep 17 00:00:00 2001 From: Mathias Fussenegger Date: Thu, 11 Mar 2021 23:49:59 +0100 Subject: feat(lsp): include original request params in handler ctx This is mostly motivated by https://github.com/neovim/neovim/issues/12326 Client side commands might need to access the original request parameters. Currently this is already possible by using closures with `vim.lsp.buf_request`, but the global handlers so far couldn't access the request parameters. --- runtime/doc/lsp.txt | 6 ++++++ runtime/lua/vim/lsp.lua | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index 48d65a22b6..c434f6db66 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -224,6 +224,11 @@ For |lsp-request|, each |lsp-handler| has this signature: > The ID of the |vim.lsp.client|. {bufnr} (Buffer) Buffer handle, or 0 for current. + + {params} (table|nil) + The parameters used in the original request + which resulted in this handler + call. {config} (table) Configuration for the handler. @@ -234,6 +239,7 @@ For |lsp-request|, each |lsp-handler| has this signature: > To configure a particular |lsp-handler|, see: |lsp-handler-configuration| + Returns: ~ The |lsp-handler| can respond by returning two values: `result, err` Where `err` must be shaped like an RPC error: diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 90c5872f11..17ba4939bd 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -896,7 +896,7 @@ function lsp.start_client(config) local _ = log.debug() and log.debug(log_prefix, "client.request", client_id, method, params, handler, bufnr) return rpc.request(method, params, function(err, result) - handler(err, result, {method=method, client_id=client_id, bufnr=bufnr}) + handler(err, result, {method=method, client_id=client_id, bufnr=bufnr, params=params}) end) end -- cgit