README: Allow to use Tab for indentation (#38)

This commit is contained in:
Andreas Schneider
2021-08-27 08:06:34 +02:00
committed by GitHub
parent 6b9570920e
commit a46cfc219b

View File

@@ -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 = {
['<Tab>'] = function(fallback)
if vim.fn.pumvisible() == 1 then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-n>', true, true, true), 'n')
elseif check_back_space() then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Tab>', true, true, true), 'n')
elseif vim.fn['vsnip#available']() == 1 then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>(vsnip-expand-or-jump)', true, true, true), '')
else