ziontee113 / syntax-tree-surfer

A plugin for Neovim that helps you surf through your document and move elements around using the nvim-treesitter API.
MIT License
472 stars 10 forks source link

Some question about some little details #4

Closed danielo515 closed 2 years ago

danielo515 commented 2 years ago

Hello, thank you for this awesome plugin! It is something I have been looking for some time, and I'm pretty happy that I, accidentally found it: Someone commented about it on a live stream, just after I spent a week looking for something like this.

The feature of targeted_jump alone is good enough to install this plugin, so I'm grateful already. However, I have a couple of doubts that you can maybe clarify.

For example, within the config for setup, what is default_desired_types for? I tried calling filtered_jump, targeted_jump without arguments expecting they will use default_desired_types, but they don't work without arguments, so I wonder what are they for?

How is the surf function supposed to work? everytime I execute it, all it does is insert a line above the current one. Will be cool if I can just enter in a mode where I can use hjkl to navigate between LSP objects. Is that what it is supposed to do?

As I said, thank you!

ziontee113 commented 2 years ago

Thank you for using the plugin. And sorry for the slow response. I nuked my SSD trying to install Linux so I'm a bit busy atm.

To your questions:

  1. Targeted jump needs arguments to work. So it's my bad for not pointing that out.
  2. If you use filtered_jump("default", true") and you haven't used targeted_jump yet, it will jump forward through nodes that is in default_desired_types. If you have already used targeted_jump, it will jump forward through nodes that has been specified in that targeted_jump that you called.
  3. I wrote the surf function back when I was still new to Neovim. If you look at https://github.com/ziontee113/syntax-tree-surfer#how-do-i-set-things-up, look at the vx, vn, H, J, K, L, <A-j> and <A-k> keymaps and try them yourself. Copy the exact code and only change the keymap to your preferences. You can check a few video examples here

Also which livestream mentioned my plugin? Can you link it and the timestamp? Thank you :) If you have further questions, feel free to ask.

danielo515 commented 2 years ago

Thank you for using the plugin. And sorry for the slow response. I nuked my SSD trying to install Linux so I'm a bit busy atm.

No worries, it is not an urgent thing.

2. If you use filtered_jump("default", true") and you haven't used targeted_jump yet, it will jump forward through nodes that is in default_desired_types.

Did you wrote filtered_jump instead of targeted_jump by mistake? Or is filtered_jump the only one using default_desired_types? Is ti not possible to use them for all jumps?

3. Copy the exact code and only change the keymap to your preferences. You can check a few video examples

Yep, that is what I did (for normal mode) but it only inserts empty lines. Does it only work within select mode? Can it be used in normal mode?

danielo515 commented 2 years ago

Also which livestream mentioned my plugin? Can you link it and the timestamp? Thank you :)

It was on this stream, but I can't remember when (timestamp) was it mentioned on the chat, sorry: https://www.youtube.com/watch?v=Rl7Tg3A0rAE&ab_channel=chris%40machine

ziontee113 commented 2 years ago

Did you wrote filtered_jump instead of targeted_jump by mistake? Or is filtered_jump the only one using default_desired_types? Is ti not possible to use them for all jumps?

Only filtered_jump uses default_desired_types. The whole reason default_desired_types is there is that if you use filtered_jump("default", true) and you haven't used targeted_jump yet, it won't throw an error.

Ok, about the version 1 functionalities, the things you can do in normal mode are very limited

Now to the surf function. you can see that I set all the keymap modes to "x" (only visual mode) The surf function serves 2 purposes:

  1. H, J, K, L is to select parent node, next sibling node, previous sibling node, first child node
  2. A-j and A-k is to swap the current visually selected node with it's previous / next sibling.

So you'll get the most out of version 1 functionalities in visual mode. And yes, I should make HJKL functionalities for normal mode in the future.