feat(lsp): inlay hints #23984

Add automatic refresh and a public interface on top of #23736

 * add on_reload, on_detach handlers in `enable()` buf_attach, and
  LspDetach autocommand in case of manual detach
* unify `__buffers` and `hint_cache_by_buf`
* use callback bufnr in `on_lines` callback, bufstate: remove __index override
* move user-facing functions into vim.lsp.buf, unify enable/disable/toggle

Closes #18086
This commit is contained in:
Chinmay Dalal
2023-06-20 11:36:54 +05:30
committed by GitHub
parent 72a6643b13
commit ca5de9306c
8 changed files with 146 additions and 60 deletions

View File

@@ -63,7 +63,7 @@ describe('inlay hints', function()
end)
it(
'inlay hints are applied when vim.lsp._inlay_hint.refresh() is called',
'inlay hints are applied when vim.lsp.buf.inlay_hint(true) is called',
function()
exec_lua([[
bufnr = vim.api.nvim_get_current_buf()
@@ -72,7 +72,7 @@ describe('inlay hints', function()
]])
insert(text)
exec_lua([[vim.lsp._inlay_hint.refresh({bufnr = bufnr})]])
exec_lua([[vim.lsp.buf.inlay_hint(bufnr, true)]])
screen:expect({
grid = [[
auto add(int a, int b)-> int { return a + b; } |
@@ -89,7 +89,7 @@ describe('inlay hints', function()
end)
it(
'inlay hints are cleared when vim.lsp._inlay_hint.clear() is called',
'inlay hints are cleared when vim.lsp.buf.inlay_hint(false) is called',
function()
exec_lua([[
bufnr = vim.api.nvim_get_current_buf()
@@ -98,7 +98,7 @@ describe('inlay hints', function()
]])
insert(text)
exec_lua([[vim.lsp._inlay_hint.refresh({bufnr = bufnr})]])
exec_lua([[vim.lsp.buf.inlay_hint(bufnr, true)]])
screen:expect({
grid = [[
auto add(int a, int b)-> int { return a + b; } |
@@ -112,7 +112,7 @@ describe('inlay hints', function()
|
]]
})
exec_lua([[vim.lsp._inlay_hint.clear()]])
exec_lua([[vim.lsp.buf.inlay_hint(bufnr, false)]])
screen:expect({
grid = [[
auto add(int a, int b) { return a + b; } |