mirror of
https://github.com/zoriya/ts-comments.nvim.git
synced 2026-08-16 02:44:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba6670cac7 | ||
|
|
57e6c133c6 | ||
|
|
d289353975 | ||
|
|
055470b331 | ||
|
|
6e84c5b4b0 | ||
|
|
52d0a587d5 | ||
|
|
87fc61f065 |
@@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [1.0.1](https://github.com/folke/ts-comments.nvim/compare/v1.0.0...v1.0.1) (2024-05-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* dont error when treesitter parser is not available ([87fc61f](https://github.com/folke/ts-comments.nvim/commit/87fc61f065db61e3e229b08765e2ea030c0eaf61))
|
||||||
|
|
||||||
## 1.0.0 (2024-05-20)
|
## 1.0.0 (2024-05-20)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
# 🚀 ts-comments.nvim
|
# 🚀 `ts-comments.nvim`
|
||||||
|
|
||||||
Tiny plugin to enhance Neovim's native comments:
|
Tiny plugin to enhance Neovim's native comments:
|
||||||
|
|
||||||
- Easily override the comment string for a given **treesitter** language
|
- Easily override the comment string for a given **treesitter** language
|
||||||
- Supports different comment strings for different **treesitter** node types
|
- Supports different comment strings for different **treesitter** node types
|
||||||
|
|
||||||
# ⚡️ Requirements
|
## ⚡️ Requirements
|
||||||
|
|
||||||
- Neovim >= 0.10.0
|
- Neovim >= 0.10.0
|
||||||
|
|
||||||
# 📦 Installation
|
## 📦 Installation
|
||||||
|
|
||||||
Using [lazy.nvim](https://github.com/folke/lazy.nvim):
|
Using [lazy.nvim](https://github.com/folke/lazy.nvim):
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
"folke/ts-comments.nvim",
|
"folke/ts-comments.nvim",
|
||||||
opts = {}
|
opts = {},
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
enabled = vim.fn.has("nvim-0.10.0") == 1,
|
enabled = vim.fn.has("nvim-0.10.0") == 1,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
# ⚙️ Configuration
|
## ⚙️ Configuration
|
||||||
|
|
||||||
Default configuration:
|
Default configuration:
|
||||||
|
|
||||||
@@ -33,6 +33,7 @@ Default configuration:
|
|||||||
c = "// %s",
|
c = "// %s",
|
||||||
cpp = "// %s",
|
cpp = "// %s",
|
||||||
css = "/* %s */",
|
css = "/* %s */",
|
||||||
|
c_sharp = "// %s",
|
||||||
gleam = "// %s",
|
gleam = "// %s",
|
||||||
glimmer = "{{! %s }}",
|
glimmer = "{{! %s }}",
|
||||||
graphql = "# %s",
|
graphql = "# %s",
|
||||||
@@ -75,6 +76,6 @@ Default configuration:
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# 🔗 Related
|
## 🔗 Related
|
||||||
|
|
||||||
- [nvim-ts-context-commentstring](https://github.com/JoosepAlviste/nvim-ts-context-commentstring)
|
- [nvim-ts-context-commentstring](https://github.com/JoosepAlviste/nvim-ts-context-commentstring)
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
Table of Contents *ts-comments.nvim-table-of-contents*
|
Table of Contents *ts-comments.nvim-table-of-contents*
|
||||||
|
|
||||||
1. ts-comments.nvim |ts-comments.nvim-ts-comments.nvim|
|
1. ts-comments.nvim |ts-comments.nvim-ts-comments.nvim|
|
||||||
2. Requirements |ts-comments.nvim-requirements|
|
- Requirements |ts-comments.nvim-ts-comments.nvim-requirements|
|
||||||
3. Installation |ts-comments.nvim-installation|
|
- Installation |ts-comments.nvim-ts-comments.nvim-installation|
|
||||||
4. Configuration |ts-comments.nvim-configuration|
|
- Configuration |ts-comments.nvim-ts-comments.nvim-configuration|
|
||||||
5. Related |ts-comments.nvim-related|
|
- Related |ts-comments.nvim-ts-comments.nvim-related|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
1. ts-comments.nvim *ts-comments.nvim-ts-comments.nvim*
|
1. ts-comments.nvim *ts-comments.nvim-ts-comments.nvim*
|
||||||
@@ -18,29 +18,26 @@ Tiny plugin to enhance Neovim’s native comments:
|
|||||||
- Supports different comment strings for different **treesitter** node types
|
- Supports different comment strings for different **treesitter** node types
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
REQUIREMENTS *ts-comments.nvim-ts-comments.nvim-requirements*
|
||||||
2. Requirements *ts-comments.nvim-requirements*
|
|
||||||
|
|
||||||
- Neovim >= 0.10.0
|
- Neovim >= 0.10.0
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
INSTALLATION *ts-comments.nvim-ts-comments.nvim-installation*
|
||||||
3. Installation *ts-comments.nvim-installation*
|
|
||||||
|
|
||||||
Using lazy.nvim <https://github.com/folke/lazy.nvim>
|
Using lazy.nvim <https://github.com/folke/lazy.nvim>
|
||||||
|
|
||||||
>lua
|
>lua
|
||||||
{
|
{
|
||||||
"folke/ts-comments.nvim",
|
"folke/ts-comments.nvim",
|
||||||
opts = {}
|
opts = {},
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
enabled = vim.fn.has("nvim-0.10.0") == 1,
|
enabled = vim.fn.has("nvim-0.10.0") == 1,
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
CONFIGURATION *ts-comments.nvim-ts-comments.nvim-configuration*
|
||||||
4. Configuration *ts-comments.nvim-configuration*
|
|
||||||
|
|
||||||
Default configuration:
|
Default configuration:
|
||||||
|
|
||||||
@@ -93,8 +90,7 @@ Default configuration:
|
|||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
RELATED *ts-comments.nvim-ts-comments.nvim-related*
|
||||||
5. Related *ts-comments.nvim-related*
|
|
||||||
|
|
||||||
- nvim-ts-context-commentstring <https://github.com/JoosepAlviste/nvim-ts-context-commentstring>
|
- nvim-ts-context-commentstring <https://github.com/JoosepAlviste/nvim-ts-context-commentstring>
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -7,6 +7,7 @@ local defaults = {
|
|||||||
c = "// %s",
|
c = "// %s",
|
||||||
cpp = "// %s",
|
cpp = "// %s",
|
||||||
css = "/* %s */",
|
css = "/* %s */",
|
||||||
|
c_sharp = "// %s",
|
||||||
gleam = "// %s",
|
gleam = "// %s",
|
||||||
glimmer = "{{! %s }}",
|
glimmer = "{{! %s }}",
|
||||||
graphql = "# %s",
|
graphql = "# %s",
|
||||||
@@ -46,12 +47,12 @@ function M.setup(opts)
|
|||||||
if option ~= "commentstring" then
|
if option ~= "commentstring" then
|
||||||
return get_option(filetype, option)
|
return get_option(filetype, option)
|
||||||
end
|
end
|
||||||
local lang = vim.treesitter.language.get_lang(filetype)
|
local lang = vim.treesitter.language.get_lang(filetype) or filetype
|
||||||
|
|
||||||
local ret = opts.lang[lang]
|
local ret = opts.lang[lang]
|
||||||
if type(ret) == "table" then
|
if type(ret) == "table" then
|
||||||
local node = vim.treesitter.get_node({ ignore_injections = false })
|
local ok, node = pcall(vim.treesitter.get_node, { ignore_injections = false })
|
||||||
while node do
|
while ok and node do
|
||||||
if ret[node:type()] then
|
if ret[node:type()] then
|
||||||
ret = ret[node:type()]
|
ret = ret[node:type()]
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user