lukas-reineke / lsp-format.nvim

A wrapper around Neovims native LSP formatting.
564 stars 27 forks source link

functions in cmd table are not running #1

Closed ahmedelgabri closed 3 years ago

ahmedelgabri commented 3 years ago

This is the config I'm testing & I have g:format_debug=v:true

This works fine

require "format".setup {
  typescript = {
    {cmd = {"prettier -w"}}
  }
}

This doesn't run

require "format".setup {
  typescript = {
    cmd = {
      function(file)
        return string.format("prettier --print-width %s -w %s", vim.bo.textwidth, file)
      end
    }
  }
}
lukas-reineke commented 3 years ago

Your second example is missing one set of {}

require "format".setup {
    typescript = {
        {
            cmd = {
                function(file)
                    return string.format("prettier --print-width %s -w %s", vim.bo.textwidth, file)
                end
            }
        }
    }
}

It's a bit confusing. I'm not super happy with the structure. :thinking:

ahmedelgabri commented 3 years ago

Thanks, it might not be perfect but what's more important I think is that it shouldn't error silently because it's very hard to debug.

lukas-reineke commented 3 years ago

it shouldn't error silently

yea I agree. I should write some validation logic to raise errors with invalid config.