nerdcommenter icon indicating copy to clipboard operation
nerdcommenter copied to clipboard

jsx comments

Open AdrienLemaire opened this issue 7 years ago • 6 comments

hi scrooloose,

Is there a way to integrate jsx style comments in your plugin?

Instead of

//<View>

I'd like to get

{/* <View> */}

I guess this won't be trivial since you need to detect whether the current line is jsx code or regular javascript. But that would be damn useful!

AdrienLemaire avatar May 24 '17 03:05 AdrienLemaire

See #280 for history and discussion of this issue. I'll keep this issue open since it is an outstanding feature request and the other issue was closed when we reverted the original code related to this.

alerque avatar May 24 '17 08:05 alerque

After some searches, I found this feature implemented in vim-commentary but not accurately implemented, so I created this issue there.

What I want to say, I think it is somehow possible to bring this feature to vim.

MuhammadSawalhy avatar Aug 12 '21 01:08 MuhammadSawalhy

Oh it's definitely possible, it's just quite a bit of work and doesn't fit well with the current layout of the code in this plugin. I'd love to see it done too because I'd benefit as well, but I haven't had time to implement it myself. Anybody is welcome to, I think if you look at the history this project has been pretty open to contributions. A tad slow reviewing sometimes, but we generally accept things when they are found to be ship shape.

alerque avatar Aug 12 '21 05:08 alerque

Hopefully this is helpful. I solved this by setting custom delimiters on javascript files, then using ca to toggle between primary and alternative when working in jsx.

let g:NERDCustomDelimiters = {'javascript': { 'left': '//', 'right': '', 'leftAlt': '{/* ', 'rightAlt': ' */}' }}

LinuxIsCool avatar Feb 28 '23 20:02 LinuxIsCool

A tree-sitter-based plugin did awesome work to support jsx and I'm now happy with it:

nvim-ts-context-commentstring & Comment.nvim

MuhammadSawalhy avatar Feb 28 '23 22:02 MuhammadSawalhy

Hi @MuhammadSawalhy -- ok, you're saying I need to switch from vim-commentary to the Comment.nvim to make this work? I added nvim-ts-context-commentstring but that did not fix the issue using vim-commentary (even though nvim-ts-context-commentstring actually recommends using vim-commentary ...)

githorse avatar Mar 10 '23 22:03 githorse