ok97465 / spyder_okvim

A plugin for Spyder to enable Vim keybindings
MIT License
9 stars 0 forks source link

Remaining in normal mode. #40

Open schmoelder opened 2 years ago

schmoelder commented 2 years ago

First of all, thanks a lot for providing this plugin! I've been waiting for vim key bindings in Spyder for so long and spyder-vim just does not seem to go anywhere...

An issue that I noticed while using it, is that sometimes okvim just randomly enters insert mode when I do one of the following actions:

However, it's not very reproducible. Sometimes it was every second time, sometimes it works fine for several times in a row. Also sometimes I had to press Escape multiple times to get out of insert mode. Seems like a bug to me.

Running spyder 5.0.5 and spyder-okvim 0.0.1.dev0

ok97465 commented 2 years ago

Thank you for using it. You are the first user. ^^

Okvim only works normally when it has focus. There are several cases in which Okvim loses focus unintentionally.

  1. When the LSP is slow to respond, an autocomplete window pops up after Okvim has focus. the autocomplete window steals focus Okvim. So Okvim enters insert mode. In order to solve this problem, we need to modify the spyder code as in the comments (https://github.com/spyder-ide/spyder/issues/15055#issuecomment-850973899).

  2. Spyder requests information from LSP for Jumping to function definition in another file. When Spyder receives the results of the LSP, Spyder opens the new file and focuses on the new file. At this time Okvim loses focus, but Okvim cannot restore focus because Okvim cannot know when Spyder receives LSP results.

My quick fix is that okvim steals focus of spyder after 300ms. https://github.com/ok97465/spyder_okvim/blob/c352d0f80f612dd7c5bc73b4eca31dd541059f6c/spyder_okvim/executor/executor_sub.py#L420-L424 I knew this could be a problem. I will ask the Spyder team for a good solution later.

  1. Spyder focuses on the editor after executing the file. https://github.com/spyder-ide/spyder/blob/5aeb1d659086b0d95bb420c51e5b35be6e19adce/spyder/plugins/editor/plugin.py#L2794-L2799 To solve this problem, I think we need to create a shortcut for Okvim, without using Global shortcut (F5).

I can't reproduce the issue of changing tab.

Thank you for reading it. I hope you can understand the result of Google Translate.

ok97465 commented 2 years ago

In addition, Okvim uses spyder's decorator to mimic vim cursor. There is currently a problem with the decorator in spyder5. So using Okvim on spyder5 for a long time can slow down the typing speed of the editor.

https://github.com/spyder-ide/spyder/issues/15295

schmoelder commented 2 years ago

Hey, thanks for your in-depth reply! Happy to be the first user! :)

I think I can live with the aforementioned issues until you (or the Spyder team) find a good solution. For now, I'm just happy to be able to use some vim keybindings.

I can't reproduce the issue of changing tab.

Maybe it was only in combination with some of the other issues. I will keep an I on it.