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.
This commit is contained in:
Mathias Fußenegger 2023-06-22 19:39:57 +02:00 committed by GitHub
parent 904ad5458d
commit 12c2c16acf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 6 deletions

View File

@ -642,7 +642,7 @@ function protocol.make_client_capabilities()
}, },
textDocument = { textDocument = {
inlayHint = { inlayHint = {
dynamicRegistration = false, dynamicRegistration = true,
resolveSupport = { resolveSupport = {
properties = {}, properties = {},
}, },

View File

@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local lsp_helpers = require('test.functional.plugin.lsp.helpers') local lsp_helpers = require('test.functional.plugin.lsp.helpers')
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local eq = helpers.eq
local dedent = helpers.dedent local dedent = helpers.dedent
local exec_lua = helpers.exec_lua local exec_lua = helpers.exec_lua
local insert = helpers.insert local insert = helpers.insert
@ -65,11 +66,17 @@ describe('inlay hints', function()
it( it(
'inlay hints are applied when vim.lsp.buf.inlay_hint(true) is called', 'inlay hints are applied when vim.lsp.buf.inlay_hint(true) is called',
function() function()
exec_lua([[ local res = exec_lua([[
bufnr = vim.api.nvim_get_current_buf() bufnr = vim.api.nvim_get_current_buf()
vim.api.nvim_win_set_buf(0, bufnr) vim.api.nvim_win_set_buf(0, bufnr)
client_id = vim.lsp.start({ name = 'dummy', cmd = server.cmd }) 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) insert(text)
exec_lua([[vim.lsp.buf.inlay_hint(bufnr, true)]]) exec_lua([[vim.lsp.buf.inlay_hint(bufnr, true)]])