From daafc6af117cb3229c5f8179ead07787d722a186 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Sat, 28 Aug 2021 09:49:25 -0400 Subject: [PATCH] fix(readme): correct code block for nvim-cmp example --- README.md | 65 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 0cb3cee..bf94405 100644 --- a/README.md +++ b/README.md @@ -87,42 +87,43 @@ If you want to add `` completion instead, be sure you don't have a completi
nvim-cmp - ```lua - local cmp = require('cmp') - local neogen = require('neogen') +```lua +local cmp = require('cmp') +local neogen = require('neogen') - local t = function(str) - return vim.api.nvim_replace_termcodes(str, true, true, true) - end +local t = function(str) + return vim.api.nvim_replace_termcodes(str, true, true, true) +end - local check_back_space = function() - local col = vim.fn.col '.' - 1 - return col == 0 or vim.fn.getline('.'):sub(col, col):match '%s' ~= nil - end +local check_back_space = function() + local col = vim.fn.col '.' - 1 + return col == 0 or vim.fn.getline('.'):sub(col, col):match '%s' ~= nil +end - cmp.setup { - ... +cmp.setup { + ... + + -- You must set mapping if you want. + mapping = { + [""] = cmp.mapping(function(fallback) + if vim.fn.pumvisible() == 1 then + vim.fn.feedkeys(t(""), "n") + elseif neogen.jumpable() then + vim.fn.feedkeys(t("lua require('neogen').jump_next()"), "") + elseif check_back_space() then + vim.fn.feedkeys(t(""), "n") + else + fallback() + end + end, { + "i", + "s", + }), + }, + ... +} +``` - -- You must set mapping if you want. - mapping = { - [""] = cmp.mapping(function(fallback) - if vim.fn.pumvisible() == 1 then - vim.fn.feedkeys(t(""), "n") - elseif neogen.jumpable() then - vim.fn.feedkeys(t("lua require('neogen').jump_next()"), "") - elseif check_back_space() then - vim.fn.feedkeys(t(""), "n") - else - fallback() - end - end, { - "i", - "s", - }), - }, - ... - } - ```
## Configuration