b3nj5m1n/kommentary

Doesn't support count?

winston0410 opened this issue · 7 comments

This plugin works great in virtual mode, but doesn't work with count in normal mode (like 3<leader>cc). Is this a missing feature? if so I can contribute to it.

i miss this feature too, i hope gcc will comment lines at once.

@FinallyFinancialFreedom I have written a plugin for it because I need that feature now. You may take a look and try it out.

https://github.com/winston0410/commented.nvim

Is this a missing feature?

This is a duplicate of #39, but since this has been requested several times now, maybe I should reconsider adding this.

if so I can contribute to it.

I'd definitely consider merging if you made a PR, that would be awesome.

For the moment I've implemented this myself in vimscript. I agree it would be nice to have in kommentary itself but this seems to work just fine:

function! KommentaryWrapper(count) " implement a hacky kommentary map that takes a count
  if a:count == 0 " no count passed, so just comment current line
    execute "normal \<Plug>kommentary_line_default"
  else " count passed, so do hacky visual select of relevant lines so we can comment them all
    let linesToGoDown = a:count - 1
    " do the weird dance of moving cursor down then back up so that it's
    " located where you'd expect it to be if you then undo
    execute "normal " . linesToGoDown . "jV" . linesToGoDown . "k"
    execute "normal \<Plug>kommentary_visual_default"
    call nvim_feedkeys("\<C-c>", 'n', v:true)
  endif
endfunction
nnoremap  <silent> <leader>c  :<C-U>call KommentaryWrapper(v:count)<CR>

@FinallyFinancialFreedom I have written a plugin for it because I need that feature now. You may take a look and try it out.

https://github.com/winston0410/commented.nvim

It's great, thank you!

This plugin works great in virtual mode, but doesn't work with count in normal mode (like 3<leader>cc). Is this a missing feature? if so I can contribute to it.

You can use a key map:
vim.api.nvim_set_keymap("n", "<leader>c", "<S-v><Plug>kommentary_visual_default<Esc>", {})

Hi, thanks for your interest in kommentary, unfortunately I'll not be adding any new features, I'm sorry I never got to this issue.