Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmdline preset mappings not working #894

Closed
2 tasks done
axieax opened this issue Apr 13, 2022 · 15 comments
Closed
2 tasks done

cmdline preset mappings not working #894

axieax opened this issue Apr 13, 2022 · 15 comments
Labels
bug Something isn't working

Comments

@axieax
Copy link

axieax commented Apr 13, 2022

FAQ

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

Issues

  • I have checked existing issues and there are no open or closed issues with the same problem.

Neovim Version

0.6.1

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-path'
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 {
  snippet = {
    expand = function(args)
      vim.fn["vsnip#anonymous"](args.body)
    end,
  },

  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 = {
    { name = "nvim_lsp" },
    { name = "buffer" },
  },
}

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

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

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

Description

Pressing <tab> after any partially-completed command won't do anything - neither triggers the Pmenu nor completion.

Steps to reproduce

Start typing :P<tab>

Expected behavior

Pmenu and completion for commands starting with P will show up.

Actual behavior

Just nothing... literally nothing...

Additional context

This is pretty much the minimal config plus the cmp.setup.cmdline(":") bit which causes it to fail. Setting up cmdline completion for "/" seems to work fine. This could be related to hrsh7th/cmp-path#38.

@axieax axieax added the bug Something isn't working label Apr 13, 2022
@axieax
Copy link
Author

axieax commented Apr 13, 2022

oo I tried using cmp.mapping.preset.insert() instead of cmp.mapping.preset.cmdline() and I get my previous issue of ^I characters appearing every time I press <Tab>.

@hrsh7th
Copy link
Owner

hrsh7th commented Apr 13, 2022

Sorry. I can't understand.

You specified the source for cmdline is path only. So I think if you don't type ~/, nvim-cmp can't show anything.

@axieax
Copy link
Author

axieax commented Apr 13, 2022

So I think if you don't type ~/, nvim-cmp can't show anything.

Actually using the path source works. It just also breaks normal command mode behaviour (i.e. without path).

@hrsh7th
Copy link
Owner

hrsh7th commented Apr 13, 2022

It just also breaks normal command mode behaviour

Please explain what is your expected behaivior?

@axieax
Copy link
Author

axieax commented Apr 13, 2022

The expected behaviour is what was defined above in the initial issue post - basically getting completion for my command. Previously, typing :P<Tab> would bring up the Pmenu, but now it does not anymore.

@hrsh7th
Copy link
Owner

hrsh7th commented Apr 13, 2022

Sorry. I don't know how to achive this without side-effect.
Do you know other plugin that achieve your expected behavior?

@axieax
Copy link
Author

axieax commented Apr 13, 2022

Hmm that's weird, everything was working fine before 801a9f9

@hrsh7th
Copy link
Owner

hrsh7th commented Apr 13, 2022

Ah. Sorry. Maybe the above commit fixes this issue. Could you try latest nvim-cmp?

@axieax
Copy link
Author

axieax commented Apr 13, 2022

Unfortunately that didn't fix it :((

@hrsh7th
Copy link
Owner

hrsh7th commented Apr 13, 2022

really??? In my environment, the last commit fixes this perfectly...

@axieax
Copy link
Author

axieax commented Apr 13, 2022

Hmm I'm not sure, but it doesn't seem to work with my default config or the minimal config provided above :((

EDIT: it's because I forgot to updated the plugin oops lemme try again

@axieax
Copy link
Author

axieax commented Apr 13, 2022

Works perfectly tysm @hrsh7th :))

@cexoso
Copy link

cexoso commented Apr 14, 2022

I has the some question, so how you guys resolve the problem? what does the "updated the plugin oops" mean?

@cexoso
Copy link

cexoso commented Apr 14, 2022

I has the some question, so how you guys resolve the problem? what does the "updated the plugin oops" mean?

it worked, see #809

@axieax
Copy link
Author

axieax commented Apr 14, 2022

Sorry by "update the plugin", I mean fetching the latest commits from the plugin (haven't use Vim-plug for a very long time haha). Good to hear it works now. I'll just leave my config here as a reference for others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants