aboutsummaryrefslogtreecommitdiffstats
path: root/lua/conform/lsp_format.lua
diff options
context:
space:
mode:
authorSteven Arcangeli <stevearc@stevearc.com>2024-01-21 10:49:44 -0800
committerSteven Arcangeli <stevearc@stevearc.com>2024-01-21 10:49:44 -0800
commit9a785eb8f0199ac47ce8bb9e9b6103de5ad8e3a7 (patch)
tree107c70dc4e872ae64e0e7309013c99ded8255b19 /lua/conform/lsp_format.lua
parentcbc5745bf7519acaf3a5cbaaa677fd556aa813d7 (diff)
fix: handle windows line endings (#274)
Diffstat (limited to 'lua/conform/lsp_format.lua')
-rw-r--r--lua/conform/lsp_format.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/lua/conform/lsp_format.lua b/lua/conform/lsp_format.lua
index f49e15f..6fa9a64 100644
--- a/lua/conform/lsp_format.lua
+++ b/lua/conform/lsp_format.lua
@@ -13,7 +13,7 @@ local function apply_text_edits(text_edits, bufnr, offset_encoding, dry_run)
and text_edits[1].range["end"].character == 0
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 })
+ local new_lines = vim.split(text_edits[1].newText, "\r?\n", {})
-- 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)