hrsh7th / nvim-cmp

A completion plugin for neovim coded in Lua.
MIT License
7.45k stars 370 forks source link

feature request: support labeldetail field #1873

Closed xzbdmw closed 2 months ago

xzbdmw commented 2 months ago

Currently custom_view support three fields, kind, abbr and menu, and menu field is left-align, which is a bit awkward because if I set capabilities.textdocument.completion.labelDetailsSupport=true, some lsp(rust-analyzer for example) sends back something like:

    --  detail: {
    --   description = "pub fn shl(self, rhs: Rhs) -> Self::Output",
    --   detail = " (use std::ops::Shl)"
    -- }

and cmp simply concat these strings in menu field, something looks like:

截屏2024-04-08 02 37 33

and if I cut off menu field it looks like:

截屏2024-04-08 02 39 01

The disadvantage of this approach is that the starting position on the leftmost side of all menus must be greater than the longest string in abbr, leaving many remaining useless spaces in between, I would like add a new field called detail to stay closely behind abbr, and leave menu field right unchanged(left algin)

note: vscode indeed have a detail field in completion items, for detail, it follows abbr and for description, it sitck to right side.

截屏2024-04-08 02 47 40
bew commented 2 months ago

Why did you you close? @xzbdmw

xzbdmw commented 2 months ago

Hmm, I just found left-align is more tidy for me.