| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Rzk.Format
Description
The formatter is designed in a way that can be consumed both by the CLI and the LSP server.
Synopsis
- data FormattingEdit = FormattingEdit Int Int Int Int Text
- formatTextEdits :: Text -> [FormattingEdit]
- format :: Text -> Text
- formatDocument :: Text -> Text
- formatFile :: FilePath -> IO Text
- formatFileWrite :: FilePath -> IO ()
- isWellFormatted :: Text -> Bool
- isWellFormattedFile :: FilePath -> IO Bool
- normalizeTabs :: Text -> Text
Documentation
data FormattingEdit Source #
All indices are 1-based (as received from the lexer) Note: LSP uses 0-based indices
Instances
| Show FormattingEdit Source # | |
Defined in Rzk.Format Methods showsPrec :: Int -> FormattingEdit -> ShowS # show :: FormattingEdit -> String # showList :: [FormattingEdit] -> ShowS # | |
| Eq FormattingEdit Source # | |
Defined in Rzk.Format Methods (==) :: FormattingEdit -> FormattingEdit -> Bool # (/=) :: FormattingEdit -> FormattingEdit -> Bool # | |
| Ord FormattingEdit Source # | |
Defined in Rzk.Format Methods compare :: FormattingEdit -> FormattingEdit -> Ordering # (<) :: FormattingEdit -> FormattingEdit -> Bool # (<=) :: FormattingEdit -> FormattingEdit -> Bool # (>) :: FormattingEdit -> FormattingEdit -> Bool # (>=) :: FormattingEdit -> FormattingEdit -> Bool # max :: FormattingEdit -> FormattingEdit -> FormattingEdit # min :: FormattingEdit -> FormattingEdit -> FormattingEdit # | |
formatTextEdits :: Text -> [FormattingEdit] Source #
format :: Text -> Text Source #
Format Rzk code, returning the formatted version. Tabs are normalized to single spaces before formatting.
formatDocument :: Text -> Text Source #
Same as format. Use this when replacing the entire document (e.g. from
the language server), so that tab normalization and all formatting rules
are applied correctly instead of applying incremental edits to tabbed source.
formatFileWrite :: FilePath -> IO () Source #
Format the file and write the result back to the file.
isWellFormatted :: Text -> Bool Source #
Check if the given Rzk source code is well formatted. This is useful for automation tasks. Tabs are normalized to single spaces before checking.
isWellFormattedFile :: FilePath -> IO Bool Source #
Same as isWellFormatted, but reads the source code from a file.
normalizeTabs :: Text -> Text Source #
Replace every tab character with a single space.
Call this before formatTextEdits so that the lexer and edit positions
are consistent (BNFC column counts are undefined when the source contains tabs).