@@ -15,18 +15,19 @@ local api, core = {}, {}
1515
1616function core .__index (that , ctype )
1717 local idxd = {}
18+ local mode , type = that .cmode , U .ctype [ctype ]
1819
1920 --- To comment the current-line
2021 --- NOTE:
2122 --- In current-line linewise method, 'opmode' is not useful which is always equals to `char`
2223 --- but we need 'nil' here which is used for current-line
2324 function idxd .current (_ , cfg )
24- Op .opfunc (nil , cfg or Config :get (), that . cmode , U . ctype [ ctype ] )
25+ Op .opfunc (nil , cfg or Config :get (), mode , type )
2526 end
2627
2728 --- To comment lines with a count
2829 function idxd .count (count , cfg )
29- Op .count (count or A .nvim_get_vvar (' count' ), cfg or Config :get (), that . cmode , U . ctype [ ctype ] )
30+ Op .count (count or A .nvim_get_vvar (' count' ), cfg or Config :get (), mode , type )
3031 end
3132
3233 --- @private
@@ -36,10 +37,10 @@ function core.__index(that, ctype)
3637 idxd .count (count , cfg )
3738 end
3839
39- return setmetatable ({ cmode = that . cmode , ctype = ctype }, {
40+ return setmetatable ({}, {
4041 __index = idxd ,
41- __call = function (this , motion , cfg )
42- Op .opfunc (motion , cfg or Config :get (), this . cmode , U . ctype [ this . ctype ] )
42+ __call = function (_ , motion , cfg )
43+ Op .opfunc (motion , cfg or Config :get (), mode , type )
4344 end ,
4445 })
4546end
5657--- @see comment.config
5758--- @usage [[
5859--- local api = require('Comment.api')
60+ --- local config = require('Comment.config'):get()
5961---
60- --- api.toggle.linewise(motion, config)
62+ --- api.toggle.linewise(motion, config? )
6163--- api.toggle.linewise.current(motion?, config?)
6264--- api.toggle.linewise.count(count, config?)
6365---
@@ -115,8 +117,9 @@ api.toggle = setmetatable({ cmode = U.cmode.toggle }, core)
115117--- @see comment.config
116118--- @usage [[
117119--- local api = require('Comment.api')
120+ --- local config = require('Comment.config'):get()
118121---
119- --- api.comment.linewise(motion, config)
122+ --- api.comment.linewise(motion, config? )
120123--- api.comment.linewise.current(motion?, config?)
121124--- api.comment.linewise.count(count, config?)
122125---
@@ -138,8 +141,9 @@ api.comment = setmetatable({ cmode = U.cmode.comment }, core)
138141--- @see comment.config
139142--- @usage [[
140143--- local api = require('Comment.api')
144+ --- local config = require('Comment.config'):get()
141145---
142- --- api.uncomment.linewise(motion, config)
146+ --- api.uncomment.linewise(motion, config? )
143147--- api.uncomment.linewise.current(motion?, config?)
144148--- api.uncomment.linewise.count(count, config?)
145149---
@@ -155,14 +159,15 @@ api.uncomment = setmetatable({ cmode = U.cmode.uncomment }, core)
155159--- @see comment.config
156160--- @usage [[
157161--- local api = require('Comment.api')
162+ --- local config = require('Comment.config'):get()
158163---
159- --- api.insert.linewise.above(cfg ?)
160- --- api.insert.linewise.below(cfg ?)
161- --- api.insert.linewise.eol(cfg ?)
164+ --- api.insert.linewise.above(config ?)
165+ --- api.insert.linewise.below(config ?)
166+ --- api.insert.linewise.eol(config ?)
162167---
163- --- api.insert.blockwise.above(cfg ?)
164- --- api.insert.blockwise.below(cfg ?)
165- --- api.insert.blockwise.eol(cfg ?)
168+ --- api.insert.blockwise.above(config ?)
169+ --- api.insert.blockwise.below(config ?)
170+ --- api.insert.blockwise.eol(config ?)
166171--- @usage ]]
167172api .insert = setmetatable ({}, {
168173 __index = function (_ , ctype )
218223--- 2. Preserves jumps and marks
219224--- 3. Stores last cursor position
220225--- @param cb string Name of the API function to call
221- --- @param op ' g@ ' | ' g@$' Operator string to execute
226+ --- @param op ' "g@" ' | ' " g@$" ' Operator-mode expression
222227--- @return fun (): string #Keymap RHS callback
223228--- @see g @
224229--- @see operatorfunc
0 commit comments