fix(lsp): don't overlay insertion-style inline completions (#36477)

* feat(lua): `Range:is_empty()` to check vim.range emptiness

* fix(lsp): don't overlay insertion-style inline completions

**Problem:** Some servers commonly respond with an empty inline
completion range which acts as a position where text should be inserted.
However, the inline completion module assumes that all responses with a
range are deletions + insertions that thus require an `overlay` display
style. This causes an incorrect preview, because the virtual text should
have the `inline` display style (to reflect that this is purely an
insertion).

**Solution:** Only use `overlay` for non-empty replacement ranges.
This commit is contained in:
Riley Bruins
2025-11-09 17:49:25 -08:00
committed by GitHub
parent c6dad6e9df
commit c2c5a0297e
5 changed files with 50 additions and 1 deletions

View File

@@ -248,7 +248,7 @@ function Completor:show(hint)
api.nvim_buf_set_extmark(self.bufnr, namespace, row, col, {
virt_text = virt_text,
virt_lines = virt_lines,
virt_text_pos = current.range and 'overlay' or 'inline',
virt_text_pos = (current.range and not current.range:is_empty() and 'overlay') or 'inline',
hl_mode = 'combine',
})
end