Skip to content
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

[FR] 'Cycle bullet/checkbox' command #1

Closed
tadashi-aikawa opened this issue Jul 13, 2024 · 4 comments
Closed

[FR] 'Cycle bullet/checkbox' command #1

tadashi-aikawa opened this issue Jul 13, 2024 · 4 comments

Comments

@tadashi-aikawa
Copy link

Hi :)

Thank you for the wonderful plugin. It's very user-friendly, especially since I regularly use Obsidian.

I have assigned the 'Cycle bullet/checkbox' command to Ctrl+Enter in Obsidian. This command has a somewhat unique behavior as described below.

hoge
↓
- hoge
↓
- [ ] hoge
↓
- [x] hoge
↓
- hoge
↓
- [ ] hoge
↓
- [x] hoge
↓
- hoge
↓
.
.

I would appreciate it if you could consider this.

@roodolv
Copy link
Owner

roodolv commented Jul 14, 2024

Hello. Thanks for using this plugin.
I am honored that you are satisfied with it.


If I implement that feature, I'll probably add a config option as shown below.
Let me know if this looks good to you.

Case1. Mimicking Obsidian's 'Cycle bullet/checkbox'

require("markdown-toggle").setup({
  enable_box_cycle_obsidian = true, -- new option
  enable_box_cycle = true,
  box_table = { "x" }, 
})

In this case, the cycle would look like this:

hoge
↓
- hoge
↓
- [ ] hoge
↓
- [x] hoge
↓
- hoge
↓
- [ ] hoge
↓

Case2. In case of various markup cycles in addition to above

require("markdown-toggle").setup({
  enable_box_cycle_obsidian = true, -- new option
  enable_box_cycle = true,
  box_table = { "x", "~", "!" }, -- for cycling between various states
})

Here's how the cycle would work:

hoge
↓
- hoge
↓
- [ ] hoge
↓
- [x] hoge
↓
- [~] hoge
↓
- [!] hoge
↓
- hoge
↓
- [ ] hoge
↓

Case3. If you don't want to use the new feature

require("markdown-toggle").setup({
  enable_box_cycle_obsidian = false, -- new option
  enable_box_cycle = true,
  box_table = { "x" }, 
})

In this case, the cycle would be like this (same as the current toggle command):

hoge
↓
- [ ] hoge
↓
- [x] hoge
↓
- [ ] hoge
↓

In addition, I'm planning to add a NEW config option for 'bullet list' as well.
This will allow for more Obsidian-like behavior in areas where the current functionality differs from Obsidian.

@roodolv
Copy link
Owner

roodolv commented Jul 14, 2024

I've just implemented the Mimicking Obsidian feature: 4daa991

Please check the latest commit.
Sorry for not versioning. (I'll do it later.)
I would appreciate any feedback or reactions.

@tadashi-aikawa
Copy link
Author

@roodolv
Thank you for your prompt response! I have confirmed that it works as expected with the following settings. It looks like Markdown editing in Neovim will be much more efficient 😊

{
  "roodolv/markdown-toggle.nvim",
  branch = "main",
  config = function()
    require("markdown-toggle").setup({
      enable_box_cycle = true,
      box_table = { "x" },
    })

    vim.api.nvim_create_autocmd("FileType", {
      desc = "markdown-toggle.nvim keymaps",
      pattern = { "markdown", "markdown.mdx" },
      callback = function(args)
        local opts = { silent = true, noremap = true, buffer = args.buf }
        local toggle = require("markdown-toggle")

        -- F12はCtrl+Enter
        vim.keymap.set({ "n", "v" }, "<F12>", toggle.checkbox, opts)
      end,
    })
  end,
}

@roodolv
Copy link
Owner

roodolv commented Jul 14, 2024

I'm glad to hear that.
Thanks.

@roodolv roodolv closed this as completed Jul 14, 2024
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

No branches or pull requests

2 participants