Skip to content

feat: support for orgmode style cycling #92

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

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

Conversation

neo451
Copy link
Member

@neo451 neo451 commented Apr 28, 2025

@sotte

Adpated from nvim-orgmode, works pretty well for me, try it out!

I also made the smart action use this. In order to do that I realized I could use <Plug> mappings, which leads me to think we have a bit of a too verbose command system, stuff like paste_img, extract_note is not really that great to use as a user command, I am not talking about deleting them, but I think we should provide more <Plug> mappings, and new feature that is not worth to be a command can go in this direction as well.

@sotte
Copy link

sotte commented Apr 28, 2025

@neo451, wow, that was quick.

I just gave it a a test run. First of all: much better than the default folding behavior. I missed it :)

I think I could create a few edge cases / inconsistent behavior.

When the cursor is on a checklist, cycle just toggles the fold for the the list:
image
image

Here it toggles the list, fine.
image
image

But when I'm on a listitem a bit further down, it toggles the entire heading.
image
image

shift-tab does not work for me at all. but let me check my terminal and nvim setup to make sure that it's not a problem on my side. The behavior is fishy.

More testing by anybody is highly welcome.

@sotte
Copy link

sotte commented Apr 28, 2025

Oh, and as always, we should add docs :)

Side note: yes, plugs are handy. I also think that our user commands are a bit to unwieldy. Not because they are not plugs, but because they contain a lot of logic. I with more of the logic was just a lua function that I could easily use to script custom things. But sometimes useful functionality is hidden within the user command and you cannot use it as only the function for the command itself is exposed.

Just to get an idea about the complexity of the commands:

❯ wc -l lua/obsidian/commands/*.lua
  136 lua/obsidian/commands/backlinks.lua
   51 lua/obsidian/commands/check.lua
   76 lua/obsidian/commands/dailies.lua
  148 lua/obsidian/commands/debug.lua
   43 lua/obsidian/commands/extract_note.lua
   10 lua/obsidian/commands/follow_link.lua
  194 lua/obsidian/commands/init-legacy.lua
  250 lua/obsidian/commands/init.lua
   40 lua/obsidian/commands/link.lua
   32 lua/obsidian/commands/link_new.lua
   88 lua/obsidian/commands/links.lua
   25 lua/obsidian/commands/new.lua
   41 lua/obsidian/commands/new_from_template.lua
  108 lua/obsidian/commands/open.lua
   29 lua/obsidian/commands/paste_img.lua
   19 lua/obsidian/commands/quick_switch.lua
  312 lua/obsidian/commands/rename.lua
   12 lua/obsidian/commands/search.lua
   96 lua/obsidian/commands/tags.lua
   37 lua/obsidian/commands/template.lua
   26 lua/obsidian/commands/toc.lua
   20 lua/obsidian/commands/today.lua
   22 lua/obsidian/commands/toggle_checkbox.lua
    6 lua/obsidian/commands/tomorrow.lua
   34 lua/obsidian/commands/workspace.lua
    6 lua/obsidian/commands/yesterday.lua
 1861 total

@sotte
Copy link

sotte commented Apr 28, 2025

shift+tab is due to some kitty settings on my end. will fix it tomorrow and give feedback.

Edit: fixed it. global cycle works like a charm!

@sotte
Copy link

sotte commented May 8, 2025

I just checked nvim-orgmode and the implemented behavior is different that what I get in this PR. The orgmode implementation does not toggle lists.
I'm not sure if we want to follow it one to one.

I wonder if we can specify tests for this. Do screen tests work for this?! :)

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.

2 participants