peitalin / vim-jsx-typescript

React JSX syntax highlighting for vim and Typescript
The Unlicense
305 stars 29 forks source link

JSX Comments are applied to entire file #14

Closed good-idea closed 5 years ago

good-idea commented 5 years ago

When commenting other lines in a .tsx file, vim-commentary uses commentstring for any selection, leading to things like:


{/* const myUtility = () => { */}
{/*   return 'something' */}
{/* } */}

export const MyComponent = () => {
  return (
    <div>
      {/* <p>Hello</p> */}
      <p>World</p>
    </div>
  )
}

Is there a way to get this to apply only to JSX?

In the meantime, a workaround is just setting the commentstring back to its default in your .vimrc:

autocmd FileType typescript.tsx setlocal commentstring=//\ %s

(this means that commenting JSX won't work, though)

good-idea commented 5 years ago

There's some discussion about this here:

https://github.com/tpope/vim-commentary/issues/68

But I haven't been able to figure it out on my end yet. I'll post back here when I figure something out.

Edit: I switched to https://github.com/tomtom/tcomment_vim instead of vim-commentary, everything works out of the box :)