tpope / vim-commentary

commentary.vim: comment stuff out
http://www.vim.org/scripts/script.php?script_id=3695
5.88k stars 215 forks source link

Different types of comments depending on the context of the code #149

Open MuhammadSawalhy opened 3 years ago

MuhammadSawalhy commented 3 years ago

I want to have the same experience of VSCode and some other code editors and IDEs, some examples are coming. As no plugin now solves this problem It seems difficult to apply different types of comments depending on the context of the code, or maybe some focus needs to be put to make this feature available.

JSX

https://user-images.githubusercontent.com/42011920/129124046-d22bf2a4-f423-4336-8f05-c27584805a58.mp4

HTML

https://user-images.githubusercontent.com/42011920/129125306-82e3487e-db76-438c-b2fd-8bc25e45b425.mp4

xaizek commented 3 years ago

As no plugin now solves this problem

Isn't that what https://github.com/suy/vim-context-commentstring is trying to do?

MuhammadSawalhy commented 3 years ago

Isn't that what https://github.com/suy/vim-context-commentstring is trying to do?

This plugin solves some problems of comments, it solves problems of HTML and Lua in Vim, but I still have the same problems of JSX (HTML in Js) syntax, the same video of JSX.

chrisbra commented 3 years ago

I think https://github.com/tomtom/tcomment_vim that solves embedded filetypes

SiddharthShyniben commented 2 years ago

This plugin solves some problems of comments, it solves problems of HTML and Lua in Vim, but I still have the same problems of JSX (HTML in Js) syntax, the same video of JSX.

You could possibly add this as a feature request to https://github.com/suy/vim-context-commentstring itself

githorse commented 1 year ago

Same problem. This Stackexchange question claims all I need to make JSX/TSX work with vim-commentary is the additional plugins vim-context-commentstring and vim-jsx-pretty, but the solution there doesn't work for me. I also have an open issue in vim-context-commentstring for this.

Would definitely be great if this plugin could handle multi-syntax files natively, or, if not, perhaps put some information in the FAQ about how to make it work with additional plugins.

MuhammadSawalhy commented 1 year ago

https://github.com/preservim/nerdcommenter/issues/298#issuecomment-1448989706

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

nvim-ts-context-commentstring & Comment.nvim

ghost commented 9 months ago

This post has made me curious ever since I looked at it, but I tried VScode, it's default behavior seems to be based on file extension alone. For example, i made a file with an .html label, then i entered some java script code, and when i highlighted the line and hit Ctrl + /, it surrounded it with the html comments which is the type of thing you are talking about.

Did you install some plugin/extension for VScode that changes that behavior?