neovim/nvim-lspconfig

`document_highlight` is not respected in the configuration

zivkovicn opened this issue · 3 comments

Description

Description

This option stoped working, in my configuration I want to have this turned off, but it stopped working from some recent updates. The words are being highlighted.

I tried disabling the LSP in the file, just to be sure that it stops highlighting - and that works, so it is LSP related.

return {
  "neovim/nvim-lspconfig",
  opts = {
    -- disable LSP word highlight under the cursor
    document_highlight = false
  }
}

here is the quick video:

Screen.Recording.2024-11-11.at.10.48.07.PM.mov

Any suggestion?

there never have document_highlight

Assuming you're using something like LazyVim. You should probably check there, might be something like the vim-illuminate plugin.

yeah, I'm using LazyVim, and I have vim-illuminate disabled, oddly, this worked before (but there was major update for LazyVim in pas few days - so it could be related).

I achieve the needed with autocmd:

vim.api.nvim_create_autocmd("LspAttach", {
  callback = function(args)
    local client = vim.lsp.get_client_by_id(args.data.client_id)
    if client == nil then
      return
    end

    -- Disable word highlighting under the cursor
    if client.server_capabilities.documentHighlightProvider then
      client.server_capabilities.documentHighlightProvider = false
    end
  end,
})

thanks both for looking into this.