Skip to content

bug: lsp doc hover incorrectly positioned #1122

@cameronr

Description

@cameronr

Did you check docs and existing issues?

  • I have read all the noice.nvim docs
  • I have updated the plugin to the latest version before submitting this issue
  • I have searched the existing issues of noice.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.11.2

Operating system/version

MacOS 15.5

Describe the bug

There are a several different cases where the lsp hover window is incorrectly positioned, including several cases where it can overlap the cursor.

When lsp_doc_border is enabled, there are two issues:

  1. The border isn't factoring in when anchoring the Nui window so it can end up overlapping the current line. To see this, there must be exactly height (default in config is 20) lines below the cursor:
Image
  1. When S anchoring (i.e. drawing the window above the cursor line), the border isn't factored in so the window is offset too high:
Image

The same issue also applies when 'E' anchoring:
Image

  1. Even with those cases fixed, the hover window is still positioned incorrectly if there's not enough space to put it below the cursor (i.e. the return from util/nui.lua:anchor starts with "S") because the hover window isn't resized to make sure it fits in the space above:
Image

Steps To Reproduce

  1. have lsp_doc_border = true, in presets

Case 1:

  1. Find an lsp doc entry that's at least 20 lines long
  2. make sure there are exactly 20 lines below the cursor
  3. Bring up the hover window via K or vim.lsp.buf.hover()

Case 2:

  1. Position cursor in the lower part of the screen (to force hover window to go above the cursor)
  2. Bring up the hover window via K or vim.lsp.buf.hover()

Case 3:

  1. Find a hover doc entry that's longer than the number of lines below the cursor
  2. Bring up the hover window via K or vim.lsp.buf.hover()

Expected Behavior

Case 1: Hover window shouldn't overlap the cursor line (or extend into the status line). Instead, it should be displayed above the cursor line

Case 2: Hover window should be position directly above the cursor line (not two lines above)

Case 3: Hover window should be positioned wherever there are the most number of lines (according to vim.go.lines not winheight) and it should be resized to not overlap the cursor

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    { "folke/noice.nvim", opts = {
      presets = {
        bottom_search = true,
        command_palette = true,
        long_message_to_split = true,
        inc_rename = false,
        lsp_doc_border = true,
      },
    } },
    -- add any other plugins here
  },
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions