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

Having trouble setting up enter as accept key #20

Closed
giuxtaposition opened this issue Oct 8, 2024 · 13 comments
Closed

Having trouble setting up enter as accept key #20

giuxtaposition opened this issue Oct 8, 2024 · 13 comments

Comments

@giuxtaposition
Copy link
Contributor

As per title, I'd like to accept the suggestion after pressing enter, but it's not working.
Here's my config:

return {
  "saghen/blink.cmp",
  lazy = false, -- lazy loading handled internally
  dependencies = "rafamadriz/friendly-snippets",
  version = "v0.*",
  opts = {
    keymap = {
      accept = "<CR>",
    },
    highlight = {
      use_nvim_cmp_as_default = true,
    },
    nerd_font_variant = "mono",
    accept = { auto_brackets = { enabled = true } },
    trigger = { signature_help = { enabled = true } },
  },
}

I've also tried <cr> and <Enter> but nothing seems to work

@nikbrunner
Copy link

nikbrunner commented Oct 8, 2024

Having the same problem. This is my config:

return {
    "saghen/blink.cmp",
    lazy = false, -- lazy loading handled internally
    dependencies = "rafamadriz/friendly-snippets",
    version = "v0.*",
    opts = {
        keymap = {
            show = "<C-space>",
            hide = "<C-e>",
            accept = "<CR>",
            select_prev = { "<Up>", "<C-j>" },
            select_next = { "<Down>", "<C-k>" },

            show_documentation = {},
            hide_documentation = {},
            scroll_documentation_up = "<C-b>",
            scroll_documentation_down = "<C-f>",

            snippet_forward = "<Tab>",
            snippet_backward = "<S-Tab>",
        },
    },
}

@giuxtaposition
Copy link
Contributor Author

I found the problem, I have nvim-autopairs that uses enter to register pairs, I guess the two mappings get in conflict.
My workaround was to set map_cr = false in nvim-autopairs config:

return {
  "windwp/nvim-autopairs",
  event = "InsertEnter",
  config = true,
  opts = {
    disablee_in_macro = false,
    map_cr = false,
  },
}

@dsully
Copy link
Contributor

dsully commented Oct 8, 2024

The same problem occurs with mini.pairs

@formadi
Copy link

formadi commented Oct 8, 2024

I don’t use mini.pairs, and I checked the mappings, but there’s nothing mapped for in insert mode, yet does not function as accept.

@julienvincent
Copy link
Contributor

Same issue.

I'm also using nvim-autopairs and can confirm that setting map_cr = false resolves this but I use the behaviour that map_cr = true enables.

Ideally blink can work alongside this config, perhaps can take a look at what nvim-cmp is doing to work here.

@chrisgrieser
Copy link
Contributor

same thing happening with ultimate-autopair (another auto-pairing plugin), which also maps CR.

@gcanat
Copy link

gcanat commented Oct 8, 2024

Btw, am I the only one to find weird that <C-j> is bounded to go <Up> in the selection and <C-k> to go <Down> ??
Feels counter intuitive.

Ah nevermind, I just saw there is already #23

@julienvincent
Copy link
Contributor

@Saghen The commit ecb3510 breaks normal editing in a buffer:

image

It inserts this when pressing keys in insert mode

@Saghen
Copy link
Owner

Saghen commented Oct 8, 2024

I'm not able to reproduce but does 5dd7d66 fix the issue for you?

@julienvincent
Copy link
Contributor

Almost. It solved the issue reported above but now when accepting it nukes the first char:

image

Notice the missing bracket.

I typed:

(group-|)
;; Press <Cr>
group-by|)

@julienvincent
Copy link
Contributor

julienvincent commented Oct 8, 2024

Hmm actually, @Saghen that seems to be a different issue that existing before I just didn't notice.

It works if I do this:

 (group-|)
 ;; <Cr>
 (group-by|)

;; However, without the space it fails
(group-|)
;; <Cr>
group-by|)

I could open a new issue if you like.

@Saghen
Copy link
Owner

Saghen commented Oct 8, 2024

New issue would be great, thanks!

@julienvincent
Copy link
Contributor

But, while #20 (comment) <- this issue is solved - This change did break the map_cr = true behaviour from nvim-autopairs.

So in other words, when I am editing with nvim-autopairs then I expect the following behaviour:

fn main() {|}
// Press <Cr>
fn main() {
  |
}

But now as of 5dd7d66 this behaviour is broken. Ideally we can find a way to both allow <Cr> to accept without swallowing existing <Cr> mappings on the buffer.

This behaviour pairing works fine on nvim-cmp so I'm sure it's possible.

lopi-py pushed a commit to lopi-py/blink.cmp that referenced this issue Oct 10, 2024
lopi-py pushed a commit to lopi-py/blink.cmp that referenced this issue Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants