`document_highlight` takes too long to take effect

Hi everyone.

I do have a functional configuration where LSP is working as intended, except the fact that document_highlight, although working, it’s taking too long to highlight whatever symbol I am in (3-4 seconds).

I do use a function that is assigned to on_attach on a client:

local on_attach = function(client, bufnr)
    if client.resolved_capabilities.document_highlight then
        vim.api.nvim_exec([[
          hi LspReferenceRead cterm=bold ctermbg=red guibg=LightYellow
          hi LspReferenceText cterm=bold ctermbg=red guibg=LightYellow
          hi LspReferenceWrite cterm=bold ctermbg=red guibg=LightYellow
          augroup lsp_document_highlight
            autocmd! * <buffer>
            autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight()
            autocmd CursorMovedI <buffer> lua vim.lsp.buf.clear_references()
          augroup END
        ]], false)
    end
end
local LspConfig = require('lspconfig')
LspConfig.sumneko_lua.setup({
    on_attach = on_attach,
})

I tried to search the documentation, unsuccessfully, for some setting related to the delay, but did not find anything.
I also tried to search Github Issues on the nvim-lspconfig repository and this forum too.

Thank you!

EDIT:

Wow, it was such a simple thing:

vim.opt.updatetime=300

This is what determines how fast CursorHold triggers.