Skip to content

Commenting JSX makes line JavaScript instead of JSX breaking context aware commenting #176

@alextes

Description

@alextes

In the following code:

const React = require("react");

export default () => (
  <div>
    {/* <h1>Hello World!</h1> */}
  </div>
);

When testing with mxw/vim-jsx and pangloss/vim-javascript the line with the jsx comment is labelled a jsxChild. Combined with othree/yajs.vim (which has way nicer highlighting 👏 ) the line becomes javaScriptBraces. This means my context aware commenting plugin adds {/* */}, but upon requesting to uncomment does nothing, or worse, when requesting to toggle the comment, comments again, making it // {/* */} as it 'correctly' recognized the JavaScript syntax was not yet commented as {/* */} is only a comment in JSX.

Related issue tomtom/tcomment_vim#248 in tcomment that has some screenshots.

I know parsing JSX is a pain in the butt, let me know if there's anything else I can do to help. Commenting I'm noticing is quite frequently used in UI work.

Thanks for an awesome plugin 🙏 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions