hrsh7th/nvim-cmp

LSP documentation on nvim-qt is narrow

Open

#1206 aperta il 2 ott 2022

Vedi su GitHub
 (0 commenti) (0 reazioni) (0 assegnatari)Lua (437 fork)batch import
bughelp wanted

Metriche repository

Star
 (9420 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

FAQ

  • I have checked the FAQ and it didn't resolve my problem.

Announcement

Minimal reproducible full config

vim.opt.completeopt = "menu,menuone,noselect"

return require("packer").startup(function(use)
    use 'wbthomason/packer.nvim'

    use {
        "neovim/nvim-lspconfig",
        after = "cmp-nvim-lsp",
        config = function()
            local opts = {noremap = true, silent = true}
            vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
            vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
            vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
            vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)

            local on_attach = function(client, bufnr)
                vim.api.nvim_buf_set_option(bufnr, 'omnifunc',
                                            'v:lua.vim.lsp.omnifunc')

                local bufopts = {noremap = true, silent = true, buffer = bufnr}
                vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
                vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
                vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
                vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
                vim.keymap
                    .set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
                vim.keymap.set('n', '<space>wa',
                               vim.lsp.buf.add_workspace_folder, bufopts)
                vim.keymap.set('n', '<space>wr',
                               vim.lsp.buf.remove_workspace_folder, bufopts)
                vim.keymap.set('n', '<space>wl', function()
                    print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
                end, bufopts)
                vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition,
                               bufopts)
                vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
                vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action,
                               bufopts)
                vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
                vim.keymap.set('n', '<space>f', vim.lsp.buf.formatting, bufopts)
            end

            local lsp_flags = {
                debounce_text_changes = 150
            }
            local capabilities = require('cmp_nvim_lsp').update_capabilities(
                                     vim.lsp.protocol.make_client_capabilities())
            require('lspconfig')['pyright'].setup {
                on_attach = on_attach,
                flags = lsp_flags,
                capabilities = capabilities
            }
        end
    }

    use {"L3MON4D3/LuaSnip"}

    use {
        "hrsh7th/nvim-cmp",
        config = function()
            local cmp = require("cmp")
            cmp.setup({
                snippet = {
                    expand = function(args)
                        require('luasnip').lsp_expand(args.body)
                    end
                },
                window = {
                    completion = cmp.config.window.bordered(),
                    documentation = cmp.config.window.bordered()
                },
                mapping = cmp.mapping.preset.insert({
                    ['<C-b>'] = cmp.mapping.scroll_docs(-4),
                    ['<C-f>'] = cmp.mapping.scroll_docs(4),
                    ['<C-Space>'] = cmp.mapping.complete(),
                    ['<C-e>'] = cmp.mapping.abort(),
                    ['<CR>'] = cmp.mapping.confirm({select = true})
                }),
                sources = cmp.config.sources({
                    {name = 'nvim_lsp'},
                    {name = 'luasnip'} 
                }, {{name = 'buffer'}})
            })
        end
    }

    use {"saadparwaiz1/cmp_luasnip"}
    use {"hrsh7th/cmp-nvim-lsp", after = "nvim-cmp"}
end)

Description

The LSP provided documentation popup is fine under a terminal running nvim. But the popup window in nvim-qt shows up too narrow to be useful. I am not sure if this is nvim-cmp or nvim-qt causing this.

Steps to reproduce

With pyright installed, create a new python file x.py and type in:

import os

os.path

Expected behavior

This is nvim on wezterm image

Actual behavior

This is nvim-qt image

Additional context

For fun, I tried it on gnvim, it looks slightly better, but not as good as the terminal one image

Guida contributor