Code Monkey home page Code Monkey logo

ts-comments.nvim's Introduction

๐Ÿš€ ts-comments.nvim

Tiny plugin to enhance Neovim's native comments:

  • Easily override the comment string for a given treesitter language
  • Supports different comment strings for different treesitter node types
  • Relaxed rules for uncommenting
  • Add proper whitespace when needed
  • Supports multiple commentstrings for the same language. The first one is used for adding comments. All are used for uncommenting.

โšก๏ธ Requirements

  • Neovim >= 0.10.0

๐Ÿ“ฆ Installation

Using lazy.nvim:

{
  "folke/ts-comments.nvim",
  opts = {},
  event = "VeryLazy",
  enabled = vim.fn.has("nvim-0.10.0") == 1,
}

โš™๏ธ Configuration

ts-comments.nvim uses the default Neovim commentstring as a fallback, so there's no need to configure every language.

Default configuration:

{
  lang = {
    astro = "<!-- %s -->",
    c = "// %s",
    cpp = "// %s",
    css = "/* %s */",
    cue = "// %s",
    c_sharp = "// %s",
    gleam = "// %s",
    glimmer = "{{! %s }}",
    handlebars = "{{! %s }}",
    hcl = "# %s",
    html = "<!-- %s -->",
    ini = "; %s",
    javascript = {
      "// %s", -- default commentstring when no treesitter node matches
      "/* %s */",
      call_expression = "// %s", -- specific commentstring for call_expression
      jsx_attribute = "// %s",
      jsx_element = "{/* %s */}",
      jsx_fragment = "{/* %s */}",
      spread_element = "// %s",
      statement_block = "// %s",
    },
    lua = { "-- %s", "--- %s" }, -- langs can have multiple commentstrings
    php = "// %s",
    rego = "# %s",
    rescript = "// %s",
    rust = { "// %s", "/* %s */", "/// %s" },
    svelte = "<!-- %s -->",
    terraform = "# %s",
    tsx = {
      "// %s", -- default commentstring when no treesitter node matches
      "/* %s */",
      call_expression = "// %s", -- specific commentstring for call_expression
      jsx_attribute = "// %s",
      jsx_element = "{/* %s */}",
      jsx_fragment = "{/* %s */}",
      spread_element = "// %s",
      statement_block = "// %s",
    },
    twig = "{# %s #}",
    typescript = "// %s",
    vim = '" %s',
    vue = "<!-- %s -->",
  },
}

๐Ÿ”— Related

ts-comments.nvim's People

Contributors

folke avatar github-actions[bot] avatar folliehiyuki avatar okuramasafumi avatar zoriya avatar fnoopv avatar ilyasakin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.