hrsh7th / nvim-cmp

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

Completion windows donot resize properly for certain Rust types #1673

Open salimp2009 opened 1 year ago

salimp2009 commented 1 year 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'
Plug "simrat39/rust-tools.nvim" 
call plug#end()
PlugInstall | quit

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

  mapping = {
    ['<CR>'] = cmp.mapping.confirm({ select = true })
  },

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

lua << EOF
local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities())
local lsp_attach = function(client, buf)
    -- Example maps, set your own with vim.api.nvim_buf_set_keymap(buf, "n", <lhs>, <rhs>, { desc = <desc> })
    -- or a plugin like which-key.nvim
    -- <lhs>        <rhs>                        <desc>
    -- "K"          vim.lsp.buf.hover            "Hover Info"
    -- "<leader>qf" vim.diagnostic.setqflist     "Quickfix Diagnostics"
    -- "[d"         vim.diagnostic.goto_prev     "Previous Diagnostic"
    -- "]d"         vim.diagnostic.goto_next     "Next Diagnostic"
    -- "<leader>e"  vim.diagnostic.open_float    "Explain Diagnostic"
    -- "<leader>ca" vim.lsp.buf.code_action      "Code Action"
    -- "<leader>cr" vim.lsp.buf.rename           "Rename Symbol"
    -- "<leader>fs" vim.lsp.buf.document_symbol  "Document Symbols"
    -- "<leader>fS" vim.lsp.buf.workspace_symbol "Workspace Symbols"
    -- "<leader>gq" vim.lsp.buf.formatting_sync  "Format File"

    vim.api.nvim_buf_set_option(buf, "formatexpr", "v:lua.vim.lsp.formatexpr()")
    vim.api.nvim_buf_set_option(buf, "omnifunc", "v:lua.vim.lsp.omnifunc")
    vim.api.nvim_buf_set_option(buf, "tagfunc", "v:lua.vim.lsp.tagfunc")
end
require("rust-tools").setup({
    server = {
        capabilities = capabilities,
        on_attach = lsp_attach,
    }
})
EOF

Description

Steps to reproduce

Expected behavior

Expected : windows resize according to terminal size instead of overlapping

Actual behavior

completion windows overlap and cannot be read image

Additional context

I used both neovim with my own config and also lunarvim (community config) they both behave the same way for certain rust types. this is reported by many users. my neovim nvim-cmp config https://github.com/salimp2009/deskmach_config/blob/main/nvim/.config/nvim/lua/user/plugins/nvim-cmp.lua

lqzzy commented 1 year ago

I have the same problem

HidemaruOwO commented 1 year ago

me too

HidemaruOwO commented 1 year ago

I researched and this issue seems to show how to fix it https://github.com/hrsh7th/nvim-cmp/issues/1154

salimp2009 commented 1 year ago

I researched and this issue seems to show how to fix it #1154

yeah but I dont think that issue is even closed . and not sure if you really want to remove the menu because it shows where the completion is coming from . I currently have this

    vim_item.menu = ({
        nvim_lsp = "[LSP]",
        nvim_lua = "[NVLUA]",
        luasnip = "[SNPT]",
        buffer = "[BFR]",
        path = "[PATH]",
        cmp_tabnine = "[TBNI]",
        codeium = "[CDEM]",
        copilot = "[CPLT]",
        crates = "[CRAT]",
        emoji = "[EMOJ]",
    })[entry.source.name]

Removing all those looks like a just temporary workaround