cmacro: don't format empty lines at end
This commit is contained in:
parent
d16dc90101
commit
8cc995ebda
@ -25,11 +25,22 @@ local function format_macros()
|
|||||||
local lines = vim.api.nvim_buf_get_lines(bufnr, start_line, end_line+1, false)
|
local lines = vim.api.nvim_buf_get_lines(bufnr, start_line, end_line+1, false)
|
||||||
local tabstop = tonumber(vim.bo[bufnr].tabstop) or 8
|
local tabstop = tonumber(vim.bo[bufnr].tabstop) or 8
|
||||||
|
|
||||||
if #lines > 2 then
|
|
||||||
for i, line in ipairs(lines) do
|
for i, line in ipairs(lines) do
|
||||||
lines[i] = line:match("^(.-)%s*[\\]?$")
|
lines[i] = line:match("^(.-)%s*[\\]?$")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
while true do
|
||||||
|
local last_line = lines[#lines]
|
||||||
|
if not last_line then break end
|
||||||
|
if last_line:match("^%s*//") or last_line:match("^%s*/%*") or last_line:match("^%s*$") then
|
||||||
|
table.remove(lines, #lines)
|
||||||
|
end_line = end_line - 1
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if #lines > 2 then
|
||||||
local line_length = 0
|
local line_length = 0
|
||||||
do
|
do
|
||||||
local textwidth = vim.bo[bufnr].textwidth
|
local textwidth = vim.bo[bufnr].textwidth
|
||||||
|
Loading…
Reference in New Issue
Block a user