From 12c2c16acf7051d364d29cfd71f2542b0943d8e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Fu=C3=9Fenegger?= Date: Thu, 22 Jun 2023 19:39:57 +0200 Subject: [PATCH] feat(lsp): opt-in to dynamicRegistration for inlay hints (#24102) Since https://github.com/neovim/neovim/pull/23681 there is dynamic registration support. We should use that for new features unless there is a good reason to turn it off. --- runtime/lua/vim/lsp/protocol.lua | 2 +- test/functional/plugin/lsp/inlay_hint_spec.lua | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/runtime/lua/vim/lsp/protocol.lua b/runtime/lua/vim/lsp/protocol.lua index b3a7903420..ea38bfe237 100644 --- a/runtime/lua/vim/lsp/protocol.lua +++ b/runtime/lua/vim/lsp/protocol.lua @@ -642,7 +642,7 @@ function protocol.make_client_capabilities() }, textDocument = { inlayHint = { - dynamicRegistration = false, + dynamicRegistration = true, resolveSupport = { properties = {}, }, diff --git a/test/functional/plugin/lsp/inlay_hint_spec.lua b/test/functional/plugin/lsp/inlay_hint_spec.lua index 103fd8d968..574a4fa5a0 100644 --- a/test/functional/plugin/lsp/inlay_hint_spec.lua +++ b/test/functional/plugin/lsp/inlay_hint_spec.lua @@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local lsp_helpers = require('test.functional.plugin.lsp.helpers') local Screen = require('test.functional.ui.screen') +local eq = helpers.eq local dedent = helpers.dedent local exec_lua = helpers.exec_lua local insert = helpers.insert @@ -65,11 +66,17 @@ describe('inlay hints', function() it( 'inlay hints are applied when vim.lsp.buf.inlay_hint(true) is called', function() - exec_lua([[ - bufnr = vim.api.nvim_get_current_buf() - vim.api.nvim_win_set_buf(0, bufnr) - client_id = vim.lsp.start({ name = 'dummy', cmd = server.cmd }) - ]]) + local res = exec_lua([[ + bufnr = vim.api.nvim_get_current_buf() + vim.api.nvim_win_set_buf(0, bufnr) + client_id = vim.lsp.start({ name = 'dummy', cmd = server.cmd }) + local client = vim.lsp.get_client_by_id(client_id) + return { + supports_method = client.supports_method("textDocument/inlayHint") + } + ]]) + eq(res, { supports_method = true }) + insert(text) exec_lua([[vim.lsp.buf.inlay_hint(bufnr, true)]])