Skip to content

Commit a841f73

Browse files
committed
feat: allow padding as a function
Now a function can be given for `padding` which can return a boolean. This will allow commenting in `norg` files. Previously it wasn't possible because of it's strict commenting rules. ```lua require('Comment').setup({ padding = function () return vim.bo.filetype ~= 'norg' end }) ````
1 parent 92da1bd commit a841f73

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Following are the **default** config for the [`setup()`](#setup). If you want to
6767
```lua
6868
{
6969
---Add a space b/w comment and the line
70-
---@type boolean
70+
---@type boolean|fun():boolean
7171
padding = true,
7272

7373
---Whether the cursor should stay at its position

lua/Comment/utils.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ end
6666

6767
---Helper to get padding (I was tired to check this everywhere)
6868
---NOTE: We can also use function to calculate padding if someone wants more spacing
69-
---@param flag boolean
69+
---@param flag boolean|fun():boolean
7070
---@return string string Padding chars
7171
---@return string string Padding pattern
7272
function U.get_padding(flag)
73-
if not flag then
73+
if not U.is_fn(flag) then
7474
return '', ''
7575
end
7676
return ' ', '%s?'

0 commit comments

Comments
 (0)