hls-brittany-plugin- Integration with the Brittany code formatter
Safe HaskellNone




provider :: FormattingHandler IdeState Source #

Formatter provider of Brittany. Formats the given source in either a given Range or the whole Document. If the provider fails an error is returned that can be displayed to the user.

formatText Source #


:: MonadIO m 
=> DynFlags 
-> Maybe FilePath

Path to configs. If Nothing, default configs will be used.

-> FormattingOptions

Options for the formatter such as indentation.

-> Text

Text to format

-> m (Either [BrittanyError] Text)

Either formatted Text or a error from Brittany.

Primitive to format text with the given option. May not throw exceptions but return a Left value. Errors may be presented to the user.

getConfFile :: NormalizedFilePath -> IO (Maybe FilePath) Source #

Recursively search in every directory of the given filepath for brittany.yaml. If no such file has been found, return Nothing.

runBrittany Source #


:: Int

tab size

-> DynFlags 
-> Maybe FilePath

local config file

-> Text

text to format

-> IO (Either [BrittanyError] Text) 

Run Brittany on the given text with the given tab size and a configuration path. If no configuration path is given, a default configuration is chosen. The configuration may overwrite tab size parameter.

Returns either a list of Brittany Errors or the reformatted text. May not throw an exception.

fromMaybeT :: Monad m => m a -> MaybeT m a -> m a Source #

opt :: a -> Option a Source #

pPrintText Source #


:: Config

global program config

-> Text

input text

-> IO ([BrittanyError], Text)

list of errors/warnings & result text

This is a temporary fix that allows us to format the text if brittany throws warnings during pretty printing.

It should be removed when our PR to brittany is merged + released. See: - https://github.com/haskell/haskell-language-server/issues/2005 - https://github.com/lspitzner/brittany/pull/351