Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Error because textDocument/documentHighlight isn't supported in the current buffer #1294

Closed
4 of 6 tasks
MariaSolOs opened this issue Jun 22, 2024 · 11 comments
Closed
4 of 6 tasks
Labels
invalid This doesn't seem right

Comments

@MariaSolOs
Copy link
Contributor

RTFM Checklist

  • I have searched exisiting issues / discussions
  • I have read the Wiki including the Advanced section
  • I have read man fzf / I am well versed in shell fzf

Operating system

Fedora 40

Shell

fish

Neovim version (nvim --version)

v0.11.0-dev-286+g38a1d41ac

Fzf version (fzf --version)

0.44.1

Output of :lua print(os.getenv('FZF_DEFAULT_OPTS'))

--color=fg:#f8f8f2,bg:#0e1419,hl:#e11299,fg+:#f8f8f2,bg+:#44475a,hl+:#e11299,info:#f1fa8c,prompt:#5 0fa7b,pointer:#ff79c6,marker:#ff79c6,spinner:#a4ffff,header:#6272a4 --cycle

Is the problem reproducible with mini.sh?

  • My issue is reproducible with mini.sh
  • My issue IS NOT reproducible with mini.sh
  • I have not tested with mini.sh (not relevant, requires LSP, Windows, etc)

Fzf-lua configuration

require('fzf-lua').setup({
  fzf_opts = {
    ['--info'] = 'default',
    ['--layout'] = 'reverse-list',
  },
  global_git_icons = false,
  files = {
    winopts = {
      preview = { hidden = 'hidden' },
    },
  },
  oldfiles = {
    include_current_session = true,
    winopts = { preview = { hidden = 'hidden' } },
  },
})

Describe the bug / steps to reproduce

During the last couple of days I've seen the error below pop up once in a while when using the files picker. It doesn't always happen, but lately I've been working on a simple Rust project.

image

@MariaSolOs MariaSolOs added the bug Something isn't working label Jun 22, 2024
@ibhagwan
Copy link
Owner

This seems to me to be coming from an auto command making a request to textDocument/documentHighlight which happens on BufEnter triggered by the vim.cmd from fzf-lua’s buf switch, fzf-lua does not make such request, ever.

@MariaSolOs
Copy link
Contributor Author

Okay, I will explore my config and other plugins! Sorry for the noisy issue.

@ibhagwan
Copy link
Owner

Okay, I will explore my config and other plugins! Sorry for the noisy issue.

Did you find the culprit? We can leave this open until you have a solution, I’m still doubtful it’s fzf-lua but you never know.

@MariaSolOs
Copy link
Contributor Author

Did you find the culprit? We can leave this open until you have a solution, I’m still doubtful it’s fzf-lua but you never know.

I'm pretty sure the issue is coming from ccc.nvim. I tried disabling it for now to validate my hypothesis.

@ibhagwan
Copy link
Owner

Did you find the culprit? We can leave this open until you have a solution, I’m still doubtful it’s fzf-lua but you never know.

I'm pretty sure the issue is coming from ccc.nvim. I tried disabling it for now to validate my hypothesis.

Nice find, ty for the update @MariaSolOs!

@ibhagwan ibhagwan added invalid This doesn't seem right and removed bug Something isn't working labels Jun 23, 2024
@MariaSolOs
Copy link
Contributor Author

Ehhh so after investigating this further it seems to be caused by an autocommand I wrote 😅 Yet I'm quite confused about the error...

I have the following in my on_attach function:

   if client.supports_method(methods.textDocument_documentHighlight) then
        local under_cursor_highlights_group =
            vim.api.nvim_create_augroup('mariasolos/cursor_highlights', { clear = false })
        vim.api.nvim_create_autocmd({ 'CursorHold', 'InsertLeave', 'BufEnter' }, {
            group = under_cursor_highlights_group,
            desc = 'Highlight references under the cursor',
            buffer = bufnr,
            callback = vim.lsp.buf.document_highlight,
        })
        vim.api.nvim_create_autocmd({ 'CursorMoved', 'InsertEnter', 'BufLeave' }, {
            group = under_cursor_highlights_group,
            desc = 'Clear highlight references',
            buffer = bufnr,
            callback = vim.lsp.buf.clear_references,
        })
    end

And so the error message seems to indicate that somehow there's no client supporting textDocument/documentHighlight in the 1st callback, despite the outer if-check...

@ibhagwan
Copy link
Owner

And so the error message seems to indicate that somehow there's no client supporting textDocument/documentHighlight in the 1st callback, despite the outer if-check...

Maybe an upstream bug? Can you check which buffer is this failing on? Would be interesting to see if this is triggered by one of your existing buffers or an fzf-lua buffer (although the preview shouldn’t trigger LSP attach).

@MariaSolOs
Copy link
Contributor Author

Maybe an upstream bug? Can you check which buffer is this failing on? Would be interesting to see if this is triggered by one of your existing buffers or an fzf-lua buffer (although the preview shouldn’t trigger LSP attach).

Yep I'll try adding extra logging there to have more information when I see the bug. It doesn't always happen, I would say it happen < 5% of the times I use the Files/Recent Files picker.

@ibhagwan
Copy link
Owner

ibhagwan commented Jun 28, 2024

Yep I'll try adding extra logging there to have more information when I see the bug. It doesn't always happen, I would say it happen < 5% of the times I use the Files/Recent Files picker.

Does it happen when you open the picker (most likely from preview) or after selecting the file (I.e. from the edit action)?

@MariaSolOs
Copy link
Contributor Author

Does it happen when you open the picker (most likely from preview) or after selecting the file (I.e. from the edit action)?

It always happen after selecting the entry, so I don't think it's the preview.

@ibhagwan
Copy link
Owner

Does it happen when you open the picker (most likely from preview) or after selecting the file (I.e. from the edit action)?

It always happen after selecting the entry, so I don't think it's the preview.

Than most likely this happens due to the BufEnter event of the selected entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants