From 2aa7eee28b4d49e999c694ca733a393da5808dd6 Mon Sep 17 00:00:00 2001 From: hrsh7th <> Date: Mon, 18 Apr 2022 23:50:09 +0900 Subject: [PATCH] Improve README.md --- README.md | 2 +- doc/cmp.txt | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4dceea6..088ba68 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Readme! 2. This is my hobby project. You can support me via GitHub sponsors. 3. Bug reports are welcome, but I might not fix if you don't provide a minimal reproduction configuration and steps. 4. The nvim-cmp documents is [here](./doc/cmp.txt). - +5. The nvim-cmp is designed for `customization`! It's not designed for `works out of the box`. Concept diff --git a/doc/cmp.txt b/doc/cmp.txt index 4a789db..95461c4 100644 --- a/doc/cmp.txt +++ b/doc/cmp.txt @@ -231,11 +231,12 @@ Mapping *cmp-mapping* The nvim-cmp's mapping mechanism is complex but flexible and user-friendly. -You can specify the mapping as function that receives the `fallback` function as arguments. +You can specify the mapping function that receives the `fallback` function as arguments. The `fallback` function can be used to call an existing mapping. -For example, typical pair-wise plugins automatically defines a mapping for `` or `(`. -The nvim-cmp will overwrite it but you can fallback to the original mapping via invoking the `fallback` function. +For example, typical pair-wise plugins automatically define the mapping for `` or `(`. +The nvim-cmp might overwrite it via your specified mapping configuration. +But you can use existing mapping via invoking the `fallback` function. > cmp.setup { mapping = { @@ -248,7 +249,20 @@ The nvim-cmp will overwrite it but you can fallback to the original mapping via end } } +< > + cmp.setup { + mapping = { + [''] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end + } + } < + And you can specify the mapping modes. > cmp.setup {