hrsh7th / nvim-cmp

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

Documentation window obstructs suggestions window when suggestions window is too wide. #1812

Open zuqini opened 5 months ago

zuqini commented 5 months ago

FAQ

Announcement

Minimal reproducible full config

if has('vim_starting')
  set encoding=utf-8
endif
scriptencoding utf-8

if &compatible
  set nocompatible
endif

let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir .. '/plug.vim')
  execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end

execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/vim-vsnip'
Plug 'neovim/nvim-lspconfig'
call plug#end()
PlugInstall | quit

" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require "cmp"
cmp.setup {
  view = {
    entries = { name = 'custom', selection_order = 'near_cursor' }
  },
  snippet = {
    expand = function(args)
      vim.fn["vsnip#anonymous"](args.body)
    end,
  },

  mapping = {
    ["<Tab>"] = cmp.mapping(function(fallback)
      if cmp.visible() then
        cmp.select_next_item()
      else
        fallback()
      end
    end, { "i", "s" }),
  },

  sources = cmp.config.sources({
    { name = "nvim_lsp" },
    { name = "buffer" },
  }),
}
EOF

lua << EOF
local capabilities = require('cmp_nvim_lsp').default_capabilities()

require'lspconfig'.pyright.setup {
  capabilities = capabilities,
}
EOF

Description

The documentation window obstructs suggestions window when suggestions window is too wide. This seems to only happen when the windows are set to be bordered and selection_order = 'near_cursor'. See the screenshots below in the "Steps to Reproduce" section.

Steps to reproduce

  1. Ensure the pyright language server is available on the PATH
  2. echo "import sys" > test.py
  3. nvim -u ~/cmp-repro.vim test.py
  4. Drag the window to be narrow width-wise, like in the provided screenshot.
  5. Begin typing in the next line: sys.audit.
  6. Press tab to go to the first result
  7. Observe that the documentation covers the suggestion window. (Note that this does not happen when we don't set cmp.config.window.bordered()) image

This repros the issue by using an extremely narrow window, but here is an example that can happen with a normal window size when the suggestion window is wide from its long method signatures: image

Expected behavior

We do not expect the documentation to cover the suggestion window. When the bordered window is not set, the documentation either does not show or only takes up the space around the suggestions.

image

Actual behavior

Documentations window blocks the suggestions window. See the screenshot in "Steps to Reproduce" section.

Additional context

No response

infamous55 commented 5 months ago

Hello! I am facing the same problem. Here is a screenshot for reference: image