Repository: neovim/neovim
File: test/functional/plugin/lsp/inlay_hint_spec.lua (Lua)

Code before:
          vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
        end)
        screen:expect({ grid = grid_with_inlay_hints, unchanged = true })
      end)

      it('for all buffers', function()
        exec_lua(function()
          vim.lsp.inlay_hint.enable(false)
        end)
        screen:expect({ grid = grid_without_inlay_hints, unchanged = true })
        n.api.nvim_win_set_buf(0, bufnr2)
        screen:expect({ grid = grid_without_inlay_hints, unchanged = true })

        exec_lua(function()
          vim.lsp.inlay_hint.enable(true)
        end)
        screen:expect({ grid = grid_with_inlay_hints, unchanged = true })
        n.api.nvim_win_set_buf(0, bufnr)
        screen:expect({ grid = grid_with_inlay_hints, unchanged = true })
      end)
    end)
  end)

  describe('get()', function()
    it('returns filtered inlay hints', function()
      local expected = response
      local expected2 = {
        kind = 1,
        paddingLeft = false,
        label = ': int',
        position = {
          character = 10,
          line = 2,
        },
        paddingRight = false,
      }

      exec_lua(function()
        _G.server2 = _G._create_server({
          capabilities = {
            inlayHintProvider = true,
          },
          handlers = {
            ['textDocument/inlayHint'] = function(_, _, callback)
              callback(nil, { expected2 })
            end,
          },
        })
        _G.client2 = vim.lsp.start({ name = 'dummy2', cmd = _G.server2.cmd })
        vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
      end)

Review comment (suggestion):
We could just get rid of `expected` and use `response` directly.

Code after:
          vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
        end)
        screen:expect({ grid = grid_with_inlay_hints, unchanged = true })
      end)

      it('for all buffers', function()
        exec_lua(function()
          vim.lsp.inlay_hint.enable(false)
        end)
        screen:expect({ grid = grid_without_inlay_hints, unchanged = true })
        n.api.nvim_win_set_buf(0, bufnr2)
        screen:expect({ grid = grid_without_inlay_hints, unchanged = true })

        exec_lua(function()
          vim.lsp.inlay_hint.enable(true)
        end)
        screen:expect({ grid = grid_with_inlay_hints, unchanged = true })
        n.api.nvim_win_set_buf(0, bufnr)
        screen:expect({ grid = grid_with_inlay_hints, unchanged = true })
      end)
    end)
  end)

  describe('get()', function()
    it('returns filtered inlay hints', function()
      local expected2 = {
        kind = 1,
        paddingLeft = false,
        label = ': int',
        position = {
          character = 10,
          line = 2,
        },
        paddingRight = false,
      }

      exec_lua(function()
        _G.server2 = _G._create_server({
          capabilities = {
            inlayHintProvider = true,
          },
          handlers = {
            ['textDocument/inlayHint'] = function(_, _, callback)
              callback(nil, { expected2 })
            end,
          },
        })
        _G.client2 = vim.lsp.start({ name = 'dummy2', cmd = _G.server2.cmd })
        vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
      end)