aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/conform/lsp_format.lua4
1 files changed, 4 insertions, 0 deletions
diff --git a/lua/conform/lsp_format.lua b/lua/conform/lsp_format.lua
index 66be47d..1400f3b 100644
--- a/lua/conform/lsp_format.lua
+++ b/lua/conform/lsp_format.lua
@@ -13,6 +13,10 @@ local function apply_text_edits(text_edits, bufnr, offset_encoding)
then
local original_lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, true)
local new_lines = vim.split(text_edits[1].newText, "\n", { plain = true })
+ -- If it had a trailing newline, remove it to make the lines match the expected vim format
+ if #new_lines > 1 and new_lines[#new_lines] == "" then
+ table.remove(new_lines)
+ end
require("conform.runner").apply_format(bufnr, original_lines, new_lines, nil, false)
else
vim.lsp.util.apply_text_edits(text_edits, bufnr, offset_encoding)