-
Notifications
You must be signed in to change notification settings - Fork 6
[FEATURE] format actions should toggle the state of current format range #150
Description
Feature Description
At the moment, format actions toggles current word or selected range's format, but consider if my cursor is already in a formatted range like **some bold text**, on the word bold, most markdown editors's “bold action" will just remove the bigger bold range, instead of still adding format to current word.
Use Case
Some sometimes I copied a paragraph of AI stuff into my notes, I want to remove some of the formats, it is counter productive to visually select each of them.
If the format is italic, I would use mini.surround to remove the *, but needing to decide on the textobj is still mental load, not to mention you can not remove double * for bold text.
In obsidian app, you could just put the cursor on every formatted range you want to remove, and hit <C-i> or <C-b>, which is the experience I am looking for.
Proposed Solution
I don't know if you have tested the treesitter solution I mentioned in the reddit post, I think the treesitter markdown parser shipped with neovim should be sufficient for you to determine if you are in a formatted range, I have this function in obsidian.nvim to decide if the cursor is in a treesitter node type, so that we don't do operations like toggling checkbox in codeblocks. https://github.com/obsidian-nvim/obsidian.nvim/blob/b6f212bc1fb5b7b2b285ce0ba5c6d2a2c86e3033/lua/obsidian/util.lua#L710