Share a configuration snippet for formatting crystal code under neovim

plugin ref: GitHub - stevearc/conform.nvim: Lightweight yet powerful formatter plugin for Neovim

lazy config:

{
  'stevearc/conform.nvim',
  event = { 'BufWritePre' },
  config = function()
    require('conform').setup {
      formatters_by_ft = {
        crystal    = { 'crystal' }
      },
      formatters = {
        crystal = {
          command = "crystal",
          args = { "tool", "format", "-" },
          stdin = true,
        },
      },
      format_on_save = {
        timeout_ms = 500,
        lsp_fallback = true,
      },
    }
  end
}
1 Like