Giter Club home page Giter Club logo

cmp-cmdline's People

Contributors

amarakon avatar gegoune avatar hrsh7th avatar magedmohamedturk avatar mikkolehtimaki avatar sassanh avatar uga-rosa avatar xein234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cmp-cmdline's Issues

Support `:set no…`

Right now, if you start typing :set no, there are no suggestions for the no-prefixed versions of options, such as nonumber.

There is no completion for lua

I'm not sure if this is a bug or not, but I don't have any completion for lua after ..

Completes:
:lua

Doesn't complete:
:lua vim.

But :echo getcompletion("lua vim.", "cmdline") gives some usefull results. Also I can complete with fallback <Tab> (internal completion).

"E141: No file name for buffer nn" on attempt to exit

Disclaimer: I'm not super familiar with lua or vimscript or the inner workings of vim. I just use vim a lot.

I recently setup neovim with nvim-cmp (love it! great work!). However, when I enable cmp-cmdline I can no longer exit vim with :wqa. I get the following error:

E141: No file name for buffer nn

Then I essentially have to :q! everything individually until I hit the last buffer which appears to be the options listed for cmp-cmdline.

I wanted to guess that the buffer wasn't set to nofile, but I cannot find where that would even happen. Is very possible its outside this plugin completely. However, when I disable this plugin I have no problem.

Steps to Repro:

  1. Set-up nvim-cmp using the recommended configuration here: https://github.com/hrsh7th/nvim-cmp
  2. Open two files (using :vs or :spl)
  3. Try to exit using :wqa (or :qa or :qa!)

Notice

E141: No file name for buffer 2 is shown

Expected

Vim would exit

Disable completion if the command starts with a number

Hi, I would like to disable completion when the command is a number, this is a problem for me because when I want to jump to a specific line a wall of completion text appears exactly where I want to look and doesn't allow me to peek the line before jumping.

Screen Shot 2022-04-26 at 13 37 04

C-n C-p not working

Using the below mappings and cmdline setup it is not possible to select entries that appear using C-n or C-p. I'm guessing this is because of the c_CTRL-N and c_CTRL-P mappings. Also using this which might be relevant set wildmode=longest:full,full. Any suggestions on a workaround?

   mapping = {
        ["<C-y>"] = cmp.mapping.confirm(),
        ["<C-n>"] = function()
            if cmp.visible() then
                cmp.select_next_item()
            else
                cmp.complete()
            end
        end,
        ["<C-p>"] = function()
            if cmp.visible() then
                cmp.select_prev_item()
            else
                cmp.complete()
            end
        end,
        ["<C-d>"] = cmp.mapping.scroll_docs(-4),
        ["<C-f>"] = cmp.mapping.scroll_docs(4),
        ["<C-e>"] = cmp.mapping.close(),
    },

command :pwd does not print the working directory

When I enable this plugin and call :pwd, it does not print the working directory but print the current file name.

On the other hand, when I disable this plugin, this issue goes away. So I think this plugin may cause this issue.

image
image

cmp-cmdline turns hlsearch off?

when searching something in the buffer with / or ? hlsearch automatically gets turned off everytime cmp window is shown/updated so there is a flicker everytime you type something

2022-01-07.21-36-10.mp4

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 'hrsh7th/cmp-cmdline'
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 = {
    { name = "nvim_lsp" },
    { name = "buffer" },
    },
}
require'cmp'.setup.cmdline(':', {
    sources = {
        { name = 'cmdline' }
    }
})
require'cmp'.setup.cmdline('/', {
    sources = {
        { name = 'buffer' }
    }
})

EOF

lua << EOF
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())

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

Completion on confirmation

I am wondering if there is a configuration that can auto select the first entry whenever I start typing characters
For example I currently use

  completion = { completeopt = 'menu,menuone,noinsert' }, -- pre select the first one

to do the trick, but it seems like when I hit on the pre select item, it doesn't auto expand to the full entry, just the character I entered, which is different from what I see in normal editor area

Continous Completion Inconsistencies with ":edit"

When running :edit with the setup specified in the README initially everything works as expected with all relative paths popping up. However if a directory is accepted with cmp.complete() and the cursor is moved all the way to the right then no new completions will be offered for the next part.

EX (▇ is cursor position):

:edit ▇ works well with proper completions autosuggested
:edit arbitraryDirectory/▇ does not result in any autosuggestions

A workaround is to delete the trailing slash with one backspace then retype it resulting in autosuggestions working again for only the segment.

cmd :find freezes

I am using neovim with the latest nightly.
I have configured cmp-cmdline as :

 cmp.setup.cmdline(':', {
    sources = cmp.config.sources({
      { name = 'path' }
    }, {
      { name = 'cmdline' }
    })
  })

But I find that when I try to use :find it freezes. It doesn't when I remove cmp-cmdline and use the normal nvim :find.
This is issue doesn't happen with any other commands that I have used till now.

I have the following set path+='.,**' as well in my nvim config to enable :find to search my project dir

keyword_length ignored

It seems that keyword_length is ignored (or misinterpreted) when using a mapping to change buffers.

  1. Set keyword_length = 3
  2. Set mappings below
  3. Open 2 files
  4. <leader>n to switch to next buffer
  5. : and completion appears immediately

Using :bn and then : uses the set keyword_length prior to triggering completion as expected.

nnoremap <silent> <leader>n :bnext<CR>     
nnoremap <silent> <leader>p :bprevious<CR> 

:help suggestions don't appear with :vert help (or :vertical help)

Hi!

First of all thank you very much for your work with cmp! I would send you a merge request fixing this, but I've been reading the code and don't understand how it works :((

The issue I'm having is that completion with :help <query> works perfectly but it doesn't work at all with :vert help <query>. I guess vert could be added as a modifier prefix so that it doesn't affect the rest of the sentence or something like that?

Again, thank you very much for your work!

modifier cleanup breaks custom completion for command

$ vim --version
NVIM v0.7.0-dev
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -g -O2 -ffile-prefix-map=/build/neovim-TaFwuh/neovim-0.7.0~ubuntu1+git202203110047-6170574d2-dd05b3569=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/build/neovim-TaFwuh/neovim-0.7.0~ubuntu1+git202203110047-6170574d2-dd05b3569/build/config -I/build/neovim-TaFwuh/neovim-0.7.0~ubuntu1+git202203110047-6170574d2-dd05b3569/src -I/build/neovim-TaFwuh/neovim-0.7.0~ubuntu1+git202203110047-6170574d2-dd05b3569/.deps/usr/include -I/usr/include -I/build/neovim-TaFwuh/neovim-0.7.0~ubuntu1+git202203110047-6170574d2-dd05b3569/build/src/nvim/auto -I/build/neovim-TaFwuh/neovim-0.7.0~ubuntu1+git202203110047-6170574d2-dd05b3569/build/include
Compiled by buildd@lcy02-amd64-015

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Given:

function! CompleteThis(A,L,P) abort
  [...]
endfunction

command! -nargs=1 -complete=custom,CompleteThis RestoreThing call Something()

when cmp-cmdline is configured like so:

cmp.setup.cmdline(':', {
   sources = {
     { name = 'cmdline', keyword_length = 2 },
     { name = 'nvim_lua' },
     { name = 'path' },
   },
})

The custom completion function fails to run. The reason appears to be this code in cmp-cmdline. The regex processing ends up mangling the command name (in this specific instance it is this regex that causes the problem).

If I comment out the code linked above everything works as expected. if I comment out the referenced regex everything works as expected. At least with my configuration, if I change the name of the command to ResToreThing or RestOreThing everything works as expected.

cmp-cmdline should use mappings of nvim-cmp

It would be great if mappings were taken from nvim-cmp configuration. Currently I have for example:

["<C-k>"] = cmp.mapping.select_prev_item(),
["<C-j>"] = cmp.mapping.select_next_item(),

But for cmp-cmdline I still have to use <tab>.

Does not expand file path

I am not sure if its just me but :e % does not expand % into the file path. This extends to something like :e %:h.

Missing completions

I've noticed cmdline isn't showing completions for some items that normally appear. Gitsigns and lua vim.lsp both don't shown any completions.

fuzzy searching only work partially.

For example, if i type cls on the cmdline, colorscheme is not in the list of completion items. Do I need to set up in my cmp config or something?

image

[Bug]: can't complete user defined command

When define a user command with -complete=command argument, cmp-cmdline can't even give a completion list.

For exxample with the following command, after input Redir in vim cmdline, <tab> do not give any further completion.

command! -nargs=1 -complete=command Redir call utils#CaptureCommandOutput(<q-args>)

Error when substituting \( or \)

I'm trying to substitute \( by using the following command

:s/\\(/<something>

But, in the same moment I write the left parent (, it shows the error "\( sin complemento", which in English would be something like "not pair found for \(" or "no complement for \(" , which seems to suggest that things are not being escaped properly at some point or maybe they are being escaped twice.

Here's the full traceback:

Error executing vim.schedule lua callback: Vim:E54: \( sin complemento
stack traceback:
        [C]: in function 'getcompletion'
        ...e/pack/packer/start/cmp-cmdline/lua/cmp_cmdline/init.lua:64: in function 'exec'
        ...e/pack/packer/start/cmp-cmdline/lua/cmpcmdline/init.lua:115: in function 'complete'
        .../re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:288: in function 'complete'
        .../re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:170: in function 'autoindent'
        .../re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:162: in function 'on_change'
        .../re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/init.lua:301: in function 'callback'
        .../site/pack/packer/start/nvim-cmp/lua/cmp/utils/async.lua:122: in function <.../site/pack/packer/start/nvim-cmp/lua/cmp/utils/async.lua:120>

Does not support completion in the presence of non-string globals

Not sure if this is problem with Neovim's own getcompletion() function or the way this plugin is using it, but it starts throwing errors when I set a global variable whose key is not a string.

Steps to reproduce:

Setup cmp-cmdline completion.

Execute:

:lua _G[{}] = true

Then start typing another lua command from the command line. I get the following error:

Error executing vim.schedule lua callback: Vim:Error executing vim._expand_pat: attempt to compare table with string
stack traceback:
        [C]: in function 'sort'
        vim/_editor.lua: in function <vim/_editor.lua:0>
        [C]: in function 'getcompletion'
        ...e/pack/packer/start/cmp-cmdline/lua/cmp_cmdline/init.lua:68: in function 'exec'
        ...e/pack/packer/start/cmp-cmdline/lua/cmp_cmdline/init.lua:115: in function 'complete'
        .../nvim/site/pack/packer/start/nvim-cmp/lua/cmp/source.lua:296: in function 'complete'
        ...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:288: in function 'complete'
        ...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:170: in function 'autoindent'
        ...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:162: in function 'on_change'
        ...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/init.lua:301: in function 'callback'
        .../site/pack/packer/start/nvim-cmp/lua/cmp/utils/async.lua:122: in function <.../site/pack/packer/start/nvim-cmp/lua/cmp/utils/async.lua:120>

Expansion of % in cmdline has an extraneous % prepended

Normally, when you type :e % and press tab, the % will expand to the current buffer's path. However, with cmp-cmdline, the % will expand to the path but with a % prepended to it.

Example:

touch myfile
nvim myfile
:e %<TAB>

Should expand to :e myfile but instead expands to :e %myfile.

Does not complete after `vert help`

In cmdline's default behavior, we can have completion for vert help, which is same as help, however, this is not the case for this source.

Ghost text implementation

Wanted to check if ghost text can be implemented for the cmdline only, it's more useful there than in editor completions.
If not, maybe treat this a feature request :)

Does not work with `sort /searchstring/` command

random document:

hello everyone
goodbye
hello nobody
:sort /he

the screen starts to highlight hello but I get no autocompletion

:sort /hello/

correctly sorts by the string hello

cmp.setup {
  sources = {
    { name = 'nvim_lsp' },
    { name = 'nvim_lsp_signature_help' },
    { name = 'path' },
    { name = 'buffer', keyword_length = 4 },
  },
}

cmp.setup.cmdline('/', {
  sources = {
    { name = 'buffer', keyword_length = 4 },
  },
})

cmp.setup.cmdline(':', {
  sources = cmp.config.sources({
    { name = 'path' },
  }, {
    { name = 'cmdline' },
  }),
})

Support for magic mode

cmp.setup.cmdline('/', {
  sources = {
		{name = 'buffer'}
		-- { name = 'rg'}, 
		-- {name = 'fuzzy_buffer'}   
  }
})

magic search in vim simplifies regex but it confuses cmp.cmdline, eg when I search for import word:
/\vimp
the buffers will not show suggestions related to 'imp' but to 'vimp'. Issue is affecting other sources that are attached to cmdline sources
/imp works ok though.
I hope there is way to filter out the magic characters.

cmp.setup.cmdline return nil

图片

:lua print(require('cmp').setup.cmdline) return a nil too.

cmp-cmdline installed.

  -- cmp
  use 'hrsh7th/nvim-cmp'
  use 'hrsh7th/cmp-vsnip'
  use 'hrsh7th/cmp-nvim-lsp'
  use 'hrsh7th/cmp-buffer'
  use 'hrsh7th/cmp-path'
  use 'hrsh7th/cmp-calc'
  use 'hrsh7th/cmp-emoji'
  use 'hrsh7th/cmp-cmdline'

config:

local cmp = require'cmp'
...
cmp.setup.cmdline(':', {
  sources = {
    { name = 'cmdline' }
  }
})

cmp.setup({
...
})

Complete system variables

cmp-cmdline doesn't seem to complete system variables like $HOME. I think this would be a nice feature. Perhaps even that it expanded the variable's value upon selection.

:! in command window hangs

E5500: autocmd has thrown an exception: Vim(lua):E5108: Error executing lua Keyboard interrupt^@stack traceback:^@^I[C]: in function 'getcompletion'^@^I.../share/nvim/pl
ugged/cmp-cmdline/lua/cmp_cmdline/init.lua:13: in function 'exec'^@^I.../share/nvim/plugged/cmp-cmdline/lua/cmp_cmdline/init.lua:68: in function 'complete'^@^I...el/.loc
al/share/nvim/plugged/nvim-cmp/lua/cmp/source.lua:290: in function 'complete'^@^I...nuel/.local/share/nvim/plugged/nvim-cmp/lua/cmp/core.lua:250: in function 'complete'^
@^I...nuel/.local/share/nvim/plugged/nvim-cmp/lua/cmp/core.lua:163: in function 'autoindent'^@^I...nuel/.local/share/nvim/plugged/nvim-cmp/lua/cmp/core.lua:155: in funct
ion 'on_change'^@^I...nuel/.local/share/nvim/plugged/nvim-cmp/lua/cmp/init.lua:301: in function 'callback'^@^I...al/share/nvim/plugged/nvim-cmp/lua/cmp/utils/autocmd.lua
:31: in function 'emit'^@^I[string ":lua"]:1: in main chunk

:! (colon exclamation mark) in command line hangs

Hi,

here is how to reproduce the issue:

  1. Open any file
  2. Type :!

I have cmp-cmdline added with:

cmp.setup.cmdline(':', {
  sources = cmp.config.sources({
    { name = 'path' }
  }, {
    { name = 'cmdline' }
  })
})

Results:
nvim-cmp hangs and can only be stopped with Ctrl-C. Error message below.

E5500: autocmd has thrown an exception: Vim(lua):E5108: Error executing lua Keyboard interrupt^@stack traceback:^@^I[C]: in function 'getcompletion'^@^I.../share/nvim/pl
ugged/cmp-cmdline/lua/cmp_cmdline/init.lua:13: in function 'exec'^@^I.../share/nvim/plugged/cmp-cmdline/lua/cmp_cmdline/init.lua:68: in function 'complete'^@^I...el/.loc
al/share/nvim/plugged/nvim-cmp/lua/cmp/source.lua:290: in function 'complete'^@^I...nuel/.local/share/nvim/plugged/nvim-cmp/lua/cmp/core.lua:250: in function 'complete'^
@^I...nuel/.local/share/nvim/plugged/nvim-cmp/lua/cmp/core.lua:163: in function 'autoindent'^@^I...nuel/.local/share/nvim/plugged/nvim-cmp/lua/cmp/core.lua:155: in funct
ion 'on_change'^@^I...nuel/.local/share/nvim/plugged/nvim-cmp/lua/cmp/init.lua:301: in function 'callback'^@^I...al/share/nvim/plugged/nvim-cmp/lua/cmp/utils/autocmd.lua
:31: in function 'emit'^@^I[string ":lua"]:1: in main chunk

Expected result:
Not hanging, being able to type a system command

:map completion doesn't find mappings with <leader>

I'm using <space> as the <leader>.

Reproduce
when typing :map leader or :map space or :map <leader> i get 0 completions, even though i have a lot of mappings starting with leader and e.g. :map <leader>g<cr> gives me output about these mappings.

Misc
This source is great! I could completely get rid of https://github.com/gelguy/wilder.nvim.

Minor things are annoying though:

  1. when typing e.g. :e to get path completions, i get some paths mixed with some other commands provided by this source. However I have setup the cmp-path source to work with this source.
cmp.setup.cmdline(':', {
  sources = cmp.config.sources({
    { name = 'path', max_item_count = 20 }
  }, {
    { name = 'cmdline', max_item_count = 30, }
  }),
})

Only when typing / or ./ etc. I get completions from (only) the path source. This is normally not necessary with :e because it assumes a relative path.
The path completions provided by this source are hard to use.

Example: I have a folder ./rc in my cwd. when typing :e r i get the completion rc/ ending in a /. Now i have no possibility to get completions for the contents of the folder easily. When typing <cr> it executes the cmdline immediately. (I have set ['<CR>'] = cmp.mapping.confirm() out of personal preference). When typing / again i get completions from the path source for root. And when typing <tab> I continue cycling the completions.

To actually descend into the folder I need to do something weird like <space><backspace> to retrigger completion.

  1. Since every completion item provided by this source seems to be of the same type Variable, displaying the type is just useless. So I tried to modify the formatting option of the cmp.setup.cmdline(':', {formatting=..} but it didn't work for me.

My current formatting table

cmp.setup({
  formatting = {
    format = require('lspkind').cmp_format({
      with_text = true,
      maxwidth = 50,
      menu = {
        cmp_tabnine = '[T9]',
        vsnip = '[VSNIP]',
        path = '[PATH]',
        nvim_lsp = '[LSP]',
        nvim_lua = '[LUA]',
        buffer = '[BUF]',
        cmdline = '[CMD]',
      },
    })
  },
}

It would be nice to be able to adjust the formatting for the cmdline completion seperately.

Unable to confirm selection with nvim's default mappings

All other default mappings work as expected. For example, <C-n> for next, <C-p> for previous, <C-e> to close.

However, <C-y> to confirm does not work on either command mode or while searching. It places a ^Y char.

Creating a mapping config does not work:

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

How can I enable this?

Cmdline don't work and don't give completion

I tried to install cmdline but it just don't give any suggestions or completion

Here is my config using packer :

use({
"hrsh7th/cmp-cmdline",
config = "require('custom.plugins.cmdline')",
})

The cmdline config :

require'cmp'.setup.cmdline(':', {
sources = {
{ name = 'cmdline' }
}
})

Super Tab binding stopped working after updating nvim-cmp

I've Ctrl-n and Ctrl-p mapping which works fine for search and cmd mode. But the Tab binding has stopped working

Cmp setup.
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

local feedkey = function(key, mode)
	vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
end


cmp.setup({
....,
	mapping = cmp.mapping.preset.insert({
                      ...
		["<Tab>"] = cmp.mapping(function(fallback)
			if cmp.visible() then
				cmp.select_next_item()
			elseif vim.fn["vsnip#available"](1) == 1 then
				feedkey("<Plug>(vsnip-expand-or-jump)", "")
			elseif has_words_before() then
				cmp.complete()
			else
				fallback()
			end
		end, { "i", "s" }),
		["<C-n>"] = cmp.mapping(function()
			if cmp.visible() then
				cmp.select_next_item()
			else
				cmp.complete()
			end
		end, { "i", "c" }),
	}),

        ....
})

cmp.setup.cmdline("/", {
	-- completion = { autocomplete = false },
	sources = {
		-- { name = 'buffer' }
		{ name = "buffer", opts = { keyword_pattern = [=[[^[:blank:]].*]=] } },
	},
})

cmp.setup.cmdline(":", {
	completion = { autocomplete = false },
    entries = {name = 'custom'--[[ , separator = '|' ]] }
	sources = cmp.config.sources({
		{ name = "path" },
	}, {
		{ name = "cmdline" },
	}),
})

Note: I use vsnip

Can't handle wildcards

Using asterisk sign in cmd cause variety of invalid behaviour:

  • Sometimes it can't find proper candidates for completion
  • It inserts whole record after asterisk, instead of only missing part
    image
  • Using double asterisk in path cause major lagging during typing e.g find ~/project/**/asdf.lua

Of course, wildcards are redundant with this plugin, but they shouldn't cause errors when people use them because of muscle memory.

cmdline causes nvim to freeze up if I try to type `:!`

Describe the bug
nvim freezes up if I try to type :! in the cmdline

Minimal config based on this

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 'hrsh7th/cmp-cmdline'
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 = {
    { name = "nvim_lsp" },
    { name = "buffer" },
  },
}

cmp.setup.cmdline(":", {
    sources = cmp.config.sources({
        { name = "path" },
    }, {
        { name = "cmdline" },
    }),
})
EOF

lua << EOF
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())

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

To Reproduce

  1. Type :!

Expected behavior
Should not freeze up

Additional context

Only happens in wsl2. Tested in MacOS and I don't have the issue

Group index - does not seem to work

According to docs following setup
cmdline => group_index = 1
cmdline_history => 2

Then if cmdline outputs any results, then cmdline_history results should get ignored. But it does not seem to work in cmp-cmdline. My setup:

cmp.setup.cmdline(":", {
  formatting = {
    format = function(entry, vim_item)
      vim_item.kind = lspkind.presets.default[vim_item.kind] .. " " .. vim_item.kind
      vim_item.abbr = vim.fn.strcharpart(vim_item.abbr, 0, 50) -- hack to clamp cmp-cmdline-history len
      vim_item.menu = ({
        cmdline_history = "[HIST]",
        cmdline = "[CMD]",
        fuzzy_path = "[PATH]",
        buffer = "[BUFF]",
      })[entry.source.name]
      return vim_item
    end,
  },
  sources = cmp.config.sources {
    { name = "cmdline_history", priority = 2, group_index=2 },
    { name = "cmdline", priority = 2, group_index=1 },
    { name = "fuzzy_path", priority = 1, group_index=2 }, -- from tzacher
    { name = "buffer", priority = 1, group_index=2 },
  },
})  

Then I try to enter :
:PackerSync -> and cmp shows cmd_history elements first, then cmdline results.

Expected:
cmdline result first, no cmd_histoyr since it is group 2

Feature request: Custom case suggestion option

👋🏼,

I have noignorecase and nosmartcase on as I want case to be consistent when searching, using :s or pretty much everything. One thing that I do miss is that is also is applied for commands, ie. :g will not recommend :Git command.

I'd love it if I was able to set ignorecase for the actual suggestions on cmp-cmdline. In that way I could keep my settings but :g would give me a tabable suggestion!

🙏🏼

does not complete vim.ui.input

vim.ui.input accepts a completion option, however cmp-cmdline will not complete candidates, but wildmenu will.
I presume same problem with vim.ui.select

es:

:lua vim.ui.input({prompt = "complete me: ", completion = 'dir'}, function(input) print(input) end)

After `PackerSync` `/` completion doesn't work

Hey I have ran PackerSync today and it broke the / completions from some reason.
: completions are working fine, I have tried to add buffer as source for : and it worked too, so I don't think its cmp-buffer

This is the setup for my cmp:

local cmp = require'cmp'
local lspkind = require('lspkind')
cmp.setup({
	snippet = {
		expand = function(args)
			require('snippy').expand_snippet(args.body) -- For `snippy` users.
		end,
	},
	mapping = {
		['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
		['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
		['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
		['<Tab>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }),
		['<S-Tab>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }),
		['<C-y>'] = cmp.config.disable,
		['<C-e>'] = cmp.mapping({
			i = cmp.mapping.abort(),
			c = cmp.mapping.close(),
		}),
		['<CR>'] = cmp.mapping.confirm({ select = true }),
	},
	formatting = {
		format = lspkind.cmp_format({
			with_text = false,
			maxwidth = 50,
			before = function (entry, vim_item)
				return vim_item
			end
		})
	},
	sources = cmp.config.sources({
		{ name = 'nvim_lsp' },
		{ name = 'snippy' },
		{ name = 'spell' },
	}, {
		{ name = 'buffer' },
	})
})

cmp.setup.cmdline('/', {
	sources = {
		{ name = 'buffer' }
	}
})

cmp.setup.cmdline(':', {
	sources = cmp.config.sources({
		{ name = 'path' }
	}, {
		{ name = 'cmdline' }
	})
})

Neovim version:

NVIM v0.8.0-dev+95b7851
Build type: Debug
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=malloc -Wsuggest-attribute=cold -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=1 -I/home/ogal/.local/nvim-nightly/neovim/build/config -I/home/ogal/.local/nvim-nightly/neovim/src -I/home/ogal/.local/nvim-nightly/neovim/.deps/usr/include -I/usr/include -I/home/ogal/.local/nvim-nightly/neovim/build/src/nvim/auto -I/home/ogal/.local/nvim-nightly/neovim/build/include
Compiled by ogal@ogal

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/home/ogal/.local/share/nvim"

Run :checkhealth for more info

Only enable `/` completion

Hello,

I didn't manage to use the completion only for the search. Is it possible?

With the following config, the "default nvim completion" gets disabled after the first search.

Thanks,


asciicast

Minimal config (nvim 0.7.0):

call plug#begin(stdpath('data') . '/plugged')
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'

" For vsnip users.
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'

" For luasnip users.
" Plug 'L3MON4D3/LuaSnip'
" Plug 'saadparwaiz1/cmp_luasnip'

" For ultisnips users.
" Plug 'SirVer/ultisnips'
" Plug 'quangnguyen30192/cmp-nvim-ultisnips'

" For snippy users.
" Plug 'dcampos/nvim-snippy'
" Plug 'dcampos/cmp-snippy'

call plug#end()

set completeopt=menu,menuone,noselect

lua <<EOF
  -- Setup nvim-cmp.
  local cmp = require'cmp'

  cmp.setup({
    snippet = {
      -- REQUIRED - you must specify a snippet engine
      expand = function(args)
        vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
        -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
        -- require('snippy').expand_snippet(args.body) -- For `snippy` users.
        -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
      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 }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
    }),
    sources = cmp.config.sources({
      { name = 'nvim_lsp' },
      { name = 'vsnip' }, -- For vsnip users.
      -- { name = 'luasnip' }, -- For luasnip users.
      -- { name = 'ultisnips' }, -- For ultisnips users.
      -- { name = 'snippy' }, -- For snippy users.
    }, {
      { name = 'buffer' },
    })
  })

  -- Set configuration for specific filetype.
  cmp.setup.filetype('gitcommit', {
    sources = cmp.config.sources({
      { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
    }, {
      { name = 'buffer' },
    })
  })

  -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
  cmp.setup.cmdline('/', {
    mapping = cmp.mapping.preset.cmdline(),
    sources = {
      { name = 'buffer' }
    }
  })
EOF

substitution completion

This plugin is awesome, the only bug I found is that whenever I want to substitute a word there's no completion e.g.

:%s/Hello/Salut/g
:s/Welcome/Bienvenue/g

There's no completion for this, the most important thing is buffer completion at this moment:

:s/
:%s/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.