chrisgrieser / nvim-spider

Use the w, e, b motions like a spider. Move by subwords and skip insignificant punctuation.
MIT License
667 stars 13 forks source link

Feature Request: skipInsignificantPunctuation only in normal mode? #19

Closed IndianBoy42 closed 1 year ago

IndianBoy42 commented 1 year ago

Feature Requested

With some experimentation, although I like skipping punctuation in normal mode when I'm probably just trying to get to some word in the code. In operator or visual mode the original behavior is a bit more intuitive/useful

I could just not bind it but I still want subword motions. I think the most elegant and idiomatic to neovim plugins way is to allow passing a config struct in motion which, key-by-key, overrides the default config. That way a user could even bind multiple versions of the motions to different keys

Relevant Screenshot

No response

Checklist

chrisgrieser commented 1 year ago

Generally, it is a rule for all vim motions that they work the same for all three modes, which is also quite essential in creating predictability/consistency. I am not totally sure how desirable it is to introduce a feature that breaks with that rule. 🤔

IndianBoy42 commented 1 year ago

Well it's completely opt in and the user can easily just think of them as separate motions. That sounds like a good principle for defaults but I think allowing for configurability is a higher principle for plugins. To let users choose what principles they want to use for their personal setup.

This would also allow the user to have separate bindings for different motions provided by the plugin (subword vs word, punctuation or no punctuation)

Rydwxz commented 1 year ago

I agree 100%. It is consistent from an abstract perspective if not functional; when we tap w we want to move to the beginning of the next word without necessarily defining everything in-between there and the current cursor position as "the current word" to do it because when we call something like ciw we want to change to the end of the current word, not the beginning of the next word! The "punctuation" should be treated like whitespace, not a continuation of the word. It would be very nice to have an API that accepts either option as args so we could do keybindings like

map('n', 'w', spider.word({ 'subWord', 'punctuation' })_
map({'o', 'x'}, 'w', spider.word({ 'subWord' })
chrisgrieser commented 1 year ago

Implemented with the latest PR