CaryWill / SingleComment.nvim

Always single line, comment sensitive, indentation preserving commenting.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Most code are copied from mini.comment and SingleComment repo. Thanks for the great work.

Motivation

I found most plugins that working with react are commenting on eaching line instead of just comment on the first and last line when available.

SingleComment plugin seems working, but it fails to do so when comment on react files like,

  render() {
    const a = 123;
    const b = 123;
    return (
      <div>
        <span>123</span>
        <span>123</span>
        <span>123</span>
        <span>123</span>
      </div>
    );
  }

what i want is like this,

  render() {
    const a = 123;
    const b = 123;
    return (
      <div>
        <span>123</span>
        {/*<span>123</span>
           <span>123</span>
           <span>123</span>*/}
      </div>
    );
  }

while well, vscode is like this, no additional indent for the following lines

  render() {
    const a = 123;
    const b = 123;
    return (
      <div>
        <span>123</span>
        {/* <span>123</span>
        <span>123</span>
        <span>123</span> */}
      </div>
    );
  }

instead of this,

  render() {
    const a = 123;
    const b = 123;
    return (
      <div>
        <span>123</span>
        {/*<span>123</span>*/}
        {/*<span>123</span>*/}
        {/*<span>123</span>*/}
      </div>
    );
  }

Since i cannot found out why i cannot get the right comment string using ts_comment_string plugin, I just copied this part of logic from mini.comment plugin.

Test case

back compatibale

if it's already formated like this, then comment on each line, since most plugins are using this kind of style

      <div>
        <span>123</span>
        {/*<span>123</span>*/}
        {/*<span>123</span>*/}
        {/*<span>123</span>*/}
      </div>

blank lines between lines

    const a = 123;

    const b = 123;

support inline comment

function test(a, /*b*/, c) {}

mutiline block

  const qrCodeProps = {
    value,
    size: size - (token.paddingSM + token.lineWidth) * 2,
    level: errorLevel,
    bgColor,
    fgColor: color,
    imageSettings: icon ? imageSettings : undefined,
  };

Goal

  • comment jsx when more than 1 line is selected no matter where the cursor is
  • need test lua file multi-lines
  • 发现vissual 打印不出来可能是被覆盖了,所以我直接写变量到全局,然后自己手动打印
  • see if i can unify just using original repo
  • add space after comment

TODO

  • can not print lua message when selecting multi-lines in visiual mode

  • single line toggle are not working right(right comment part missing, i guess it's because of toggle_lines impl, yes it is)

  • support setup config(like disable, custom comment string)

  • json file comment not right like coc.json(yeah, actually json file type doesnt support comment)

  • comment then uncomment should made file remain unchanged, why i need to save the file again

  • jsx comment like in vscode

  • ignore blank line

  • bug

        fuzzy = true,                   -- false will only do exact matching

What not support

  1. 10gc, ...

Refs

  1. test
  2. mini.comment
  3. my fork
  4. lua guide

About

Always single line, comment sensitive, indentation preserving commenting.

License:GNU General Public License v3.0


Languages

Language:Lua 95.1%Language:HTML 3.7%Language:TypeScript 1.2%