sassanh / qnvim

Neovim backend for Qt Creator
MIT License
134 stars 8 forks source link

Process completion in insert mode #30

Closed Shatur closed 3 years ago

Shatur commented 4 years ago

Continuation of #25. Closes #18. I disable event filtering for events for insert mode to allow auto-completion. This how it works in vscode-neovim. This allows to have first-class insert mode and all other Neovim modes. I think that this is a good idea since completion in IDE is very important thing :)

sassanh commented 4 years ago

Thanks! I tested it and it looks very good, I'm sure it improves the user experience for many people who don't have any important insert mode mappings, but there are people (including myself) that have important insert mode mappings and these mappings are crucial for them to feel at home.

I mean vim without imap ` <c-c> doesn't feel vim for me. Whenever I have vim mode in a product (like bash, fish, IPython, etc) I spend some time to bring imap ` <c-c> in it. There are long discussions of me and repository owners in Github or their mailing list about supporting this and fortunately they always were kind enough to instruct me to achieve this or add some features to their product so that I can achieve this. Or there is a plugin I use that automatically inserts )whenever I type ( (same for {}, [], "", '', XML, HTML and JSX tags, etc)

So I think we can't simply drop insert mode mapping support. So far we can:

  1. Provide full insert mode mappings support, without good auto-completion user experience.
  2. We can provide good auto-completion user experience without insert mode mappings support.

So to have the advantages of both worlds, I'm thinking maybe we can introduce a vim command that switches between these two worlds. Let's call this command QNVIMToggleInsertModeMappings then user can simply create a mapping like this:

imap <SOME_KEY_SEQUENCE> <c-o>:QNVIMToggleInsertModeMappings<cr>i
imap <SOME_KEY_SEQUENCE> <c-o>:QNVIMEnableInsertModeMappings<cr>i
imap <SOME_KEY_SEQUENCE> <c-o>:QNVIMDisableInsertModeMappings<cr>i

Or maybe

imap <SOME_KEY_SEQUENCE> <plug>(QNVIMToggleInsertModeMappings)
imap <SOME_KEY_SEQUENCE> <plug>(QNVIMEnableInsertModeMappings)
imap <SOME_KEY_SEQUENCE> <plug>(QNVIMDisableInsertModeMappings)

so that the user doesn't have to deal with difficulties of running a command in insert mode and ruining undo history and we do it the hard way internally.

What do you think?

Shatur commented 4 years ago

This is a good idea! I will try to implement it.

Shatur commented 3 years ago

I am currently using VSCode with the Neovim extension and do not plan to return to QtCreator yet :( If someone wants to take this PR and continue the implementation, it would be great.