aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp.lua
diff options
context:
space:
mode:
authorChinmay Dalal <dalal.chinmay.0101@gmail.com>2023-06-11 15:23:37 +0530
committerGitHub <noreply@github.com>2023-06-11 11:53:37 +0200
commit643546b82b4bc0c29ca869f81af868a019723d83 (patch)
treedcabb24372fa2d5157cce4b9b8eea2b0c9927735 /runtime/lua/vim/lsp.lua
parentcce9460524aa17bcd4daa095f4706220b81f8845 (diff)
downloadrneovim-643546b82b4bc0c29ca869f81af868a019723d83.tar.gz
rneovim-643546b82b4bc0c29ca869f81af868a019723d83.tar.bz2
rneovim-643546b82b4bc0c29ca869f81af868a019723d83.zip
feat(lsp): add handlers for inlay hints (#23736)
initial support; public API left for a follow-up PR
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r--runtime/lua/vim/lsp.lua17
1 files changed, 12 insertions, 5 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 1d9a91801a..6f9a6c460b 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -17,6 +17,7 @@ local if_nil = vim.F.if_nil
local lsp = {
protocol = protocol,
+ _inlay_hint = require('vim.lsp._inlay_hint'),
handlers = default_handlers,
@@ -60,6 +61,8 @@ lsp._request_name_to_capability = {
['textDocument/documentHighlight'] = { 'documentHighlightProvider' },
['textDocument/semanticTokens/full'] = { 'semanticTokensProvider' },
['textDocument/semanticTokens/full/delta'] = { 'semanticTokensProvider' },
+ ['textDocument/inlayHint'] = { 'inlayHintProvider' },
+ ['inlayHint/resolve'] = { 'inlayHintProvider', 'resolveProvider' },
}
-- TODO improve handling of scratch buffers with LSP attached.
@@ -1498,16 +1501,20 @@ function lsp.start_client(config)
end
-- Ensure pending didChange notifications are sent so that the server doesn't operate on a stale state
changetracking.flush(client, bufnr)
+ local version = util.buf_versions[bufnr]
bufnr = resolve_bufnr(bufnr)
if log.debug() then
log.debug(log_prefix, 'client.request', client_id, method, params, handler, bufnr)
end
local success, request_id = rpc.request(method, params, function(err, result)
- handler(
- err,
- result,
- { method = method, client_id = client_id, bufnr = bufnr, params = params }
- )
+ local context = {
+ method = method,
+ client_id = client_id,
+ bufnr = bufnr,
+ params = params,
+ version = version,
+ }
+ handler(err, result, context)
end, function(request_id)
local request = client.requests[request_id]
request.type = 'complete'