Use `\r\n` for new files on Windows (#1596)

* Use `\r\n` for new files on Windows

* Add `config.line_endings`
This commit is contained in:
Guldoman 2023-11-30 16:51:10 +01:00 committed by George Sokianos
parent 7111b8a6c9
commit a29327e375
2 changed files with 9 additions and 0 deletions

View File

@ -153,6 +153,12 @@ config.tab_type = "soft"
---@type boolean ---@type boolean
config.keep_newline_whitespace = false config.keep_newline_whitespace = false
---Default line endings for new files.
---
---Defaults to `crlf` (`\r\n`) on Windows and `lf` (`\n`) on everything else.
---@type "crlf" | "lf"
config.line_endings = PLATFORM == "Windows" and "crlf" or "lf"
---Maximum number of characters per-line for the line guide. ---Maximum number of characters per-line for the line guide.
--- ---
---Defaults to 80. ---Defaults to 80.

View File

@ -28,6 +28,9 @@ function Doc:new(filename, abs_filename, new_file)
self:load(filename) self:load(filename)
end end
end end
if new_file then
self.crlf = config.line_endings == "crlf"
end
end end
function Doc:reset() function Doc:reset()