neorg icon indicating copy to clipboard operation
neorg copied to clipboard

Override neovim's regular indentation keybinds to instead refactor Neorg document hierarchy

Open elmarsto opened this issue 4 years ago • 3 comments

Issues

  • [X] I have checked existing issues and there are no existing ones with the same request.

Feature description

As it stands, when I select lines in Visual Mode (linewise or blockwise) and hit >>, my list is indented.

What I'd like is for >> and <<, in Visual and Normal Modes, to be context-aware, such that if I'm indenting content like

* foo
* bar
 ** baz

It is altered to read

** foo
** bar
*** baz

Instead of current-behavior, which would yield:

   * foo
   * bar
   ** baz

This behaviour should also be extended to ^T and ^D in Insert Mode.

Notably, the feature I'm imagining would also have to be context-sensitive enough to work on indents, bullet lists, etc.

For example, one might have quoted text like:

> foo
> bar
>> baz

With the feature I'm proposing, you could select the above text in Visual mode, hit >>, and have it change to

>> foo
>> bar
>>> baz

Mutatis mutandis, it should also handle other hierarchical structures provided by neorg, such as - [ ], ~, etc.

I am aware that this will be annoying to code, but after careful thought I have decided that it is the behaviour which is optimal for user experience :D

Help

Yes, but I don't know how to start. I would need guidance

Implementation help

To develop for Neorg will involve a learning ramp for me. This is low-hanging fruit for others, but high-hanging fruit for me right now, so I'm hoping someone else gets to fixing this before I do.

That said, I'd find it satisfying to help fix this issue, because this is the only thing currently about Neorg that defies my expectations-as-a-user. Whenever I go to change the hierarchy of my sections, I experience the fleeting wish I had just done the thing in OmniOutliner like I used to back in '05. (I don't; not really. I just wanna refactor!)

I love Neorg and this is basically the last thing about it that I find regrettable; when it is fixed, I shall dance in the streets

elmarsto avatar Dec 31 '21 00:12 elmarsto

Yo! Promoting/demoting and better indentation are things I really want to tackle as quickly as possible. They annoy me a lot when they don't work as intended as well :P

That being said, I've never managed to find time for it, especially since there's a decent lot of pressure from several different sides of the Neorg core - by this I mean we have to refactor quite a lot of things to get Neorg to a "good" state internally (stuff like a better keybind system or the concealer performance improvements for example).

There's a fairly inactive PR here, which I will be returning to whenever I can: https://github.com/nvim-neorg/neorg/pull/183

I'll start working on promoting/demoting after I figure out the concealer performance improvements. Hopefully I shouldn't keep you waiting for too long!

vhyrro avatar Dec 31 '21 10:12 vhyrro

I hear you! Thank you for taking the time to reply on NYE! Happy holidays and thank you for all your work! I'm now managing basically my entire corpus of personal information in Neorg, aside for some Markdown leftovers from my Obsidian period (another great app but one that sadly is not super compatible with my neovim lifeway)

elmarsto avatar Dec 31 '21 18:12 elmarsto

Feel free to join the discord @elmarsto !

danymat avatar Dec 31 '21 18:12 danymat

Hi there! This was recently (re)implemented in a very nice way by a fantastic contributor @champignoom! :tada: ❤ :tada: Test it out and see if it works for you!

NORMAL >> promotes element and any sub-elements NORMAL << demotes element and any sub-elements NORMAL >. promotes element without subelements, also works with INSERT ctrl-T NORMAL <, demotes element without subelements, also works with INSERT ctrl-D

Unfortunately doesn't always play well with Visual {_, block, line}, but I'm not sure how much of that is setting up the right keymaps vs needing to implement something feature-wise.

d-r-a-b avatar May 01 '23 02:05 d-r-a-b

The visual mode functions are something that have to be manually implemented for them to work. Fantastic work by champignoom indeed! I think it's safe to close this issue now :)

vhyrro avatar May 02 '23 12:05 vhyrro