IntelliTab is a small neovim plugin that fixes an annoying gripe I've had with vim's tab completion implementation for ages: pressing tab on a blank line only indents by a single space, instead of automatically indenting to your specified location.
With IntelliTab, pressing Tab works like it does on editors such as VSCode, by
indenting to the same place smartindent
would have indented it to if it were
a new line.
Install using your favourite package manager:
Plug 'pta2002/intellitab.nvim'
Now, just rebind <Tab>
:
inoremap <Tab> <CMD>lua require("intellitab").indent()<CR>
That's it!
CoC wants to have its own binding for Tab, which means it won't be compatible with intellitab by default. A solution to this is to bind Tab to this instead:
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? <CMD>lua require("intellitab").indent()<CR> :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
On the nvim-cmp
setup, add this binding for tab:
['<Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_next_item() -- or whatever else you want nvim-cmp to do when you press tab
else
require("intellitab").indent()
end
end