autolist.nvim icon indicating copy to clipboard operation
autolist.nvim copied to clipboard

User set keymaps

Open namjul opened this issue 3 years ago • 14 comments

Hey, nice work. I love the checkbox feature from bullets.vim. What do you think about adding this?

namjul avatar Aug 26 '22 21:08 namjul

Yeah that’s fine, just add it in the “please submit module ideas” issue so we don’t double up. Currently I’m just working on getting the base ordered and unordered list stable, but that will be pretty high priority.

gaoDean avatar Aug 26 '22 21:08 gaoDean

just to confirm, an empty checkbox looks like [ ] content and a filled checkbox looks like [x] content?

gaoDean avatar Aug 26 '22 23:08 gaoDean

on further inspection, an empty checkbox looks like - [ ] content and a filled checkbox looks like - [x] content?

So a list should be:

- [ ] todo1
- [ ] todo2
- [x] todo3
- [ ] todo4

gaoDean avatar Aug 27 '22 00:08 gaoDean

Do you mind if it doesn't support 1. [ ] content, because it just adds unnecessary complication

gaoDean avatar Aug 27 '22 00:08 gaoDean

checkboxes merged, test it out and tell what you think @namjul

gaoDean avatar Aug 27 '22 01:08 gaoDean

Do you mind if it doesn't support 1. [ ] content, because it just adds unnecessary complication

I don't think I ever used this combination, so would not mind. But I would consider it part of the full-feature set.

Also what I am using is a way to toggle the checkbox. I would expose this as a help using-<Plug> mapping. Like https://github.com/gbprod/yanky.nvim does it.

A print has found its way into here https://github.com/gaoDean/autolist.nvim/blob/8e01f57a4d0b811e73ac53f03c86475ad7b7c4dd/lua/autolist/generic.lua#L97 :)

namjul avatar Aug 27 '22 06:08 namjul

don't know if i understood your question, but use <c-r> to toggle the checkbox just like toggling a list

gaoDean avatar Aug 27 '22 08:08 gaoDean

also thanks for the test catch

gaoDean avatar Aug 27 '22 08:08 gaoDean

Also what I am using is a way to toggle the checkbox. I would expose this as a help using-<Plug> mapping. Like https://github.com/gbprod/yanky.nvim does it.

Im not sure what you mean by a help using-<Plug>. Could you please explain?

gaoDean avatar Aug 27 '22 08:08 gaoDean

don't know if I understood your question, but use to toggle the checkbox just like toggling a list

yes that is what I meant but rather would use <leader>-x

I'm not sure what you mean by a help using-<Plug>. Could you please explain?

So I was thinking to expose a <Plug> mapping this way users can set the key mapping themself. like:

vim.keymap.set({"n"}, "<leader>-x", "<Plug>(AutolistToggleCheckbox)")

:help using-<Plug> refers to the help page.

namjul avatar Aug 27 '22 09:08 namjul

I mean you can use config.invert_mapping, that mapping calls the function that toggles the list. I see what you mean, but for things like <c-t> which are built in mappings, it is a bit useless. Oh I just realised, you would want a toggle checklist for normal mode as well. Thanks.

gaoDean avatar Aug 27 '22 10:08 gaoDean

Just a thought, with <Plug>, how would you only set the keymap for certain filetypes? Would the plugin have to check, or does the user put in an autocommand?

gaoDean avatar Aug 27 '22 10:08 gaoDean

alright, there is an option for config.invert_normal_mapping, and ill think about the <Plug>.

gaoDean avatar Aug 27 '22 10:08 gaoDean

Just a thought, with <Plug>, how would you only set the keymap for certain filetypes? Would the plugin have to check, or does the user put in an autocommand?

Have not thought about that. The plugin I use for keymaps has an open issue for that https://github.com/folke/which-key.nvim/issues/281. So the base assumption I had was that it is better when the user controlls setting keymaps. But I can see in this case that if the plugin handles it it would make sure that they only get applied on the correct filetypes, which simplifies things for users. Maybe we can have both. So people opt-in to let the plugin handle them and otherwise use the <Plug>(AutolistToggleCheckbox) mapping to do it themselfs (or reverse).

namjul avatar Aug 27 '22 11:08 namjul

Hey, I have added a config option to have custom mappings. Will add to docs later, look for the new release later this week for changes.

gaoDean avatar Sep 13 '22 11:09 gaoDean

look towards v1.5 for the new mapping changes

gaoDean avatar Sep 14 '22 08:09 gaoDean

Any updates on exposing <Plug> functions for custom keybindings in WhichKey etc? I didn't see anything in the Readme for what I might include in WhichKey. Is there anywhere else that I might look?

Thanks again for a great plugin :)

benbrastmckie avatar Feb 07 '23 20:02 benbrastmckie