Currently I'm writing a pull request for this vim plugin which should set commas and semicolons automatically.
At the moment it looks if it should set a comma/semicolon/double point or not everytime the user presses any key . This makes the plugin a little bit heavy (in my opinion) so I want to call a function only when the user presses the return key and not for every key.
What I have now at this moment
This is currently in the plugin:
autocmd BufEnter * call cosco_autocmds#RefreshAutocmds()
cosco_autocmd#RefreshAutocmds() enables the auto-setting for the current buffer:
autocmd TextChangedI <buffer> call cosco#AdaptCode()
Now I've tried this:
inoremap <CR> <C-O>:call cosco#AdaptCode()<CR>
But it looks like that the mapping doesn't call the function (you can try to add a
echom "Test" in the
cosco#AdaptCode() function). Do you have an idea how I can fix this?
Test it on your own
If you want to test it on your own, add my pull request to your plugin manager. For vim-plug it should be: