tomtom / tcomment_vim

An extensible & universal comment vim-plugin that also handles embedded filetypes
http://www.vim.org/scripts/script.php?script_id=1173
GNU General Public License v3.0
1.4k stars 103 forks source link

javascriptreact(jsx) comment do like javascript #295

Open xiote opened 2 years ago

xiote commented 2 years ago
  // App.jsx
  import logo from './logo.svg';
  import './App.css';

  function App() {
    return (
      <div className="App">
        <header className="App-header"/>
      </div>
    );
  }

  export default App;

:call tcomment#debug#CollectInfo()

TCOMMENT: &ft = javascriptreact => javascriptreact
TCOMMENT: stx = jsParen => javascriptParen
TCOMMENT: ct  = {'rxmid': '', 'rxend': '', '_args': {'beg': 7, 'fallbackFiletype': '', 'end': 7, 'filetype': 'javascriptreact', 'comment_mode': ''}, 'commentstring': '// %s', 'commentstring_rx': '\%%(// %s\|/* %s */\)', 'mode': '', 'filetype': 'javascript', 'replacements': {'*/': {'subst': '|)}>#', 'guard_rx': '^\s*/\?\*'}, '/*': {'subst': '#<{(|', 'guard_rx': '^\s*/\?\*'}}, 'rxbeg': '\*\+'}

gcc is wrong

  // App.jsx
  import logo from './logo.svg';
  import './App.css';

  function App() {
    return (
      <div className="App">
        // <header className="App-header"/>
      </div>
    );
  }

  export default App;

:TCommentAs jsx is Ok!

  // App.jsx
  import logo from './logo.svg';
  import './App.css';

  function App() {
    return (
      <div className="App">
        {/* <header className="App-header"/> */}
      </div>
    );
  }

  export default App;

How can i do gcc like commentAs jsx?

tomtom commented 2 years ago

The cursor is over the < and the trans syntax group is jsParen? What's the output of :echo synIDattr(synID(line('.'), col('.'), 0), 'name')?