neoclide / coc-lists

Common lists for coc.nvim
264 stars 24 forks source link

How to set ctrl+n and ctrl+p to up or down list? #139

Closed ymzuiku closed 1 year ago

ymzuiku commented 1 year ago

This is a novice question. In coc-lists, ctrl+j and ctrl+k is very simple change list, but in coc suggestions use ctrl+n and ctrl+p, how can i set it same keymap?

fannheyward commented 1 year ago

You can set them by list.normalMappings and list.insertMappings.

ymzuiku commented 1 year ago

Thanks @fannheyward , but it's no work.

My ~/.vim/coc-settings.json:

{
  "list.insertMappings": {
    "<C-n>": "do:next",
    "<C-p>": "do:previous"
  },
  "list.normalMappings": {
    "<C-n>": "do:next",
    "<C-p>": "do:previous"
  }
}

or:

{
  "list.insertMappings": {
      "<C-n>": "normal:j",
      "<C-p>": "normal:k",
  },
  "list.normalMappings": {
      "<C-n>": "normal:j",
      "<C-p>": "normal:k",
  }
}
fannheyward commented 1 year ago

Check :h coc-list-mappings-custom.

ymzuiku commented 1 year ago

@fannheyward Thanks, It's work:

  "list.insertMappings": {
    "<C-n>": "feedkeys:\\<Down>",
    "<C-p>": "feedkeys:\\<Up>"
  },
  "list.normalMappings": {
    "<C-n>": "feedkeys:\\<Down>",
    "<C-p>": "feedkeys:\\<Up>"
  }
chemzqm commented 1 year ago
"list.insertMappings": {
    "<C-n>": "do:next",
    "<C-p>": "do:previous"
  }

works on nvim, but not vim.

chemzqm commented 1 year ago

Fixed on coc.nvim.