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

Doesn't work ootb with mini.comment / Comment.nvim (React) #99

Open
StitiFatah opened this issue Mar 16, 2024 · 2 comments
Open

Doesn't work ootb with mini.comment / Comment.nvim (React) #99

StitiFatah opened this issue Mar 16, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@StitiFatah
Copy link

StitiFatah commented Mar 16, 2024

Minimal reproducible full config

https://github.com/nvim-lua/kickstart.nvim/blob/master/init.lua + add 'JoosepAlviste/nvim-ts-context-commentstring' inside require('lazy').setup({})

Description

The README says that it works ootb, I tried with comment.nvim and mini.comment and it didn't. I had to add this configuration to mini.comment :

{
  "echasnovski/mini.comment",
  event = "VeryLazy",
  opts = {
    options = {
      custom_commentstring = function()
        return require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring
      end,
    },
  },
}

and this to comment.nvim :

return {
  'numToStr/Comment.nvim',
  lazy = false,
  config = function()
    require('Comment').setup {
      pre_hook = require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook(),
    }
  end,
}

Steps to reproduce

  • clone this repo where you want the config to be https://github.com/nvim-lua/kickstart.nvim
  • add 'JoosepAlviste/nvim-ts-context-commentstring' to require('lazy').setup({})
  • See that commenting random React's jsx in a .tsx file just adds the classic js //

Expected behavior

Should work ootb as per the README

Actual behavior

Doesn't work ootb

@StitiFatah StitiFatah added the bug Something isn't working label Mar 16, 2024
@sarmong
Copy link

sarmong commented May 18, 2024

Should work ootb as per the README

No it shouldn't, and the readme clearly lists steps to make it work for all popular commenting plugins.

As I understand the author, Defaults work out of the box. means that it works without requiring .setup() call as many plugins do and sets up the default config automatically.

JoosepAlviste added a commit that referenced this issue Jul 10, 2024
@JoosepAlviste
Copy link
Owner

Hey! The set up instructions are a little bit out of date, it looks like. It used to be that Comment.nvim and mini.comment only used the commentstring setting when commenting, but they now have some extra logic. Comment.nvim doesn't use commentstring by default but has its own logic. Mini.nvim uses Treesitter (if available) to get the commentstring of the corresponding filetype, not the buffer's commentstring option that this plugin sets.

This means that it won't work OOTB with these plugins like it does with the native Neovim commenting, for example. I improved the setup docs a little bit here: 6b5f95a. How does it look now?

Also, I was thinking of moving away from the autocmd approach to the approach discussed here: #109. I think that that might make the initial set up of the plugin a bit easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants