diff --git a/README.md b/README.md index 484edba..3e1f852 100644 --- a/README.md +++ b/README.md @@ -178,10 +178,17 @@ mapping = { You can specify your own custom mapping function. ```lua +local check_back_space = function() + local col = vim.fn.col('.') - 1 + return col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') +end + mapping = { [''] = function(fallback) if vim.fn.pumvisible() == 1 then vim.fn.feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n') + elseif check_back_space() then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n') elseif vim.fn['vsnip#available']() == 1 then vim.fn.feedkeys(vim.api.nvim_replace_termcodes('(vsnip-expand-or-jump)', true, true, true), '') else