From 5b3b5886d4921c1350e851938885aab7cfdb74c1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 16 Apr 2024 12:35:37 +0800 Subject: [PATCH] fix(format): fix formatter end_line --- bundle/format.nvim/lua/format.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bundle/format.nvim/lua/format.lua b/bundle/format.nvim/lua/format.lua index 1400671ca..ce865baee 100644 --- a/bundle/format.nvim/lua/format.lua +++ b/bundle/format.nvim/lua/format.lua @@ -18,7 +18,7 @@ function M.format(bang, user_input, start_line, end_line) local ok, formatter if custom_formatters[filetype] then formatter = custom_formatters[filetype] - if formatter.exe and type(formatter.exe) == "string" then + if formatter.exe and type(formatter.exe) == 'string' then util.info('using custom formatter:' .. formatter.exe) end end @@ -33,9 +33,9 @@ function M.format(bang, user_input, start_line, end_line) task.run({ bufnr = vim.fn.bufnr(), - stdin = vim.api.nvim_buf_get_lines(0, start_line - 1, end_line - 1, false), + stdin = vim.api.nvim_buf_get_lines(0, start_line - 1, end_line, false), start_line = start_line - 1, - end_line = end_line - 1, + end_line = end_line, formatter = formatter, }) end @@ -43,10 +43,11 @@ end function M.setup(opt) if opt.custom_formatters and type(opt.custom_formatters) == 'table' then for k, v in pairs(opt.custom_formatters) do - if type(v) == "table" then + if type(v) == 'table' then custom_formatters[k] = v end end end end + return M