Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: implement vim keymap (Resolves Issue #24) #51

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ThomasD0213
Copy link

Hey there, I decided to take a stab at #24 and this is what I came up with.

I used the codemirror-vim package: repo as suggested by @nilsherzig here.

All in all it works without a hitch! cut (dd, dw, d$, etc.), copy (yy, yw, y$, etc.) and paste (p) all work without issue in my testing. Along with this, all the basic movement commands I tested (h, j, k, l, gg, G, w, b), highlighting (Shift-V, Ctrl-v), etc. all worked.

The only issue I managed to find was if you delete the whole line (dd) inside of an empty or 1 line block it uncovers the separator regex for the next block, and the next block inherits the code highlighting of the block you just removed. I tried to find a workaround for this, but with my limited JavaScript skills and lack of understanding of how the app works as a whole, I could only deduce that it had something to do with maybe the extra line break between the separators getting deleted. these comments I think help support this hypothesis.

I am unsure if this issue can be avoided without implementing a custom keymap like what you have in emacs.js. The commented out code in keymap.js was my sad attempt at trying to avoid deleting the extra line break. Perhaps someone with more knowledge with codemirror and it's Vim keybindings package can make a better attempt at fixing the issue!

Overall, I think the net positive of having Vim keybindings is worth the minor headache of having to delete the ∞∞∞text that pops up and reassign the blocks highlighting, but ultimately that's not my call!

PS. Sweet app! I find myself too often pasting things inside of a new tab address bar for temporary jotting. Once I saw your post on Hacker News I knew I had to get it... so long as it had Vim keybindings 😉

@heyman
Copy link
Owner

heyman commented Dec 23, 2023

Cool! It's nice to see that it seems to mostly work out of the box.

I want Heynote to stay "polished", and having the ∞∞∞ appear when editing is going to feel buggy. Therefore I would want that to be fixed before merging. I'm sure it should be solvable though!

@ThomasD0213
Copy link
Author

Cool! It's nice to see that it seems to mostly work out of the box.

It was quite a pleasant surprise while I was testing!

I want Heynote to stay "polished", and having the ∞∞∞ appear when editing is going to feel buggy. Therefore I would want that to be fixed before merging. I'm sure it should be solvable though!

completely understandable, I'll try and see what I can do tomorrow (it's quite late right now where I am) and if nothing else, the next guy can use this as a basis to start from!

@ThomasD0213 ThomasD0213 changed the title implement vim keymap (Resolves Issue #24) Draft: implement vim keymap (Resolves Issue #24) Dec 23, 2023
@johnthedebs
Copy link

I started adding vim support myself and then found this branch - nice work!

Some other issues I found with the block delimiters + vim mode:

  • When searching with / for any part of the delimiter lines (eg, "javascript" from ∞∞∞javascript) it will match the hidden delimiter and not show the cursor (regular ctrl-f search also does this)
  • From there you could delete the delimiter line (dd) to join the blocks above and below, or otherwise modify it
  • Stuff like d/j (delete from cursor to search for letter "j") will operate on the delimiter text
  • Search/replace (:%s/cpp/javascript/g) modifies delimiter text as well
  • etc

These are all variations of the same theme.

@heyman
Copy link
Owner

heyman commented Dec 24, 2023

When searching with / for any part of the delimiter lines (eg, "javascript" from ∞∞∞javascript) it will match the hidden delimiter and not show the cursor (regular ctrl-f search also does this)

Yeah, the current search is just using the one that comes with Codemirror. I would like to implement a "block-aware" search. Created issue #60 for that.

Stuff like d/j (delete from cursor to search for letter "j") will operate on the delimiter text
Search/replace (:%s/cpp/javascript/g) modifies delimiter text as well

It's likely that we need to copy these implementations into Heynote and make them block aware for the Vim mode.

@skyronic
Copy link

Hello! I took the liberty to test out this branch as well! Aside from the delimiter issues, it works quite well. Any issues I found was mostly around the delimiter text. I'll try to use this branch as a daily driver for a little while to see if I can find any non-trivial issues!

@pb376
Copy link

pb376 commented Jan 5, 2024

Is this going to be merged into master for the next release? Lack of vim keybindings is the one thing making it very hard for me to get into the flow of using this. I've stopped for now but will revisit if/when this is added.

@fresh2dev
Copy link

Same

@heyman
Copy link
Owner

heyman commented Jan 12, 2024

Is this going to be merged into master for the next release? Lack of vim keybindings is the one thing making it very hard for me to get into the flow of using this. I've stopped for now but will revisit if/when this is added.

It's not going to merged as long as it has known bugs. Please see my comment, which is just a couple of comments above yours.

I'd love to merge support for Vim key bindings, but then someone needs to do the work. And unfortunately, it's unlikely to be me since I've never used Vim and need to google how to quit anytime Vi opens up in a terminal.

@fresh2dev
Copy link

ATTN: Vim nerds

I opted for https://github.com/lukas-reineke/headlines.nvim instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants