Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/folke/ts-comments.nvim
Tiny plugin to enhance Neovim's native comments
https://github.com/folke/ts-comments.nvim
neovim neovim-plugin nvim nvim-plugin
Last synced: 4 days ago
JSON representation
Tiny plugin to enhance Neovim's native comments
- Host: GitHub
- URL: https://github.com/folke/ts-comments.nvim
- Owner: folke
- License: apache-2.0
- Created: 2024-05-20T21:09:01.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-05-22T17:32:19.000Z (6 months ago)
- Last Synced: 2024-05-22T23:50:20.800Z (6 months ago)
- Topics: neovim, neovim-plugin, nvim, nvim-plugin
- Language: Lua
- Homepage:
- Size: 44.9 KB
- Stars: 158
- Watchers: 3
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 🚀 `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](https://github.com/folke/lazy.nvim):
```lua
{
"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:
```lua
{
lang = {
astro = "",
axaml = "",
blueprint = "// %s",
c = "// %s",
c_sharp = "// %s",
clojure = { ";; %s", "; %s" },
cpp = "// %s",
cs_project = "",
cue = "// %s",
fsharp = "// %s",
fsharp_project = "",
gleam = "// %s",
glimmer = "{{! %s }}",
graphql = "# %s",
handlebars = "{{! %s }}",
hcl = "# %s",
html = "",
hyprlang = "# %s",
ini = "; %s",
ipynb = "# %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",
},
kdl = "// %s",
php = "// %s",
rego = "# %s",
rescript = "// %s",
rust = { "// %s", "/* %s */" },
sql = "-- %s",
styled = "/* %s */",
svelte = "",
templ = {
"// %s",
component_block = "",
},
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", "/* %s */" }, -- langs can have multiple commentstrings
vue = "",
xaml = "",
},
}
```## 🔗 Related
- [nvim-ts-context-commentstring](https://github.com/JoosepAlviste/nvim-ts-context-commentstring)