hrsh7th / nvim-cmp

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

Junk characters inside the scroll bar #315

Closed folliehiyuki closed 3 years ago

folliehiyuki commented 3 years ago

This only happens with a big list (either large doc or long list of completions). See screenshots below.

screenshot1 screenshot2

My config:

    local cmp = require('cmp')
    local luasnip = require('luasnip')

    local has_words_before = function()
        local line, col = unpack(vim.api.nvim_win_get_cursor(0))
        return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil
    end

    cmp.setup {
        formatting = {
            format = function(entry, vim_item)
                local lspkind_icons = {
                    Text = '',
                    Method = '',
                    Function = '',
                    Constructor = '',
                    Field = 'ﰠ',
                    Variable = '',
                    Class = 'ﴯ',
                    Interface = '',
                    Module = '',
                    Property = 'ﰠ',
                    Unit = '塞',
                    Value = '',
                    Enum = '',
                    Keyword = '',
                    Snippet = '',
                    Color = '',
                    File = '',
                    Reference = '',
                    Folder = '',
                    EnumMember = '',
                    Constant = '',
                    Struct = '',
                    Event = '',
                    Operator = '',
                    TypeParameter = ''
                }
                -- load lspkind icons
                vim_item.kind = string.format('%s %s', lspkind_icons[vim_item.kind], vim_item.kind)

                vim_item.menu = ({
                    luasnip = '[SNIP]',
                    path = '[PATH]',
                    buffer = '[BUF]',
                    -- calc = '[CALC]',
                    -- nuspell = '[SPELL]',
                    spell = '[SPELL]',
                    emoji = '[EMOJI]',
                    -- treesitter = '[TS]',
                    nvim_lsp = '[LSP]',
                    -- cmp_tabnine = '[TN]',
                    latex_symbols = '[TEX]',
                    -- tmux = '[TMUX]',
                    -- conjure = '[CJ]',
                    orgmode = '[ORG]'
                })[entry.source.name]

                return vim_item
            end
        },
        -- documentation = {
        --     border = {'╭', '─', '╮', '│', '╯', '─', '╰', '│'}
        -- },
        mapping = {
            ['<C-Space>'] = cmp.mapping.complete(),
            ['<C-p>'] = cmp.mapping.select_prev_item(),
            ['<C-n>'] = cmp.mapping.select_next_item(),
            ['<C-b>'] = cmp.mapping.scroll_docs(-4),
            ['<C-f>'] = cmp.mapping.scroll_docs(4),
            ['<C-d>'] = cmp.mapping.close(),
            -- Change choice nodes for luasnip
            ['<C-j>'] = cmp.mapping(function(fallback)
                if luasnip.choice_active() then
                    luasnip.change_choice(-1)
                else
                    fallback()
                end
            end, {'i', 's'}),
            ['<C-k>'] = cmp.mapping(function(fallback)
                if luasnip.choice_active() then
                    luasnip.change_choice(1)
                else
                    fallback()
                end
            end, {'i', 's'}),
            -- supertab-like mapping
            ['<Tab>'] = cmp.mapping(function(fallback)
                if cmp.visible() then
                    cmp.select_next_item()
                elseif luasnip.expand_or_jumpable() then
                    luasnip.expand_or_jump()
                elseif has_words_before() then
                    cmp.complete()
                else
                    fallback()
                end
            end, {'i', 's'}),
            ['<S-Tab>'] = cmp.mapping(function(fallback)
                if cmp.visible() then
                    cmp.select_prev_item()
                elseif luasnip.jumpable(-1) then
                    luasnip.jump(-1)
                else
                    fallback()
                end
            end, {'i', 's'})
        },
        snippet = {
            expand = function(args)
                luasnip.lsp_expand(args.body)
            end
        },
        sources = {
            {name = 'luasnip'},
            {name = 'path'},
            {name = 'buffer'},
            -- {name = 'calc'},
            -- {name = 'nuspell'},
            {name = 'spell'},
            {name = 'emoji'},
            -- {name = 'treesitter'},
            {name = 'nvim_lsp'},
            -- {name = 'cmp_tabnine'},
            {name = 'latex_symbols'},
            -- {name = 'tmux'},
            -- {name = 'conjure'},
            {name = 'orgmode'}
        }
    }
hrsh7th commented 3 years ago

@FollieHiyuki Could you provide you'r using plugin lists?

folliehiyuki commented 3 years ago

Yes. The list is here (lazily copied from PackerStatus):

 • LuaSnip (not loaded)
 • alpha-nvim
 • asyncrun.vim (not loaded)
 • asynctasks.vim (not loaded)
 • bracey.vim (not loaded)
 • bufferline.nvim
 • cmp-buffer (not loaded)
 • cmp-emoji (not loaded)
 • cmp-latex-symbols (not loaded)
 • cmp-nvim-lsp (not loaded)
 • cmp-path (not loaded)
 • cmp-spell (not loaded)
 • cmp_luasnip (not loaded)
 • diffview.nvim (not loaded)
 • editorconfig-vim
 • feline.nvim
 • filetype.nvim
 • friendly-snippets (not loaded)
 • gitsigns.nvim
 • hop.nvim (not loaded)
 • indent-blankline.nvim
 • iswap.nvim (not loaded)
 • lsp_signature.nvim
 • markdown-preview.nvim (not loaded)
 • neogen (not loaded)
 • neogit (not loaded)
 • neoscroll.nvim
 • null-ls.nvim
 • nvim-autopairs (not loaded)
 • nvim-cmp (not loaded)
 • nvim-colorizer.lua (not loaded)
 • nvim-comment (not loaded)
 • nvim-dap
 • nvim-dap-ui
 • nvim-lspconfig
 • nvim-spectre
 • nvim-tree.lua (not loaded)
 • nvim-treesitter
 • nvim-treesitter-context
 • nvim-treesitter-textobjects
 • nvim-ts-autotag (not loaded)
 • nvim-ts-rainbow
 • nvim-web-devicons
 • octo.nvim (not loaded)
 • orgmode.nvim (not loaded)
 • packer.nvim (manually loaded)
 • parinfer-rust (not loaded)
 • persistence.nvim
 • plenary.nvim
 • popup.nvim (not loaded)
 • project.nvim
 • rest.nvim (not loaded)
 • sniprun (not loaded)
 • sqls.nvim (not loaded)
 • symbols-outline.nvim (not loaded)
 • telescope-fzf-native.nvim (not loaded)
 • telescope-project.nvim (not loaded)
 • telescope-symbols.nvim (not loaded)
 • telescope.nvim (not loaded)
 • toggleterm.nvim (not loaded)
 • translate-shell.vim (not loaded)
 • trouble.nvim (not loaded)
 • twilight.nvim (not loaded)
 • undotree (not loaded)
 • vim-easy-align (not loaded)
 • vim-eft
 • vim-illuminate
 • vim-matchup
 • vim-sandwich (not loaded)
 • vim-startuptime (not loaded)
 • which-key.nvim
 • zen-mode.nvim (not loaded)
hrsh7th commented 3 years ago

Thank you. I think it relates to persistence.nvim. I've fixed it maybe .

folliehiyuki commented 3 years ago

Thanks @hrsh7th I just updated to the latest commit and the scroll bar looks normal now.