Skip to content
Closed
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
5 changes: 4 additions & 1 deletion doc/mini-comment.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ Defaults ~
-- Whether to ignore blank lines in actions and textobject
ignore_blank_line = false,

-- Whether to ignore blank lines at beginning or end of range selection
ignore_surrounding_blank_line = false,

-- Whether to recognize as comment only lines without indent
start_of_line = false,

Expand Down Expand Up @@ -227,4 +230,4 @@ Return ~
`(string)` Relevant value of 'commentstring'.


vim:tw=78:ts=8:noet:ft=help:norl:
vim:tw=78:ts=8:noet:ft=help:norl:
11 changes: 11 additions & 0 deletions lua/mini/comment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ MiniComment.config = {
-- Whether to ignore blank lines in actions and textobject
ignore_blank_line = false,

-- Whether to ignore blank lines at beginning or end of range selection
ignore_surrounding_blank_line = false,

-- Whether to recognize as comment only lines without indent
start_of_line = false,

Expand Down Expand Up @@ -200,6 +203,13 @@ MiniComment.operator = function(mode)
-- tree-sitter-based 'commentstring'. Recompute every time for a proper
-- dot-repeat. In Visual and sometimes Normal mode it uses left position.
local cursor = vim.api.nvim_win_get_cursor(0)

local config = H.get_config()
if (lnum_from ~= lnum_to) and config.options.ignore_surrounding_blank_line then
lnum_from = vim.fn.nextnonblank(lnum_from)
lnum_to = vim.fn.prevnonblank(lnum_to)
cursor = { lnum_from, 1 }
end
MiniComment.toggle_lines(lnum_from, lnum_to, { ref_position = { cursor[1], cursor[2] + 1 } })
return ''
end
Expand Down Expand Up @@ -413,6 +423,7 @@ H.setup_config = function(config)
H.check_type('options', config.options, 'table')
H.check_type('options.custom_commentstring', config.options.custom_commentstring, 'function', true)
H.check_type('options.ignore_blank_line', config.options.ignore_blank_line, 'boolean')
H.check_type('options.ignore_surrounding_blank_line', config.options.ignore_surrounding_blank_line, 'boolean')
H.check_type('options.start_of_line', config.options.start_of_line, 'boolean')
H.check_type('options.pad_comment_parts', config.options.pad_comment_parts, 'boolean')

Expand Down
3 changes: 3 additions & 0 deletions readmes/mini-comment.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ Here are code snippets for some common installation methods (use only one):
-- Whether to ignore blank lines when commenting
ignore_blank_line = false,

-- Whether to ignore blank lines at beginning or end of range selection
ignore_surrounding_blank_line = false,

-- Whether to ignore blank lines in actions and textobject
start_of_line = false,

Expand Down