Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ Following are the **default** config for the [`setup()`](#setup). If you want to
},

---Pre-hook, called before commenting the line
---@type fun(ctx: Ctx):string
---@type fun(ctx: CommentCtx):string
pre_hook = nil,

---Post-hook, called after commenting is done
---@type fun(ctx: Ctx)
---@type fun(ctx: CommentCtx)
post_hook = nil,
}
```
Expand Down Expand Up @@ -255,7 +255,7 @@ There are two hook methods i.e `pre_hook` and `post_hook` which are called befor
```lua
-- NOTE: The example below is a proper integration and it is RECOMMENDED.
{
---@param ctx Ctx
---@param ctx CommentCtx
pre_hook = function(ctx)
-- Only calculate commentstring for tsx filetypes
if vim.bo.filetype == 'typescriptreact' then
Expand Down Expand Up @@ -287,7 +287,7 @@ There are two hook methods i.e `pre_hook` and `post_hook` which are called befor

```lua
{
---@param ctx Ctx
---@param ctx CommentCtx
post_hook = function(ctx)
if ctx.range.srow == ctx.range.erow then
-- do something with the current line
Expand Down Expand Up @@ -411,21 +411,21 @@ The following object is provided as an argument to `pre_hook` and `post_hook` fu

```lua
---Comment context
---@class Ctx
---@field ctype CType
---@field cmode CMode
---@field cmotion CMotion
---@field range CRange
---@class CommentCtx
---@field ctype CommentType
---@field cmode CommentMode
---@field cmotion CommentMotion
---@field range CommentRange

---Range of the selection that needs to be commented
---@class CRange
---@class CommentRange
---@field srow number Starting row
---@field scol number Starting column
---@field erow number Ending row
---@field ecol number Ending column
```

`CType` (Comment type), `CMode` (Comment mode) and `CMotion` (Comment motion) all of them are exported from the plugin's utils for reuse
`CommentType`, `CommentMode` and `CommentMotion` all of them are exported from the plugin's utils for reuse

```lua
require('Comment.utils').ctype.{line,block}
Expand Down
92 changes: 46 additions & 46 deletions doc/API.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# ⚙️ API

Following are list of APIs that are exported from the plugin. These can be used to setup [custom keybinding](#usage) or to make your own custom comment function. All API functions can take `vmode` (defined below) and a optional [`cfg`](../README.md#config) argument which can be used to override the [default configuration](../README.md#config)
Following are list of APIs that are exported from the plugin. These can be used to setup [custom keybinding](#usage) or to make your own custom comment function. All API functions can take `opmode` (defined below) and a optional [`cfg`](../README.md#config) argument which can be used to override the [default configuration](../README.md#config)

```lua
---@alias VMode '"line"'|'"char"'|'"v"'|'"V"' Vim Mode. Read `:h map-operator`
---@alias OpMode 'line'|'char'|'v'|'V' Vim operator-mode motions. Read `:h map-operator`
```

### Core
Expand All @@ -14,41 +14,41 @@ These APIs powers the [basic-mappings](../README.md#basic-mappings).
--######### LINEWISE #########--

---Toggle linewise-comment on the current line
---@param cfg? Config
---@param cfg? CommentConfig
require('Comment.api').toggle_current_linewise(cfg)

---(Operator-Pending) Toggle linewise-comment on the current line
---@param vmode VMode
---@param cfg? Config
require('Comment.api').toggle_current_linewise_op(vmode, cfg)
---@param opmode OpMode
---@param cfg? CommentConfig
require('Comment.api').toggle_current_linewise_op(opmode, cfg)

---(Operator-Pending) Toggle linewise-comment over multiple lines
---@param vmode VMode
---@param cfg? Config
require('Comment.api').toggle_linewise_op(vmode, cfg)
---@param opmode OpMode
---@param cfg? CommentConfig
require('Comment.api').toggle_linewise_op(opmode, cfg)

---Toggle linewise-comment over multiple lines using `vim.v.count`
---@param cfg? Config
---@param cfg? CommentConfig
require('Comment.api').toggle_linewise_count(cfg)

--######### BLOCKWISE #########--

---Toggle blockwise comment on the current line
---@param cfg? Config
---@param cfg? CommentConfig
require('Comment.api').toggle_current_blockwise(cfg)

---(Operator-Pending) Toggle blockwise comment on the current line
---@param vmode VMode
---@param cfg? Config
require('Comment.api').toggle_current_blockwise_op(vmode, cfg)
---@param opmode OpMode
---@param cfg? CommentConfig
require('Comment.api').toggle_current_blockwise_op(opmode, cfg)

---(Operator-Pending) Toggle blockwise-comment over multiple lines
---@param vmode VMode
---@param cfg? Config
require('Comment.api').toggle_blockwise_op(vmode, cfg)
---@param opmode OpMode
---@param cfg? CommentConfig
require('Comment.api').toggle_blockwise_op(opmode, cfg)

---Toggle blockwise-comment over multiple lines using `vim.v.count`
---@param cfg? Config
---@param cfg? CommentConfig
require('Comment.api').toggle_blockwise_count(cfg)
```

Expand All @@ -60,29 +60,29 @@ These APIs powers the [extra-mappings](../README.md#extra-mappings) and also pro
--######### LINEWISE #########--

---Insert a linewise-comment below
---@param cfg? Config
---@param cfg? CommentConfig
require('Comment.api').insert_linewise_below(cfg)

---Insert a linewise-comment above
---@param cfg? Config
---@param cfg? CommentConfig
require('Comment.api').insert_linewise_above(cfg)

---Insert a linewise-comment at the end-of-line
---@param cfg? Config
---@param cfg? CommentConfig
require('Comment.api').insert_linewise_eol(cfg)

--######### BLOCKWISE #########--

---Insert a blockwise-comment below
---@param cfg? Config
---@param cfg? CommentConfig
require('Comment.api').insert_blockwise_below(cfg)

---Insert a blockwise-comment above
---@param cfg? Config
---@param cfg? CommentConfig
require('Comment.api').insert_blockwise_above(cfg)

---Insert a blockwise-comment at the end-of-line
---@param cfg? Config
---@param cfg? CommentConfig
require('Comment.api').insert_blockwise_eol(cfg)
```

Expand All @@ -94,52 +94,52 @@ These APIs powers the [extended-mappings](../README.md#extended-mappings).
--######### LINEWISE #########--

---Comment current line using linewise-comment
---@param cfg? Config
---@param cfg? CommentConfig
require('Comment.api').comment_current_linewise(cfg)

---(Operator-Pending) Comment current line using linewise-comment
---@param vmode VMode
---@param cfg? Config
require('Comment.api').comment_current_linewise_op(vmode, cfg)
---@param opmode OpMode
---@param cfg? CommentConfig
require('Comment.api').comment_current_linewise_op(opmode, cfg)

---(Operator-Pending) Comment multiple line using linewise-comment
---@param vmode VMode
---@param cfg? Config
require('Comment.api').comment_linewise_op(vmode, cfg)
---@param opmode OpMode
---@param cfg? CommentConfig
require('Comment.api').comment_linewise_op(opmode, cfg)

---Uncomment current line using linewise-comment
---@param cfg? Config
---@param cfg? CommentConfig
require('Comment.api').uncomment_current_linewise(cfg)

---(Operator-Pending) Uncomment current line using linewise-comment
---@param vmode VMode
---@param cfg? Config
require('Comment.api').uncomment_current_linewise_op(vmode, cfg)
---@param opmode OpMode
---@param cfg? CommentConfig
require('Comment.api').uncomment_current_linewise_op(opmode, cfg)

---(Operator-Pending) Uncomment multiple line using linewise-comment
---@param vmode VMode
---@param cfg? Config
require('Comment.api').uncomment_linewise_op(vmode, cfg)
---@param opmode OpMode
---@param cfg? CommentConfig
require('Comment.api').uncomment_linewise_op(opmode, cfg)

--######### BLOCKWISE #########--

---Comment current line using linewise-comment
---@param cfg? Config
---@param cfg? CommentConfig
require('Comment.api').comment_current_blockwise(cfg)

---(Operator-Pending) Comment current line using blockwise-comment
---@param vmode VMode
---@param cfg? Config
require('Comment.api').comment_current_blockwise_op(vmode, cfg)
---@param opmode OpMode
---@param cfg? CommentConfig
require('Comment.api').comment_current_blockwise_op(opmode, cfg)

---Uncomment current line using blockwise-comment
---@param cfg? Config
---@param cfg? CommentConfig
require('Comment.api').uncomment_current_blockwise(cfg)

---(Operator-Pending) Uncomment current line using blockwise-comment
---@param vmode VMode
---@param cfg? Config
require('Comment.api').uncomment_current_blockwise_op(vmode, cfg)
---@param opmode OpMode
---@param cfg? CommentConfig
require('Comment.api').uncomment_current_blockwise_op(opmode, cfg)
```

### Additional
Expand Down
Loading