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

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

Open
alextes opened this issue Mar 26, 2019 · 1 comment

Comments

@alextes
Copy link

alextes commented Mar 26, 2019

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 🙏 .

@yuezk
Copy link

yuezk commented Jul 18, 2019

Hi @alextes, try to replace mxw/jsx with vim-jsx-pretty. It works well with the test case you provided if you use the tpope/vim-commentary plugin.

I will try to find a way to fix the problem with tcomment.

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

2 participants