mhartington/formatter.nvim

lua formatter remove the final newline on Windows 11

Closed this issue · 1 comments

Before proceeding
If you modified the configuration yourself, check that you tried options such as no_append or ignore_exitcode, and also, if you can, try to run the configuration in your shell.

Shell command and output (optional):

Which configuration?
Type (custom or builtin): custom
Filetype: lua
Formatter: stylua

Configuration(s) (post all the variants you tried):

vim.cmd [[packadd packer.nvim]]
require('packer').startup(function(use)
  use 'wbthomason/packer.nvim'
  use 'mhartington/formatter.nvim'
end)

local util = require "formatter.util"
require("formatter").setup {
  logging = true,
  log_level = vim.log.levels.WARN,
  filetype = {
    lua = {
      require("formatter.filetypes.lua").stylua,
      function()
        return {
          exe = "stylua",
          args = {
            "--search-parent-directories",
            "--stdin-filepath",
            util.escape_path(util.get_current_buffer_file_path()),
            "--",
            "-",
          },
          stdin = true,
        }
      end
    },
  }
}

Expected behavior
Before

local a

After

local a

Actual behaviour

local a

Additional context
Add any other context about the problem here.

  • stylua inserts the final newline always

https://stackoverflow.com/questions/15639511/vim-show-newline-at-the-end-of-file

EOL or "newline" doesn't mean "there's an empty line after here", it means "this marks the end of the line, any further characters are to be displayed on another line". "newline" != "new line".