Skip to content

Weird document highlighting #1670

@delafthi

Description

@delafthi

How are you using the lua-language-server?

NeoVim

Which OS are you using?

Linux

What is the issue affecting?

Other

Expected Behaviour

Only instances of the variable I ran vim.lsp.buf.document_highlight() on should be highlighted with LspReferenceRead or LspReferenceWrite (I'm not sure whether LspReferenceText is used). Thus, foo shouln't be highlighted (see the images in the next section).

Actual Behaviour

Somehow foo is also highlighted with LspReferenceWrite (LspReferenceWrite = blue bg, LspReferenceRead = green bg, LspReferenceText = red bg).
wrong_hl

However, if I add a line after foo gets initialized where foo gets another value, the highlighting is correct.
correct_hl

If I read foo instead of writing it the highlighting is still wrong.
still_wrong_hl

Reproduction steps

  1. Create a test file test.lua
  2. Open the test file and past the following text:
local zing = foo
local foo = 4

local bar = {
  baz = foo
}

bar.baz = 5

print(bar.baz)
  1. Activate the language-server
  2. Activate document highlight with the field baz. In nvim place the cursor over the field baz and run :lua vim.lsp.buf.document_highlight().
  3. Make sure the your hl colors for LspReference... are distinguishable from the rest.

Additional Notes

No response

Log File

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions