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

Control space not working for cmp #601

Closed
jay-babu opened this issue Jun 8, 2022 · 12 comments
Closed

Control space not working for cmp #601

jay-babu opened this issue Jun 8, 2022 · 12 comments
Labels
question Further information is requested upstream Issues that apply to upstream plugins and not AstroNvim directly.

Comments

@jay-babu
Copy link
Contributor

jay-babu commented Jun 8, 2022

["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),

nothing happens when I press Ctrl + Space. the other bindings work. I did not test them all

@jay-babu
Copy link
Contributor Author

jay-babu commented Jun 8, 2022

@mehalter
Copy link
Member

mehalter commented Jun 8, 2022

<c-space> here is triggering the complete() function. Basically this is used to open the completion menu if it is not available (to my knowledge). So it might not be doing what you think if you are picturing it doing "selection".

An example of this is here: https://asciinema.org/a/dinLAO4CjcdXWKWjObFdsIglJ

When there is no completion menu available, if I press <c-space> then it will open the completion menu appropriately

@mehalter mehalter added the question Further information is requested label Jun 8, 2022
@jay-babu
Copy link
Contributor Author

jay-babu commented Jun 8, 2022

Correct that is not happening. I can send a video later. I can try with vanilla AstroNvim however I don't really see anything conflicting

@mehalter
Copy link
Member

mehalter commented Jun 8, 2022

Could it be because there is nothing matching the completion? The easiest way to test this is to start typing something where the menu is open automatically and then use <c-e> to close it and then immediately do <c-space> and see if it reopens.

@johnsiras
Copy link

Could it be because there is nothing matching the completion? The easiest way to test this is to start typing something where the menu is open automatically and then use <c-e> to close it and then immediately do <c-space> and see if it reopens.

I have the same issue too, doing <c-e> after that doing <c-space> doesn't work

@mehalter
Copy link
Member

mehalter commented Jun 9, 2022

@johnsiras could you share your user configuration? Also what terminal and operating system are you on?

@johnsiras
Copy link

I still don't have my nvim user config repo yet, but my terminal is wezterm both wezterm, terminal, and alacritty doesn't work.
Operating system is windows

@mehalter
Copy link
Member

mehalter commented Jun 9, 2022

@johnsiras @jayp0521 this appears to be a bug upstream for Neovim on windows: neovim/neovim#8435

@mehalter mehalter added the upstream Issues that apply to upstream plugins and not AstroNvim directly. label Jun 9, 2022
@johnsiras
Copy link

@johnsiras @jayp0521 this appears to be a bug upstream for Neovim on windows: neovim/neovim#8435

Btw, <c-space> but doing <tab> it works??
I pressed <c-e> then tab works only space doesn't work that's so weird....

And it's annoying too when using tab ik it's for indentation not for cmp completion

wezterm-gui_O2Z4p1A1NU.mp4

@mehalter
Copy link
Member

mehalter commented Jun 9, 2022

@johnsiras we are currently using a replication of the "super tab" like functionality found here: https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip

This checks to see if there are words before the cursor and if there are then it will try to complete which is the behavior you are experiencing. It will not trigger the complete if you are tabbing in a new line which is most of the cases where one tends to put tab characters.

This functionality can be overridden in the user configuration (I do this because I am not a fan of this default, but the general consensus by the users on the discord/here are that this is preferred):

return {
  plugins = {
    cmp = function(config)
      local cmp = require "cmp"
      local luasnip = require "luasnip"
      config.mapping["<Tab>"] = cmp.mapping(function(fallback)
        if luasnip.expandable() then
          luasnip.expand()
        elseif luasnip.expand_or_jumpable() then
          luasnip.expand_or_jump()
        else
          fallback()
        end
      end, { "i", "s" })
      config.mapping["<S-Tab>"] = cmp.mapping(function(fallback)
        if luasnip.jumpable(-1) then
          luasnip.jump(-1)
        else
          fallback()
        end
      end, { "i", "s" })
      return config
    end,
  },
}

@mehalter
Copy link
Member

Since this is an upstream bug affecting windows users and not related to AstroNvim in particular, I'm going to go ahead and close this and leave the issue searchable for anyone else who may have the same problem/question.

@mehalter mehalter closed this as not planned Won't fix, can't repro, duplicate, stale Jun 11, 2022
@gfcroft
Copy link

gfcroft commented Mar 16, 2023

For anyone stumbling across this thread who has a similar issue (ctrl-space not working when trying to trigger completion) I would recommend checking that your keyboard/terminal app/whatever in the input chain to vim is actually sending the input (ctrl-space) you think it is - particularly if you're on MacOs!

I questioned if my terminal app (iterm2) wasn't sending ctrl-Space through properly, so on iterm2 I turned on raw key reporting mode:

image

that showed me that space bar wouldn't register any input when ctrl was pressed at the same time

I then stumbled across this article which says that apparently a default system shortcut was made a while ago in macos that uses the ctrl-space combination

https://apple.stackexchange.com/a/351058

deselecting this shortcut like so solved my problem:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested upstream Issues that apply to upstream plugins and not AstroNvim directly.
Projects
None yet
Development

No branches or pull requests

4 participants