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

issue with plugin (commentary) #2

Closed
ranjithshegde opened this issue Apr 28, 2021 · 23 comments
Closed

issue with plugin (commentary) #2

ranjithshegde opened this issue Apr 28, 2021 · 23 comments

Comments

@ranjithshegde
Copy link
Contributor

What a wonderful plugin!
Planning to try out with all my plugin with default whichkey config first.

So far I have the following problems.

  1. Does not load prefix related to tpope's commentary plugin. only shows the first level after pressing 'g' (c->plug commentary)
  2. If timeout length is set to small, because of no prefix popup, gcc does not work
  3. for yank, delete, change, treesitter-textobjects dont work regardless of timeout length (exaple: ac -around conditional, al-around loop, af-around function....)

Will report more as they come in.

@shadmansaleh shadmansaleh mentioned this issue Apr 28, 2021
@folke
Copy link
Owner

folke commented Apr 28, 2021

Thank you for the report!

  1. I see the same with kommentary. It's because they define a operator pending mapping. It can probably already be supported by reading in those keymaps as well. Need to check this.
  2. probably related to 1, since initially you are in NORMAL mode and after pressing gc you're in operator pending mode. However, it does work in my case with kommentary.
  3. might also be related to the same thing.

It might be that gcc needs the timeoutlen. Will check if there's something I can do.

@folke
Copy link
Owner

folke commented Apr 28, 2021

I just pushed a fix that should make NORMAL => OPERATOR PENDING mappings work.

Can you recheck if it does?

It should even work with timeoutlen = 0

@folke
Copy link
Owner

folke commented Apr 28, 2021

Your 3. should also work as expected now

@ranjithshegde
Copy link
Contributor Author

Just checked. thank you for the quick update!

2 works perfectly for any length!

Stuff that does not work:

  1. vim commentary (and vim-surround) still only shows first level prefix fully, lacking in second level prefix. For example after typing gc I get option c, not ap, ip, and so on. Not only do they not display, if timeout length is small then they wont work.

  2. Same issue still. treesitter-textobjects dont work for operator pending. mappings based on [,] or any other key work except for the ones based on g,y,d,c

@ranjithshegde
Copy link
Contributor Author

ranjithshegde commented Apr 28, 2021

I may have narrowed down the problem for .2 problem.

Treesitter-textobject mappings are defined this way

require'nvim-treesitter.configs'.setup {
  textobjects = {
    select = {
      enable = true,
      keymaps = {
        ["af"] = "@function.outer",
        ["if"] = "@function.inner",
        ["ac"] = "@class.outer",
        ["ic"] = "@class.inner",

So whichkey reads them as actual mappings inplace of appended mappings. Now I cant get into insert mode as i need to press 'i' and whichkey reads them as mappings for textobjects

@folke
Copy link
Owner

folke commented Apr 28, 2021

@ranjithshegde damn, indeed.

I just disabled my earlier changes for operator pending stuff. Need to look into this in more depth.

@folke
Copy link
Owner

folke commented Apr 29, 2021

@ranjithshegde I just pushed a bunch of changes, which should solve these issues.

Treesitter text objects work as they should now, but I'm working on #10 to also get them to show up in the text objects list.

@konart
Copy link

konart commented Apr 29, 2021

@folke gcc (vim commentary ) is still broken. gc leads you to +Comments (which looks strangely similar to +Change to me, see the screenshot) but not further action actually adds comments. The timeout doesn't really matter

change

comments

^ they are exactly the same actually, except for CSurround

@folke
Copy link
Owner

folke commented Apr 29, 2021

They would be similar since we show all motions and text objects for both comment and change. Under i/a, you should now also see the treesitter text objects.

For me it all seems to work with kommentary. Both plugins should be similar, but I will test with commentary just to be sure.

How it should work:

  • typing g and then waiting for the popup: anything should work
  • typing the command quickly without popup: gcip should all work
  • typing gc: no popup will be displayed, since you're then in operator pending mode handled by commentary, but again commenting should work

Can you check if it works if WhichKey is loaded and setup before commentary?

I lazy load kommentary, so that might make a difference

@konart
Copy link

konart commented Apr 29, 2021

Can you check if it works if WhichKey is loaded and setup before commentary?

Checked. I don't see any difference.

  1. g -> wait for the popup -> c -> c (not preset in the list of options) does not work
  2. gcc (quickly typed) -> nothing
  3. gc (quickly typed) -> opens +Comments popup

@folke
Copy link
Owner

folke commented Apr 29, 2021

ok, I'll install commentary to see what's happening here.

@folke
Copy link
Owner

folke commented Apr 29, 2021

Commentary doesn't seem to create key mappings: https://github.com/tpope/vim-commentary/blob/349340debb34f6302931f0eb7139b2c11dfdf427/plugin/commentary.vim#L108

I don't really get why not. Even if I load WK after it, they're still missing.

Pretty sure the problem is not that we are replacing them, since the keymap for gcc is also missing.

Will look into it further

@folke
Copy link
Owner

folke commented Apr 29, 2021

Just pushed a fix. Let know if it work now. 🤞

@konart
Copy link

konart commented Apr 29, 2021

@folke works perfectly now! (at least cases I typically use)

Popup has correct info too:
Снимок экрана 2021-04-29 в 17 30 41

@ranjithshegde
Copy link
Contributor Author

ranjithshegde commented Apr 29, 2021

@konart thank you for further verification. After #10 fix I wanted to write about gcc problem. But that seems to be resoved with the previous PR.
@folke
From what I can tell, it works for all my needs. I will verify once more with all my TS mappings along with some camcelCasePlugins and respond this evening.
Thanks again for such quick implementations!

@folke
Copy link
Owner

folke commented Apr 29, 2021

@ranjithshegde awesome, thanks!

@ranjithshegde
Copy link
Contributor Author

ranjithshegde commented Apr 29, 2021

All my TS keymaps, whether they were defined within TSconfig block or implicitly as keymaps, all plugin defined motions such as commentary or unimpaired, they work perfectly. Even with 0 timeout.
Also except for numbers mappings related #11, I see all bindings show up in the popup area. Zero problems for my setup!
This is incredible work. Thank you so much

@folke
Copy link
Owner

folke commented Apr 29, 2021

@ranjithshegde great to hear! Thanks again for taking the time to help testing all of this

@ranjithshegde
Copy link
Contributor Author

no problem. Maybe in future I also contribute in the means of PRs.
Cheers

@folke
Copy link
Owner

folke commented Apr 29, 2021

@ranjithshegde fyi: just fixed #10 as well

@ranjithshegde
Copy link
Contributor Author

@folke Just saw it! Fantastic. This is such an upgrade over regular whichkey. I used to have a host of rempas for z, g and ] internals to get them to show up in the old whichkey! this is perfect

@ricbermo
Copy link

ricbermo commented Oct 3, 2021

Hello @folke how u doing? First that all, thanks for this amazing plugin.

I'd like to report something. I'm using terrortylor/nvim-comment which just a lua version of TPope's Commentary but it doesn't seem to be working.

use {
  "terrortylor/nvim-comment",
  cmd = "CommentToggle",
  config = function() require('config.comments') end
}
 -- the config
local nvim_comment = prequire("nvim_comment")
if not (nvim_comment) then return end

nvim_comment.setup()

Just to be clear, the CommentToggle command is working. When I press g this is what I get
image

IDK if I'm doing something wrong or if it's a nvim-comment issue.

Thanks!

@ricbermo
Copy link

ricbermo commented Oct 3, 2021

@folke my bad. I just removed cmd = "CommentToggle", from my config and got it working. Thanks.

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

4 participants