Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nfrid/markdown-togglecheck
Simple neovim plugin to toggle checkboxes in markdown
https://github.com/nfrid/markdown-togglecheck
Last synced: about 1 month ago
JSON representation
Simple neovim plugin to toggle checkboxes in markdown
- Host: GitHub
- URL: https://github.com/nfrid/markdown-togglecheck
- Owner: nfrid
- License: mit
- Created: 2022-11-07T17:21:35.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-04T16:36:08.000Z (over 1 year ago)
- Last Synced: 2024-08-01T21:18:53.601Z (4 months ago)
- Language: Lua
- Size: 3.91 KB
- Stars: 20
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-neovim - nfrid/markdown-togglecheck - Simple Neovim plugin for toggling check boxes using Tree-sitter. (Programming Languages Support / Markdown and LaTeX)
README
# markdown-togglecheck
Stupidly simple neovim plugin that toggles task list check boxes in markdown
using treesitter.## Requirements
This plugin requires my other plugin -
[treesitter-utils](https://github.com/nfrid/treesitter-utils).## Installation
Use your favorite package manager.
`lazy.nvim`:
```lua
{
'nfrid/markdown-togglecheck',
dependencies = { 'nfrid/treesitter-utils' },
ft = { 'markdown' },
}
```## Setup
You **don't need** to execute a setup function to use the defaults but in case you
want to redefine them, you can do it with `setup`:```lua
require('markdown-togglecheck').setup({
-- create empty checkbox on item without any while toggling
create = true,
-- remove checked checkbox instead of unckecking it while toggling
remove = false,
})
```## Usage
The plugin does not provide default keybindings.
You should define them yourself:
```lua
-- toggle checked / create checkbox if it doesn't exist
vim.keymap.set('n', 'nn', require('markdown-togglecheck').toggle, { desc = 'Toggle Checkmark' });
-- toggle checkbox (it doesn't remember toggle state and always creates [ ])
vim.keymap.set('n', 'nN', require('markdown-togglecheck').toggle_box, { desc = 'Toggle Checkbox' });
```If you need dot repeat for this plugin you can use `operatorfunc` to bind the keys
(they'll work the same way but will provide . repeat functionality):```lua
local function toggle()
vim.go.operatorfunc = "v:lua.require'markdown-togglecheck'.toggle"
return 'g@l'
endlocal function toggle_box()
vim.go.operatorfunc = "v:lua.require'markdown-togglecheck'.toggle_box"
return 'g@l'
endvim.keymap.set('n', 'nn', toggle, { expr = true, desc = 'Toggle Checkmark' })
vim.keymap.set('n', 'nN', toggle_box, { expr = true, desc = 'Toggle Checkbox' })
```You also might add some highlight queries yourself for the check boxes. For
example:```query
;; YOUR_CONFIG/after/queries/markdown/highlights.scm; inherits: markdown
(task_list_marker_unchecked) @comment
(task_list_marker_checked) @function
```## Todo
- replace treesitter-utils with new treesitter api