@@ -13,6 +13,10 @@ local A = vim.api
1313
1414local api , core = {}, {}
1515
16+ --- API metamethods
17+ --- @param that table
18+ --- @param ctype CommentType
19+ --- @return table
1620function core .__index (that , ctype )
1721 local idxd = {}
1822 local mode , type = that .cmode , U .ctype [ctype ]
@@ -22,25 +26,25 @@ function core.__index(that, ctype)
2226 --- In current-line linewise method, 'opmode' is not useful which is always equals to `char`
2327 --- but we need 'nil' here which is used for current-line
2428 function idxd .current (_ , cfg )
25- Op .opfunc ( nil , cfg or Config :get (), mode , type )
29+ U . catch ( Op .opfunc , nil , cfg or Config :get (), mode , type )
2630 end
2731
2832 --- To comment lines with a count
2933 function idxd .count (count , cfg )
30- Op .count ( count or A .nvim_get_vvar (' count' ), cfg or Config :get (), mode , type )
34+ U . catch ( Op .count , count or A .nvim_get_vvar (' count' ), cfg or Config :get (), mode , type )
3135 end
3236
3337 --- @private
3438 --- To comment lines with a count, also dot-repeatable
35- --- WARNING : This is not part of the API but anyone case use it, if they want
39+ --- WARN : This is not part of the API but anyone case use it, if they want
3640 function idxd .count_repeat (_ , count , cfg )
3741 idxd .count (count , cfg )
3842 end
3943
4044 return setmetatable ({}, {
4145 __index = idxd ,
4246 __call = function (_ , motion , cfg )
43- Op .opfunc ( motion , cfg or Config :get (), mode , type )
47+ U . catch ( Op .opfunc , motion , cfg or Config :get (), mode , type )
4448 end ,
4549 })
4650end
@@ -173,13 +177,13 @@ api.insert = setmetatable({}, {
173177 __index = function (_ , ctype )
174178 return {
175179 above = function (cfg )
176- Ex .insert_above ( U .ctype [ctype ], cfg or Config :get ())
180+ U . catch ( Ex .insert_above , U .ctype [ctype ], cfg or Config :get ())
177181 end ,
178182 below = function (cfg )
179- Ex .insert_below ( U .ctype [ctype ], cfg or Config :get ())
183+ U . catch ( Ex .insert_below , U .ctype [ctype ], cfg or Config :get ())
180184 end ,
181185 eol = function (cfg )
182- Ex .insert_eol ( U .ctype [ctype ], cfg or Config :get ())
186+ U . catch ( Ex .insert_eol , U .ctype [ctype ], cfg or Config :get ())
183187 end ,
184188 }
185189 end ,
0 commit comments