Skip to content

Commit

Permalink
Clean up comment_line func
Browse files Browse the repository at this point in the history
  • Loading branch information
alex.tylor committed Aug 1, 2021
1 parent 48563db commit 6363118
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions lua/nvim_comment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,12 @@ function M.get_comment_wrapper()
end

function M.comment_line(l, indent, left, right, comment_empty)
local line = l
local comment_pad = indent

if not comment_empty and l:match("^%s*$") then return line end

-- most linters want padding to be formatted correctly
-- so remove comment padding from line
if comment_pad then
line = l:gsub("^" .. comment_pad, "")
else
comment_pad = ""
end
if not comment_empty and l:match("^%s*$") then return l end

-- standarise indentation before adding
local line = l:gsub("^" .. indent, "")
if right then line = line .. right end
return comment_pad .. left .. line
return indent .. left .. line
end

function M.uncomment_line(l, left, right)
Expand Down

0 comments on commit 6363118

Please sign in to comment.