kylechui / nvim-surround

Add/change/delete surrounding delimiter pairs with ease. Written with :heart: in Lua.
MIT License
3.15k stars 63 forks source link

docs: added a reference to relevant helptexts for motions #294

Closed JL102 closed 8 months ago

JL102 commented 9 months ago

Re: discussion https://github.com/kylechui/nvim-surround/discussions/259 Added a reference to the relevant help text for motions, specifically for people who aren't super familiar with vim and never heard of text objects.

I think that the :h motion part is pretty facepalm-worthy obvious, but for someone who doesn't know about text-objects, I think it'd be hard to find info on a and i. But it would feel weird to give the suggestion for :h text-objects without mentioning :h motion.

kylechui commented 9 months ago

I think I'm not opposed to adding "... or {text-object} ..." to the help docs; unsure if an explicit call-out is necessary since the point of the curly braces is to allow people to use K to visit them directly.

JL102 commented 8 months ago

I think I'm not opposed to adding "... or {text-object} ..." to the help docs; unsure if an explicit call-out is necessary since the point of the curly braces is to allow people to use K to visit them directly.

Oh, I wasn't aware that curly braces made a link that you could visit with a keybind! Sure, I'll change the PR.

JL102 commented 8 months ago

@kylechui Updated my branch. However, I see strange behavior in my own neovim instance when editing nvim-surround.txt.

If my cursor is over a letter in the word text, i.e. ... or [te[x]t object} with..., when I press K it opens the helptext for the word text (i.e. the same as when I enter :h text), and if my cursor is over a letter in the word object, i.e. ... or {text ob[j]ect} with..., when I press K it opens the helptext for the word object. I only get the correct helptext if I enter visual mode and highlight the whole word before pressing K.

Then, if I edit the helptext in my nvim install, i.e. .config/nvim/lazy/nvim-surround/doc/nvim-surround.txt and then open the Surround helptext via :h surround, when I press K with my cursor over {text-object} or {text-objects} it tells me E149: Sorry, no help for {text-objects}. The other helptext links work fine, though, i.e. hitting K when the cursor is over {motion} works fine.

I don't know what the deal is with this weird behavior.

kylechui commented 8 months ago

It seems like I might've been mistaken---perhaps it should be |text-objects| instead?

JL102 commented 8 months ago

It seems like I might've been mistaken---perhaps it should be |text-objects| instead?

Good catch, Neovim's docs do mention that links to other help docs need pipes around it. I get the same behavior regarding linking the individual words while I'm editing the text file, but if I then open :h surround the |text-object| link works for me.