Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.
/ sync-format.nvim Public archive

Synchronous formatter runner for Neovim using in-place formatters. No stdin support.

License

Notifications You must be signed in to change notification settings

mgnsk/sync-format.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

conform.nvim runs formatters synchronously and uses stdin so that only a single file write is required.

sync-format.nvim

Synchronous formatter runner for Neovim using in-place formatters. No stdin support.

Features

  • In-place formatting only, no stdin support.
  • Simple configuration.
  • Can run multiple formatters in sequence.
  • Preserves scroll positions when editing the same buffer in multiple windows at different positions by using the edit command to reload the buffer.

Installation

Example using lazy.nvim:

{
    "mgnsk/sync-format.nvim",
    event = "BufEnter",
    config = function()
        require("formatter").setup({
            typescript = { "prettier", "-w" },
            lua = { "stylua", "--indent-type", "Spaces", "--indent-width", "4" },
            fish = { "fish", "-c", [['fish_indent -w $argv[1]']] },
            c = { "clang-format", "-i" },
            proto = { "buf", "format", "-w" },
            lua = { "stylua" },
            go = {
                { "goimports", "-w" },
                { "gofumpt", "-w" },
            },
            rust = { "rustfmt" },
            sh = { "shfmt", "-w" },
            php = { "pint" },
            sql = { "pg_format", "-i", "--type-case", "0" },
        })
    end,
}

Commands

The plugin provides a few commands:

  • AutoformatToggle - Toggle autoformat globally
  • AutoformatEnable - Enable autoformat globally
  • AutoformatDisable - Disable autoformat globally
  • AutoformatToggleBuffer - Toggle autoformat for buffer
  • AutoformatEnableBuffer - Enable autoformat for buffer
  • AutoformatDisableBuffer - Disable autoformat for buffer

About

Synchronous formatter runner for Neovim using in-place formatters. No stdin support.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages